hyperspy._components.gaussianhf module

class hyperspy._components.gaussianhf.GaussianHF(height=1.0, fwhm=1.0, centre=0.0, **kwargs)

Bases: hyperspy._components.expression.Expression

Normalized gaussian function component, with a fwhm parameter instead of the sigma parameter, and a height parameter instead of the A parameter (scaling difference of sigma * sqrt(2*Pi)). This makes the parameter vs. peak maximum independent of sigma, and thereby makes locking of the parameter more viable. As long as there is no binning, the height parameter corresponds directly to the peak maximum, if not, the value is scaled by a linear constant (signal_axis.scale).

f(x) = h \sqrt{2\pi}\mathrm{exp}{\left[-\frac{4 \log{2}\left(x-c\right)^{2}}{W^{2}}\right]}

Parameters:
  • height (float) – The height of the peak. If there is no binning, this corresponds directly to the maximum, otherwise the maximum divided by signal_axis.scale
  • centre (float) – Location of the gaussian maximum, also the mean position.
  • fwhm (float) – The full width half maximum value, i.e. the width of the gaussian at half the value of gaussian peak (at centre).
  • **kwargs – Extra keyword arguments are passes to the Expression component. An useful keyword argument that can be used to speed up the component is module. See the Expression component documentation for details.

The helper properties sigma and A are also defined for compatibility with Gaussian component.

See also

hyperspy.components.Gaussian

A
estimate_parameters(signal, x1, x2, only_current=False)

Estimate the gaussian by calculating the momenta.

Parameters:
  • signal (Signal1D instance) –
  • x1 (float) – Defines the left limit of the spectral range to use for the estimation.
  • x2 (float) – Defines the right limit of the spectral range to use for the estimation.
  • only_current (bool) – If False estimates the parameters for the full dataset.
Returns:

Return type:

bool

Notes

Adapted from http://www.scipy.org/Cookbook/FittingData

Examples

>>> g = hs.model.components1D.GaussianHF()
>>> x = np.arange(-10, 10, 0.01)
>>> data = np.zeros((32, 32, 2000))
>>> data[:] = g.function(x).reshape((1, 1, 2000))
>>> s = hs.signals.Signal1D(data)
>>> s.axes_manager._axes[-1].offset = -10
>>> s.axes_manager._axes[-1].scale = 0.01
>>> g.estimate_parameters(s, -10, 10, False)
integral_as_signal()

Utility function to get gaussian integral as Signal1D

sigma