HyperSpy API has changed in version 2.0, see the release notes!

Creating a model#

A Model1D can be created for data in the Signal1D class using the create_model() method:

>>> s = hs.signals.Signal1D(np.arange(300).reshape(30, 10))
>>> m = s.create_model() # Creates the 1D-Model and assign it to m

Similarly, a Model2D can be created for data in the Signal2D class using the create_model() method:

>>> im = hs.signals.Signal2D(np.arange(300).reshape(3, 10, 10))
>>> mod = im.create_model() # Create the 2D-Model and assign it to mod

The syntax for creating both one-dimensional and two-dimensional models is thus identical for the user in practice. When a model is created you may be prompted to provide important information not already included in the datafile, e.g. if s is EELS data, you may be asked for the accelerating voltage, convergence and collection semi-angles etc.


  • Before creating a model verify that the is_binned attribute of the signal axis is set to the correct value because the resulting model depends on this parameter. See Binned and unbinned signals for more details.

  • When importing data that has been binned using other software, in particular Gatan’s DM, the stored values may be the averages of the binned channels or pixels, instead of their sum, as would be required for proper statistical analysis. We therefore cannot guarantee that the statistics will be valid, and so strongly recommend that all pre-fitting binning is performed using Hyperspy.