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
E.G. energy = average_energy_scans(en1, en2) signal = combine_energy_scans(energy, (en1, sig1), (en2, sig2))
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
energy
|
(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
default_n_holes(element)
¶
Return the default number of holes for a given element
Source code in mmg_toolbox/xas/spectra_analysis.py
energy_range_edge_label(min_energy_ev, max_energy_ev=None, energy_range_ev=10.0, search_edges=SEARCH_EDGES)
¶
Return mode string for x-ray absorption edges in energy range raises ValueError is no edges are found or if multiple non-equivalent edges are found
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min_energy_ev
|
float
|
energy to find x-ray absorption edges within |
required |
max_energy_ev
|
float | None
|
energy to find x-ray absorption edges within |
None
|
energy_range_ev
|
float
|
energy to find x-ray absorption edges within |
10.0
|
search_edges
|
tuple[str]
|
if not None, only return energies for these edges, e.g. ('L3', 'L2') |
SEARCH_EDGES
|
Returns:
| Type | Description |
|---|---|
tuple[str, str]
|
element, mode strings, e.g. 'Mn', 'L2, L3' |
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_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
load_edge_energies(edges=SEARCH_EDGES)
¶
return arrays of energies and labels for x-ray absorption edges
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edges
|
if not None, only return energies for these edges, e.g. ('L3', 'L2') |
SEARCH_EDGES
|
Returns:
| Type | Description |
|---|---|
tuple[ndarray, ndarray]
|
energies[ndarray], labels[ndarray] |
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
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
|
int | 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
xray_edges_in_range(min_energy_ev, max_energy_ev=None, energy_range_ev=10.0, search_edges=SEARCH_EDGES)
¶
Return all x-ray absorption edges within the range
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min_energy_ev
|
float
|
energy to find x-ray absorption edges within |
required |
max_energy_ev
|
float | None
|
energy to find x-ray absorption edges within |
None
|
energy_range_ev
|
float
|
energy to find x-ray absorption edges within |
10.0
|
search_edges
|
None | tuple[str]
|
if not None, only return energies for these edges, e.g. ('L3', 'L2') |
SEARCH_EDGES
|
Returns:
| Type | Description |
|---|---|
list[tuple[str, float]]
|
list[(edge_label[str], energy[float])] |