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

Class Profiler

source code


An interface for creating profiles, and allowing to evaluate them and calculate the central difference with respect to a coordinate grid.

Instance Methods [hide private]
 
__init__(self, x, func=<function interp_file at 0x10b959d70>, dfunc=None, order=3, *args, **kwargs)
Create an instance of the Profiler() class.
source code
array/float
__call__(self, x=None, warn=1)
Evaluate the profile function at a coordinate point.
source code
array/float
eval(self, x=None, warn=1)
Evaluate the profile function at a coordinate point.
source code
array/float
diff(self, x=None, warn=1)
Evaluate the derivative of the profile function at a coordinate point.
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, x, func=<function interp_file at 0x10b959d70>, dfunc=None, order=3, *args, **kwargs)
(Constructor)

source code 

Create an instance of the Profiler() class. Requires a coordinate grid and a function object for the profile. A function for the derivative is optional. The functions can also be given as an interpolation object.

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

The default coordinate grid is evaluated for both the function and the derivative. They are saved in self.y and self.dydx. Alternatively, new evaluations can be attained through eval and diff.

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

Parameters:
  • x (array) - The default coordinate points, minimum three points. In the case of an interpolation function, this is the default grid returned by the instance. The original x/y of the interpolated profile are saved as xori/yori in the object.
  • func (function/interp1d object) - The function that describes the profile with respect to x. Can be given as an interp1d object. Default is a read function that interpolates data and returns the interpolator object. If interpolation object, x and eval(x) are assumed to be the original grids, unless xin and yin are given as keywords with arrays as values for the original grids.

    (default: interp_file)

  • 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 of the derivative. Default is cubic. Not used for the interpolation if func returns an interpolation object. Use read_order in that case.

    (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, x=None, warn=1)
(Call operator)

source code 

Evaluate the profile function at a coordinate point.

x can be any value or array. If func is an interpolation object, it is in principle limited by the x-range of the interpolator. It is advised not to extend much beyond the given x-range. No warning is printed here. Use eval() if that functionality is preferred.

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

Passes the call to eval.

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

    (default: None)

  • warn (bool) - Warn when extrapolation occurs.

    (default: 1)

Returns: array/float
The profile evaluated at x

eval(self, x=None, warn=1)

source code 

Evaluate the profile function at a coordinate point.

x can be any value or array. If func is an interpolation object, it is in principle limited by the x-range of the interpolator. It is advised not to extend much beyond the given x-range.

The default y-grid is returned if x is None.a

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

    (default: None)

  • warn (bool) - Warn when extrapolation occurs.

    (default: 1)

Returns: array/float
The profile evaluated at x

diff(self, x=None, warn=1)

source code 

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

x can be any value or array. If func is an interpolation object, it is in principle limited by the x-range of the interpolator. It is advised not to extend much beyond the given x-range.

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

    (default: None)

  • warn (bool) - Warn when extrapolation occurs.

    (default: 1)

Returns: array/float
The derivative evaluated at x