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

Module Profiler

source code

Tools for making profiles of any kind.

Author: R. Lombaert

Classes [hide private]
  Profiler
An interface for creating profiles, and allowing to evaluate them and calculate the central difference with respect to a coordinate grid.
  Profiler2D
An interface for creating 2D profiles, and allowing to evaluate them and calculate the central difference with respect to a 2D coordinate grid.
Functions [hide private]
 
waterFraction1StepProfiler(model_id, path_gastronoom, fraction, rfrac)
Create a 1-step fractional profile for water.
source code
interpolation object
interp_file(x=None, read_func=<function readCols at 0x1042aa8c0>, xcol=0, ycol=1, itype='spline', ikwargs={'ext': 3, 'k': 3}, *args, **kwargs)
Read an arbitrary file and return an interpolation object for that file.
source code
 
step(x, ylow, yhigh, xstep)
Step function.
source code
array
constant2D(x, y, cfunc, axis=1, *args, **kwargs)
Define a 2D array where the variable is constant with respect to one of the two axes.
source code
array
constant(x, c=None, *args, **kwargs)
Define a function for a constant profile.
source code
array
zero(x, *args, **kwargs)
Define a function for a zero profile.
source code
array
zero2D(x, y=None, *args, **kwargs)
Define a function for a zero profile.
source code
Variables [hide private]
  __package__ = 'ComboCode.cc.modeling.profilers'
Function Details [hide private]

waterFraction1StepProfiler(model_id, path_gastronoom, fraction, rfrac)

source code 

Create a 1-step fractional profile for water.

The original water abundance profile is taken from the output of the original model without fractional abundances.

These fraction profiles can be used for CHANGE_ABUNDANCE_FRACTION in mline

Parameters:
  • model_id (string) - The model id of the original cooling model
  • path_gastronoom (string) - The model subfolder in ~/GASTRoNOoM/
  • fraction (float) - the fraction used
  • rfrac (float) - the radius at the step to the fractional abundance [cm]

interp_file(x=None, read_func=<function readCols at 0x1042aa8c0>, xcol=0, ycol=1, itype='spline', ikwargs={'ext': 3, 'k': 3}, *args, **kwargs)

source code 

Read an arbitrary file and return an interpolation object for that file.

Extra arguments are passed to the chosen read_func. This must include a filename. Order of args/kwargs follows that of the requested function.

Parameters:
  • x (array) - The x grid requested for the interpolation. Note that this is a dummy variable to allow Profiler to work with this function. x can however be used for the interpolation if xcol is None, but that requires x to have the same dimensions as the y variable.

    (default: None)

  • read_func (function/str) - The function used to read the file. Default is straightforward function for reading columns. Alternatives include getInputData, getKeyData, etc. Can be given as a string, in which case the function must be defined in DataIO.

    (default: DataIO.readCols)

  • xcol (int) - The column index of the X independent variable

    (default: 0)

  • ycol (int) - The column index of the Y dependent variable

    (default: 1)

  • itype (str) - The type of interpolator used. Either 'linear' or 'spline'.

    (default: 'spline')

  • ikwargs (dict) - Extra keyword arguments for the interpolation. Default extrapolates by returning boundary values, and interpolates with spline of order 3.

    (default: {'ext':3,'k':3})

Returns: interpolation object
The interpolation object for the file.

step(x, ylow, yhigh, xstep)

source code 

Step function. At x <= xstep: ylow, at x > xstep: yhigh.

Parameters:
  • x (array/float) - x grid (can be array or float)
  • ylow (float) - y value for x < xstep
  • yhigh (float) - y value for x > xstep
  • xstep (float) - The boundary value between high and low end

constant2D(x, y, cfunc, axis=1, *args, **kwargs)

source code 

Define a 2D array where the variable is constant with respect to one of the two axes.

The function can be passed any arbitrary args and kwargs.

Parameters:
  • x (array) - The primary coordinate on axis 0
  • y (array) - The secondary coordinate on axis 1.
  • cfunc (function/interpolator) - The function for the variable axis. Can be an interpolator.
  • axis (int) - The axis that is constant. x is 0, y is 1.

    (default: 1)

  • args (dict) - args to be passed to function. Should be empty in case of interpolator.

    (default: ())

  • kwargs (dict) - kwargs to be passed to function. Should be empty in case of interpolator.

    (default: {})

Returns: array
The 2d profile (x.size,y.size)

constant(x, c=None, *args, **kwargs)

source code 

Define a function for a constant profile.

Parameters:
  • x (array) - The radial points
  • c (float) - The constant value. If None, it is taken from args/kwargs. This allows arbitrary naming of the constant. Except of course either x or y. A constant must always be given!

    (default: None)

  • args (dict) - In case the constant is defined under a different name

    (default: ())

  • kwargs (dict) - In case the constant is defined under a different name

    (default: {})

Returns: array
The constant profile, either 1d (x.size) or 2d (x.size,y.size)

zero(x, *args, **kwargs)

source code 

Define a function for a zero profile.

Parameters:
  • x (array) - The coordinate points
  • args (dict) - To catch any extra keywords. They are not used.

    (default: ())

  • kwargs (dict) - To catch any extra keywords. They are not used.

    (default: {})

Returns: array
The constant profile, either 1d (x.size) or 2d (x.size,y.size)

zero2D(x, y=None, *args, **kwargs)

source code 

Define a function for a zero profile.

Parameters:
  • x (array) - The coordinate points
  • y (array) - The secondary points. If None, a 1d array is returned. If not None a 2d array is returned.

    (default: None)

  • args (dict) - To catch any extra keywords. They are not used.

    (default: ())

  • kwargs (dict) - To catch any extra keywords. They are not used.

    (default: {})

Returns: array
The constant profile, either 1d (x.size) or 2d (x.size,y.size)