Skip to main content

ResampleMethod

Enum ResampleMethod 

Source
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:

  1. metadata.measurement_conditions.spectral_resolution_nm — the instrument’s optical resolution, physically the most meaningful choice.
  2. 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

Source§

fn clone(&self) -> ResampleMethod

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ResampleMethod

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for ResampleMethod

Source§

fn eq(&self, other: &ResampleMethod) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for ResampleMethod

Source§

impl Eq for ResampleMethod

Source§

impl StructuralPartialEq for ResampleMethod

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.