EELS_Tools: Spectroscopy


Analysis of EDS Spectra#


OpenInColab

part of

pyTEMlib

a pycroscopy ecosystem package

Notebook by Gerd Duscher, 2025

Microscopy Facilities
Institute of Advanced Materials & Manufacturing
The University of Tennessee, Knoxville

Model based analysis and quantification of data acquired with transmission electron microscopes

Content#

An Introduction into displaying and analyzing EDS spectrum images and spectra This works also on Google Colab.

Prerequesites#

Install pyTEMlib#

If you have not done so in the Introduction Notebook, please test and install pyTEMlib and other important packages with the code cell below.

import sys
import importlib.metadata

def test_package(package_name):
    """Test if package exists and returns version or -1"""
    try:
        version = importlib.metadata.version(package_name)
    except importlib.metadata.PackageNotFoundError:
        version = '-1'
    return version


# pyTEMlib setup ------------------
if test_package('pyTEMlib') < '0.2024.02.0':
    print('installing pyTEMlib')
   
    !{sys.executable} -m pip install pyTEMlib -q --upgrade

# ------------------------------
print('done')
done

In Google Colab: Please restart runtime Ctrl+M

Loading of necessary libraries#

Please note, that we only need to load the pyTEMlib library, which is based on sidpy Datsets.

%matplotlib widget
import numpy as np
import scipy

import matplotlib.pylab as plt
import sys

if 'google.colab' in sys.modules:
    from google.colab import output
    output.enable_custom_widget_manager()
    from google.colab import drive

import pyTEMlib
# using  pyTEMlib.eds_tools, pyTEMlib.file_tools and pyTEMlib.eels_tools (for line definitions)
if 'google.colab' in sys.modules:
    drive.mount("/content/drive")

# For archiving reasons it is a good idea to print the version numbers out at this point
print('pyTEM version: ',pyTEMlib.__version__)
__notebook__ = 'EDS_Spectrum_Analysis'
__notebook_version__ = '2025_08_06'
pyTEM version:  0.2025.04.2

Open File#

Load File#

Select a main dataset and any additional data like reference data and such.

fileWidget = pyTEMlib.file_tools.FileWidget()
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[3], line 1
----> 1 fileWidget = pyTEMlib.file_tools.FileWidget()

AttributeError: module 'pyTEMlib' has no attribute 'file_tools'

Select and Plot Dataset#

Select a dataset from the drop down value and display it with the code cell below.

Here we sum the spectra of the 4 quadrants and define the detector parameter.

spectrum = fileWidget.selected_dataset

start = np.searchsorted(spectrum.energy_scale.values, 100)
energy_scale = spectrum.energy_scale.values[start:]
detector_Efficiency= pyTEMlib.eds_tools.detector_response(spectrum)  # tags, spectrum.energy_scale.values[start:])
if 'start_energy' not in spectrum.metadata['EDS']['detector']:
    spectrum.metadata['EDS']['detector']['start_energy'] = 120
spectrum[:np.searchsorted(spectrum.energy_scale.values,spectrum.metadata['EDS']['detector']['start_energy'])] = 0.
spectrum.metadata['EDS']['detector']['detector_efficiency']  = detector_Efficiency
view = spectrum.plot()
spectrum.metadata['EDS'].keys()
dict_keys(['detector'])

Find Elements#

# --------Input -----------
minimum_number_of_peaks = 10
# --------------------------
minor_peaks = pyTEMlib.eds_tools.detect_peaks(spectrum, minimum_number_of_peaks=minimum_number_of_peaks)

keys = list(spectrum.metadata['EDS'].keys())
for key in keys:
    if len(key) < 3:
        del spectrum.metadata['EDS'][key]

elements = pyTEMlib.eds_tools.find_elements(spectrum, minor_peaks)

print(elements)
spectrum.metadata['EDS'].update(pyTEMlib.eds_tools.get_x_ray_lines(spectrum, elements))
plt.figure()
plt.plot(spectrum.energy_scale,spectrum, label = 'spectrum')
pyTEMlib.eds_tools.plot_lines(spectrum.metadata['EDS'], plt.gca())
C:\Users\gduscher\AppData\Local\anaconda3\Lib\site-packages\dask\array\core.py:1744: FutureWarning: The `numpy.argsort` function is not implemented by Dask array. You may want to use the da.map_blocks function or something similar to silence this warning. Your code may stop working in a future release.
  warnings.warn(
['Sr', 'O', 'Ti', 'Cu']

Quantify#

# ------- Input --------
mask = ['Cu']
# ----------------------
peaks, pp = pyTEMlib.eds_tools.fit_model(spectrum, elements, use_detector_efficiency=True)
print('0', spectrum.metadata['EDS']['O'])
model = pyTEMlib.eds_tools.get_model(spectrum)
k_factors = pyTEMlib.eds_tools.load_k_factors()

pyTEMlib.eds_tools.quantify_EDS(spectrum, k_factors=k_factors, mask=mask) 

plt.figure()
plt.plot(spectrum.energy_scale, spectrum, label='spectrum')
plt.plot(spectrum.energy_scale, model, label='model')
plt.plot(spectrum.energy_scale, spectrum-model, label='difference')
plt.xlabel('Energy (eV)')
pyTEMlib.eds_tools.plot_lines(spectrum.metadata['EDS'], plt.gca())
plt.axhline(y=0, xmin=0, xmax=1, color='gray')
plt.legend()
{'Sr': {'Z': 38, 'K-family': {'main': 'K-L3', 'weight': 1.0, 'lines': ['K-L3', 'K-L2', 'K-M3', 'K-N3', 'K-M2', 'K-M5'], 'height': np.float64(782.0), 'K-L3': {'weight': 1.0, 'position': 14165.000000000002}, 'K-L2': {'weight': 0.564, 'position': 14097.800000000003}, 'K-M3': {'weight': 0.144, 'position': 15835.500000000002}, 'K-N3': {'weight': 0.0328, 'position': 16084.700000000003}, 'K-M2': {'weight': 0.0731, 'position': 15824.800000000003}, 'K-M5': {'weight': 0.000368, 'position': 15971.500000000002}, 'probability': np.float64(7.515862548497007)}, 'L-family': {'main': 'L3-M5', 'weight': 1.0, 'lines': ['L3-M5', 'L3-M4', 'L3-M1', 'L2-N3', 'L2-M4', 'L2-M3', 'L2-N1', 'L2-M1', 'L1-M3', 'L1-M2', 'L1-N2', 'L1-N3'], 'height': np.float64(4091.0), 'L3-M5': {'weight': 1.0, 'position': 1806.5}, 'L3-M4': {'weight': 0.114, 'position': 1804.6}, 'L3-M1': {'weight': 0.0412, 'position': 1582.1}, 'L2-N3': {'weight': 0.00524, 'position': 1986.9}, 'L2-M4': {'weight': 0.499, 'position': 1871.8000000000002}, 'L2-M3': {'weight': 0.000116, 'position': 1737.7000000000003}, 'L2-N1': {'weight': 0.00187, 'position': 1969.1000000000001}, 'L2-M1': {'weight': 0.0261, 'position': 1649.3000000000002}, 'L1-M3': {'weight': 0.0274, 'position': 1947.1999999999998}, 'L1-M2': {'weight': 0.0394, 'position': 1936.4999999999998}, 'L1-N2': {'weight': 0.000191, 'position': 2196.3999999999996}, 'L1-N3': {'weight': 0.00341, 'position': 2196.3999999999996}, 'probability': np.float64(114.05222567397621)}}, 'O': {'Z': 8, 'K-family': {'main': 'K-L3', 'weight': 1.0, 'lines': ['K-L3', 'K-L2'], 'height': np.float64(3306.0), 'K-L3': {'weight': 1.0, 'position': 524.9}, 'K-L2': {'weight': 0.5, 'position': 524.9}, 'probability': np.float64(59.425625355705854)}}, 'Ti': {'Z': 22, 'K-family': {'main': 'K-L3', 'weight': 1.0, 'lines': ['K-L3', 'K-L2', 'K-M3', 'K-M2'], 'height': np.float64(2739.0), 'K-L3': {'weight': 1.0, 'position': 4510.900000000001}, 'K-L2': {'weight': 0.509, 'position': 4504.900000000001}, 'K-M3': {'weight': 0.128, 'position': 4931.8}, 'K-M2': {'weight': 0.0733, 'position': 4931.8}, 'probability': np.float64(36.84992223562213)}, 'L-family': {'main': 'L3-M1', 'weight': 0.556, 'lines': ['L3-M1', 'L2-M3', 'L2-M1', 'L1-M3', 'L1-M2'], 'height': np.float64(969.4244604316546), 'L3-M1': {'weight': 0.556, 'position': 395.2}, 'L2-M3': {'weight': 9.85e-05, 'position': 426.9}, 'L2-M1': {'weight': 0.272, 'position': 401.2}, 'L1-M3': {'weight': 0.00654, 'position': 529.0999999999999}, 'L1-M2': {'weight': 0.0173, 'position': 529.0999999999999}}}, 'Cu': {'Z': 29, 'K-family': {'main': 'K-L3', 'weight': 1.0, 'lines': ['K-L3', 'K-L2', 'K-M3', 'K-M2', 'K-M5'], 'height': np.float64(471.0), 'K-L3': {'weight': 1.0, 'position': 8047.799999999999}, 'K-L2': {'weight': 0.653, 'position': 8027.9}, 'K-M3': {'weight': 0.155, 'position': 8905.3}, 'K-M2': {'weight': 0.0864, 'position': 8905.3}, 'K-M5': {'weight': 0.000282, 'position': 8977.3}, 'probability': np.float64(19.48309778240112)}, 'L-family': {'main': 'L3-M5', 'weight': 1.0, 'lines': ['L3-M5', 'L3-M4', 'L3-M1', 'L2-M4', 'L2-M3', 'L2-M1', 'L1-M3', 'L1-M2'], 'height': np.float64(137.0), 'L3-M5': {'weight': 1.0, 'position': 929.5}, 'L3-M4': {'weight': 0.114, 'position': 929.5}, 'L3-M1': {'weight': 0.0654, 'position': 811.3000000000001}, 'L2-M4': {'weight': 0.0949, 'position': 949.4}, 'L2-M3': {'weight': 9.47e-05, 'position': 877.4}, 'L2-M1': {'weight': 0.0164, 'position': 831.2}, 'L1-M3': {'weight': 0.00104, 'position': 1022.5000000000001}, 'L1-M2': {'weight': 0.00623, 'position': 1022.5000000000001}, 'probability': np.float64(159.114672583887)}}}
{'Sr': {'Z': 38, 'K-family': {'main': 'K-L3', 'weight': 1.0, 'lines': ['K-L3', 'K-L2', 'K-M3', 'K-N3', 'K-M2', 'K-M5'], 'height': np.float64(782.0), 'K-L3': {'weight': 1.0, 'position': 14165.000000000002}, 'K-L2': {'weight': 0.564, 'position': 14097.800000000003}, 'K-M3': {'weight': 0.144, 'position': 15835.500000000002}, 'K-N3': {'weight': 0.0328, 'position': 16084.700000000003}, 'K-M2': {'weight': 0.0731, 'position': 15824.800000000003}, 'K-M5': {'weight': 0.000368, 'position': 15971.500000000002}, 'probability': np.float64(7.515862548497007), 'peaks': array([0., 0., 0., ..., 0., 0., 0.], shape=(2048,))}, 'L-family': {'main': 'L3-M5', 'weight': 1.0, 'lines': ['L3-M5', 'L3-M4', 'L3-M1', 'L2-N3', 'L2-M4', 'L2-M3', 'L2-N1', 'L2-M1', 'L1-M3', 'L1-M2', 'L1-N2', 'L1-N3'], 'height': np.float64(4091.0), 'L3-M5': {'weight': 1.0, 'position': 1806.5}, 'L3-M4': {'weight': 0.114, 'position': 1804.6}, 'L3-M1': {'weight': 0.0412, 'position': 1582.1}, 'L2-N3': {'weight': 0.00524, 'position': 1986.9}, 'L2-M4': {'weight': 0.499, 'position': 1871.8000000000002}, 'L2-M3': {'weight': 0.000116, 'position': 1737.7000000000003}, 'L2-N1': {'weight': 0.00187, 'position': 1969.1000000000001}, 'L2-M1': {'weight': 0.0261, 'position': 1649.3000000000002}, 'L1-M3': {'weight': 0.0274, 'position': 1947.1999999999998}, 'L1-M2': {'weight': 0.0394, 'position': 1936.4999999999998}, 'L1-N2': {'weight': 0.000191, 'position': 2196.3999999999996}, 'L1-N3': {'weight': 0.00341, 'position': 2196.3999999999996}, 'probability': np.float64(114.05222567397621), 'peaks': array([0., 0., 0., ..., 0., 0., 0.], shape=(2048,))}}, 'O': {'Z': 8, 'K-family': {'main': 'K-L3', 'weight': 1.0, 'lines': ['K-L3', 'K-L2'], 'height': np.float64(3306.0), 'K-L3': {'weight': 1.0, 'position': 524.9}, 'K-L2': {'weight': 0.5, 'position': 524.9}, 'probability': np.float64(59.425625355705854), 'peaks': array([3.40167382e-144, 1.58146464e-140, 6.58640062e-137, ...,
       0.00000000e+000, 0.00000000e+000, 0.00000000e+000], shape=(2048,))}}, 'Ti': {'Z': 22, 'K-family': {'main': 'K-L3', 'weight': 1.0, 'lines': ['K-L3', 'K-L2', 'K-M3', 'K-M2'], 'height': np.float64(2739.0), 'K-L3': {'weight': 1.0, 'position': 4510.900000000001}, 'K-L2': {'weight': 0.509, 'position': 4504.900000000001}, 'K-M3': {'weight': 0.128, 'position': 4931.8}, 'K-M2': {'weight': 0.0733, 'position': 4931.8}, 'probability': np.float64(36.84992223562213), 'peaks': array([0., 0., 0., ..., 0., 0., 0.], shape=(2048,))}, 'L-family': {'main': 'L3-M1', 'weight': 0.556, 'lines': ['L3-M1', 'L2-M3', 'L2-M1', 'L1-M3', 'L1-M2'], 'height': np.float64(969.4244604316546), 'L3-M1': {'weight': 0.556, 'position': 395.2}, 'L2-M3': {'weight': 9.85e-05, 'position': 426.9}, 'L2-M1': {'weight': 0.272, 'position': 401.2}, 'L1-M3': {'weight': 0.00654, 'position': 529.0999999999999}, 'L1-M2': {'weight': 0.0173, 'position': 529.0999999999999}, 'peaks': array([2.24087967e-107, 4.05986937e-104, 6.53997934e-101, ...,
       0.00000000e+000, 0.00000000e+000, 0.00000000e+000], shape=(2048,))}}, 'Cu': {'Z': 29, 'K-family': {'main': 'K-L3', 'weight': 1.0, 'lines': ['K-L3', 'K-L2', 'K-M3', 'K-M2', 'K-M5'], 'height': np.float64(471.0), 'K-L3': {'weight': 1.0, 'position': 8047.799999999999}, 'K-L2': {'weight': 0.653, 'position': 8027.9}, 'K-M3': {'weight': 0.155, 'position': 8905.3}, 'K-M2': {'weight': 0.0864, 'position': 8905.3}, 'K-M5': {'weight': 0.000282, 'position': 8977.3}, 'probability': np.float64(19.48309778240112), 'peaks': array([0., 0., 0., ..., 0., 0., 0.], shape=(2048,))}, 'L-family': {'main': 'L3-M5', 'weight': 1.0, 'lines': ['L3-M5', 'L3-M4', 'L3-M1', 'L2-M4', 'L2-M3', 'L2-M1', 'L1-M3', 'L1-M2'], 'height': np.float64(137.0), 'L3-M5': {'weight': 1.0, 'position': 929.5}, 'L3-M4': {'weight': 0.114, 'position': 929.5}, 'L3-M1': {'weight': 0.0654, 'position': 811.3000000000001}, 'L2-M4': {'weight': 0.0949, 'position': 949.4}, 'L2-M3': {'weight': 9.47e-05, 'position': 877.4}, 'L2-M1': {'weight': 0.0164, 'position': 831.2}, 'L1-M3': {'weight': 0.00104, 'position': 1022.5000000000001}, 'L1-M2': {'weight': 0.00623, 'position': 1022.5000000000001}, 'probability': np.float64(159.114672583887), 'peaks': array([2.63139458e-237, 6.74927149e-233, 1.57203169e-228, ...,
       0.00000000e+000, 0.00000000e+000, 0.00000000e+000], shape=(2048,))}}}
{'Sr': {'Z': 38, 'K-family': {'main': 'K-L3', 'weight': 1.0, 'lines': ['K-L3', 'K-L2', 'K-M3', 'K-N3', 'K-M2', 'K-M5'], 'height': np.float64(782.0), 'K-L3': {'weight': 1.0, 'position': 14165.000000000002}, 'K-L2': {'weight': 0.564, 'position': 14097.800000000003}, 'K-M3': {'weight': 0.144, 'position': 15835.500000000002}, 'K-N3': {'weight': 0.0328, 'position': 16084.700000000003}, 'K-M2': {'weight': 0.0731, 'position': 15824.800000000003}, 'K-M5': {'weight': 0.000368, 'position': 15971.500000000002}, 'probability': np.float64(7.515862548497007), 'peaks': array([0., 0., 0., ..., 0., 0., 0.], shape=(2048,)), 'areal_density': np.float64(18844.420470478253)}, 'L-family': {'main': 'L3-M5', 'weight': 1.0, 'lines': ['L3-M5', 'L3-M4', 'L3-M1', 'L2-N3', 'L2-M4', 'L2-M3', 'L2-N1', 'L2-M1', 'L1-M3', 'L1-M2', 'L1-N2', 'L1-N3'], 'height': np.float64(4091.0), 'L3-M5': {'weight': 1.0, 'position': 1806.5}, 'L3-M4': {'weight': 0.114, 'position': 1804.6}, 'L3-M1': {'weight': 0.0412, 'position': 1582.1}, 'L2-N3': {'weight': 0.00524, 'position': 1986.9}, 'L2-M4': {'weight': 0.499, 'position': 1871.8000000000002}, 'L2-M3': {'weight': 0.000116, 'position': 1737.7000000000003}, 'L2-N1': {'weight': 0.00187, 'position': 1969.1000000000001}, 'L2-M1': {'weight': 0.0261, 'position': 1649.3000000000002}, 'L1-M3': {'weight': 0.0274, 'position': 1947.1999999999998}, 'L1-M2': {'weight': 0.0394, 'position': 1936.4999999999998}, 'L1-N2': {'weight': 0.000191, 'position': 2196.3999999999996}, 'L1-N3': {'weight': 0.00341, 'position': 2196.3999999999996}, 'probability': np.float64(114.05222567397621), 'peaks': array([0., 0., 0., ..., 0., 0., 0.], shape=(2048,)), 'areal_density': np.float64(56215.65482734997)}}, 'O': {'Z': 8, 'K-family': {'main': 'K-L3', 'weight': 1.0, 'lines': ['K-L3', 'K-L2'], 'height': np.float64(3306.0), 'K-L3': {'weight': 1.0, 'position': 524.9}, 'K-L2': {'weight': 0.5, 'position': 524.9}, 'probability': np.float64(59.425625355705854), 'peaks': array([3.40167382e-144, 1.58146464e-140, 6.58640062e-137, ...,
       0.00000000e+000, 0.00000000e+000, 0.00000000e+000], shape=(2048,)), 'areal_density': np.float64(32912.00978730916)}}, 'Ti': {'Z': 22, 'K-family': {'main': 'K-L3', 'weight': 1.0, 'lines': ['K-L3', 'K-L2', 'K-M3', 'K-M2'], 'height': np.float64(2739.0), 'K-L3': {'weight': 1.0, 'position': 4510.900000000001}, 'K-L2': {'weight': 0.509, 'position': 4504.900000000001}, 'K-M3': {'weight': 0.128, 'position': 4931.8}, 'K-M2': {'weight': 0.0733, 'position': 4931.8}, 'probability': np.float64(36.84992223562213), 'peaks': array([0., 0., 0., ..., 0., 0., 0.], shape=(2048,)), 'areal_density': np.float64(39087.78212654097)}, 'L-family': {'main': 'L3-M1', 'weight': 0.556, 'lines': ['L3-M1', 'L2-M3', 'L2-M1', 'L1-M3', 'L1-M2'], 'height': np.float64(969.4244604316546), 'L3-M1': {'weight': 0.556, 'position': 395.2}, 'L2-M3': {'weight': 9.85e-05, 'position': 426.9}, 'L2-M1': {'weight': 0.272, 'position': 401.2}, 'L1-M3': {'weight': 0.00654, 'position': 529.0999999999999}, 'L1-M2': {'weight': 0.0173, 'position': 529.0999999999999}, 'peaks': array([2.24087967e-107, 4.05986937e-104, 6.53997934e-101, ...,
       0.00000000e+000, 0.00000000e+000, 0.00000000e+000], shape=(2048,)), 'areal_density': np.float64(7563.4306149423455)}}, 'Cu': {'Z': 29, 'K-family': {'main': 'K-L3', 'weight': 1.0, 'lines': ['K-L3', 'K-L2', 'K-M3', 'K-M2', 'K-M5'], 'height': np.float64(471.0), 'K-L3': {'weight': 1.0, 'position': 8047.799999999999}, 'K-L2': {'weight': 0.653, 'position': 8027.9}, 'K-M3': {'weight': 0.155, 'position': 8905.3}, 'K-M2': {'weight': 0.0864, 'position': 8905.3}, 'K-M5': {'weight': 0.000282, 'position': 8977.3}, 'probability': np.float64(19.48309778240112), 'peaks': array([0., 0., 0., ..., 0., 0., 0.], shape=(2048,)), 'areal_density': np.float64(8228.634292473906)}, 'L-family': {'main': 'L3-M5', 'weight': 1.0, 'lines': ['L3-M5', 'L3-M4', 'L3-M1', 'L2-M4', 'L2-M3', 'L2-M1', 'L1-M3', 'L1-M2'], 'height': np.float64(137.0), 'L3-M5': {'weight': 1.0, 'position': 929.5}, 'L3-M4': {'weight': 0.114, 'position': 929.5}, 'L3-M1': {'weight': 0.0654, 'position': 811.3000000000001}, 'L2-M4': {'weight': 0.0949, 'position': 949.4}, 'L2-M3': {'weight': 9.47e-05, 'position': 877.4}, 'L2-M1': {'weight': 0.0164, 'position': 831.2}, 'L1-M3': {'weight': 0.00104, 'position': 1022.5000000000001}, 'L1-M2': {'weight': 0.00623, 'position': 1022.5000000000001}, 'probability': np.float64(159.114672583887), 'peaks': array([2.63139458e-237, 6.74927149e-233, 1.57203169e-228, ...,
       0.00000000e+000, 0.00000000e+000, 0.00000000e+000], shape=(2048,)), 'areal_density': np.float64(496.913255761689)}}, 'bremsstrahlung': array([ 1.00000000e+07, -2.39388440e+02,  2.61336760e+02, -1.30530517e-03])}
{'Sr': {'Z': 38, 'K-family': {'main': 'K-L3', 'weight': 1.0, 'lines': ['K-L3', 'K-L2', 'K-M3', 'K-N3', 'K-M2', 'K-M5'], 'height': np.float64(782.0), 'K-L3': {'weight': 1.0, 'position': 14165.000000000002}, 'K-L2': {'weight': 0.564, 'position': 14097.800000000003}, 'K-M3': {'weight': 0.144, 'position': 15835.500000000002}, 'K-N3': {'weight': 0.0328, 'position': 16084.700000000003}, 'K-M2': {'weight': 0.0731, 'position': 15824.800000000003}, 'K-M5': {'weight': 0.000368, 'position': 15971.500000000002}, 'probability': np.float64(7.515862548497007), 'peaks': array([0., 0., 0., ..., 0., 0., 0.], shape=(2048,)), 'areal_density': np.float64(18844.420470478253)}, 'L-family': {'main': 'L3-M5', 'weight': 1.0, 'lines': ['L3-M5', 'L3-M4', 'L3-M1', 'L2-N3', 'L2-M4', 'L2-M3', 'L2-N1', 'L2-M1', 'L1-M3', 'L1-M2', 'L1-N2', 'L1-N3'], 'height': np.float64(4091.0), 'L3-M5': {'weight': 1.0, 'position': 1806.5}, 'L3-M4': {'weight': 0.114, 'position': 1804.6}, 'L3-M1': {'weight': 0.0412, 'position': 1582.1}, 'L2-N3': {'weight': 0.00524, 'position': 1986.9}, 'L2-M4': {'weight': 0.499, 'position': 1871.8000000000002}, 'L2-M3': {'weight': 0.000116, 'position': 1737.7000000000003}, 'L2-N1': {'weight': 0.00187, 'position': 1969.1000000000001}, 'L2-M1': {'weight': 0.0261, 'position': 1649.3000000000002}, 'L1-M3': {'weight': 0.0274, 'position': 1947.1999999999998}, 'L1-M2': {'weight': 0.0394, 'position': 1936.4999999999998}, 'L1-N2': {'weight': 0.000191, 'position': 2196.3999999999996}, 'L1-N3': {'weight': 0.00341, 'position': 2196.3999999999996}, 'probability': np.float64(114.05222567397621), 'peaks': array([0., 0., 0., ..., 0., 0., 0.], shape=(2048,)), 'areal_density': np.float64(56215.65482734997)}}, 'O': {'Z': 8, 'K-family': {'main': 'K-L3', 'weight': 1.0, 'lines': ['K-L3', 'K-L2'], 'height': np.float64(3306.0), 'K-L3': {'weight': 1.0, 'position': 524.9}, 'K-L2': {'weight': 0.5, 'position': 524.9}, 'probability': np.float64(59.425625355705854), 'peaks': array([3.40167382e-144, 1.58146464e-140, 6.58640062e-137, ...,
       0.00000000e+000, 0.00000000e+000, 0.00000000e+000], shape=(2048,)), 'areal_density': np.float64(32912.00978730916)}}, 'Ti': {'Z': 22, 'K-family': {'main': 'K-L3', 'weight': 1.0, 'lines': ['K-L3', 'K-L2', 'K-M3', 'K-M2'], 'height': np.float64(2739.0), 'K-L3': {'weight': 1.0, 'position': 4510.900000000001}, 'K-L2': {'weight': 0.509, 'position': 4504.900000000001}, 'K-M3': {'weight': 0.128, 'position': 4931.8}, 'K-M2': {'weight': 0.0733, 'position': 4931.8}, 'probability': np.float64(36.84992223562213), 'peaks': array([0., 0., 0., ..., 0., 0., 0.], shape=(2048,)), 'areal_density': np.float64(39087.78212654097)}, 'L-family': {'main': 'L3-M1', 'weight': 0.556, 'lines': ['L3-M1', 'L2-M3', 'L2-M1', 'L1-M3', 'L1-M2'], 'height': np.float64(969.4244604316546), 'L3-M1': {'weight': 0.556, 'position': 395.2}, 'L2-M3': {'weight': 9.85e-05, 'position': 426.9}, 'L2-M1': {'weight': 0.272, 'position': 401.2}, 'L1-M3': {'weight': 0.00654, 'position': 529.0999999999999}, 'L1-M2': {'weight': 0.0173, 'position': 529.0999999999999}, 'peaks': array([2.24087967e-107, 4.05986937e-104, 6.53997934e-101, ...,
       0.00000000e+000, 0.00000000e+000, 0.00000000e+000], shape=(2048,)), 'areal_density': np.float64(7563.4306149423455)}}, 'Cu': {'Z': 29, 'K-family': {'main': 'K-L3', 'weight': 1.0, 'lines': ['K-L3', 'K-L2', 'K-M3', 'K-M2', 'K-M5'], 'height': np.float64(471.0), 'K-L3': {'weight': 1.0, 'position': 8047.799999999999}, 'K-L2': {'weight': 0.653, 'position': 8027.9}, 'K-M3': {'weight': 0.155, 'position': 8905.3}, 'K-M2': {'weight': 0.0864, 'position': 8905.3}, 'K-M5': {'weight': 0.000282, 'position': 8977.3}, 'probability': np.float64(19.48309778240112), 'peaks': array([0., 0., 0., ..., 0., 0., 0.], shape=(2048,)), 'areal_density': np.float64(8228.634292473906)}, 'L-family': {'main': 'L3-M5', 'weight': 1.0, 'lines': ['L3-M5', 'L3-M4', 'L3-M1', 'L2-M4', 'L2-M3', 'L2-M1', 'L1-M3', 'L1-M2'], 'height': np.float64(137.0), 'L3-M5': {'weight': 1.0, 'position': 929.5}, 'L3-M4': {'weight': 0.114, 'position': 929.5}, 'L3-M1': {'weight': 0.0654, 'position': 811.3000000000001}, 'L2-M4': {'weight': 0.0949, 'position': 949.4}, 'L2-M3': {'weight': 9.47e-05, 'position': 877.4}, 'L2-M1': {'weight': 0.0164, 'position': 831.2}, 'L1-M3': {'weight': 0.00104, 'position': 1022.5000000000001}, 'L1-M2': {'weight': 0.00623, 'position': 1022.5000000000001}, 'probability': np.float64(159.114672583887), 'peaks': array([2.63139458e-237, 6.74927149e-233, 1.57203169e-228, ...,
       0.00000000e+000, 0.00000000e+000, 0.00000000e+000], shape=(2048,)), 'areal_density': np.float64(496.913255761689)}}, 'bremsstrahlung': array([ 1.00000000e+07, -2.39388440e+02,  2.61336760e+02, -1.30530517e-03])}
0 {'Z': 8, 'K-family': {'main': 'K-L3', 'weight': 1.0, 'lines': ['K-L3', 'K-L2'], 'height': np.float64(3306.0), 'K-L3': {'weight': 1.0, 'position': 524.9}, 'K-L2': {'weight': 0.5, 'position': 524.9}, 'probability': np.float64(59.425625355705854), 'peaks': array([3.40167382e-144, 1.58146464e-140, 6.58640062e-137, ...,
       0.00000000e+000, 0.00000000e+000, 0.00000000e+000], shape=(2048,)), 'areal_density': np.float64(32912.00978730916)}}
C:\Users\gduscher\AppData\Local\anaconda3\Lib\site-packages\pyTEMlib\eels_tools.py:1625: RuntimeWarning: Number of calls to function has reached maxfev = 2000.
  [p, _] = leastsq(bgdfit, p0, args=(y, x), maxfev=2000)
Sr quantification
O quantification
Ti quantification
Sr: 21.82 at% 50.38 wt%
O : 58.35 at% 24.60 wt%
Ti: 19.83 at% 25.01 wt%
excluded from quantification  ['Cu']
<matplotlib.legend.Legend at 0x194d8cb81a0>
spectrum.metadata['EDS']['O']
{'Z': 8,
 'K-family': {'main': 'K-L3',
  'weight': 1.0,
  'lines': ['K-L3', 'K-L2'],
  'height': np.float64(3306.0),
  'K-L3': {'weight': 1.0, 'position': 524.9},
  'K-L2': {'weight': 0.5, 'position': 524.9},
  'probability': np.float64(59.425625355705854)}}

Summary#

Using the k-factors of Spectra300, a model of the complete spectrum is used for quantification.

Appendix#

Background#

The determined background used for the model-based quantification is based on the detector effciency.

Note:

The detector efficiency is also used for the quantification model.

detector_efficiency = pyTEMlib.eds_tools.detector_response(spectrum)  # tags, spectrum.energy_scale.values[start:])
energy_scale = spectrum.energy_scale.values
start = np.searchsorted(energy_scale, 50)
E_0= spectrum.metadata['experiment']['acceleration_voltage']

bremsstrahlung = detector_efficiency * (pp[-3] + pp[-2] * (E_0 - energy_scale) / energy_scale + pp[-1] * (E_0 - energy_scale) ** 2 / energy_scale)
bremsstrahlung[:start] = 0.

plt.figure()
plt.plot(spectrum.energy_scale, spectrum, label='spectrum')
plt.plot(spectrum.energy_scale, bremsstrahlung, label='background')
plt.plot(spectrum.energy_scale, model, label='model')
pyTEMlib.eds_tools.plot_lines(spectrum.metadata['EDS'], plt.gca())
plt.legend()
<matplotlib.legend.Legend at 0x1c765b11810>