EngeModel¶
-
class
zgoubidoo.fieldmaps.fieldmap.
EngeModel
[source]¶ Bases:
lmfit.model.Model
Enge model to be used with lmfit.
Create a model from a user-supplied model function.
The model function will normally take an independent variable (generally, the first argument) and a series of arguments that are meant to be parameters for the model. It will return an array of data to model some data as for a curve-fitting problem.
- Parameters
func (callable) – Function to be wrapped.
independent_vars (list of str, optional) – Arguments to func that are independent variables (default is None).
param_names (list of str, optional) – Names of arguments to func that are to be made into parameters (default is None).
nan_policy (str, optional) – How to handle NaN and missing values in data. Must be one of ‘raise’ (default), ‘propagate’, or ‘omit’. See Note below.
prefix (str, optional) – Prefix used for the model.
name (str, optional) – Name for the model. When None (default) the name is the same as the model function (func).
**kws (dict, optional) – Additional keyword arguments to pass to model function.
Notes
1. Parameter names are inferred from the function arguments, and a residual function is automatically constructed.
2. The model function must return an array that will be the same size as the data being modeled.
3. nan_policy sets what to do when a NaN or missing value is seen in the data. Should be one of:
‘raise’ : Raise a ValueError (default)
‘propagate’ : do nothing
‘omit’ : drop missing data
Examples
The model function will normally take an independent variable (generally, the first argument) and a series of arguments that are meant to be parameters for the model. Thus, a simple peak using a Gaussian defined as:
>>> import numpy as np >>> def gaussian(x, amp, cen, wid): ... return amp * np.exp(-(x-cen)**2 / wid)
can be turned into a Model with:
>>> gmodel = Model(gaussian)
this will automatically discover the names of the independent variables and parameters:
>>> print(gmodel.param_names, gmodel.independent_vars) ['amp', 'cen', 'wid'], ['x']
Attributes Summary
The parameters of the Enge model (interface to lmfit.Model.make_params()).
Attributes Documentation
-
params
¶ The parameters of the Enge model (interface to lmfit.Model.make_params()).