- class hyperspy.models.model2d.Model2D(signal2D, dictionary=None)
Model and data fitting for two dimensional signals.
A model is constructed as a linear combination of
components2Dthat are added to the model using
extend(). There are many predifined components available in the in the
components2Dmodule. 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
multifit(). 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.
It contains the data to fit.
Chi-squared of the signal (or np.nan if not yet fit)
A Signal of floats
Degrees of freedom of the signal (0 if not yet fit)
A Signal of integers
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.
Append one component to the model.
Append multiple components to the model.
Remove component from model.
- fit, multifit
Fit the model to the data at the current position or the full dataset.
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.