spectra_analysis¶
Set of functions for analysing x-ray absorption spectra
average_energy_scans(*args)
¶
Return the minimum range covered by all input arguments
Source code in mmg_toolbox/xas/spectra_analysis.py
average_energy_spectra(energy, *args)
¶
Average energy spectra, interpolating at given energy
energy = average_energy_scans(en1, en2)
signal = combine_energy_scans(energy, (en1, sig1), (en2, sig2))
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
energy
|
ndarray
|
(n*1) array of energy values, in eV |
required |
args
|
tuple[ndarray, ndarray]
|
(mes_energy, mes_signal): pair of (m*1) arrays for energy and measurement raw_signals |
()
|
Returns:
| Type | Description |
|---|---|
|
(n*1) array of averaged signal values at points in energy |
Source code in mmg_toolbox/xas/spectra_analysis.py
find_shifts(*args, differentiate=False)
¶
Find relative shifts between energy spectra to align on a common energy grid
shifts = find_shifts((en1, sig1), (en2, sig2))
energy = average_energy_scans(en1, en2)
signal = combine_energy_scans(energy, (en1+shifts[0], sig1), (en2+shifts[1], sig2))
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args
|
tuple[ndarray, ndarray]
|
(mes_energy, mes_signal): m pairs of arrays for energy and measurement |
()
|
differentiate
|
bool
|
(bool) whether to differentiate the signal before cross-correlation |
False
|
Returns:
| Type | Description |
|---|---|
list[float]
|
list[m] of energy shifts |
Source code in mmg_toolbox/xas/spectra_analysis.py
fit_curve_background(energy, signal, ev_from_start=5.0)
¶
Use lmfit to determine sloping background
Source code in mmg_toolbox/xas/spectra_analysis.py
fit_double_edge_step_background(energy, signal, l3_energy, l2_energy, peak_width_ev=5.0)
¶
Use lmfit to determine sloping background
Source code in mmg_toolbox/xas/spectra_analysis.py
fit_double_l_edge_background(energy, signal, fit=True)
¶
Fit double L edge step function The pre-edge region must be zero before fitting.
Parameters :energy: ndarray[n] of spectra energy in eV :signal: ndarray[n] of spectra signal
Returns:
| Type | Description |
|---|---|
tuple[ndarray, float, ModelResult]
|
background[ndarray], jump[float], lmfit.ModelResult |
Source code in mmg_toolbox/xas/spectra_analysis.py
fit_exp_background(energy, signal, ev_from_start=5.0)
¶
Use lmfit to determine sloping background
Source code in mmg_toolbox/xas/spectra_analysis.py
fit_linear_background(energy, signal, ev_from_start=5.0)
¶
Use lmfit to determine sloping background
Source code in mmg_toolbox/xas/spectra_analysis.py
fit_spectra_background(energy, signal, *step_energies, peak_width_ev=5.0)
¶
Generic fit of spectra background using an order-2 polynomial and n-edges, fitted to region with peaks removed
The returned ModelResult object has the following attributes: params['bkg_0'] flat background params['bkg_1'] sloping background params['bkg_2'] curved background params['edgeN_center'] step N centre [in eV] params['edgeN_amplitude'] step N height params['edgeN_sigma'] step N width [in eV]
Parameters :energy: ndarray[n] of spectra energy in eV :signal: ndarray[n] of spectra signal :step_energies: list of absorption energy steps, in eV :peak_width_ev: float width of absorption peak in eV
Returns:
| Type | Description |
|---|---|
tuple[ndarray, float, ModelResult]
|
background[ndarray], jump[float], lmfit.ModelResult |
Source code in mmg_toolbox/xas/spectra_analysis.py
fit_spectra_exp_background(energy, signal, *step_energies, peak_width_ev=5.0)
¶
Generic fit of spectra background using an exponential and n-edges, fitted to region with peaks removed
The returned ModelResult object has the following attributes: params['bkg_0'] flat background params['bkg_1'] sloping background params['bkg_2'] curved background params['edgeN_center'] step N centre [in eV] params['edgeN_amplitude'] step N height params['edgeN_sigma'] step N width [in eV]
Parameters :energy: ndarray[n] of spectra energy in eV :signal: ndarray[n] of spectra signal :step_energies: list of absorption energy steps, in eV :peak_width_ev: float width of absorption peak in eV
Returns:
| Type | Description |
|---|---|
tuple[ndarray, float, ModelResult]
|
background[ndarray], jump[float], lmfit.ModelResult |
Source code in mmg_toolbox/xas/spectra_analysis.py
fit_step_background(energy, signal, ev_from_start=5.0)
¶
Use lmfit to detemine edge background
Source code in mmg_toolbox/xas/spectra_analysis.py
fit_three_region_background(energy, signal)
¶
Fit Three Region Background function to the data
Parameters :energy: ndarray[n] of spectra energy in eV :signal: ndarray[n] of spectra signal
Returns:
| Type | Description |
|---|---|
tuple[ndarray, float, ModelResult]
|
background[ndarray], jump[float], lmfit.ModelResult |
Source code in mmg_toolbox/xas/spectra_analysis.py
magnetic_moment(orbital, spin)
¶
Calculate the magnetic moment of the system using the formula: M = -g * (L + 2 * S) WHERE DOES THIS COME FROM?
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
orbital
|
float
|
Orbital angular momentum of the system |
required |
spin
|
float
|
Spin angular momentum of the system |
required |
Returns:
| Type | Description |
|---|---|
float
|
Magnetic moment of the system |
Source code in mmg_toolbox/xas/spectra_analysis.py
normalise_background(energy, signal, ev_from_start=5.0)
¶
Normalise background to one
Source code in mmg_toolbox/xas/spectra_analysis.py
orbital_angular_momentum(energy, average, difference, nholes)
¶
Calculate the sum rule for the angular momentum of the spectra using the formula: L = -2 * nholes * int[spectra d energy] / sum(spectra)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
energy
|
ndarray
|
Energy axis of the spectra |
required |
average
|
ndarray
|
average XAS spectra (left + right) for both polarisations |
required |
difference
|
ndarray
|
difference XAS spectra (right - left) for both polarisations |
required |
nholes
|
float
|
Number of holes in the system |
required |
Returns:
| Type | Description |
|---|---|
float
|
Angular momentum of the spectra |
Source code in mmg_toolbox/xas/spectra_analysis.py
postedge_signal(energy, signal, ev_from_end=5.0)
¶
preedge_signal(energy, signal, ev_from_start=5.0)
¶
signal_jump(energy, signal, ev_from_start=5.0, ev_from_end=None)
¶
Return signal jump from start to end
Source code in mmg_toolbox/xas/spectra_analysis.py
spin_angular_momentum(energy, average, difference, nholes, split_energy=None, dipole_term=0)
¶
Calculate the sum rule for the spin angular momentum of the spectra using the formula: S = -2 * nholes * int[spectra d energy] / sum(spectra)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
energy
|
ndarray
|
Energy axis of the spectra |
required |
average
|
ndarray
|
average XAS spectra (left + right) for both polarisations |
required |
difference
|
ndarray
|
difference XAS spectra (right - left) for both polarisations |
required |
nholes
|
float
|
Number of holes in the system |
required |
split_energy
|
float | None
|
energy to split the spectra between L3 and L2 (or None to use the middle of the spectra) |
None
|
dipole_term
|
float
|
magnetic dopole term (T_z), defaults to 0 for effective spin |
0
|
Returns:
| Type | Description |
|---|---|
float
|
Spin angular momentum of the spectra |
Source code in mmg_toolbox/xas/spectra_analysis.py
subtract_flat_background(energy, signal, ev_from_start=5.0)
¶
Subtract flat background