ncempy.algo.math module

Module containing definitions of basic math functions, which can be used for fitting.

If you add functions here, do not forget to update the lookup table at the bottom as well.

ncempy.algo.math.const(x, param)[source]

Constant function.

f = param[0] .

Parameters:
  • x (np.ndarray) – Positions at which to evaluate function.
  • param (np.ndarray) – Necessary parameters.
Returns:

Values of function at x.

Return type:

(np.ndarray)

ncempy.algo.math.linear(x, param)[source]

Linear function.

f = param[0] * x + param[1] .

Parameters:
  • x (np.ndarray) – Positions at which to evaluate function.
  • param (np.ndarray) – Necessary parameters.
Returns:

Values of function at x.

Return type:

(np.ndarray)

ncempy.algo.math.lkp_funcs = {'voigt': (<function voigt>, 4), 'powlaw': (<function powlaw>, 2), 'const': (<function const>, 1), 'linear': (<function linear>, 2)}

(dict) – Look-up table for functions implemented in this module. Functions are identified by strings, the entries give handles to the functions as well as the number of arguments necessary.

ncempy.algo.math.powlaw(x, param)[source]

Power law.

f = param[0] * x^param[1] .

Parameters:
  • x (np.ndarray) – Positions at which to evaluate function.
  • param (np.ndarray) – Necessary parameters.
Returns:

Values of function at x.

Return type:

(np.ndarray)

ncempy.algo.math.sum_functions(x, funcs, param)[source]

Sum functions in funcs over range x.

Parameters:
  • x (np.ndarray) – Positions at which to evaluate the functions.
  • funcs (list) – List of strings identifying function implemented in ncempy.algo.math.
  • param (np.ndarray) – Concatenated parameters for functions in funcs.
Returns:

Values of sum of functions at x.

Return type:

(np.ndarray)

ncempy.algo.math.voigt(x, param)[source]

Voigt peak function.

f = param[0]/(param[2] * sqrt(2*pi)) * Re( Faddeeva( ((x - param[1]) + i*param[3])/(param[2] * sqrt(2)) ) )

Parameters:
  • x (np.ndarray) – Positions at which to evaluate function.
  • param (np.ndarray) – Necessary parameters.
Returns:

Values of function at x.

Return type:

(np.ndarray)