pub struct TabulatedResolution { /* private fields */ }Expand description
A tabulated resolution function from Monte Carlo instrument simulation.
Contains reference kernels R(Δt; E_ref) at discrete energies, stored in TOF-offset space (μs). Kernels are interpolated between reference energies and converted from TOF to energy space when applied.
§File Format (VENUS/FTS)
FTS BL10 case i00dd folded triang FWHM 350 ns PSR ← header
----- ← separator
5.00000e-004 0.00000e+000 ← energy block start
-53.458917835671329 2.051764258257523e-04 ← (tof_offset_μs, weight)
...
← blank line separates blocks
1.00000e-003 0.00000e+000 ← next energy block
...Implementations§
Source§impl TabulatedResolution
impl TabulatedResolution
Sourcepub fn ref_energies(&self) -> &[f64]
pub fn ref_energies(&self) -> &[f64]
Reference energies (eV), sorted ascending.
Sourcepub fn kernels(&self) -> &[(Vec<f64>, Vec<f64>)]
pub fn kernels(&self) -> &[(Vec<f64>, Vec<f64>)]
For each reference energy: (tof_offsets_μs, weights) pairs. Weights are peak-normalized (max=1.0).
Sourcepub fn flight_path_m(&self) -> f64
pub fn flight_path_m(&self) -> f64
Flight path length in meters (needed for TOF↔energy conversion).
Source§impl TabulatedResolution
impl TabulatedResolution
Sourcepub fn from_text(
text: &str,
flight_path_m: f64,
) -> Result<Self, ResolutionParseError>
pub fn from_text( text: &str, flight_path_m: f64, ) -> Result<Self, ResolutionParseError>
Parse a VENUS/FTS resolution file.
§Arguments
text— File contents as a string.flight_path_m— Flight path length in meters.
Sourcepub fn from_file(
path: &str,
flight_path_m: f64,
) -> Result<Self, ResolutionParseError>
pub fn from_file( path: &str, flight_path_m: f64, ) -> Result<Self, ResolutionParseError>
Parse a VENUS/FTS resolution file from disk.
Sourcepub fn broaden(
&self,
energies: &[f64],
spectrum: &[f64],
) -> Result<Vec<f64>, ResolutionError>
pub fn broaden( &self, energies: &[f64], spectrum: &[f64], ) -> Result<Vec<f64>, ResolutionError>
Apply tabulated resolution broadening to a spectrum.
For each energy point:
- Find bracketing reference energies and interpolate kernel (log-space)
- Convert TOF offsets to energy offsets using exact TOF↔energy relation
- Convolve spectrum with interpolated kernel (trapezoidal integration)
§Errors
Returns ResolutionError::LengthMismatch if the arrays differ in
length, or ResolutionError::UnsortedEnergies if the energy grid is
not sorted in non-descending order.
Trait Implementations§
Source§impl Clone for TabulatedResolution
impl Clone for TabulatedResolution
Source§fn clone(&self) -> TabulatedResolution
fn clone(&self) -> TabulatedResolution
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for TabulatedResolution
impl RefUnwindSafe for TabulatedResolution
impl Send for TabulatedResolution
impl Sync for TabulatedResolution
impl Unpin for TabulatedResolution
impl UnwindSafe for TabulatedResolution
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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 more