Model2D#

class hyperspy.models.model2d.Model2D(signal2D, dictionary=None)#

Bases: 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 predifined components available in the components2D module and custom components can made using the Expression. 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.

Methods

add_signal_range([x1, x2, y1, y2])

Adds the data in the given range from the data range (calibrated values) that will be used by the fitting rountine.

remove_signal_range([x1, x2, y1, y2])

Removes the data in the given range (calibrated values) from the data range that will be used by the fitting rountine

reset_signal_range()

Resets the data range.

set_signal_range([x1, x2, y1, y2])

Use only the selected range defined in its own units in the fitting routine.

Notes

Methods are not yet defined for plotting 2D models or using gradient based optimisation methods.

add_signal_range(x1=None, x2=None, y1=None, y2=None)#

Adds the data in the given range from the data range (calibrated values) that will be used by the fitting rountine.

Parameters:
x1, x2None or float

Start and end of the range in the first axis (horizontal) in units.

y1, y2None or float

Start and end of the range in the second axis (vertical) in units.

remove_signal_range(x1=None, x2=None, y1=None, y2=None)#

Removes the data in the given range (calibrated values) from the data range that will be used by the fitting rountine

Parameters:
x1, x2None or float

Start and end of the range in the first axis (horizontal) in units.

y1, y2None or float

Start and end of the range in the second axis (vertical) in units.

reset_signal_range()#

Resets the data range.

set_signal_range(x1=None, x2=None, y1=None, y2=None)#

Use only the selected range defined in its own units in the fitting routine.

Parameters:
x1, x2None or float

Start and end of the range in the first axis (horizontal) in units.

y1, y2None or float

Start and end of the range in the second axis (vertical) in units.