matheo.utils.function_def#

Functions to define commonly used function forms

class matheo.utils.function_def.RepeatingFuncUtil(f: Callable, centres: ndarray, widths: ndarray, normalise: bool = False, x_sampling: float = 0.01, xlim_width: float = 3.0)[source]#

Bases: object

Helper class to define repeating functions along a coordinate axis

Parameters:
  • f – function to repeat

  • centres – distribution centres

  • widths – distribution widths

  • normalise – (default True) switch to define if area of return SRFs should be normalised to 1

  • x_sampling – sampling along function coordinates

  • xlim_width – (default 3) multiple function widths to define function over

return_fs() Tuple[ndarray, ndarray][source]#

Evaluates all repeating functions along a coordinate axis

Returns:

evaluated functions

Returns:

evaluated function coordinates

matheo.utils.function_def.f_gaussian(x: ndarray, centre: float, width: float) ndarray[source]#

Evaluate a gaussian function along x

Parameters:
  • x – coordinate array

  • centre – mean of distribution

  • width – FWHM of distribution

Returns:

gaussian function

matheo.utils.function_def.f_normalised(f: Callable, x: ndarray, *args, high_res_sampling: float = 0.001)[source]#

Return normalised f along x

Parameters:
  • f – defining function

  • x – coordinate array

  • args – f parameters

  • high_res_sampling – (default 0.001) sampling to evaluate area of function to normalise by

Returns:

normalised function

matheo.utils.function_def.f_tophat(x: ndarray, centre: float, width: float) ndarray[source]#

Evaluate a top hat function along x

Parameters:
  • x – coordinate array

  • centre – x position of centre top hat

  • width – FWHM width of top hat

Returns:

top hat function

matheo.utils.function_def.f_triangle(x: ndarray, centre: float, width: float) ndarray[source]#

Evaluate a top hat function along x

Parameters:
  • x – coordinate array

  • centre – x position of start of triangle

  • width – half width of base of triangle (i.e. FWHM)

Returns:

top hat function

Return type:

numpy.ndarray

matheo.utils.function_def.iter_f(f: Callable, centres: ndarray, widths: ndarray, normalise: bool = False, x_sampling: float = 0.01, xlim_width: float = 3.0) Iterator[source]#

Returns iterator to evaluate repeating functions along a coordinate axis

Note

Offers a lower memory solution to matheo.utils.function_def.return_fs().

Parameters:
  • f – function to repeat

  • centres – distribution centres

  • widths – distribution widths

  • normalise – (default True) switch to define if area of return SRFs should be normalised to 1

  • x_sampling – sampling along function coordinates

  • xlim_width – (default 3) multiple function widths to define function over

Returns:

repeating function iterator

matheo.utils.function_def.repeat_f(f: Callable, centres: ndarray, widths: ndarray, normalise: bool = False, x_sampling: float = 0.01, xlim_width: float = 3.0) Tuple[ndarray, ndarray][source]#

Evaluates repeating functions along a coordinate axis

Note

Defines all function on common x coordinates, so may use a lot of memory if many bands defined with x sampling. For a lower memory solution try matheo.utils.function_def.iter_fs()..

Parameters:
  • f – function to repeat

  • centres – function centres

  • widths – function widths

  • normalise – (default True) switch to define if area of return SRFs should be normalised to 1

  • x_sampling – sampling along function coordinates

  • xlim_width – (default 3) multiple function widths to define function over

Returns:

evaluated functions

Returns:

evaluated function coordinates