pub struct PrePostEdge {Show 14 fields
pub pre_edge_start: Option<f64>,
pub pre_edge_end: Option<f64>,
pub norm_start: Option<f64>,
pub norm_end: Option<f64>,
pub norm_polyorder: Option<i32>,
pub n_victoreen: Option<i32>,
pub e0: Option<f64>,
pub edge_step: Option<f64>,
pub pre_edge: Option<DVector<f64>>,
pub post_edge: Option<DVector<f64>>,
pub norm: Option<DVector<f64>>,
pub flat: Option<DVector<f64>>,
pub pre_coefficients: Option<Vec<f64>>,
pub norm_coefficients: Option<Vec<f64>>,
}Expand description
Pre-edge subtraction, edge-step normalization and post-edge flattening.
Use new() for data-dependent fit ranges and polynomial degree, as in the
Python/TypeScript constructors. default() instead uses fixed offsets
−200/−30/150/2000 eV and degree 2. Endpoints are offsets from E0, not absolute
energies. Results are cached in this object after normalize.
The method fits a line to mu * E.powi(n_victoreen), removes that background,
and fits a post-edge polynomial to estimate the edge step. See
Newville, Fundamentals of XAFS.
The precise automatic ranges and flattening convention are rexafs choices.
For photon energy E in eV and input absorption mu(E), the fitted models are
p(E) = (a + b*E) * E^(-v) and a polynomial P(E) fitted to mu(E)-p(E).
Here v is n_victoreen; coefficients have the units required to match mu.
pre_edge is p(E), and post_edge is p(E)+P(E). If E* is the measured
energy nearest E0, the automatic jump is P(E*), in mu units. With the
resolved jump D, the dimensionless outputs are
norm(E) = (mu(E) - p(E)) / D
flat(E) = norm(E) for E < E*
= norm(E) - (P(E) - P(E*)) / D for E >= E*The jump must be finite and is floored at 1e-12. This numerical floor is not evidence of a usable absorption edge. Flattening is a separate display output; AUTOBK uses the original absorption and resolved edge step. Automatic values filled into this object are retained. Set a field back to None, or construct fresh settings, to request its automatic resolution again.
Fields§
§pre_edge_start: Option<f64>Lower pre-edge fit offset from E0 in eV. new() leaves this automatic;
default() uses −200. Automatic selection follows the available pre-edge data.
pre_edge_end: Option<f64>Upper pre-edge fit offset from E0 in eV. new() is automatic; default()
uses −30. Choose a range below edge structure with enough points for a line.
norm_start: Option<f64>Lower post-edge fit offset from E0 in eV. new() is automatic; default()
uses 150. Automatic selection depends on the resolved upper endpoint.
norm_end: Option<f64>Upper post-edge fit offset from E0 in eV. new() uses the available range;
default() uses 2000. Fit intervals are evaluated on available samples.
norm_polyorder: Option<i32>Degree of the post-edge polynomial. Automatic degrees are 0, 1, or 2 for
spans below 50 eV, below 350 eV, or at least 350 eV; explicit values are
clamped to 0–5. new() is automatic and default() uses 2.
n_victoreen: Option<i32>Exponent v in the pre-edge model (a + b*E) * E.powi(-v).
The line is fitted to mu * E.powi(v); automatic v is 0 (ordinary line).
e0: Option<f64>Absorption edge energy in eV; None requests automatic detection.
When using Spectrum, an explicit E0 must be finite and strictly inside the
energy range or normalization returns E0OutOfRange. The lower-level
PrePostEdge::fill_parameter instead replaces a nonfinite value or one
outside the first through penultimate input energies with a derivative estimate.
edge_step: Option<f64>Absorption jump in the same units as mu. None uses post-edge minus
pre-edge at the energy sample nearest E0. A finite result is floored at
1e-12; inspect nonpositive or tiny jumps rather than trusting that floor.
pre_edge: Option<DVector<f64>>Fitted pre-edge background on the energy grid, in input mu units.
None until normalization runs.
post_edge: Option<DVector<f64>>Pre-edge background plus the post-edge polynomial, in input mu units.
None until normalization runs.
norm: Option<DVector<f64>>Dimensionless (mu - pre_edge) / edge_step on the energy grid.
None until normalization runs.
flat: Option<DVector<f64>>Dimensionless normalized absorption with the post-edge trend removed above
the sample nearest E0. Values below that sample equal norm. This is a
separate display output and is not substituted into AUTOBK.
pre_coefficients: Option<Vec<f64>>Fitted line coefficients [a, b] for mu * E.powi(n_victoreen).
Coefficient units depend on the exponent and the use of E in eV.
norm_coefficients: Option<Vec<f64>>Post-edge polynomial coefficients in increasing powers of absolute E in eV. Their weighted sum has input mu units; they are not powers of E − E0.
Implementations§
Source§impl PrePostEdge
impl PrePostEdge
Sourcepub fn new() -> PrePostEdge
pub fn new() -> PrePostEdge
Create automatic normalization settings.
Unlike default(), every configurable field starts as None; the next
calculation resolves fit ranges, degree, edge energy and edge step from data.
Sourcepub fn fill_parameter(
&mut self,
energy: &DVector<f64>,
mu: &DVector<f64>,
) -> Result<&mut Self, NormalizationError>
pub fn fill_parameter( &mut self, energy: &DVector<f64>, mu: &DVector<f64>, ) -> Result<&mut Self, NormalizationError>
Resolve automatic settings from equal-length finite energy/mu arrays.
Requires at least two samples and nondecreasing energy in eV. This mutates settings but does not fit the backgrounds or refresh result arrays. Resolved values remain stored; reset a field to None or create a fresh object to request automatic selection again.
Sourcepub fn get_pre_edge_start(&self) -> Option<f64>
pub fn get_pre_edge_start(&self) -> Option<f64>
Read the stored value without recalculating.
Lower pre-edge fit offset from E0 in eV. new() leaves this automatic;
default() uses −200. Automatic selection follows the available pre-edge data.
Sourcepub fn get_pre_edge_end(&self) -> Option<f64>
pub fn get_pre_edge_end(&self) -> Option<f64>
Read the stored value without recalculating.
Upper pre-edge fit offset from E0 in eV. new() is automatic; default()
uses −30. Choose a range below edge structure with enough points for a line.
Sourcepub fn get_norm_start(&self) -> Option<f64>
pub fn get_norm_start(&self) -> Option<f64>
Read the stored value without recalculating.
Lower post-edge fit offset from E0 in eV. new() is automatic; default()
uses 150. Automatic selection depends on the resolved upper endpoint.
Sourcepub fn get_norm_end(&self) -> Option<f64>
pub fn get_norm_end(&self) -> Option<f64>
Read the stored value without recalculating.
Upper post-edge fit offset from E0 in eV. new() uses the available range;
default() uses 2000. Fit intervals are evaluated on available samples.
Sourcepub fn get_norm_polyorder(&self) -> Option<i32>
pub fn get_norm_polyorder(&self) -> Option<i32>
Read the stored value without recalculating.
Degree of the post-edge polynomial. Automatic degrees are 0, 1, or 2 for
spans below 50 eV, below 350 eV, or at least 350 eV; explicit values are
clamped to 0–5. new() is automatic and default() uses 2.
Sourcepub fn get_n_victoreen(&self) -> Option<i32>
pub fn get_n_victoreen(&self) -> Option<i32>
Read the stored value without recalculating.
Exponent v in the pre-edge model (a + b*E) * E.powi(-v).
The line is fitted to mu * E.powi(v); automatic v is 0 (ordinary line).
Sourcepub fn get_pre_edge(&self) -> Option<&DVector<f64>>
pub fn get_pre_edge(&self) -> Option<&DVector<f64>>
Read the stored value without recalculating.
Fitted pre-edge background on the energy grid, in input mu units.
None until normalization runs.
Sourcepub fn get_post_edge(&self) -> Option<&DVector<f64>>
pub fn get_post_edge(&self) -> Option<&DVector<f64>>
Read the stored value without recalculating.
Pre-edge background plus the post-edge polynomial, in input mu units.
None until normalization runs.
Sourcepub fn get_norm_coefficients(&self) -> Option<&Vec<f64>>
pub fn get_norm_coefficients(&self) -> Option<&Vec<f64>>
Read the stored value without recalculating.
Post-edge polynomial coefficients in increasing powers of absolute E in eV. Their weighted sum has input mu units; they are not powers of E − E0.
Sourcepub fn get_pre_coefficients(&self) -> Option<&Vec<f64>>
pub fn get_pre_coefficients(&self) -> Option<&Vec<f64>>
Read the stored value without recalculating.
Fitted line coefficients [a, b] for mu * E.powi(n_victoreen).
Coefficient units depend on the exponent and the use of E in eV.
Trait Implementations§
Source§impl Clone for PrePostEdge
impl Clone for PrePostEdge
Source§impl Debug for PrePostEdge
impl Debug for PrePostEdge
Source§impl Default for PrePostEdge
impl Default for PrePostEdge
Source§impl<'de> Deserialize<'de> for PrePostEdgewhere
PrePostEdge: Default,
impl<'de> Deserialize<'de> for PrePostEdgewhere
PrePostEdge: Default,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl From<PrePostEdge> for NormalizationMethod
impl From<PrePostEdge> for NormalizationMethod
Source§fn from(parameters: PrePostEdge) -> Self
fn from(parameters: PrePostEdge) -> Self
Source§impl From<PrePostEdge> for Option<NormalizationMethod>
impl From<PrePostEdge> for Option<NormalizationMethod>
Source§fn from(parameters: PrePostEdge) -> Self
fn from(parameters: PrePostEdge) -> Self
Source§impl Normalization for PrePostEdge
impl Normalization for PrePostEdge
Source§fn normalize(
&mut self,
energy: &DVector<f64>,
mu: &DVector<f64>,
) -> Result<&mut Self, NormalizationError>
fn normalize( &mut self, energy: &DVector<f64>, mu: &DVector<f64>, ) -> Result<&mut Self, NormalizationError>
NormalizationError.
The low-level PrePostEdge implementation zips its inputs and filters
nonfinite pairs before fitting: unequal lengths can discard the longer
tail, and result arrays then describe only retained pairs. Spectrum
validates finite matching arrays before this step; prefer that contract.Source§fn get_edge_step(&self) -> Option<f64>
fn get_edge_step(&self) -> Option<f64>
None while automatic/unresolved.Source§fn get_flat(&self) -> Option<&DVector<f64>>
fn get_flat(&self) -> Option<&DVector<f64>>
None before calculation.Source§fn get_norm(&self) -> Option<&DVector<f64>>
fn get_norm(&self) -> Option<&DVector<f64>>
None before calculation.Source§fn set_e0(&mut self, e0: Option<f64>) -> &mut Self
fn set_e0(&mut self, e0: Option<f64>) -> &mut Self
None for automatic detection; recalculate results afterward.Source§fn set_edge_step(&mut self, edge_step: Option<f64>) -> &mut Self
fn set_edge_step(&mut self, edge_step: Option<f64>) -> &mut Self
None for estimation; recalculate results afterward.Source§impl PartialEq for PrePostEdge
impl PartialEq for PrePostEdge
Source§impl Serialize for PrePostEdge
impl Serialize for PrePostEdge
impl StructuralPartialEq for PrePostEdge
Auto Trait Implementations§
impl Freeze for PrePostEdge
impl RefUnwindSafe for PrePostEdge
impl Send for PrePostEdge
impl Sync for PrePostEdge
impl Unpin for PrePostEdge
impl UnsafeUnpin for PrePostEdge
impl UnwindSafe for PrePostEdge
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> CloneAny for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.impl<T, U> Imply<T> for U
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().impl<T> Scalar for T
impl<T> Scalar for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.