hyperspy._components.lorentzian module

class hyperspy._components.lorentzian.Lorentzian(A=1.0, gamma=1.0, centre=0.0, module='numexpr', **kwargs)

Bases: Expression

Cauchy-Lorentz distribution (a.k.a. Lorentzian function) component.

f(x)=\frac{A}{\pi}\left[\frac{\gamma}{\left(x-x_{0}\right)^{2}
    +\gamma^{2}}\right]

Variable

Parameter

A

A

\gamma

gamma

x_0

centre

Parameters
  • A (float) – Area parameter, where A/(\gamma\pi) is the maximum (height) of peak.

  • gamma (float) – Scale parameter corresponding to the half-width-at-half-maximum of the peak, which corresponds to the interquartile spread.

  • centre (float) – Location of the peak maximum.

  • **kwargs – Extra keyword arguments are passed to the Expression component.

For convenience the fwhm and height attributes can be used to get and set the full-with-half-maximum and height of the distribution, respectively.

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

Estimate the Lorentzian by calculating the median (centre) and half the interquartile range (gamma).

Note that an insufficient range will affect the accuracy of this method.

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.

Return type

bool

Notes

Adapted from gaussian.py and https://en.wikipedia.org/wiki/Cauchy_distribution

Examples

>>> g = hs.model.components1D.Lorentzian()
>>> 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[-1].offset = -10
>>> s.axes_manager[-1].scale = 0.01
>>> g.estimate_parameters(s, -10, 10, False)