hyperspy._components.voigt module
- class hyperspy._components.voigt.Voigt(centre=10.0, area=1.0, gamma=0.2, sigma=0.1, module=['numpy', 'scipy'], **kwargs)
Bases:
Expression
Voigt component.
Symmetric peak shape based on the convolution of a Lorentzian and Normal (Gaussian) distribution:
\[f(x) = G(x) \cdot L(x)\]where \(G(x)\) is the Gaussian function and \(L(x)\) is the Lorentzian function. In this case using an approximate formula by David (see Notes). This approximation improves on the pseudo-Voigt function (linear combination instead of convolution of the distributions) and is, to a very good approximation, equivalent to a Voigt function:
\[\begin{split}z(x) &= \frac{x + i \gamma}{\sqrt{2} \sigma} \\ w(z) &= \frac{e^{-z^2} \text{erfc}(-i z)}{\sqrt{2 \pi} \sigma} \\ f(x) &= A \cdot \Re\left\{ w \left[ z(x - x_0) \right] \right\}\end{split}\]Variable
Parameter
\(x_0\)
centre
\(A\)
area
\(\gamma\)
gamma
\(\sigma\)
sigma
- Parameters:
centre (float) – Location of the maximum of the peak.
area (float) – Intensity below the peak.
gamma (float) – \(\gamma\) = HWHM of the Lorentzian distribution.
sigma (float) – \(2 \sigma \sqrt{(2 \log(2))}\) = FWHM of the Gaussian distribution.
**kwargs – Extra keyword arguments are passed to the
Expression
component.
Notes
For convenience the gwidth and lwidth attributes can also be used to set and get the FWHM of the Gaussian and Lorentzian parts of the distribution, respectively. For backwards compatability, FWHM is another alias for the Gaussian width.
W.I.F. David, J. Appl. Cryst. (1986). 19, 63-64, doi:10.1107/S0021889886089999
- estimate_parameters(signal, x1, x2, only_current=False)
Estimate the Voigt function by calculating the momenta of the Gaussian.
- Parameters:
- Returns:
Exit status required for the
remove_background()
function.- Return type:
Notes
Adapted from https://scipy-cookbook.readthedocs.io/items/FittingData.html
Examples
>>> g = hs.model.components1D.Voigt(legacy=False) >>> 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)