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. |
|
|
|
|
Multiple peaks with optional Fermi-Dirac distribution and background. |
|
A callable class for an arbitrary degree polynomial. |
- class erlab.analysis.fit.functions.dynamic.DynamicFunction[source]¶
Bases:
objectBase class for dynamic functions.
Dynamic functions exploits the way
lmfithandles asteval functions inlmfit.Model._parse_params.
- class erlab.analysis.fit.functions.dynamic.FermiEdge2dFunction(degree=1)[source]¶
Bases:
DynamicFunction
- class erlab.analysis.fit.functions.dynamic.MultiPeakFunction(npeaks, peak_shapes=None, *, fd=True, background='linear', degree=2, convolve=True, oversample=3, segmented=False)[source]¶
Bases:
DynamicFunctionMultiple peaks with optional Fermi-Dirac distribution and background.
- Parameters:
npeaks (
int) – The number of peaks to fit.peak_shapes (
list[str] |str|None, default: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, default:True) – 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.background (
Literal['constant','linear','polynomial','none','shirley'], default:"linear") –The type of background to include in the model. Possible values are:
Value
Additional parameters
’none’
None
’constant’
const_bkg’linear’
lin_bkg,const_bkg’polynomial’
c0,c1, … depending ondegree’shirley’
const_bkg,lin_bkg,k_slope, andk_step_iwith i from 0 tonpeaks- 1Note
The ‘shirley’ background is calculated by
erlab.analysis.fit.functions.general.active_shirley()See its documentation for details about the parameters.degree (
int, default:2) – The degree of the polynomial background. Only used ifbackgroundis'polynomial'. Default is 2.convolve (
bool, default:True) – Flag indicating whether the model should be convolved with a gaussian kernel. IfTrue, adds aresolutionparameter to the model, corresponding to the FWHM of the gaussian kernel.oversample (
int, default:3) – Factor by which to oversamplexduring convolution to reduce numerical artifacts.segmented (
bool, default:False) – Flag indicating whether to convolve the model in segments. IfTrue, the model will be convolved in segments of uniform spacing. This must be set toTruewhen fitting data with large gaps or discontinuities in the x-axis.
- class erlab.analysis.fit.functions.dynamic.PolynomialFunction(degree=1)[source]¶
Bases:
DynamicFunctionA callable class for an arbitrary degree polynomial.
- Parameters:
degree (
int, default:1) – 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})