epdfsuite.pdf_extraction
Functions
|
Compute the composition-averaged atomic scattering factor f_avg(q). |
|
Compute the electron Pair Distribution Function G(r) from a SAED intensity profile. |
|
Compute the composition-averaged squared scattering factor <f²>(q). |
|
Fit and return a polynomial background to the reduced structure function F(Q). |
|
Parse a chemical formula string into element symbols and molar fractions. |
- epdfsuite.pdf_extraction.parse_formula(formula)[source]
Parse a chemical formula string into element symbols and molar fractions.
- Parameters:
formula (str) – Chemical formula, e.g.
'SiO2','Al2O3','Fe0.5Ni0.5'.- Returns:
elements (list of str) – Element symbols in the order they appear in the formula.
ratios (list of float) – Molar fractions of each element (sum to 1).
- epdfsuite.pdf_extraction.compute_avg_scattering_factor(formula, x_max, x_step, qvalues=True, xray=False)[source]
Compute the composition-averaged atomic scattering factor f_avg(q).
The average is the weighted sum over all elements:
f_avg(q) = sum_i x_i * f_i(q)wherex_iare the molar fractions parsed fromformula.- Parameters:
formula (str) – Chemical formula of the sample (e.g.
'SiO2').x_max (float) – Upper limit of the scattering variable axis. Interpreted as q (Å⁻¹) if
qvalues=True, otherwise as s = q/(2π).x_step (float) – Sampling step of the scattering variable axis, same units as
x_max.qvalues (bool, optional) – If
True(default),x_maxandx_stepare in q units (Å⁻¹). IfFalse, they are in s = q/(2π) units.xray (bool, optional) – If
True, use X-ray scattering factors instead of electron scattering factors. Default isFalse(electron factors).
- Returns:
q (ndarray) – Momentum transfer axis in Å⁻¹.
favg (ndarray) – Composition-averaged scattering factor f_avg(q).
- epdfsuite.pdf_extraction.compute_f2avg(formula, x_max, x_step, qvalues=True, xray=False)[source]
Compute the composition-averaged squared scattering factor <f²>(q).
The average is the weighted sum of squared individual factors:
<f²>(q) = sum_i x_i * f_i²(q)wherex_iare the molar fractions parsed fromformula. This quantity is used for the normalisation of the reduced structure function F(Q) in the PDFgetX3 formalism.- Parameters:
formula (str) – Chemical formula of the sample (e.g.
'SiO2').x_max (float) – Upper limit of the scattering variable axis. Interpreted as q (Å⁻¹) if
qvalues=True, otherwise as s = q/(2π).x_step (float) – Sampling step of the scattering variable axis, same units as
x_max.qvalues (bool, optional) – If
True(default),x_maxandx_stepare in q units (Å⁻¹). IfFalse, they are in s = q/(2π) units.xray (bool, optional) – If
True, use X-ray scattering factors. Default isFalse(electron scattering factors).
- Returns:
q (ndarray) – Momentum transfer axis in Å⁻¹.
f2avg (ndarray) – Composition-averaged squared scattering factor <f²>(q).
- epdfsuite.pdf_extraction.fit_polynomial_background(q, Fm, rpoly=0.9, qmin=0.3, qmax=None)[source]
Fit and return a polynomial background to the reduced structure function F(Q).
Follows the PDFgetX3 convention: the polynomial degree is determined by
deg = round(rpoly * qmax / π), and the fit is performed on F(Q)/Q to enforce the correct low-Q behaviour.- Parameters:
q (ndarray) – Momentum transfer axis in Å⁻¹.
Fm (ndarray) – Reduced structure function F(Q) = Q * (I_norm / I_inf - 1).
rpoly (float, optional) – Polynomial degree control parameter (PDFgetX3 convention). Default is 0.9.
qmin (float, optional) – Lower bound of the fitting range in Å⁻¹. Default is 0.3.
qmax (float, optional) – Upper bound of the fitting range in Å⁻¹. Defaults to
q.max().
- Returns:
background (ndarray) – Polynomial background evaluated on the full
qgrid, same shape asFm.
- epdfsuite.pdf_extraction.compute_ePDF(q, Iexp, composition, Iref=None, bgscale=1.0, qmin=0.3, qmax=None, qmaxinst=None, rmin=0.0, rmax=50.0, rstep=0.01, rpoly=1.4, Lorch=True, plot=False)[source]
Compute the electron Pair Distribution Function G(r) from a SAED intensity profile.
Follows the PDFgetX3 formalism adapted for electron scattering:
Optional background subtraction:
I = Iexp - bgscale * IrefNormalisation by the composition-averaged squared scattering factor <f²>(Q)
Construction of the reduced structure function:
F(Q) = Q * (I_norm / I_inf - 1)Polynomial background removal (PDFgetX3 convention, controlled by
rpoly)Optional Lorch modification function to suppress Fourier ripples
Sine Fourier transform to obtain G(r)
- Parameters:
q (ndarray) – Momentum transfer axis in Å⁻¹.
Iexp (ndarray) – Experimental azimuthally averaged intensity profile.
composition (str) – Chemical formula of the sample (e.g.
'SiO2','Al2O3').Iref (ndarray, optional) – Reference (background) intensity profile. If its length differs from
Iexp, it is interpolated onto theqgrid. Default isNone.bgscale (float, optional) – Scaling factor applied to the reference before subtraction. Default is 1.0.
qmin (float, optional) – Minimum Q used for the Fourier transform (Å⁻¹). Default is 0.3.
qmax (float, optional) – Maximum Q used for the Fourier transform (Å⁻¹). Defaults to
q.max().qmaxinst (float, optional) – Maximum Q used for the polynomial background fit. Defaults to
qmax. Useful when the data are noisy nearqmax.rmin (float, optional) – Minimum real-space distance r (Å). Default is 0.0.
rmax (float, optional) – Maximum real-space distance r (Å). Default is 50.0.
rstep (float, optional) – Step size in real space (Å). Default is 0.01.
rpoly (float, optional) – Polynomial degree control for background removal (PDFgetX3 convention). Default is 1.4.
Lorch (bool, optional) – If
True(default), apply the Lorch modification functionsinc(Q/Qmax)before the Fourier transform to reduce termination ripples.plot (bool, optional) – If
True, display diagnostic plots of the raw intensities, F(Q), and G(r). Default isFalse.
- Returns:
r (ndarray) – Real-space distance axis in Å.
G (ndarray) – Reduced pair distribution function G(r) in Å⁻².
Notes
The normalisation factor
I_infis estimated as the mean intensity in the top 10 % of the Q range (q > 0.9 * qmax).