use ndarray::Array1;
#[derive(Debug, Clone)]
pub struct DriverMeasurement {
pub freq: Array1<f64>,
pub spl: Array1<f64>,
pub phase: Option<Array1<f64>>,
}
impl DriverMeasurement {
pub fn new(freq: Array1<f64>, spl: Array1<f64>, phase: Option<Array1<f64>>) -> Self {
assert_eq!(freq.len(), spl.len(), "freq and spl must have same length");
if let Some(ref p) = phase {
assert_eq!(freq.len(), p.len(), "freq and phase must have same length");
}
Self { freq, spl, phase }
}
pub fn freq_range(&self) -> (f64, f64) {
let min_freq = self.freq.iter().copied().fold(f64::INFINITY, f64::min);
let max_freq = self.freq.iter().copied().fold(f64::NEG_INFINITY, f64::max);
(min_freq, max_freq)
}
pub fn mean_freq(&self) -> f64 {
let (min_freq, max_freq) = self.freq_range();
(min_freq * max_freq).sqrt()
}
}