hyperspy.models.model2d module
- class hyperspy.models.model2d.Model2D(signal2D, dictionary=None)
Bases:
hyperspy.model.BaseModel
Model and data fitting for two dimensional signals.
A model is constructed as a linear combination of
components2D
that are added to the model usingappend()
orextend()
. There are many predifined components available in the in thecomponents2D
module. If needed, new components can be created easily using the code of existing components as a template.Once defined, the model can be fitted to the data using
fit()
ormultifit()
. Once the optimizer reaches the convergence criteria or the maximum number of iterations the new value of the component parameters are stored in the components.It is possible to access the components in the model by their name or by the index in the model. An example is given at the end of this docstring.
Note that methods are not yet defined for plotting 2D models or using gradient based optimisation methods - these will be added soon.
- signal
It contains the data to fit.
- Type
Signal2D instance
- chisq
Chi-squared of the signal (or np.nan if not yet fit)
- Type
A Signal of floats
- dof
Degrees of freedom of the signal (0 if not yet fit)
- Type
A Signal of integers
- red_chisq
Reduced chi-squared.
- Type
Signal instance
- components
The components of the model are attributes of this class. This provides a convinient way to access the model components when working in IPython as it enables tab completion.
- Type
ModelComponents instance
- append()
Append one component to the model.
- extend()
Append multiple components to the model.
- remove()
Remove component from model.
- fit, multifit
Fit the model to the data at the current position or the full dataset.
See also
Base
,Model1D
Example
- _check_analytical_jacobian()
Check all components have analytical gradients.
If they do, return True and an empty string. If they do not, return False and an error message.