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).

electron_range(element, beam_energy[, ...])

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

get_xray_lines(elements[, weight_threshold, ...])

Get all X-ray lines for the given elements.

get_xray_lines_near_energy(energy[, width, ...])

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

print_lines(elements[, weight_threshold, ...])

Display a table of X-ray lines for given elements.

print_lines_near_energy(energy[, width, ...])

Display a table of X-ray lines close to a given energy.

take_off_angle(tilt_stage, azimuth_angle, ...)

Calculate the take-off-angle (TOA).

xray_range(xray_line, beam_energy[, density])

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

zeta_to_cross_section(zfactors, elements)

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

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:
  • 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 – The zeta factors with units kg/m^2.

Return type:

list of float

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:
  • element (str) – The element symbol, e.g. ‘Al’.

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

  • density (float or str ('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:

electron_range – Electron range in micrometers.

Return type:

float

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.

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:
  • elements (tuple or list) – The list of elements.

  • 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:

hyperspy.misc.utils.DictionaryTreeBrowser

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_lines and 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:

list

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:
  • elements (list, tuple or None) – The list of elements.

  • 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  | ########## |
+---------+------+--------------+--------+------------+
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:
  • 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 – The 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
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:
  • 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:

xray_range – The X-ray range in micrometer.

Return type:

float

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:
  • 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 – The cross sections with units in barns.

Return type:

list of float