Package ComboCode :: Package cc :: Package modeling :: Package profilers :: Module Opacity :: Class Opacity
[hide private]
[frames] | no frames]

Class Opacity

source code


An interface for an opacity profile and any type of extinction quantity.

Instance Methods [hide private]
 
__init__(self, l, func, dfunc=None, order=3, *args, **kwargs)
Create an instance of the Opacity() class.
source code
array/float
__call__(self, l=None, *args, **kwargs)
Evaluate the profile function at a coordinate point.
source code
array/float
eval(self, l=None, alpha=2.0)
Evaluate the profile function at a coordinate point.
source code
array/float
diff(self, l=None, alpha=2.0)
Evaluate the derivative of the profile function at a coordinate point.
source code
array
getEfficiency(self, l, a, sd, P=0.0, alpha=2.0)
Calculate the extinction/absorption/scattering (depending on index) efficiency for given grain size and porosity on a wavelength grid.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, l, func, dfunc=None, order=3, *args, **kwargs)
(Constructor)

source code 

Create an instance of the Opacity() class. Requires a wavelength grid.

The function can also be given as an interpolation object.

The optional args and kwargs give the additional arguments for the opacity function, which are ignored in case func is an interpolation object.

Eval and diff work with the mass extinction coefficient in cm2/g.

In case func refers to an interpolation object in KappaReader, the args/kwargs should always contain an index indicating whether extinction (default), absorption or scattering is requested:

  • 0: extinction,
  • 1: absorption,
  • 2: scattering

Note that if func is an interpolator object, the original input x and y grids can be passed as additional keywords xin/lin and yin, which would then be arrays. Otherwise, the x and the interpolator(x) are set as xin/lin and yin. xin/lin and yin are ignored if func is a function, even if it returns an interpolator (in which case the original grids are known)

Extrapolation is done outside of the "original" (depending on if xin/yin are given) wavelength ranges according to a power law ~l^-alpha, with alpha given upon eval() calls.

Parameters:
  • l (array) - The wavelength points (cm)
  • func (function) - The function that describes the opacity profile. Can be given as an interpolation object, in which case lin and yin keywords can be passed as arrays for the original grids.
  • dfunc (function/interpolation object) - Function that describes the derivative of the profile with respect to x. Can be given as an interpolation object. If None, a generic central difference is taken & interpolated with a spline of which the order can be chosen.

    (default: None)

  • order (int) - Order of the spline interpolation. Default is cubic.

    (default: 3)

  • args (tuple) - Additional parameters passed to the functions when eval or diff are called.

    (default: [])

  • kwargs (dict) - Additional keywords passed to the functions when eval or diff are called.

    (default: {})

Overrides: object.__init__

__call__(self, l=None, *args, **kwargs)
(Call operator)

source code 

Evaluate the profile function at a coordinate point.

l can be any value or array. No warning is printed in case of extrapolation, which is done with a power law at small or large l values by the eval() function.

The default y-grid is returned if l is None.

Passes the call to eval. Additional keywords for the power law extrapolation can be passed this way as well.

Parameters:
  • l (array/float) - The primary coordinate point(s). If None, the default coordinate grid is used.

    (default: None)

Returns: array/float
The profile evaluated at l
Overrides: cc.modeling.profilers.Profiler.Profiler.__call__

eval(self, l=None, alpha=2.0)

source code 

Evaluate the profile function at a coordinate point.

l can be any value or array. No warning is printed in case of extrapolation, which is done with a power law at small or large l values

The default y-grid is returned if l is None and alpha is 2 (the default)

Parameters:
  • l (array/float) - The coordinate point(s). If None, the default coordinate grid is used.

    (default: None)

  • alpha (float) - The exponent of the wavelength-dependent power law extrapolation, such that kappa ~ lambda^-alpha

    (default: 2.)

Returns: array/float
The profile evaluated at l
Overrides: cc.modeling.profilers.Profiler.Profiler.eval

diff(self, l=None, alpha=2.0)

source code 

Evaluate the derivative of the profile function at a coordinate point.

l can be any value or array. No warning is printed in case of extrapolation, which is done with a power law at small or large l values

The default y-grid is returned if l is None and alpha is 2 (the default)

Parameters:
  • l (array/float) - The coordinate point(s). If None, the default coordinate grid is used.

    (default: None)

  • alpha (float) - The exponent of the wavelength-dependent power law extrapolation, such that kappa ~ lambda^-alpha

    (default: 2.)

Returns: array/float
The derivative evaluated at l
Overrides: cc.modeling.profilers.Profiler.Profiler.diff

getEfficiency(self, l, a, sd, P=0.0, alpha=2.0)

source code 

Calculate the extinction/absorption/scattering (depending on index) efficiency for given grain size and porosity on a wavelength grid.

Follows: Q = (extinction cross section) / (geometric cross section) where geometric cross section is the effective surface, hence pi*a^2/(1-P)^(2/3), taking into account the porosity of the grain.

Parameters:
  • l (array) - The wavelength points (cm)
  • a (float) - The grain size (cm)
  • sd (float) - The specific density of the dust species (g/cm3)
  • P (float) - The porosity of the grain (or equivalent, to represent effective grain surface). Default is the spherical case. Is given as the ratio of vacuum per unit volume of a grain.

    (default: 0)

  • alpha (float) - The exponent of the wavelength-dependent power law extrapolation, such that kappa ~ lambda^-alpha

    (default: 2.)

Returns: array
The dimensionless extinction efficiencies