trace_detectability

Function trace_detectability 

Source
pub fn trace_detectability(
    config: &TraceDetectabilityConfig<'_>,
    trace: &ResonanceData,
    trace_ppm: f64,
) -> Result<TraceDetectabilityReport, PipelineError>
Expand description

Compute trace-detectability for a single matrix+trace isotope pair.

Two forward_model calls (with/without trace) + argmax over the difference spectrum. Resolution broadening is included when provided, so the SNR reflects realistic peak spreading at VENUS.

§Arguments

  • config — Shared analysis parameters (matrix isotopes, energies, I₀, etc.).
  • trace — Resonance data for the trace isotope.
  • trace_ppm — Trace concentration in ppm by atom.

§Preconditions

  • config.energies must be non-empty and sorted ascending.
  • config.i0 must be positive (used as 1/√I₀ for noise estimate).
  • config.matrix_isotopes must be non-empty with positive densities.
  • config.snr_threshold must be non-negative.
  • trace_ppm must be non-negative.

The Python bindings validate all of these; Rust callers are responsible for ensuring valid inputs.

§Returns

TraceDetectabilityReport with peak SNR, peak energy, detectability flag, and the full |ΔT| spectrum.