No GUI: data nodes¶
Experimental signals¶
One of the design goals of ParSeq is to allow data to be imported into any data
node, not only into the head node(s) of a pipeline. Nevertheless, some nodes in
the ParSeq-XAS pipeline are designated as input nodes – those listed in this
section – where experimental signals are initially loaded. The nodes
NodeIF and NodeIE perform similar functions and can accept
either single-channel or multi-channel fluorescence or electron yield signals.
The separation into two distinct nodes reduces the need to redefine data
formats when switching between multi-channel and single-channel data.
The node NodeIXES is designed to handle a 2D intensity array obtained
from a HERFD scan.
Note
Please refer to the general data format definitions of ParSeq. Note that any data channel can be defined using a Python expression, e.g. np.log(Col5/Col4).
- class parseq_XAS.XAS_nodes.NodeIT(widgetClasses=[])¶
- The following three arrays are required:
- eraw: the original energy axis in eV; it will later transform to e,i0: the I₀ signal – intensity upstream of the sample,itr: the transmitted intensity.
An optional array eref can be given to be used for energy calibration. If used, it should contain an absorption spectrum of a foil.
- class parseq_XAS.XAS_nodes.NodeIF(widgetClasses=[])¶
- The following three arrays are required:
- eraw: the original energy axis in eV; it will later transform to e,i0: the I₀ signal – intensity upstream of the sample,ify: the partial fluorescence yield signal.
An optional array eref can be given to be used for energy calibration. If used, it should contain an absorption spectrum of a foil.
Note
Please see the general data format definitions of ParSeq. Multiple fluorescence channels can either be loaded as a sum or a collection of individual spectra. The data format can be defined by a Python list or a list comprehension expression, e.g
[f'Col{n}' for n in range(10, 17)]. One can also insert it into thesum()function.
- class parseq_XAS.XAS_nodes.NodeIE(widgetClasses=[])¶
- The following three arrays are required:
- eraw: the original energy axis in eV; it will later transform to e,i0: the I₀ signal – intensity upstream of the sample,iey: the partial fluorescence yield signal.
An optional array eref can be given to be used for energy calibration. If used, it should contain an absorption spectrum of a foil.
- class parseq_XAS.XAS_nodes.NodeIXES(widgetClasses=[])¶
- The following three arrays are required:
- eraw: the original energy axis in eV; it will later transform to e,i0: the I₀ signal – intensity upstream of the sample,xes2D: the 2D intensity array in (scan axis (DCM energy) vs meridional detector pixel) coordinates. The number of rows of xes2D must be equal to the length of eraw and i0.
An optional array eref can be given to be used for energy calibration. If used, it should contain an absorption spectrum of a foil.
Absorption coefficient µ(E)¶
- class parseq_XAS.XAS_nodes.NodeMu(widgetClasses=[])¶
- The following two arrays are required:
- eraw: the original energy axis in eV; it will transform to e,muraw: the original absorption coefficient; it will transform to mu.
An optional array eref can be given to be used for energy calibration. If used, it should contain an absorption spectrum of a foil.
EXAFS function χ(k)¶
- class parseq_XAS.XAS_nodes.NodeChi(widgetClasses=[])¶
- The following two arrays are required:
- k: the photoelectron wavenumber axis as an equidistant mesh,chi: the EXAFS function multiplied by kʷ.
Fourier-transformed EXAFS function χ(r)¶
- class parseq_XAS.XAS_nodes.NodeFT(widgetClasses=[])¶
- The following four arrays are required:
- r: the uncorrected distance axis as an equidistant mesh,ft: the absolute Fourier-transformed EXAFS function multiplied by kʷ.ftr: the real Fourier-transformed EXAFS function multiplied by kʷ.fti: the imag Fourier-transformed EXAFS function multiplied by kʷ.
Fourier-filtered EXAFS function χ̃(k)¶
- class parseq_XAS.XAS_nodes.NodeBFT(widgetClasses=[])¶
- The following two arrays are required:
- bftk: the photoelectron wavenumber axis as an equidistant mesh,bft: the EXAFS function multiplied by kʷ.
No GUI: data transformations¶
Make absorption coefficient¶
In all cases, the obtained absorption coefficient is unnormalized, i.e. defined down to an unknown multiplicative constant.
- class parseq_XAS.XAS_transforms.MakeTrMu(fromNode, toNode)¶
The transmission absorption coefficient is calculated as \(µ_{tr}(E)=\log(I_0/I_{tr})\).
- class parseq_XAS.XAS_transforms.MakeFYMu(fromNode, toNode)¶
- class parseq_XAS.XAS_transforms.MakeTEYMu(fromNode, toNode)¶
These versions of \(µ(E)\) (in fluorescence or electron yield) are obtained by dividing the measured signal by \(I_0\). In addition, the result is multiplied by \(\max(I_0)\) in order to keep the physical meaning and units of the original signal.
- class parseq_XAS.XAS_transforms.MakeHERFD(fromNode, toNode)¶
The 2D count array xes2D (the scan axis (DCM energy e) vs meridional detector pixel) is summed within a given band ROI horizontally (i.e. the columns are summed) to get a 1D count array of the length of e. This array is divided by \(I_0\) and multiplied by \(\max(I_0)\) to get the HERFD absorption coefficient in count units.
Make EXAFS function χ(k)¶
- class parseq_XAS.XAS_transforms.MakeChi(fromNode, toNode)¶
This transformation is the most extensive in terms of both code size (~600 lines of Python) and computational load. It consists of several sub-steps, which are described below.
Edge position \(E_0\)¶
The absorption coefficient is differentiated and may optionally be smoothed. The value of \(E_0\) is determined within the search interval defined by e0Where (specified as two relative fractions of the energy range of the spectrum). The determination is based on one of three methods selected via e0Method:
(0) maximum of the raw derivative,(1) maximum of the derivative of an interpolating spline,(2, default) center of mass of the derivative of an interpolating spline.Energy calibration¶
The energy axis can be calibrated so that the calculated \(E_0\) matches a tabulated value. Calibration can be performed using a Bragg angle offset (default), a lattice parameter offset, or a constant energy offset (eShiftKind = 0, 1, 2). The shift can be applied either by adjusting \(E_0\) to a target value (eCalibrationMethod = 0) or by applying a specified offset to \(E_0\) (eCalibrationMethod = 1). The latter approach is useful when transferring a calibration shift – determined, for example, from a metal foil – to other spectra measured during the same beamtime.
If a calibration foil is measured simultaneously with the sample, two calibration scenarios are possible:
1. The sample and foil spectra are loaded separately by modifying their format definitions. The foil spectrum is calibrated, and its resulting \(E_0\) shift is then applied to the sample spectrum.
2. Only the sample spectrum is loaded, while the derivative of the reference foil spectrum is used for determining \(E_0\) (by setting useERefCurve = True).
Data rebinning¶
If the energy scan is performed in continuous scanning with a constant slew rate, the resulting spectrum is often strongly oversampled. In such cases, multiple experimental points may fall within a single \(dk\) interval (the EXAFS function is defined on a uniform \(dk\) grid, see below). Moreover, since k-space and energy space are quadratically related, the energy intervals corresponding to \(dk\) increase linearly with k. As a result, progressively more experimental points are grouped within a single \(dk\) interval toward the high-energy end of the spectrum.
When converting from energy space to k-space, interpolation is applied, typically using only the local polynomial defined by neighboring experimental points. To make use of all measured data, an alternative approach – rebinning – can be employed. This method aggregates all experimental points within each \(dk\) interval prior to interpolation.
Rebinning is controlled by the user-defined rebinRegions dictionary, which specifies regions (pre-edge, edge, post-edge, and EXAFS) through their boundaries (splitters) and bin sizes (deltas). The resulting bins are passed to
numpy.histogram()to perform the rebinning.The number of original bins and the distribution of the new bins across regions are reported in nbinOriginal and binDistrNew, respectively.
Pre-edge background¶
The pre-edge background \(\mu_b(E)\) is constructed using polynomial interpolation over the region specified by preedgeWhere. The polynomial form is defined by preedgeExps.
For absorption spectra measured in transmission mode, a Victoreen polynomial \(aE^{-3} + bE^{-4}\), or a modified version \(aE^{-3} + b\), is typically used. The coefficients are determined via least-squares fitting using the
numpy.polynomial.Polynomialclass.For absorption spectra measured in fluorescence mode, explicit background subtraction is often unnecessary. In many cases, a constant offset (power “0”) is sufficient. When the spectrum exhibits a gradual increase with energy, a linear approximation (powers “0” and “1”) can be applied.
Self-absorption correction¶
See the description of self-absorption correction, including its history, here.
The correction is defined by the dictionary selfAbsorptionCorrectionDict, which includes the following keys:
corrChemFormula – chemical formula of the material,
corrDataTable – absorption data source (one of “Henke”, “BrCo”, “Chantler”, or “Chantler total”),
corrCalibEnergy – energy at which the calibration constant \(C\) is determined,
corrFluoEnergy – fluorescence line energy,
corrPhiDeg, corrThetaDeg, corrTauDeg – observation angles φ, θ, and τ (in degrees),
corrFormula – correction model (“thick” or any other string),
corrThickness – edge jump value used in the thin sample case.
The entry selfAbsorptionCorrectionDict[‘corrJumpStr’] contains a string representing the tabulated edge jump if it could be determined. If the specified material does not exhibit an absorption edge within the energy range of the spectrum, this is reported in the same entry.
Post-edge background and edge normalization¶
The post-edge background is required for proper edge normalization.
It is constructed by polynomial interpolation over the region specified by postedgeWhere, with the polynomial form defined by postedgeExps. The same considerations for selecting the polynomial apply as for the pre-edge background.
The resulting edge height is reported in edgeJump.
In addition, the post-edge background can be used to create a “flat” representation of the absorption coefficient, in which the post-edge region appears horizontal. This representation is particularly useful for linear combination fitting and function fitting of \(\mu(E)\).
Atomic-like absorption coefficient µ₀¶
The definition of the EXAFS function (see below) includes \(\mu_0\) – an artificial absorption coefficient representing the material in the absence of EXAFS oscillations, i.e. as if the central atom were isolated without neighboring atoms. Since such a single-atom gas is typically not experimentally accessible – and its electronic state would differ from that in condensed matter – \(\mu_0\) must be constructed artificially. It is assumed to be a smooth function of energy and is therefore usually approximated by a spline.
Two methods are available for constructing the spline, controlled by mu0method (0 or 1): “through internal k-spaced knots” and “smoothing spline”. The first method is generally preferred, as it preserves high-frequency oscillations in \(\chi(k)\) by restricting \(\mu_0\) to low-frequency components. In contrast, the smoothing spline may partially absorb real EXAFS signal into \(\mu_0\), reducing the amplitude of \(\chi(k)\). However, it is simpler to use and typically more robust.
Before constructing \(\mu_0\), an auxiliary curve “µ₀ prior” is generated to shape the result to resemble an absorption edge, optionally including a white line. This prior is subtracted from \(\mu\) before spline fitting and added back afterward.
In the first method (spline through k-spaced knots), a specified number of knots (mu0knots) are placed uniformly in k-space, and a least-squares B-spline is computed using
scipy.interpolate.LSQUnivariateSpline(). The difference \(\mu_0 - \mu_0^{\mathrm{prior}}\) can optionally be weighted by \(k^w\) (with \(w\) = mu0kpow). Additionally, a selected number of initial knots can be allowed to vary in height to minimize the low-R region (defined by ftMinRange) of the Fourier-transformed EXAFS signal. The number of such variable knots (ftMinNKnots) should be kept small relative to the total number of knots to ensure stable minimization.The second method (smoothing spline) depends on a smoothing parameter (mu0smoothingFactor), which is typically adjusted by examining the low-R region of the Fourier transform. Compared to the first method, the resulting first Fourier peak is consistently lower due to partial signal loss. This attenuation is acceptable if it remains smaller than the uncertainty in determining the first-shell coordination number.
k-mesh and χ(k)¶
Finally, the EXAFS function χ(k) is defined as:
\[χ(k) = \frac{µ - µ_b - µ_0}{µ_0 - µ_b}\]where
\[k = \sqrt{2m_e(E-E_0)} / \hbar\]The resulted χ(k) is interpolated onto the equidistant k-mesh defined by krange and dk and weighted by \(k^w\), where \(w\) is defined by kw.
Denoising¶
The EXAFS curve can optionally be denoised using
scipy.signal.butter(). The two main parameters – order and low-pass frequency – correspond to the first two arguments ofscipy.signal.butter(). The former is used directly, while the latter is scaled as \(W_n = (\text{low-pass frequency}) \times k_{\max}\). The noise level is estimated as the normalized difference between the original and the denoised \(\chi \cdot k^w\) curve:\[N/S = \left( \sum_k(χ·k^w-χ_{\rm denoised}·k^w)^2 / \sum_k(χ_{\rm denoised}·k^w)^2 \right)^{1/2}.\]
Make Fourier-transformed EXAFS function χ(r)¶
- class parseq_XAS.XAS_transforms.MakeFT(fromNode, toNode)¶
The use of a uniform \(\chi(k)\) grid enables efficient computation via the Fast Fourier Transform (FFT). ParSeq-XAS uses the NumPy function
fft.rfft()to compute the one-dimensional FFT for real-valued input.Because the EXAFS Fourier transform uses the kernel \(\exp(-2ikr)\) rather than the standard \(\exp(-ikr)\), the result is scaled by \(dk/2\) instead of the usual \(dk\). The real-space sampling interval is given by \(dr = \pi / (N \cdot dk)\). The corresponding real-space grid is obtained using
fft.rfftfreq(N, dk/π), where the number of grid points \(N\) is defined by the class variablenfft(set to 4096).Before performing the Fourier transform, \(\chi(k)\) is multiplied by a window function selected via ftWindowKind. Available options include ‘none’, ‘box’, ‘linear-tapered’, ‘cosine-tapered’, and ‘Gaussian-tapered’.
Optionally, the zero-frequency component (corresponding here \(r = 0\)) can be suppressed by enforcing a zero integral of \(\chi(k)k^w\). This behavior is controlled by forceFT0.
For visualization purposes, the resulting Fourier transform is truncated at a user-defined maximum distance rmax.
Make back-Fourier-transformed EXAFS function χ̃(k)¶
- class parseq_XAS.XAS_transforms.MakeBFT(fromNode, toNode)¶
This class applies a window function, as defined by bftWindowKind, bftWindowRange, and bftWindowWidth, and computes the Back Fourier Transform (BFT) using NumPy’s
fft.irfft().The resulting BFT is then restricted to the k-range defined in the preceding steps.
No GUI: data fits¶
Linear Combination Fit of µ(E)¶
- class parseq_XAS.XAS_fits.LCF_mu(node=None, widgetClass=None)¶
The Linear Combination Fit (LCF) models the spectrum of interest as a weighted sum of reference spectra. In this procedure, the array attribute flat (the flattened absorption spectrum with a horizontal post-edge) is used as the ordinate, while e serves as the abscissa. The resulting fit curve is stored in a new array attribute, fitLCF, within the data container.
The fitting process creates an attribute lcf_params in the data container. This attribute is a list of dictionaries – one per reference spectrum – with the following entries:
name str, alias of the reference spectrum
use bool, enables or disables the reference
w float, weight of the reference
wBounds 3-list [min, max, Δ]; Δ is used only by the GUI
If xVary is enabled, the following additional entries are included:
dx float, energy shift of the reference
dxBounds 3-list [min, max, Δ] for the energy shift
Optional entries wtie and dxtie define tie expressions for the weight (w) and energy shift (dx). A tie expression is a string that either begins with “fix” or with one of the symbols “=”, “>”, or “<”, followed by a Python expression involving other parameters (e.g. “w[1]”, “dx[2]”). User-defined metavariables may also be introduced for use in such expressions. Alternatively, parameters can be fixed by setting their bounds such that min ≥ max, in which case the parameter is fixed at the value of min.
After fitting, the entries wError and dxError store the estimated uncertainties of the corresponding parameters.
The class variable xVary determines whether reference spectra are allowed to shift along the energy axis, which can be useful when energy calibration is uncertain.
Optionally, a pinhole fraction can be introduced as an additional fitting parameter, primarily relevant for transmission measurements.
The fitting itself is performed using
scipy.optimize.curve_fit(). The resulting fit information returned by this function is stored in thelcf_resultattribute of the data container.
Function Fit of µ(E)¶
- class parseq_XAS.XAS_fits.FunctionFit_mu(node=None, widgetClass=None)¶
The Function Fit fits a Python expression that depends on a set of user variables to the data. In this procedure, the array attribute flat (the flattened absorption coefficient with a horizontal post-edge) of the fitted data object is used as the ordinate, while e serves as the abscissa. The fit curve is stored as a new array attribute, fitFunc, in the data container.
The fitting process creates several attributes in the data container:
ffit_formula str, the fit formula
ffit_params dict, fitting variables as keys
ffit_xRange 2-list [min, max], defining the energy range
The dictionary ffit_params is itself a dictionary of dictionaries with the following entries:
value float, current value of the fitting variable
lim 2-list [min, max], bounds of the variable
tie str, tie expression linking the variable to others
error float, estimated uncertainty of the variable
The fitting itself is performed using
scipy.optimize.curve_fit(). The resulting fit information returned by this function is stored in the ffit_result attribute of the data container.
EXAFS Fit of χ(k) and χ(r)¶
- class parseq_XAS.XAS_fits.EXAFSFit(node=None, widgetClass=None)¶
The EXAFS Fit models the data as a sum of EXAFS shells. The array attribute bft of the fitted data object is used as the ordinate, while the attribute bftk serves as the abscissa. The fit curve is stored as a new array attribute, bftfit, in the data container. Optionally, the fit can be performed in Fourier space; in this case, ft is used versus r, and the fit curve is stored in ftfit.
The fitting process creates several attributes in the data container:
exafsfit_params list of dictionaries, one per EXAFS shell
exafsfit_aux list of shell specifications, including paths to FEFF files and their descriptions
exafsfit_kRange 2-list [min, max] of the k-range
exafsfit_k_use bool, whether the fit is performed in k-space
exafsfit_rRange 2-list [min, max] of the r-range
exafsfit_r_use bool, whether the fit is performed in r-space
The list exafsfit_params contains one dictionary per shell. Each shell dictionary defines the four fitting parameters
r,n,s, andeas keys, with corresponding parameter dictionaries as values. Each parameter dictionary includes:value float, current value of the parameter
step float, step size used in the fitting procedure
lim 2-list [min, max], parameter bounds
error float, estimated uncertainty of the parameter
Optionally, a parameter dictionary may also include a tie entry defining a constraint expression.
The list exafsfit_params includes an additional dictionary that defines the
s0parameter (the multi-electron damping factor), along with optional metavariables.The fitting is performed using
scipy.optimize.curve_fit(). The resulting fit information returned by this function is stored in the exafsfit_result attribute of the data container.