pub enum ResampleMethod {
Linear,
BoxcarAverage,
Gaussian,
}Expand description
Method used when resampling a spectrum to a new wavelength axis.
Variants§
Linear
Linear interpolation between adjacent input samples.
Each output value is computed by linearly interpolating between the two nearest input wavelengths. Output wavelengths outside the input range are clamped to the nearest endpoint (no extrapolation).
Works for both upsampling and downsampling.
BoxcarAverage
Boxcar (rectangular window) averaging.
For each output wavelength λ, all input samples within the half-step
window [λ − step/2, λ + step/2] are averaged, where step is the
mean spacing of the target axis. Falls back to linear interpolation
for any output wavelength whose window contains no input samples.
Most appropriate when downsampling to a coarser grid (e.g. 1 nm → 10 nm).
Assumes a regular (uniformly-spaced) target grid. The window
half-width is derived from the mean spacing of the entire target axis;
for irregular target grids the bins may overlap or leave gaps. Use a
WavelengthAxis with range_nm (start / end / interval) to guarantee
a regular grid.
Gaussian
Gaussian kernel resampling.
Each output value is a weighted average of the input samples, where the
weight of input sample at w is exp(−½ ((w − λ) / σ)²). Samples
further than 3σ from the output wavelength are excluded. Weights are
normalised by their sum, so output values at the edges of the input
range are not artificially attenuated.
The kernel FWHM is resolved in this order:
metadata.measurement_conditions.spectral_resolution_nm— the instrument’s optical resolution, physically the most meaningful choice.- Mean step size of the target axis — used as a fallback when no resolution is recorded, matching the kernel width to the output sampling interval.
σ is derived from the FWHM as FWHM / (2√(2 ln 2)) ≈ FWHM / 2.355.
If the FWHM is much smaller than the input sampling interval the kernel degenerates toward nearest-neighbour interpolation; if no input samples fall within the 3σ window the method falls back to linear interpolation.
Trait Implementations§
Source§impl Clone for ResampleMethod
impl Clone for ResampleMethod
Source§fn clone(&self) -> ResampleMethod
fn clone(&self) -> ResampleMethod
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ResampleMethod
impl Debug for ResampleMethod
Source§impl PartialEq for ResampleMethod
impl PartialEq for ResampleMethod
Source§fn eq(&self, other: &ResampleMethod) -> bool
fn eq(&self, other: &ResampleMethod) -> bool
self and other values to be equal, and is used by ==.