PowerLaw¶
- class gdt.core.spectra.functions.PowerLaw[source]¶
Bases:
FunctionA power law function:
\(F(E) = A \bigl(\frac{E}{E_{piv}}\bigr)^{\lambda}\),
where
\(A\) is the amplitude in ph/s/cm^2/keV
\(\lambda\) is the power-law index
\(E_{piv}\) is the pivot energy in keV. Nominally fixed to 100 keV.
Attributes Summary
The default parameter values.
The maximum absolute fitting step size for each parameter.
The maximum relative fitting step size for each parameter.
For each parameter, mark True if left free for fitting, otherwise mark False to fix at the default value.
The maximum possible value for each parameter.
The minimum possible value for each parameter.
The name of the function.
Number of parameters in the function.
Number of function components.
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.1, -2.0, 100.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, False]¶
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, inf, inf]¶
The maximum possible value for each parameter. If not defined, each default to np.inf
- min_values: List[float] = [1e-10, -20.0, 0.01]¶
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'), ('index', '', 'Photon index'), ('Epiv', '', 'Pivot energy')]¶
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:
- Returns:
- 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 theparamsvector should only contain the free fit parameters. The parameters that are set to fixed will automatically be passed toeval()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
nparamsor 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:
- Returns:
- 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), …])