pyEELSMODEL.components package

Subpackages

Submodules

pyEELSMODEL.components.afterglow module

class pyEELSMODEL.components.afterglow.AfterGlow(specshape, zlp, Epos, A=1)

Bases: Component

Component which can add a afterglow if it is observed in the experimental data. Simple approximation which uses the same zlp for each spectrum whereas drift could make this different. Additionally, the position of the after glow needs to be indicated which would not be needed

#todo find a generic way to handle the afterglow with any need of Epos

calculate()

This calculates the spectral data of the component. Each derived class from Component will need to implement its own functionality here.

Return type:

None.

set_fixeddata(zlp, Epos)

Sets the component using the zlp data and the energy where it is seen.

Parameters:
  • specshape (Spectrumshape) – The spectrum shape used to model

  • zlp (numpy array) – The zlp array which is best taken to be the average.

  • Epos (energy position of the peak of the afterglow)

pyEELSMODEL.components.exponential module

copyright University of Antwerp 2021 author: Jo Verbeeck and Daen Jannis

class pyEELSMODEL.components.exponential.Exponential(specshape, A, b)

Bases: Component

Initialises an Exponential component

Parameters:
  • specshape (Spectrumshape) – The spectrum shape used to model

  • A (float) – Amplitude of the exponential

  • b (float) – The constant in the exponential

autofit(spectrum, istart, istop)

Perform a linear least square fitting to get an estimate of the exponential fit.

Parameters:
  • spectrum (Spectrum) – The spectrum used to get the estimate from

  • istart (uint) – The starting index over which to get the linear least square fit

  • istop (uint) – The ending index over which to get the linear least square fit

calculate()

This calculates the spectral data of the component. Each derived class from Component will need to implement its own functionality here.

Return type:

None.

exponential_function(A, b)
getgradient(parameter)

Get a reference to the gradient of this component with respect to parameter, if an analytical gradient is available. This function needs to be overoaded for every specific component

Parameters:

parameter (Parameter) – Reference to an existing parameter in the component.

Returns:

  • A reference to a Spectrum holding the gradient if the parameter was

  • indeed a parameter of this component and has an analytical gradient

  • defined gradient. None in all other cases.

pyEELSMODEL.components.fast_background module

copyright University of Antwerp 2021 author: Jo Verbeeck and Daen Jannis

class pyEELSMODEL.components.fast_background.FastBG2(specshape, A1=1, A2=1, r1=2.5, r2=3.5)

Bases: Component

Fast background model, fully linear and using two terms to model the background

calculate()

This calculates the spectral data of the component. Each derived class from Component will need to implement its own functionality here.

Return type:

None.

fast_background(A1, r1, A2, r2)
getgradient(parameter)

calculate the analytical partial derivative wrt parameter j returns true if succesful, gradient is stored in component.gradient

class pyEELSMODEL.components.fast_background.FastBG3(specshape, A1=1, A2=1, A3=1, r1=2, r2=3, r3=4)

Bases: Component

Fast background model, fully linear and using three terms to model the background

calculate()

This calculates the spectral data of the component. Each derived class from Component will need to implement its own functionality here.

Return type:

None.

fast_background3(A1, r1, A2, r2, A3, r3)
getgradient(parameter)

calculate the analytical partial derivative wrt parameter j returns true if succesful, gradient is stored in component.gradient

pyEELSMODEL.components.fixedpattern module

copyright University of Antwerp 2021 author: Jo Verbeeck and Daen Jannis

class pyEELSMODEL.components.fixedpattern.FixedPattern(specshape, spectrum, A=1, scale=1, shift=0, name=' ')

Bases: Component

Fixed pattern as component. This component can be used when an experimental edge can get extracted from experimental data.

Parameters:
  • specshape (Spectrumshape) – The spectrum shape used to model

  • spectrum (Spectrum) – The spectrum from which to extract the fixed pattern.

  • A (float) – The amplitude of fixed pattern compared to the data of the spectrum. (default: 1)

  • scale (float (> 0)) – A scale value for changing the energy axis. This can be used when another dispersion is used between the fixed pattern and the experimental data. (default: 1)

  • shift (float [eV]) – Shifting the data from the spectrum with the given value. (default: 0)

calculate()

This calculates the spectral data of the component. Each derived class from Component will need to implement its own functionality here.

Return type:

None.

getgradient(parameter)

Get a reference to the gradient of this component with respect to parameter, if an analytical gradient is available. This function needs to be overoaded for every specific component

Parameters:

parameter (Parameter) – Reference to an existing parameter in the component.

Returns:

  • A reference to a Spectrum holding the gradient if the parameter was

  • indeed a parameter of this component and has an analytical gradient

  • defined gradient. None in all other cases.

modified_fixedpattern(fixedpattern, A, scale, shift)

Recalculates the fixed pattern. The amplitude,

Parameters:
  • fixedpattern (numpy array (1D)) – The unmodified fixed pattern data.

  • A (float) – The amplitude of the fixed pattern.

  • scale (float) – The scale to change the energy axis

  • shift (float) – The shift of the energy axis

Returns:

res – The recalculated data from the fixed pattern.

Return type:

numpy array (1D)

set_fixeddata(spectrum)

It can happen that the fixed pattern does not have the same energy axis as the spectrum to which we want to fit. Hence a interpolation is performed to match the fixedpattern data with the energy axis of the model.

Parameters:

spectrum (Spectrum) – The spectrum from where the data is interpolated on the other energy axis.

Returns:

int_spec.data – The raw data of the interpolated spectrum on the energy axis given by the spectrum shape of the fixed pattern.

Return type:

numpy 1d array

pyEELSMODEL.components.gaussian module

copyright University of Antwerp 2021 author: Jo Verbeeck and Daen Jannis

class pyEELSMODEL.components.gaussian.Gaussian(specshape, A, centre, fwhm)

Bases: Component

A Gaussian component.

Parameters:
  • specshape (Spectrumshape) – The spectrum shape used to model

  • A (float) – Amplitude of the gaussian function.

  • centre (float) – The peak position of the gaussian function.

  • fwhm (float) – The full width halve maximum of the gaussian function.

calculate()

This calculates the spectral data of the component. Each derived class from Component will need to implement its own functionality here.

Return type:

None.

gaussian_function(A, centre, sigma)
getgradient(parameter)

Get a reference to the gradient of this component with respect to parameter, if an analytical gradient is available. This function needs to be overoaded for every specific component

Parameters:

parameter (Parameter) – Reference to an existing parameter in the component.

Returns:

  • A reference to a Spectrum holding the gradient if the parameter was

  • indeed a parameter of this component and has an analytical gradient

  • defined gradient. None in all other cases.

pyEELSMODEL.components.gdoslin module

class pyEELSMODEL.components.gdoslin.GDOSLin(specshape, estart, ewidth=50, degree=20, interpolationtype='linear')

Bases: Component

Linear fine structure DOS Component This component will create in the onset region [estart-estart+ewidth] of a core loss a interpolated curve going through degree points which are free parameters of the model This curve is then added to the core loss cross section and will increase or decrease certain areas in the cross section As this is added, this is also a linear component

calculate()

This calculates the spectral data of the component. Each derived class from Component will need to implement its own functionality here.

Return type:

None.

calculate_integral_per_parameter()

Since the integral for each individual parameter is not the same we calculate the difference which is then applied to the component as a multiplication factor to resolve this interpolation problem

couple_parameter_to_edge()

Couples the parameters of the gdoslin to the edge such that this template edge can be used to fit the spectrum where the gdoslin is no variable anymore.

classmethod gdoslin_from_edge(specshape, component, pre_e=5, ewidth=50, degree=20, interpolationtype='linear')

Class method is made to create an gdoslin which is connected to a coreloss edge. No need to input the onset energy

Parameters:
  • specshape (Spectrumshape) – The spectrum shape used to model

  • component (CoreLossEdge) – The coreloss edge on which to add the fine structure.

  • pre_e (float [eV]) – The value of the energy onset of the fine structure with respect to the onset energy of the coreloss edge. Hence for oxygen at 532eV with pre_e=5, the starting energy for the fine structure is 527 eV. (default: 5)

  • ewidth (float [eV]) – The energy width over which the fine structure is modelled. (default: 50)

  • degree (int) – The number of parameters used to model the fine structure. (default: 20)

  • interpolationtype (string) – The type of interpolation used.

initDOS()
set_gdos_name()

Set the proper name of the gdos

pyEELSMODEL.components.linear module

class pyEELSMODEL.components.linear.Linear(specshape, m, q)

Bases: Component

A Linear component.

calculate()

This calculates the spectral data of the component. Each derived class from Component will need to implement its own functionality here.

Return type:

None.

getgradient(parameter)

Get a reference to the gradient of this component with respect to parameter, if an analytical gradient is available. This function needs to be overoaded for every specific component

Parameters:

parameter (Parameter) – Reference to an existing parameter in the component.

Returns:

  • A reference to a Spectrum holding the gradient if the parameter was

  • indeed a parameter of this component and has an analytical gradient

  • defined gradient. None in all other cases.

linear_function(m, q)

pyEELSMODEL.components.linear_background module

copyright University of Antwerp 2021 author: Jo Verbeeck and Daen Jannis

class pyEELSMODEL.components.linear_background.LinearBG(specshape, rlist=[1, 2, 3, 4, 5])

Bases: Component

Fast background model, where the number of components can be varied.

Parameters:
  • specshape (Spectrumshape) – The spectrum shape used to model

  • rlist (list) – List of the r values used in the linear background model. (default: [1,2,3,4,5])

calculate()

This calculates the spectral data of the component. Each derived class from Component will need to implement its own functionality here.

Return type:

None.

get_rlist()
getgradient(parameter)

calculate the analytical partial derivative wrt parameter j returns true if succesful, gradient is stored in component.gradient

linear_background(Alist, rlist)

pyEELSMODEL.components.lorentzian module

copyright University of Antwerp 2021 author: Jo Verbeeck and Daen Jannis

class pyEELSMODEL.components.lorentzian.Lorentzian(specshape, A, centre, fwhm)

Bases: Component

Initialises a lorentzian component.

Parameters:
  • specshape (Spectrumshape) – The spectrum shape used to model

  • A (float) – Amplitude of the lorentzian. Be careful about the exact implementation.

  • centre (float) – The position of the peak position

  • fwhm (float) – The full width half maximum of the lorentzian.

calculate()

Calculates the lorentzian function

getgradient(parameter)

Calculates the gradient with respect to the given parameter. Sets this has the gradient of the component.

Parameters

lorentz(x, A, x0, dT)

Definition of the lorentzian function. Quite important to know this when wanting to extract relevant infromation from it such as fwhm or integral.

pyEELSMODEL.components.lorentzian_sq module

copyright University of Antwerp 2021 author: Jo Verbeeck and Daen Jannis

class pyEELSMODEL.components.lorentzian_sq.Lorentzian_sq(specshape, A, centre, fwhm)

Bases: Component

calculate()

This calculates the spectral data of the component. Each derived class from Component will need to implement its own functionality here.

Return type:

None.

getgradient(parameter)

Get a reference to the gradient of this component with respect to parameter, if an analytical gradient is available. This function needs to be overoaded for every specific component

Parameters:

parameter (Parameter) – Reference to an existing parameter in the component.

Returns:

  • A reference to a Spectrum holding the gradient if the parameter was

  • indeed a parameter of this component and has an analytical gradient

  • defined gradient. None in all other cases.

lorentz_sq(x, A, x0, dT)

pyEELSMODEL.components.offset module

copyright University of Antwerp 2021 author: Jo Verbeeck and Daen Jannis

class pyEELSMODEL.components.offset.Offset(specshape, A)

Bases: Component

An offset component

calculate()

This calculates the spectral data of the component. Each derived class from Component will need to implement its own functionality here.

Return type:

None.

getgradient(parameter)

Get a reference to the gradient of this component with respect to parameter, if an analytical gradient is available. This function needs to be overoaded for every specific component

Parameters:

parameter (Parameter) – Reference to an existing parameter in the component.

Returns:

  • A reference to a Spectrum holding the gradient if the parameter was

  • indeed a parameter of this component and has an analytical gradient

  • defined gradient. None in all other cases.

pyEELSMODEL.components.plasmon module

copyright University of Antwerp 2021 author: Jo Verbeeck and Daen Jannis

class pyEELSMODEL.components.plasmon.Plasmon(specshape, A, Ep, Ew, n, tlambda, beta, E0)

Bases: Component

A physical model of ZL and plasmon peaks This is not very adquate to use for model based fitting. The description of the plasmon calculation can be found in the Egerton book, Edition 3 (p.139, formula 3.43c)

calculate()

This calculates the spectral data of the component. Each derived class from Component will need to implement its own functionality here.

Return type:

None.

calculate_plasmon(Ep, Ew, Eb, beta, E0)

The drude model of the plasmon from which the enerrgy differential cross section is calculated. The description of the formula can be found in the Egerton book (p.139, formula 3.43c)

Parameters:
  • Ep (float [eV]) – Position plasmon energy

  • Ew (float [eV]) – The width of the plasmon peak

  • Eb (float [eV]) – The binding energy of plasmon

  • beta (float [rad]) – The collection angle

  • E0 (float [V])

plasmon_function()
poisson_fraction(n, tlambda)
Parameters:
  • n – integer value of the plasmon

  • tlambda – thickness over mean free path (lambda) ratio

Returns:

fraction

pyEELSMODEL.components.polynomial module

copyright University of Antwerp 2021 author: Jo Verbeeck and Daen Jannis

class pyEELSMODEL.components.polynomial.Polynomial(specshape, order=1)

Bases: Component

A Polynomial component. The constant value of the polynomials are all set to 1 as initial value. The coefficients of the powers are normalized since they produce numerical results because the x-axis is useually expressed in eV.

Parameters:
  • specshape (Spectrumshape) – The spectrum shape used to model

  • order (uint) – The order of the polynomial.

calculate()

This calculates the spectral data of the component. Each derived class from Component will need to implement its own functionality here.

Return type:

None.

getgradient(parameter)

Get a reference to the gradient of this component with respect to parameter, if an analytical gradient is available. This function needs to be overoaded for every specific component

Parameters:

parameter (Parameter) – Reference to an existing parameter in the component.

Returns:

  • A reference to a Spectrum holding the gradient if the parameter was

  • indeed a parameter of this component and has an analytical gradient

  • defined gradient. None in all other cases.

pyEELSMODEL.components.powerlaw module

copyright University of Antwerp 2021 author: Jo Verbeeck and Daen Jannis

class pyEELSMODEL.components.powerlaw.PowerLaw(specshape, A, r)

Bases: Component

A power law background model

Parameters:
  • specshape (Spectrumshape) – The spectrum shape used to model

  • A (float) – Amplitude of the powerlaw. Defined such that the offset energy has the value of the amplitude A.

  • r (float) – The exponent value of the powerlaw.

autofit(spectrum, istart, istop)

Performs a first guess of the parameters from the Powerlaw fit. It checks if the obtained values are resonable and will apply them to the components parameters. The procedure is explained in Electron Energy Loss Spectroscopy (Third Edition) of Egerton in …

Parameters:
  • spectrum (Spectrum) – The spectrum data from which an estimate is done on the background

  • istart (int) – Index from where to start

  • istop (int) – Index indicating the end of the fitting region

Return type:

None.

autofit1(spectrum, istart, istop)

Performs a first guess of the parameters from the Powerlaw fit. It checks if the obtained values are resonable and will apply them to the components parameters. The procedure is explained in Electron Energy Loss Spectroscopy (Third Edition) of Egerton in …

Parameters:
  • spectrum (Spectrum) – The spectrum data from which an estimate is done on the background

  • istart (int) – Index from where to start

  • istop (int) – Index indicating the end of the fitting region

Return type:

None.

autofit_(spectrum, istart, istop)

Performs a first guess of the parameters from the Powerlaw fit. It checks if the obtained values are reasonable and will apply them to the components parameters. The procedure is explained in Electron Energy Loss Spectroscopy (Third Edition) of Egerton in …

Parameters:
  • spectrum (Spectrum) – The spectrum data from which an estimate is done on the background

  • istart (int) – Index from where to start

  • istop (int) – Index indicating the end of the fitting region

Return type:

None.

autofit_areas(spectrum, istart, istop)

Performs a first guess of the parameters from the Powerlaw fit. It checks if the obtained values are resonable and will apply them to the components parameters. The procedure is explained in Electron Energy Loss Spectroscopy (Third Edition) of Egerton in Chapter 4.4.2. (ISBN: 978-1-4419-9583-4).

Parameters:
  • spectrum (Spectrum) – The spectrum data from which an estimate is done on the background

  • istart (int) – Index from where to start

  • istop (int) – Index indicating the end of the fitting region

Return type:

None.

autofit_matrix(spectrum, istart, istop)
Weighted linear least squares where the variance is given by

the square root of the

signal

Parameters:
  • spectrum

  • istart

  • istop

Returns:

autofit_twowindow(spectrum, istart, istop)

Performs a first guess of the parameters from the Powerlaw fit. It checks if the obtained values are resonable and will apply them to the components parameters. The procedure is explained in Electron Energy Loss Spectroscopy (Third Edition) of Egerton in …

This is the two-window technique. It is quick and dirty, and not as accurate as a proper least squares fit, but is has its uses.

Parameters:
  • spectrum (Spectrum) – The spectrum data from which an estimate is done on the background

  • istart (int) – Index from where to start

  • istop (int) – Index indicating the end of the fitting region

Return type:

None.

calculate()

This calculates the spectral data of the component. Each derived class from Component will need to implement its own functionality here.

Return type:

None.

getgradient(parameter)

calculate the analytical partial derivative wrt parameter returns a reference to the gradient

powerlaw(A, r)

pyEELSMODEL.components.voigt module

copyright University of Antwerp 2021 author: Jo Verbeeck and Daen Jannis

class pyEELSMODEL.components.voigt.Voigt(specshape, A, centre, gamma, sigma)

Bases: Component

Initialises a voigt component. The voigt function is the convolution of a gaussian with a lorentzian function.

calculate()

This calculates the spectral data of the component. Each derived class from Component will need to implement its own functionality here.

Return type:

None.

get_fwhm()
getgradient(parameter)

Get a reference to the gradient of this component with respect to parameter, if an analytical gradient is available. This function needs to be overoaded for every specific component

Parameters:

parameter (Parameter) – Reference to an existing parameter in the component.

Returns:

  • A reference to a Spectrum holding the gradient if the parameter was

  • indeed a parameter of this component and has an analytical gradient

  • defined gradient. None in all other cases.

voigt(x, A, centre, gamma, sigma)

Voigt function. #todo add citation where to find definition of this calculation

Module contents