LogNormal

class gdt.core.spectra.functions.LogNormal[source]

Bases: Function

A Log-Normal function:

\(F(E) = \frac{A}{\sqrt{2\pi} \sigma E} e^{-\bigl(\frac{\ln E - \mu}{2\sigma}\bigr)^2}\)

where

  • \(A\) is the amplitude in ph/s/cm^2/keV

  • \(\mu\) is the natural log of energy

  • \(\sigma\) is the logarithmic standard deviation

Attributes Summary

default_values

The default parameter values.

delta_abs

The maximum absolute fitting step size for each parameter.

delta_rel

The maximum relative fitting step size for each parameter.

free

For each parameter, mark True if left free for fitting, otherwise mark False to fix at the default value.

max_values

The maximum possible value for each parameter.

min_values

The minimum possible value for each parameter.

name

The name of the function.

nparams

Number of parameters in the function.

num_components

Number of function components.

param_list

The list of parameters.

Methods Summary

add(func1, func2)

Add two Functions.

eval(params, x)

Evaluate the function.

fit_eval(params, x, **kwargs)

Evaluate the function for a fit.

integrate(params, erange[, num_points, log, ...])

Integrate the function over energy to produce a flux.

multiply(func1, func2)

Multiply two Functions.

parameter_bounds([apply_state])

The valid parameter bounds in the form [(min, max), ...]

Attributes Documentation

default_values: List[float] = [0.01, 5.0, 1.0]

The default parameter values. If not defined, each defaults to 1.0

delta_abs: List[float] = [0.1, 0.1, 0.1]

The maximum absolute fitting step size for each parameter. If not defined, each default to 0.1

delta_rel: List[float] = [0.01, 0.01, 0.01]

The maximum relative fitting step size for each parameter. If not defined, each default to 0.01

free: List[bool] = [True, True, True]

For each parameter, mark True if left free for fitting, otherwise mark False to fix at the default value. If not defined, each default to True.”””

max_values: List[float] = [inf, 10.0, inf]

The maximum possible value for each parameter. If not defined, each default to np.inf

min_values: List[float] = [1e-10, -1.0, 0.0]

The minimum possible value for each parameter. If not defined, each default to -np.inf

name: str = None

The name of the function.

nparams: int = 3

Number of parameters in the function.

num_components

Number of function components. For a normal function this is one, for a SuperFunction, this can be > 1.

Type:

(int)

param_list: List[Tuple[str, str, str]] = [('A', 'ph/s/cm^2/keV', 'Amplitude'), ('mu', 'Ln(keV)', 'Ln(Energy)'), ('sigma', 'Ln(keV)', 'Log Standard Deviation')]

The list of parameters. Each element is of form (parameter name, units, short description)

Methods Documentation

classmethod add(func1, func2)

Add two Functions. Can also use the + operator.

Parameters:
  • func1 (Function) – A function

  • func2 (Function) – A function to add to func1.

Returns:

(SuperFunction)

eval(params, x)[source]

Evaluate the function.

Parameters:
  • params (iterable) – The parameter vector of the free parameters

  • x (np.array) – The values at which to evaluate the function

Returns:

(np.array)

fit_eval(params, x, **kwargs)

Evaluate the function for a fit. This differs from eval() because the params vector should only contain the free fit parameters. The parameters that are set to fixed will automatically be passed to eval() at their fixed value. This enables a fit to be performed with fixed parameters and the associated jacobian and covariance matrices will have the appropriate shape.

Parameters:
  • params (iterable) – The parameter vector of the free parameters

  • x (np.array) – The values at which to evaluate the function

Returns:

(np.array)

integrate(params, erange, num_points=1000, log=True, energy=False)

Integrate the function over energy to produce a flux.

Parameters:
  • params (iterable) – The parameter vector, which can be of length nparams or equal to the length of the non-fixed (free) parameters.

  • erange (float, float) – The energy range over which to integrate

  • num_points (int, optional) – The number of points used for integration. Default is 1000.

  • log (bool, optional) – If True, the integration grid is made in log-space, otherwise it is linear. Default is True.

  • energy (bool, optional) – If True, perform integration of E*F(E) to produce an energy flux, otherwise integration is over F(E) to produce a photon flux. Default is False.

Returns:

(float)

classmethod multiply(func1, func2)

Multiply two Functions. Can also use the * operator.

Parameters:
  • func1 (Function) – A function

  • func2 (Function) – A function to multiply to func1.

Returns:

(SuperFunction)

parameter_bounds(apply_state=True)

The valid parameter bounds in the form [(min, max), …]

Parameters:

apply_state (bool, optional) – If True, will only return the bounds for free parameters. Default is True.

Returns:

([(float, float), …])