hyperspy._components.gaussian module

class hyperspy._components.gaussian.Gaussian(A=1.0, sigma=1.0, centre=0.0)

Bases: hyperspy.component.Component

Normalized gaussian function component

f(x) = \frac{a}{\sqrt{2\pi c^{2}}}exp\left[-\frac{\left(x-b\right)^{2}}{2c^{2}}\right]

Parameter Attribute
   
a A
b centre
c sigma

For convenience the fwhm attribute can be used to get and set the full-with-half-maximum.

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.Gaussian()
>>> 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)
function(x)
fwhm
grad_A(x)
grad_centre(x)
grad_sigma(x)