hyperspy.misc.eds.utils module

hyperspy.misc.eds.utils._get_element_and_line(xray_line)

Returns the element name and line character for a particular X-ray line as a tuple.

By example, if xray_line = ‘Mn_Ka’ this function returns (‘Mn’, ‘Ka’)

hyperspy.misc.eds.utils._get_energy_xray_line(xray_line)

Returns the energy (in keV) associated with a given X-ray line.

By example, if xray_line = ‘Mn_Ka’ this function returns 5.8987

hyperspy.misc.eds.utils._get_xray_lines_family(xray_line)

Returns the family to which a particular X-ray line belongs.

By example, if xray_line = ‘Mn_Ka’ this function returns ‘Mn_K’

hyperspy.misc.eds.utils._quantification_cliff_lorimer(intensities, kfactors, absorption_correction, ref_index=0, ref_index2=1)

Quantification using Cliff-Lorimer

Parameters
  • intensities (numpy.array) – the intensities for each X-ray lines. The first axis should be the elements axis.

  • absorption_correction (numpy.array) – value between 0 and 1 in order to correct the intensities based on estimated absorption.

  • kfactors (list of float) – The list of kfactor in same order as intensities eg. kfactors = [1, 1.47, 1.72] for [‘Al_Ka’,’Cr_Ka’, ‘Ni_Ka’]

  • ref_index (int) – index of the elements that will be in the denominator. Should be non zeros if possible.

  • ref_index2 (int) – index of the elements that will be in the denominator. Should be non zeros if possible.

Returns

  • numpy.array containing the weight fraction with the same

  • shape as intensities.

hyperspy.misc.eds.utils.edx_cross_section_to_zeta(cross_sections, elements)

Convert a list of cross_sections in barns (b) to zeta-factors (kg/m^2).

Parameters
  • cross_section (list of float) – A list of cross sections in barns.

  • elements (list of str) – A list of element chemical symbols in the same order as the cross sections e.g. [‘Al’,’Zn’]

Returns

zeta_factors – zeta_factors with units kg/m^2.

Return type

list of float

hyperspy.misc.eds.utils.electron_range(element, beam_energy, density='auto', tilt=0)

Returns the maximum electron range for a pure bulk material according to the Kanaya-Okayama parameterziation.

Parameters
  • element (str) – The element symbol, e.g. ‘Al’.

  • beam_energy (float) – The energy of the beam in keV.

  • density ({float, 'auto'}) – The density of the material in g/cm3. If ‘auto’, the density of the pure element is used.

  • tilt (float.) – The tilt of the sample in degrees.

Returns

Return type

Electron range in micrometers.

Examples

>>> # Electron range in pure Copper at 30 kV in micron
>>> hs.eds.electron_range('Cu', 30.)
2.8766744984001607

Notes

From Kanaya, K. and S. Okayama (1972). J. Phys. D. Appl. Phys. 5, p43

See also the textbook of Goldstein et al., Plenum publisher, third edition p 72.

hyperspy.misc.eds.utils.get_FWHM_at_Energy(energy_resolution_MnKa, E)

Calculates an approximate FWHM, accounting for peak broadening due to the detector, for a peak at energy E given a known width at a reference energy.

The factor 2.5 is a constant derived by Fiori & Newbury as references below.

Parameters
  • energy_resolution_MnKa (float) – Energy resolution of Mn Ka in eV

  • E (float) – Energy of the peak in keV

Returns

float

Return type

FWHM of the peak in keV

Notes

This method implements the equation derived by Fiori and Newbury as is documented in the following:

Fiori, C. E., and Newbury, D. E. (1978). In SEM/1978/I, SEM, Inc., AMF O’Hare, Illinois, p. 401.

Goldstein et al. (2003). “Scanning Electron Microscopy & X-ray Microanalysis”, Plenum, third edition, p 315.

hyperspy.misc.eds.utils.get_abs_corr_cross_section(composition, number_of_atoms, take_off_angle, probe_area)

Calculate absorption correction terms.

Parameters
  • number_of_atoms (list of signal) – Stack of maps with number of atoms per pixel.

  • take_off_angle (float) – X-ray take-off angle in degrees.

hyperspy.misc.eds.utils.get_abs_corr_zeta(weight_percent, mass_thickness, take_off_angle)

Calculate absorption correction terms.

Parameters
  • weight_percent (list of signal) – Composition in weight percent.

  • mass_thickness (signal) – Density-thickness map in kg/m^2

  • take_off_angle (float) – X-ray take-off angle in degrees.

hyperspy.misc.eds.utils.get_xray_lines_near_energy(energy, width=0.2, only_lines=None)

Find xray lines near a specific energy, more specifically all xray lines that satisfy only_lines and are within the given energy window width around the passed energy.

Parameters
  • energy (float) – Energy to search near in keV

  • width (float) – Window width in keV around energy in which to find nearby energies, i.e. a value of 0.2 keV (the default) means to search +/- 0.1 keV.

  • only_lines – If not None, only the given lines will be added (eg. (‘a’,’Kb’)).

Returns

Return type

List of xray-lines sorted by energy difference to given energy.

hyperspy.misc.eds.utils.quantification_cliff_lorimer(intensities, kfactors, absorption_correction=None, mask=None)

Quantification using Cliff-Lorimer

Parameters
  • intensities (numpy.array) – the intensities for each X-ray lines. The first axis should be the elements axis.

  • kfactors (list of float) – The list of kfactor in same order as intensities eg. kfactors = [1, 1.47, 1.72] for [‘Al_Ka’,’Cr_Ka’, ‘Ni_Ka’]

  • mask (array of bool) – The mask with the dimension of intensities[0]. If a pixel is True, the composition is set to zero.

Returns

  • numpy.array containing the weight fraction with the same

  • shape as intensities.

hyperspy.misc.eds.utils.quantification_cross_section(intensities, cross_sections, dose, absorption_correction=None)

Quantification using EDX cross sections Calculate the atomic compostion and the number of atoms per pixel from the raw X-ray intensity

Parameters
  • intensity (numpy.ndarray) – The integrated intensity for each X-ray line, where the first axis is the element axis.

  • cross_sections (list of floats) – List of X-ray scattering cross-sections in the same order as the intensities.

  • dose (float) – the dose per unit area given by i*t*N/A, i the current, t the acquisition time, and N the number of electron by unit electric charge.

Returns

  • numpy.array containing the atomic fraction of each element, with

  • the same shape as the intensity input.

  • numpy.array of the number of atoms counts for each element, with the same

  • shape as the intensity input.

hyperspy.misc.eds.utils.quantification_zeta_factor(intensities, zfactors, dose, absorption_correction=None)

Quantification using the zeta-factor method

Parameters
  • intensities (numpy.array) – The intensities for each X-ray line. The first axis should be the elements axis.

  • zfactors (list of float) – The list of zeta-factors in the same order as intensities e.g. zfactors = [628.10, 539.89] for [‘As_Ka’, ‘Ga_Ka’].

  • dose (float) – The total electron dose given by i*t*N, i the current, t the acquisition time and N the number of electrons per unit electric charge (1/e).

Returns

  • A numpy.array containing the weight fraction with the same

  • shape as intensities and mass thickness in kg/m^2.

hyperspy.misc.eds.utils.take_off_angle(tilt_stage, azimuth_angle, elevation_angle, beta_tilt=0.0)

Calculate the take-off-angle (TOA).

TOA is the angle with which the X-rays leave the surface towards the detector.

Parameters
  • alpha_tilt (float) – The alpha-tilt of the stage in degrees. The sample is facing the detector when positively tilted.

  • azimuth_angle (float) – The azimuth of the detector in degrees. 0 is perpendicular to the alpha tilt axis.

  • elevation_angle (float) – The elevation of the detector in degrees.

  • beta_tilt (float) – The beta-tilt of the stage in degrees. The sample is facing positive 90 in the azimuthal direction when positively tilted.

Returns

take_off_angle – In degrees.

Return type

float.

Examples

>>> hs.eds.take_off_angle(alpha_tilt=10., beta_tilt=0.
>>>                          azimuth_angle=45., elevation_angle=22.)
28.865971201155283
hyperspy.misc.eds.utils.xray_lines_model(elements, beam_energy=200, weight_percents=None, energy_resolution_MnKa=130, energy_axis=None)

Generate a model of X-ray lines using a Gaussian distribution for each peak.

The area under a main peak (alpha) is equal to 1 and weighted by the composition.

Parameters
  • elements (list of strings) – A list of chemical element symbols.

  • beam_energy (float) – The energy of the beam in keV.

  • weight_percents (list of float) – The composition in weight percent.

  • energy_resolution_MnKa (float) – The energy resolution of the detector in eV

  • energy_axis (dic) – The dictionary for the energy axis. It must contains ‘size’ and the units must be ‘eV’ of ‘keV’.

Example

>>> s = xray_lines_model(['Cu', 'Fe'], beam_energy=30)
>>> s.plot()
hyperspy.misc.eds.utils.xray_range(xray_line, beam_energy, density='auto')

Return the maximum range of X-ray generation according to the Anderson-Hasler parameterization.

Parameters
  • xray_line (str) – The X-ray line, e.g. ‘Al_Ka’

  • beam_energy (float) – The energy of the beam in kV.

  • density ({float, 'auto'}) – The density of the material in g/cm3. If ‘auto’, the density of the pure element is used.

Returns

Return type

X-ray range in micrometer.

Examples

>>> # X-ray range of Cu Ka in pure Copper at 30 kV in micron
>>> hs.eds.xray_range('Cu_Ka', 30.)
1.9361716759499248
>>> # X-ray range of Cu Ka in pure Carbon at 30kV in micron
>>> hs.eds.xray_range('Cu_Ka', 30., hs.material.elements.C.
>>>                      Physical_properties.density_gcm3)
7.6418811280855454

Notes

From Anderson, C.A. and M.F. Hasler (1966). In proceedings of the 4th international conference on X-ray optics and microanalysis.

See also the textbook of Goldstein et al., Plenum publisher, third edition p 286

hyperspy.misc.eds.utils.zeta_to_edx_cross_section(zfactors, elements)

Convert a list of zeta-factors (kg/m^2) to cross_sections in barns (b).

Parameters
  • zfactors (list of float) – A list of zeta-factors.

  • elements (list of str) – A list of element chemical symbols in the same order as the cross sections e.g. [‘Al’,’Zn’]

Returns

cross_sections – cross_sections with units in barns.

Return type

list of float