GUI: transformations

Experimental 1D signals

The first three transformation nodes use the same transformation widget. Its sole purpose is to highlight monochromator glitches in the current transformation node, as well as in the µd(E) and χ(k) nodes.

class parseq_XAS.XAS_widgets.CurWidget(*args: Any, **kwargs: Any)

This widget provides a single tool – a panel for highlighting monochromator glitches across several transformation nodes. It is not a part of any transformation and serves purely for visual diagnostics.

Glitch detection is based on scipy.signal.find_peaks(). Refer to the tooltips of the two associated parameters for details.

Note

Glitch detection operates on a single data item only – the first one among any selected items.

Note

Glitch detection is static and does not update automatically when the data selection changes. Updates must be triggered manually by re-enabling the “mark glitches” checkbox.



class parseq_XAS.XAS_widgets.HERFDWidget(*args: Any, **kwargs: Any)

This widget controls the calculation of HERFD µ from a 2D data array in “scanning energy” versus “tangential detector axis” coordinates. It defines the parameters for two operations: level cutoff and integration within a region of interest (ROI).



Level cutoff

Applying a cutoff can be useful if a defective pixel appears within the ROI. The side histograms can assist in selecting an appropriate cutoff level.

Caution

Check the “max pixel” value calculated after applying the cutoff. It should be significantly lower than the cutoff value; otherwise, the cutoff may remove valid signal.

Integration ROI

Two types of ROIs are available: a vertical band (horizontal range) and a slanted band. The ROI can be defined interactively using the mouse in the 2D plot or by editing the “geometry” field in the table. The current ROI can be removed via the context menu in the plot.

The calculations are performed by XAS_transforms.MakeHERFD.

Absorption coefficient µd(E)

class parseq_XAS.XAS_widgets.MuWidget(*args: Any, **kwargs: Any)

The calculations are performed by XAS_transforms.MakeChi.

Tip

The range-selection widgets provide both an automatic option and a custom selection option. The latter can be defined interactively using the mouse in the plot or by entering values in the corresponding edit fields. Hovering the mouse over an edit field reveals the meaning of the min and max values – these may represent fractions of a given range or absolute values in specific units. Likewise, the tooltip of the “auto” radio button indicates the automatically selected range.

Edge position E₀

The three E₀ options give similar, still varying, results.

0: (µd)’ max

1: (spline)’ max

2: µd’ peak mean

E₀=7112.498

E₀=7112.655

E₀=7112.333







When the absorption edge exhibits multiple maxima in its derivative, the edge position should be assigned to the first maximum. In such cases, the \(E_0\) search interval should be defined so as to exclude the main derivative peak:



Energy calibration

The identified \(E_0\) position can be aligned with a tabulated value, either selected from the drop-down list or entered manually. Alternatively, a fixed shift of \(E_0\) can be specified.

The first approach is recommended for reference materials with a known edge position (typically a metal foil), as it determines the appropriate \(E_0\) offset. This offset can then be propagated to other spectra acquired during the same beamtime.

In most cases, the energy correction is applied as a constant offset in the Bragg angle.

Pre-edge background

Note

When “show subtracted” is unchecked, not only does the pre-edge background become visible, but edge normalization is also disabled.

For transmission spectra, a Victoreen polynomial, \(aE^{-3} + bE^{-4}\), or a modified form, \(aE^{-3} + b\), is typically used. For fluorescence spectra, the background is usually modeled as either constant or linear.

Pinhole correction

Tip

The pinhole correction widget can be found in the “data correction” splitter, which is hidden by default. It can be revealed using the small vertical button located to the left of the transformation widget.

The effect of pinholes in transmission spectra is modeled using a binary approximation: a fraction \(x\) of the incident x-rays passes through pinholes without absorption, while the remaining fraction is absorbed by the sample. The transmitted intensity is then given by:

\(I_1 = x I_0 + (1-x) I_0\exp(-(µd)_{true}) = I_0 \exp(-(µd)_{distorted})\).

From this expression, the true absorption term can be recovered from the distorted one:

\((µd)_{true} = \ln \left(\frac{1-x}{\exp(-(µd)_{distorted}) - x}\right)\).

When the sample is thick and its absorption is dominated by a filler material, a “pinhole” is probably not a true void that transmits the beam without any attenuation, but rather a region containing only the filler. For example, in a transmission liquid cell, a pinhole may result in a partial loss of the absorption edge while retaining substantial absorption from the liquid. The transmitted intensity can be expressed as

\(I_1 = x I_0 + y I_0\exp(-z(µd)_{pre-edge}) + (1-x-y) I_0\exp(-(µd)_{true}) = I_0 \exp(-(µd)_{distorted})\),

where a fraction \(x\) of the incident x-rays passes through pinholes without attenuation, a fraction \(y\) passes through the filler material (matrix) alone, and the corresponding absorption is modeled as a fraction \(z\) of the extrapolated pre-edge absorption.

The true absorption term can be recovered as:

\((µd)_{true} = \ln \left(\frac{1-x-y}{\exp(-(µd)_{distorted}) - x - y \exp(-z(µd)_{pre-edge})}\right)\).

Instead of attempting to correct the pinhole effect, the pinhole-induced distortion can be incorporated directly into the Linear Combination Fit (LCF). The unknown parameters \(x\), \(y\), and \(z\) can then be treated as fitting variables and determined simultaneously through the fitting procedure.

Self-absorption correction

See the description of self-absorption correction, including its background and history, here.

Tip

The self-absorption correction widget can be found in the “data correction” splitter, which is hidden by default. Use the small vertical button located to the left of the transformation widget to make it visible.

Provide a chemical formula (see the given examples). Select a table of scattering factors from the drop-down list; the Chantler dataset is recommended. The parameter “calibration energy” specifies the energy at which the calibration constant C is calculated. The status indicator below this field turns green if an absorption edge within the spectrum range is detected.

The “fluorescence energy” parameter is currently a free input field but is planned to become a drop-down list in future versions. The three angular parameters are defined in the geometry figure.

Note

The “thin” variant of the correction is computationally more demanding.

Post-edge background and edge normalization

The post-edge background is required for defining edge normalization. It is constructed using polynomial interpolation. The considerations for selecting the polynomial are the same as for the pre-edge background.

Note

The “show edge height normalized” checkbox is not specific to an individual data item but is a global display setting affecting all data items.

Note

The “show edge height normalized” option is disabled when the pre-edge background is displayed without subtraction.

The post-edge background can also be displayed in a “flat” (horizontal) form. This representation can be useful for linear combination fitting and function fitting of \(\mu(E)\).

Atomic-like absorption coefficient µ₀

A “µ₀ prior” curve is a step-like function derived from the absorption spectrum itself, optionally including a “white line”. The sharp step can be smoothed, and the curve may also be vertically adjusted by applying a multiplicative factor.

Two methods are available for constructing the spline: “through internal k-spaced knots” and “smoothing spline”. The former method is generally preferable, as it restricts the spline to low-frequency variations, allowing \(\chi(k)\) to retain its true structural oscillations. In contrast, the smoothing spline may partially suppress the signal in \(\chi(k)\) by transferring it into \(\mu_0\), although this method is simpler to use and typically robust.

Tip

When optimizing \(\mu_0\), make the FT node visible by dragging it to another screen or docking it next to the µd(E) node, as shown in the figure below. The goal of optimization is to minimize the low-r portion of the FT curve, typically within the range 0 to 1 Å.

 A demonstration of simultaneous observation of µd(E) and χ(r) during the optimization of µ₀.

 A demonstration of simultaneous observation of µd(E) and χ(r) during the optimization of µ₀.

In the first µ₀ method (“through internal k-spaced knots”), a given number of knots are placed equidistantly in k-space, and a spline is constructed through them. The difference µ₀ − µ₀ prior can optionally be weighted by a \(k^{\rm exp\ weight}\) factor. In addition, a selected number of the initial knots can vary in height to automatically minimize the low-r portion of the FT EXAFS. These variable knots are indicated by larger markers in the plot.

The number of variable knots should be kept small (much smaller than the total number of knots) to ensure stable minimization.

Note

The minimization may occasionally become unstable, in which case the original (fixed) knot configuration can yield better results. This behavior is typically caused by strong correlations between the knots, leading to an ill-posed optimization problem.

The second µ₀ method (“smoothing spline”) depends on a smoothing parameter that is adjusted based on the low-r portion of the Fourier transform. When comparing the two methods, the first FT peak is generally lower with the smoothing spline. This reduction reflects partial signal loss, which may be acceptable if it remains smaller than the uncertainty in the first-shell coordination number.

EXAFS function χ(k)

class parseq_XAS.XAS_widgets.ChiWidget(*args: Any, **kwargs: Any)

Data rebinning

 The rebin widget.

 The rebin widget.

If the energy scan is performed continuously with a constant slew rate, the resulting spectrum is typically strongly oversampled. This means that several experimental points fall within a single \(dk\) interval of \(\chi(k)\). Moreover, the \(dk\) intervals correspond to increasingly larger energy ranges toward the end of the spectrum, so that more experimental points are grouped within each interval.

These points can be averaged within each interval; this procedure is referred to as rebinning.

The rebinning table defines four regions by specifying their boundaries and step sizes in either energy or k-space.

Tip

Hover the mouse pointer over any table cell to see a tooltip describing the meaning of its value.

k range

 The k range panel.

 The k range panel.

The desired k-range can be set either using the spin box controls or interactively via the range selection widget in the plot.

Note

The default maximum k-value is not set to the end of the spectrum. Check the “data k max” value and use the icoLast button to extend the range to its maximum.

Denoising

Denoising utilizes scipy.signal.butter(). The two parameters, order and low-pass frequency, correspond to the first two arguments of scipy.signal.butter(). The calculated noise level is defined as the normalized difference between the original and the denoised \(\chi \cdot k^w\) curve (see tooltip for details).

FT window

The tapered FT window functions (the last three options in the list) are defined by two parameters: the width of the tapered region and the minimum value reached at the ends. These parameters can be adjusted either via the spin box controls or interactively using the pointer widget in the plot. The pointer can be dragged within the top-left quadrant of the plot.

Note

The true maximum value of the FT window function is 1. However, its displayed height is scaled to match the vertical range of the data. This scaling may interfere with auto-zooming. In such cases, temporarily hide the window, perform auto-zooming, and then display the window again.

Fourier-transformed EXAFS function χ(r)

class parseq_XAS.XAS_widgets.FTWidget(*args: Any, **kwargs: Any)

The resulting Fourier transform (FT) is truncated at a selected maximum \(r\) value, primarily for visualization purposes.

The zero-frequency component of the FT can be removed by forcing the first integral of \(\chi(k) \cdot k^w\) to vanish. This behavior is controlled by the checkbox “force FT(0)=0”.

BFT window

The Back Fourier Transform (BFT) window function can be defined either using the spin box controls or interactively through the range selection widget in the plot.

Note

The true maximum value of the FT window function equals 1. However, its displayed height is scaled to the vertical range of the data. This scaling may interfere with auto-zooming. In such cases, hide the window, perform auto-zoom, and then display the window again.

GUI: fits

Linear Combination Fit of µ(E)

class parseq.gui.fits.LCFWidget(*args: Any, **kwargs: Any)
 A collection of reference Cu K XANES spectra and two test mixtures.

 A collection of reference Cu K XANES spectra and two test mixtures.
 A Linear Combination Fit of a test mixture. Notice the two ways of fixing fitting parameters, here the ΔE parameter.

 A Linear Combination Fit of a test mixture. Notice the two ways of fixing fitting parameters, here the ΔE parameter.

Consider the supplied project file saved/Cu-LCF.pspj.

In this example, 16 reference Cu K XANES spectra can be used as a basis set for the Linear Combination Fit (LCF). Two physical mixtures, mix1 and mix2, were prepared to validate the fitting results.

Reference spectra can be added to the fit in two ways: from a list of spectra available in the popup menu or from the data tree using the popup menu command “Add ref spectra”.

Each reference spectrum introduces two fitting variables: weight \(w\) and energy shift \(\Delta E\). The necessity of \(\Delta E\), as well as its range and interpretation, is left to the user. Allowing \(\Delta E\) to vary may be useful when spectra originate from different sources with slightly misaligned energy scales.

The weights \(w\) should typically be constrained within the interval [0, 1]. In the fit table, an additional value, δ, defines the display precision and sets the increment used by the spin-box editor for the initial \(w\) value. Final parameter values and their uncertainties can be examined with higher precision via cell tooltips.

A fitting variable can be fixed in three ways: (a) by setting a tie expression "fixed", (b) by assigning a constant tie expression such as "=0.5", (c) by defining bounds with min ≥ max, the value is fixed at min.

Tie expressions can also link multiple \(w\) variables using their indexed notation (e.g., w[1], w[2]). Refer to the tooltips of the table headers for details. In addition, user-defined metavariables can be introduced and used in tie expressions.

The entire fit configuration can be copied from one data item to others. All fitting results and settings can be exported by saving the project. The project file is a text file in ini format and contains the complete fit description.

Function Fit of µ(E)

class parseq.gui.fits.FunctionFitWidget(*args: Any, **kwargs: Any)
 A Function Fit example.

 A Function Fit example.

The formula may use NumPy functions accessed as attributes of np, for example np.exp(x). In addition, the following helper functions are available:

gau(x, m, s)

normalized Gaussian function, where m is the center and s is the standard deviation (sigma)

lor(x, m, s)

normalized Lorentzian function, where m is the center and s is the half-width at half-maximum (HWHM)

EXAFS Fit of χ(k) and χ(r)

class parseq.gui.fits.EXAFSFitWidget(*args: Any, **kwargs: Any)
 An EXAFS Fit example with a single coordination shell.

 An EXAFS Fit example with a single coordination shell.

Consider the supplied project file saved/Cu.pspj. In the BFT tab, click the “EXAFS fit” button below the plot, select the first data item, and hide the others (use the eye icon in the data tree header). Then press “Start fitting” to generate the fit curve.

The first tab of the fit widget corresponds to the first coordination shell (in this example, a single shell is used). The last tab contains the factor \(S_0^2\) along with any user-defined metavariables.

Hover the mouse cursor over the table headers to view descriptions of the corresponding columns.

 The correlation matrix of a single shell fit.

 The correlation matrix of a single shell fit.

The last two columns display fitting errors computed in two ways: (a) without considering pair correlations, and (b) including all pair correlations. The latter should generally be preferred, but it may fail if the \(\chi^2\) function does not reach a true minimum.

In such cases, the table of pair correlation coefficients can provide useful diagnostic information. It can be displayed by clicking on the headers of the error columns. Problematic variables identified in this way should be constrained or fixed to improve the stability of the fit.

 The FEFF-file selection dialog.

 The FEFF-file selection dialog.

Each coordination shell requires a FEFF file containing scattering amplitudes and phases (feffNNNN.dat), generated by the FEFF program (specifically the ff2chi module with PRINT level set to 3). Use the icoAP button to open the FEFF file selection dialog. This dialog scans the current directory for feffNNNN.dat files and highlights in green those corresponding to single-scattering paths.

The preview panel displays the header of the selected file, including a summary shown in bold green text. Once a file is confirmed, its deg (degeneracy) and reff (effective radius) values are used to initialize the shell parameters n and r.

Tip

Multiple feffNNNN.dat files can be selected simultaneously, which results in the creation of multiple coordination shells.

Note

Multiple-scattering paths are handled in the same way as single-scattering ones. Appropriate tie expressions should be applied to coordination numbers and, if necessary, to interatomic distances.

The fit uses four parameters per shell: r1, n1, s1, e1, r2, and so on. The global amplitude factor \(S_0^2\) is represented by the variable s0. These variable names can be referenced in tie expressions. Examples of valid expressions include "fixed", "=n1*0.5", and ">4.4-r1" (e.g., for the r2 parameter, enforcing \(r_1 + r_2 > 4.4 \,\text{\AA}\)).

Note

The \(E_0\) shift parameters (e) for different shells should not differ significantly. The acceptable variation depends on how the atomic potentials were calculated. If they were obtained self-consistently, the shifts should be identical. In any case, shells corresponding to the same chemical element should share the same energy shift.

 An example of a joint fit of two EXAFS spectra.

 An example of a joint fit of two EXAFS spectra.

Tie expressions may refer to fit parameters from other data items. Consider the project file saved/CeRu2.pspj, where the same interatomic distance is probed at two different absorption edges.

The tie expression "=fit['CE0074'].r1" assigns the parameter r2 to be equal to r1 of the data item with alias 'CE0074'. In this way, two otherwise independent fits are coupled into a single, larger fitting problem.

The resulting correlation matrix can be examined to identify the relationships between the involved fitting parameters.