exspy.components#

DoublePowerLaw([A, r, origin, shift, ratio, ...])

Double power law component for EELS spectra.

EELSArctan([A, k, x0, module])

Arctan function component for EELS (with minimum at zero).

EELSCLEdge(element_subshell[, GOS, ...])

EELS core loss ionisation edge from hydrogenic or tabulated GOS with splines for fine structure fitting.

PESCoreLineShape([A, FWHM, origin, ab, shirley])

Gaussian component with a Shirley background for photoemission spectroscopy analysis.

PESVoigt()

Voigt component for photoemission spectroscopy data analysis.

SEE([A, Phi, B, module, compute_gradients])

Secondary electron emission component for Photoemission Spectroscopy.

Vignetting()

Model the vignetting of the lens with a cos^4 law multiplied by lines on the edges

VolumePlasmonDrude([intensity, ...])

Drude volume plasmon energy loss function component, the energy loss function is defined as:

Components

class exspy.components.DoublePowerLaw(A=1e-05, r=3.0, origin=0.0, shift=20.0, ratio=1.0, left_cutoff=0.0, module='numexpr', compute_gradients=False, **kwargs)#

Bases: Expression

Double power law component for EELS spectra.

\[f(x) = A \cdot [s_r \cdot (x - x_0 - x_s)^{-r} + (x - x_0)^{-r}]\]

Variable

Parameter

\(A\)

A

\(r\)

r

\(x_0\)

origin

\(x_s\)

shift

\(s_r\)

ratio

Parameters:
  • A (float) – Height parameter.

  • r (float) – Power law coefficient.

  • origin (float) – Location parameter.

  • shift (float) – Offset of second power law.

  • ratio (float) – Height ratio of the two power law components.

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

left_cutoff#

For x <= left_cutoff, the function returns 0. Default value is 0.0.

Type:

float

Parameters:
  • parameter_name_list (list) – The list of parameter names.

  • linear_parameter_list (list, optional) – The list of linear parameter. The default is None.

function_nd(axis)#

Returns a numpy array containing the value of the component for all indices. If enough memory is available, this is useful to quickly to obtain the fitted component without iterating over the navigation axes.

class exspy.components.EELSArctan(A=1.0, k=1.0, x0=1.0, module=['numpy'], **kwargs)#

Bases: Expression

Arctan function component for EELS (with minimum at zero).

\[f(x) = A \cdot \left( \frac{\pi}{2} + \arctan \left[ k \left( x-x_0 \right) \right] \right)\]

Variable

Parameter

\(A\)

A

\(k\)

k

\(x_0\)

x0

Parameters:
  • A (float) – Amplitude parameter. \(\lim_{x\to -\infty}f(x)=0\) and \(\lim_{x\to\infty}f(x)=2A\)

  • k (float) – Slope (steepness of the step). The larger \(k\), the sharper the step.

  • x0 (float) – Center parameter (\(f(x_0)=A\)).

  • parameter_name_list (list) – The list of parameter names.

  • linear_parameter_list (list, optional) – The list of linear parameter. The default is None.

class exspy.components.EELSCLEdge(element_subshell, GOS='dft', gos_file_path=None)#

Bases: Component

EELS core loss ionisation edge from hydrogenic or tabulated GOS with splines for fine structure fitting.

Hydrogenic GOS are limited to K and L shells.

Several possibilities are available for tabulated GOS.

The preferred option is to use a database of cross sections in GOSH format. One such database can be freely downloaded from Zenodo at: https://doi.org/10.5281/zenodo.7645765 while information on the GOSH format are available at: gguzzina/gosh. Alternatively, one can use the Dirac GOSH database to include relativistic effects, available at: https://doi.org/10.5281/zenodo.12800856.

eXSpy also supports Peter Rez’s Hartree Slater cross sections parametrised as distributed by Gatan in their Digital Micrograph (DM) software. If Digital Micrograph is installed in the system in the standard location, eXSpy should find the path to the HS GOS folder. Otherwise, the location of the folder can be defined in the eXSpy preferences, which can be done through hyperspy.api.preferences.gui() or the hyperspy.api.preferences.EELS.eels_gos_files_path variable.

Parameters:
  • element_subshell (str or dict) – Usually a string, for example, 'Ti_L3' for the GOS of the titanium L3 subshell. If a dictionary is passed, it is assumed that Hartree Slater GOS was exported using GOS.as_dictionary, and will be reconstructed.

  • GOS ('dft',``’dirac’, ``'hydrogenic', 'Hartree-Slater' or str) – The GOS to use. Default is 'dft'. If str, it must the path to gosh GOS file. The 'dft' and 'dirac' databases are in the 'gosh' format.

  • gos_file_path (str, None) – Only with GOS='dft' or 'dirac'. Specify the file path of the gosh file to use. If None, use the file from https://doi.org/10.5281/zenodo.7645765

onset_energy#

The edge onset position

Type:

Parameter

intensity#

The factor by which the cross section is multiplied, what in favourable cases is proportional to the number of atoms of the element. It is a component.Parameter instance. It is fixed by default.

Type:

Parameter

effective_angle#

The effective collection semi-angle. It is automatically calculated by set_microscope_parameters. It is a component.Parameter instance. It is fixed by default.

Type:

Parameter

fine_structure_active#

Activates/deactivates the fine structure features. When active, the fine structure region is not defined by the simulated EELS core-loss edge, but by a spline (if fine_structure_spline_active is True) and/or any component in fine_structure_components.

Type:

bool, default False

fine_structure_spline_active#

If True and fine_structure_active is True, the region from fine_structure_spline_onset until fine_structure_width are modelled with a spline.

Type:

bool, default True

fine_structure_coeff#

The coefficients of the spline that fits the fine structure. Fix this parameter to fix the fine structure. It is a component.Parameter instance.

Type:

Parameter

fine_structure_smoothing#

Controls the level of smoothing of the fine structure model. Decreasing the value increases the level of smoothing.

Type:

float between 0 and 1, default 0.3

fine_structure_spline_onset#

The position, from the ionization edge onset, at which the region modelled by the spline function starts.

Type:

float, default 0.

fine_structure_width#

The width of the energy region, from the ionization edge onset, where the model is a spline function and/or any component in fine_structure_components instead of the EELS ionization edges simulation.

Type:

float, default 30.

fine_structure_components#

A set containing components to model the fine structure region of the EELS ionization edge.

Type:

set, default set()

Parameters:
  • parameter_name_list (list) – The list of parameter names.

  • linear_parameter_list (list, optional) – The list of linear parameter. The default is None.

as_dictionary(fullcopy=True)#

Returns component as a dictionary. For more information on method and conventions, see export_to_dictionary().

Parameters:

fullcopy (bool, optional False) – Copies of objects are stored, not references. If any found, functions will be pickled and signals converted to dictionaries

Returns:

dic – A dictionary, containing at least the following fields:

  • parameters: a list of dictionaries of the parameters, one per component.

  • _whitelist: a dictionary with keys used as references saved attributes, for more information, see export_to_dictionary().

  • any field from _whitelist.keys().

Return type:

dict

fix_fine_structure()#

Fixes the fine structure spline and the parameters of the fine structure components, if any.

free_fine_structure()#

Frees the parameters of the fine structure

If there are fine structure components, only the parameters that have been previously fixed with fix_fine_structure will be set free.

The spline parameters set free only if fine_structure_spline_active is True.

function(E)#

Returns the number of counts in barns

get_fine_structure_as_signal1D()#

Returns a spectrum containing the fine structure.

Notes

The fine structure is corrected from multiple scattering if the model was convolved with a low-loss spectrum

gui(display=True, toolkit=None, **kwargs)#

Display or return interactive GUI element if available.

Parameters:
  • display (bool) – If True, display the user interface widgets. If False, return the widgets container in a dictionary, usually for customisation or testing.

  • toolkit (str, iterable of str or None) – If None (default), all available widgets are displayed or returned. If string, only the widgets of the selected toolkit are displayed if available. If an interable of toolkit strings, the widgets of all listed toolkits are displayed or returned.

set_microscope_parameters(E0, alpha, beta, energy_scale)#

Set the microscope parameters.

Parameters:
  • E0 (float) – Electron beam energy in keV.

  • alpha (float) – Convergence semi-angle in mrad.

  • beta (float) – Collection semi-angle in mrad.

  • energy_scale (float) – The energy step in eV.

class exspy.components.PESCoreLineShape(A=1.0, FWHM=1.0, origin=0.0, ab=0.0, shirley=0.0)#

Bases: Component

Gaussian component with a Shirley background for photoemission spectroscopy analysis.

Parameters:
  • parameter_name_list (list) – The list of parameter names.

  • linear_parameter_list (list, optional) – The list of linear parameter. The default is None.

function_nd(axis)#

Returns a numpy array containing the value of the component for all indices. If enough memory is available, this is useful to quickly to obtain the fitted component without iterating over the navigation axes.

class exspy.components.PESVoigt#

Bases: Component

Voigt component for photoemission spectroscopy data analysis.

Voigt profile component with support for shirley background, non_isochromaticity, transmission_function corrections and spin orbit splitting specially suited for photoemission spectroscopy data analysis.

\[f(x) = G(x) \cdot L(x)\]

where \(G(x)\) is the Gaussian function and \(L(x)\) is the Lorentzian function. This component uses an approximate formula by David (see Notes).

Parameters:
  • area (Parameter) – Intensity below the peak.

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

  • FWHM (Parameter) – FWHM = \(2 \sigma \sqrt{(2 \log(2))}\) of the Gaussian distribution.

  • gamma (Parameter) – \(\gamma\) of the Lorentzian distribution.

  • resolution (Parameter)

  • shirley_background (Parameter)

  • non_isochromaticity (Parameter)

  • transmission_function (Parameter)

  • spin_orbit_splitting (Bool)

  • spin_orbit_branching_ratio (float)

  • spin_orbit_splitting_energy (float)

Notes

Uses an approximate formula according to W.I.F. David, J. Appl. Cryst. (1986). 19, 63-64. doi:10.1107/S0021889886089999

Parameters:
  • parameter_name_list (list) – The list of parameter names.

  • linear_parameter_list (list, optional) – The list of linear parameter. The default is None.

estimate_parameters(signal, E1, E2, only_current=False)#

Estimate the Voigt function by calculating the momenta of the Gaussian.

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:

Exit status required for the remove_background() function.

Return type:

bool

Notes

Adapted from https://scipy-cookbook.readthedocs.io/items/FittingData.html

Examples

>>> g = hs.model.components1D.PESVoigt()
>>> 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)
class exspy.components.SEE(A=1.0, Phi=1.0, B=0.0, module='numexpr', compute_gradients=False, **kwargs)#

Bases: Expression

Secondary electron emission component for Photoemission Spectroscopy.

\[ f(x) = \begin{cases} 0, & x \leq \Phi\\ A\cdot{ (x-\Phi) / (x-\Phi+B)^{4}}, & x > \Phi \end{cases} \]

Variable

Parameter

\(A\)

A

\(\Phi\)

Phi

\(B\)

B

Parameters:
  • A (float) – Height parameter

  • Phi (float) – Position parameter

  • B (float) – Tail or asymmetry parameter

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

  • parameter_name_list (list) – The list of parameter names.

  • linear_parameter_list (list, optional) – The list of linear parameter. The default is None.

class exspy.components.Vignetting#

Bases: Component

Model the vignetting of the lens with a cos^4 law multiplied by lines on the edges

Parameters:
  • parameter_name_list (list) – The list of parameter names.

  • linear_parameter_list (list, optional) – The list of linear parameter. The default is None.

class exspy.components.VolumePlasmonDrude(intensity=1.0, plasmon_energy=15.0, fwhm=1.5, module='numexpr', compute_gradients=False, **kwargs)#

Bases: Expression

Drude volume plasmon energy loss function component, the energy loss function is defined as:

\[f(E) = I_0 \frac{E(\Delta E_p)E_p^2}{(E^2-E_p^2)^2+(E\Delta E_p)^2}\]

Variable

Parameter

\(I_0\)

intensity

\(E_p\)

plasmon_energy

\(\Delta E_p\)

fwhm

Parameters:

Notes

Refer to Egerton, R. F., Electron Energy-Loss Spectroscopy in the Electron Microscope, 2nd edition, Plenum Press 1996, pp. 154-158 for details, including original equations.

Parameters:
  • parameter_name_list (list) – The list of parameter names.

  • linear_parameter_list (list, optional) – The list of linear parameter. The default is None.