exspy.utils.eds#
|
Convert a list of cross_sections in barns (b) to zeta-factors (kg/m^2). |
|
Returns the maximum electron range for a pure bulk material according to the Kanaya-Okayama parameterziation. |
|
Get all X-ray lines for the given elements. |
|
Find X-ray lines near a specific energy, more specifically all X-ray lines that satisfy |
|
Display a table of X-ray lines for given elements. |
|
Display a table of X-ray lines close to a given energy. |
|
Calculate the take-off-angle (TOA). |
|
Return the maximum range of X-ray generation according to the Anderson-Hasler parameterization. |
|
Convert a list of zeta-factors (kg/m^2) to cross_sections in barns (b). |
Utility functions for EDS analysis.
- exspy.utils.eds.cross_section_to_zeta(cross_sections, elements)#
Convert a list of cross_sections in barns (b) to zeta-factors (kg/m^2).
- Parameters:
- Returns:
zeta_factors – The zeta factors with units kg/m^2.
- Return type:
See also
- exspy.utils.eds.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:
- Returns:
electron_range – Electron range in micrometers.
- Return type:
See also
Examples
>>> # Electron range in pure Copper at 30 kV in micron >>> exspy.utils.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.
- exspy.utils.eds.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:
- Returns:
FWHM – FWHM of the peak in keV
- Return type:
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.
- exspy.utils.eds.get_abs_corr_cross_section(composition, number_of_atoms, take_off_angle, probe_area)#
Calculate absorption correction terms.
- exspy.utils.eds.get_abs_corr_zeta(weight_percent, mass_thickness, take_off_angle)#
Calculate absorption correction terms.
- exspy.utils.eds.get_xray_lines(elements, weight_threshold=0.1, energy_range=None, only_lines=None)#
Get all X-ray lines for the given elements.
- Parameters:
weight_threshold (float) – Define the threshold of the weight below which the lines are ignored. Must be between 0 and 1. Default is 0.1.
energy_range (list or tuple of length 2) – Define the start and the end of the X-ray energy range to consider. X-ray energies outside the range will be ignored. If
None, all X-ray energies are considered. Default is None.only_lines (list of str, optional) – Define the lines to be considered (eg. (‘a’,’Kb’)). If None, all lines are included. Default is None.
- Return type:
Examples
Get the X-ray lines of a single element:
>>> from exspy.utils.eds import get_xray_lines >>> get_xray_lines(["O"]) └── O └── Ka ├── energy (keV) = 0.5249 └── weight = 1.0
Get the X-ray lines of multiple elements:
>>> get_xray_lines(["O", "Fe"]) ├── Fe │ ├── Ka │ │ ├── energy (keV) = 6.4039 │ │ └── weight = 1.0 │ ├── Kb │ │ ├── energy (keV) = 7.058 │ │ └── weight = 0.1272 │ ├── La │ │ ├── energy (keV) = 0.7045 │ │ └── weight = 1.0 │ ├── Ll │ │ ├── energy (keV) = 0.6152 │ │ └── weight = 0.3086 │ └── Ln │ ├── energy (keV) = 0.6282 │ └── weight = 0.12525 └── O └── Ka ├── energy (keV) = 0.5249 └── weight = 1.0
Restrict to a specific energy range:
>>> exspy.utils.eds.get_xray_lines(["O", "Fe"], energy_range=[0.5, 1.0]) ├── Fe │ ├── La │ │ ├── energy (keV) = 0.7045 │ │ └── weight = 1.0 │ ├── Ll │ │ ├── energy (keV) = 0.6152 │ │ └── weight = 0.3086 │ └── Ln │ ├── energy (keV) = 0.6282 │ └── weight = 0.12525 └── O └── Ka ├── energy (keV) = 0.5249 └── weight = 1.0
Restrict to specific lines:
>>> exspy.utils.eds.get_xray_lines(["O", "Fe"], energy_range=[0.5, 1.0], only_lines=["a"]) ├── Fe │ └── La │ ├── energy (keV) = 0.7045 │ └── weight = 1.0 └── O └── Ka ├── energy (keV) = 0.5249 └── weight = 1.0
Specify a threshold to only return high intensity X-ray lines
>>> exspy.utils.eds.get_xray_lines(["O", "Fe"], weight_threshold=0.5) ├── Fe │ ├── Ka │ │ ├── energy (keV) = 6.4039 │ │ └── weight = 1.0 │ └── La │ ├── energy (keV) = 0.7045 │ └── weight = 1.0 └── O └── Ka ├── energy (keV) = 0.5249 └── weight = 1.0
- exspy.utils.eds.get_xray_lines_near_energy(energy, width=0.2, only_lines=None)#
Find X-ray lines near a specific energy, more specifically all X-ray lines that satisfy
only_linesand are within the given energy window width around the passed energy.- Parameters:
energy (float) – Energy in keV around which to search.
width (float) – Window width in keV around energy in which to find nearby energies, i.e. a value of 0.1 keV (the default) means to search +/- 0.05 keV.
only_lines (list of str, optional) – Define the lines to be considered (eg. (‘a’,’Kb’)). If None, all lines are included. Default is None.
- Returns:
xray_lines – List of X-ray-lines sorted by energy difference to the given energy.
- Return type:
See also
- exspy.utils.eds.print_lines(elements, weight_threshold=0.1, energy_range=None, only_lines=None, sorting='elements', float_format='.2')#
Display a table of X-ray lines for given elements.
- Parameters:
weight_threshold (float) – Define the threshold of the weight below which the lines are ignored. Must be between 0 and 1. Default is 0.1.
energy_range (list or tuple of length 2) – Define the start and the end of the X-ray energy range to consider. X-ray energies outside the range will be ignored. If
None, all X-ray energies are considered. Default is None.only_lines (list of str, optional) – Define the lines to be considered (eg. (‘a’,’Kb’)). If None, all lines are included. Default is None.
sorting (str) – Define the sorting of the table, either
"elements"or"energy". Default is"elements".float_format (str) – The formatting of the float in the table passed to
prettytable.PrettyTable. Default is “.2”.
Examples
>>> import exspy >>> exspy.utils.eds.print_lines(elements=["Fe", "Pt"]) +---------+------+--------------+--------+------------+ | Element | Line | Energy (keV) | Weight | Intensity | +---------+------+--------------+--------+------------+ | Fe | Ka | 6.40 | 1.00 | ########## | | | Kb | 7.06 | 0.13 | # | | | La | 0.70 | 1.00 | ########## | | | Ll | 0.62 | 0.31 | ### | | | Ln | 0.63 | 0.13 | # | +---------+------+--------------+--------+------------+ | Pt | Ka | 66.83 | 1.00 | ########## | | | Kb | 75.75 | 0.15 | # | | | La | 9.44 | 1.00 | ########## | | | Lb1 | 11.07 | 0.41 | #### | | | Lb2 | 11.25 | 0.22 | ## | | | Ma | 2.05 | 1.00 | ########## | | | Mb | 2.13 | 0.59 | ##### | +---------+------+--------------+--------+------------+
- exspy.utils.eds.print_lines_near_energy(energy, width=0.1, weight_threshold=0.1, only_lines=None, sorting='energy', float_format='.2')#
Display a table of X-ray lines close to a given energy.
- Parameters:
energy (float) – The energy to search around, in keV.
width (float) – Window width in keV around energy in which to find nearby energies, i.e. a value of 0.1 keV (the default) means to search +/- 0.05 keV.
weight_threshold (float) – Define the threshold of the weight below which the lines are ignored. Must be between 0 and 1. Default is 0.1.
only_lines (list of str, optional) – Define the lines to be considered (eg. (‘a’,’Kb’)). If None, all lines are included. Default is None.
sorting (str) – Define the sorting of the table, either
"elements"or"energy". Default is"elements".float_format (str) – The formatting of the float in the table passed to
prettytable.PrettyTable. Default is “.2”.
Examples
>>> import exspy >>> exspy.utils.eds.print_lines_near_energy(energy=6.4) +---------+------+--------------+--------+------------+ | Element | Line | Energy (keV) | Weight | Intensity | +---------+------+--------------+--------+------------+ | Sm | Lb3 | 6.32 | 0.13 | # | | Pm | Lb2 | 6.34 | 0.20 | # | | Fe | Ka | 6.40 | 1.00 | ########## | | Eu | Lb1 | 6.46 | 0.44 | #### | | Mn | Kb | 6.49 | 0.13 | # | | Dy | La | 6.50 | 1.00 | ########## | +---------+------+--------------+--------+------------+
See also
- exspy.utils.eds.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’]
absorption_correction (numpy.ndarray or None) – If None (default), absorption correction is ignored, otherwise, the array must contain values between 0 and 1 to correct the intensities based on estimated absorption.
mask (array of bool, signal of bool or None) – 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.
- exspy.utils.eds.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.
absorption_correction (numpy.ndarray or None) – If None (default), absorption correction is ignored, otherwise, the array must contain values between 0 and 1 to correct the intensities based on estimated absorption.
- 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.
- exspy.utils.eds.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).
absorption_correction (numpy.ndarray or None) – If None (default), absorption correction is ignored, otherwise, the array must contain values between 0 and 1 to correct the intensities based on estimated absorption.
- Returns:
A numpy.array containing the weight fraction with the same
shape as intensities and mass thickness in kg/m^2.
- exspy.utils.eds.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:
tilt_stage (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 – The take off angle in degrees.
- Return type:
Examples
>>> exspy.utils.eds.take_off_angle(tilt_stage=10., beta_tilt=0. >>> azimuth_angle=45., elevation_angle=22.) 28.865971201155283
- exspy.utils.eds.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()
- exspy.utils.eds.xray_range(xray_line, beam_energy, density='auto')#
Return the maximum range of X-ray generation according to the Anderson-Hasler parameterization.
- Parameters:
- Returns:
xray_range – The X-ray range in micrometer.
- Return type:
See also
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
- exspy.utils.eds.zeta_to_cross_section(zfactors, elements)#
Convert a list of zeta-factors (kg/m^2) to cross_sections in barns (b).
- Parameters:
- Returns:
cross_sections – The cross sections with units in barns.
- Return type:
See also