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 using append() or extend(). There are many predifined components available in the in the components2D 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() or 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.

signal

Signal2D instance – It contains the data to fit.

chisq

A Signal of floats – Chi-squared of the signal (or np.nan if not yet fit)

dof

A Signal of integers – Degrees of freedom of the signal (0 if not yet fit)

red_chisq

Signal instance – Reduced chi-squared.

components

ModelComponents instance – 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()

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

add_signal_range(*args, **kwargs)
disable_adjust_position()
enable_adjust_position(components=None, fix_them=True, show_label=True)
plot(plot_components=False)
remove_signal_range(*args, **kwargs)
reset_signal_range()
reset_the_signal_range()
set_signal_range(*args, **kwargs)
signal