Expand description
Spectrum file parser for TOF/energy bin edges or centers.
Parses CSV/TXT files containing TOF or energy values that define the spectral bins of a neutron imaging dataset.
§Supported formats
- Single-column: one value per line
- Two-column (CSV/TSV): first column used, rest ignored
- Comment lines starting with
#are skipped - First non-comment line skipped if it cannot be parsed as a number (header)
§VENUS *_Spectra.txt sidecars
Autoreduced VENUS TIFF folders ship a <run>_Spectra.txt sidecar whose
first column is each frame’s start time in seconds (N rows for N
frames; the second column is counts). read_tof_sidecar converts it
to the N+1 ascending TOF bin edges in microseconds that
crate::tof::tof_edges_to_energy_centers expects. The start-time =
left-bin-edge semantics is established from measured autoreduce output
(see parse_tof_sidecar_text for the evidence and for how NEREIDS
differs from PLEIADES here).
Enums§
- Spectrum
Unit - Whether spectrum values represent TOF or energy.
- Spectrum
Value Kind - Whether values are bin edges (N+1 for N bins) or bin centers (N for N bins).
Constants§
- MICROSECONDS_
PER_ SECOND - Microseconds per second — sidecar start times are recorded in seconds, while every NEREIDS TOF axis is in microseconds.
Functions§
- parse_
spectrum_ file - Parse a spectrum file from disk.
- parse_
spectrum_ text - Parse spectrum values from a string.
- parse_
tof_ sidecar_ text - Parse VENUS
*_Spectra.txtsidecar text into TOF bin edges (µs). - read_
tof_ sidecar - Read a VENUS
*_Spectra.txtTOF sidecar into bin edges (µs). - validate_
monotonic - Validate that values are strictly monotonically increasing.
- validate_
spectrum_ frame_ count - Validate that spectrum values are compatible with the TIFF frame count.