erlab.analysis.fit.functions.dynamic¶
Class-based dynamic functions for fitting.
These functions are not limited to a single function form, and can be used to create complex models.
Functions
|
Get all argument names and default values from a function signature. |
|
Classes
Base class for dynamic functions. |
|
|
|
|
A callable class for a multi-peak model. |
|
|
|
A callable class for a arbitrary degree polynomial. |
- class erlab.analysis.fit.functions.dynamic.DynamicFunction[source]¶
Bases:
object
Base class for dynamic functions.
Dynamic functions exploits the way
lmfit
handles asteval functions inlmfit.Model._parse_params
.
- class erlab.analysis.fit.functions.dynamic.FermiEdge2dFunction(degree=1)[source]¶
Bases:
DynamicFunction
- property kwargs¶
- class erlab.analysis.fit.functions.dynamic.MultiPeakFunction(npeaks, peak_shapes=None, fd=True, convolve=True)[source]¶
Bases:
DynamicFunction
A callable class for a multi-peak model.
- Parameters:
npeaks (int) – The number of peaks to fit.
peak_shapes (list[str] | str | None) – The shape(s) of the peaks in the model. If a list of strings is provided, each string represents the shape of a peak. If a single string is provided, it will be split by spaces to create a list of peak shapes. If not provided, the default peak shape will be used for all peaks.
fd (bool) – Flag indicating whether the model should be multiplied by the Fermi-Dirac distribution. This adds three parameters to the model:
efermi
,temp
, andoffset
, each corresponding to the Fermi level, temperature in K, and constant background.convolve (bool) – Flag indicating whether the model should be convolved with a gaussian kernel. If
True
, adds aresolution
parameter to the model, corresponding to the FWHM of the gaussian kernel.
- PEAK_SHAPES: ClassVar[dict[Callable, list[str]]] = {CPUDispatcher(<function gaussian_wh>): ['gaussian', 'gauss', 'g'], CPUDispatcher(<function lorentzian_wh>): ['lorentzian', 'lor', 'l']}¶
- property kwargs¶
- class erlab.analysis.fit.functions.dynamic.PolynomialFunction(degree=1)[source]¶
Bases:
DynamicFunction
A callable class for a arbitrary degree polynomial.
- Parameters:
degree (int) – The degree of the polynomial.
- erlab.analysis.fit.functions.dynamic.get_args_kwargs(func)[source]¶
Get all argument names and default values from a function signature.
- Parameters:
func (Callable) – The function to inspect.
- Returns:
- Return type:
Note
This function does not support function signatures containing varargs.
Example
>>> def my_func(a, b=10): ... pass >>> get_args_kwargs(my_func) (['a'], {'b': 10})