Skip to main content

intervals_where

Function intervals_where 

Source
pub fn intervals_where(
    times: &[f64],
    values: &[f64],
    duration_s: f64,
    min_value: Option<f64>,
    max_value: Option<f64>,
) -> Result<Vec<(f64, f64)>, IoError>
Expand description

Derive the run-time intervals on which a transition-log PV satisfies min_value <= value <= max_value (either bound optional), using the correct step-function semantics (issue #637): values[i] holds on [times[i], times[i+1]), the last value holds to duration_s.

Time before the first transition entry is treated as not matching (the state is unrecorded; excluding it is the conservative choice for a keep-filter). NaN values never match. Adjacent/overlapping matching segments are merged; empty segments (t_end <= t_start) are dropped. The final segment’s end is padded by one f32 ULP above duration_s because SNS records /entry/duration in float32 while pulse times are float64 — without the pad, a keep-everything filter drops the final pulse of roughly half of real runs.

§Errors

IoError::InvalidParameter on non-finite/negative duration_s, descending times, mismatched lengths, or a bound pair with min_value > max_value.