Skip to main content

Module spectrum

Module spectrum 

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

SpectrumUnit
Whether spectrum values represent TOF or energy.
SpectrumValueKind
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.txt sidecar text into TOF bin edges (µs).
read_tof_sidecar
Read a VENUS *_Spectra.txt TOF 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.