Static backgrounds
The naming of the following two background functions as “static backgrounds” might lead to some confusion. The functions shirley_calculate() and tougaard_calculate() are referred to as static simply because they aren’t designed to be directly integrated into the fitting model itself.
Because these functions are not part of the fit model, they need to be applied separately to the data, removing the background before applying the Levenberg–Marquardt algorithm through lmfit. Unlike the approach in Background Models, where the background is dynamically adjusted and optimized at each iteration step of model optimization, here the background has to be removed before the fitting process begins.
However, these static backgrounds are implemented iteratively, allowing their scaling parameters to be optimized for the input dataset.
Especially in cases where the fitting model is complex, applying these static background functions to the dataset can aid in approximating suitable starting parameters for the Background Models within the fit model.
shirley_calculate()
- lmfitxps.backgrounds.shirley_calculate(x, y, tol=1e-05, maxit=10, bounds=None)[source]
Calculates the Shirley background for a given set of x (energy) and y (intensity) data.
The implementation was inspired by the python implementation of Kane O’Donnell [5].
The Shirley background is calculated iteratively:
(1)\[B_{S, n}(E) = k_n \cdot \int_{E}^{E_{\text{right}}} [I(E') - I_{\text{right}} - B_{S, n-1}(E')] \, dE'\]- where:
\(B_{S, n}(E)\) represents the Shirley background at \(E\) in the \(n\)-th iteration,
\(I(E')\) is the intensity at \(E'\),
\(k_n\) is the Shirley scaling parameter for the \(n\)-th iteration.
\(E_{\text{right}}\) and \(I_{\text{right}}\) are the rightmost energy/intensity of the dataset.
The iterative process continues until the difference \(B_{S, n}(E) - B_{S, n-1}(E)\) is suitable small or the number of maximum iterations \(maxit\) is exceeded.
Initially, \(B_{S, 0}(E)=0\) is choosen and \(k_n\) is found from the requirement, that \(\left(I_{\text{left}}-B_{S, n}(E_{\text{left}})\right)=0\). For further details, please refer to e.g. S. Tougaard [6] .
Typically, convergence is reached after \(\approx 5\) iterations. The convergence criterion is:
(2)\[\langle\left(B_{S, n}(E)-B_{S, n-1}(E)\right)^2\rangle<tol\]Parameters:
Returns:
array: The function returns the calculated Shirley background as anarray.Hint
This function should be used, if you intend to calculate and remove the background from your data before starting the fitting procedure, if you instead wish to include the background in the fitting model, please use the desired background model, e.g. ShirleyBG.
tougaard_calculate()
- lmfitxps.backgrounds.tougaard_calculate(x, y, tb=2866, tc=1643, tcd=1, td=1, maxit=100)[source]
Calculates the Tougaard background for a given set of x and y data. The calculation is hereby based on the four-parameter loss function (4-PIESCS) as suggested by R.Hesse [1].
The implementation was inspired by the IGOR implementation of James Mudd [2].
The Tougaard background is calculated using:
(3)\[B_T(E) = \int_{E}^{\infty} \frac{B \cdot T}{{(C + C_d \cdot T^2)^2} + D \cdot T^2} \cdot y(E') \, dE'\]where:
\(B_T(E)\) represents the Tougaard background at energy \(E\),
\(y(E')\) is the measured intensity at \(E'\),
\(T\) is the energy difference \(E' - E\).
\(B\) parameter of the 4-PIESCS loss function as introduced by R.Hesse [1]. Acts as the scaling factor for the Tougaard background model. This parameter is the only one optimized/variated during the calculation.
\(C\) , \(C_d\) and \(D\) are parameter of the 4-PIESCS loss function as introduced by R.Hesse [1]. These parameters are kept fixed during the calculation.
To generate the 2-PIESCS loss function, set \(C_d\) to 1 and \(D\) to 0. Set \(C_d=1\) and \(D !=\) \(0\) to get the 3-PIESCS loss function.
For further details on the 2-PIESCS loss function, please refer to S.Tougaard [3], and for the 3-PIESCS loss function, see S. Tougaard [4].
During the calculation, the Tougaard background is calculated using the provided start parameters based on equation (3). This process is iteratively repeated, adapting the \(B\) parameter, until convergence is reached or the number of iterations exceeds \(maxit\).
The convergence is hereby defined by the deviation between the calculated Tougaard background \(B_T(E)\) and the measured intensity \(y(E)\) at the leftmost datapoint.
The Tougaard background is considered to converge if \(|B_T(E)-y(E)|< 10^{-6}\cdot B_T(E)\) is fulfilled.
Parameters:
Table 3 Available parameters Parameter
Type
Description
x
array1D-array containing the x-values (energies) of the spectrum.
y
array1D-array containing the y-values (intensities) of the spectrum.
tb
floatB parameter of the 4-PIESCS loss function [1]. Acts as scaling parameter and is optimized during the fit. Defaults to 2866 as starting value.
tc
floatC parameter of the 4-PIESCS loss function [1]. Defaults to 1643.
tcd
floatC’ parameter of the 4-PIESCS loss function [1]. Defaults to 1.
td
floatD parameter of the 4-PIESCS loss function [1]. Defaults to 1.
maxit
intMaximum number of iterations before calculation is interrupted. Defaults to 100.
Returns:
tupleof (numpy.ndarray,float): The function returns a tuple consisting of the calculated Tougaard background as anumpy.arrayand the Tougaard scale parameter \(B\) asfloat.Hint
This function should be used, if you intend to calculate and remove the background from your data before starting the fitting procedure, if you instead wish to include the background in the fitting model, please use the desired background model, e.g. TougaardBG.