doris_rs/record/
measurement.rs1#[cfg(doc)]
2use crate::prelude::{GroundStation, TimeScale, DORIS};
3
4use crate::{
5 error::ParsingError,
6 prelude::{ClockOffset, Duration, Observable, Observation},
7};
8
9#[cfg(feature = "serde")]
10use serde::{Deserialize, Serialize};
11
12use itertools::Itertools;
13use std::collections::HashMap;
14
15#[derive(Clone, Debug, Default, PartialEq)]
17#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
18pub struct Measurements {
19 pub satellite_clock_offset: Option<ClockOffset>,
21
22 pub observations: HashMap<Observable, Observation>,
24}
25
26impl Measurements {
27 pub fn add_observation(&mut self, observable: Observable, observation: Observation) {
29 self.observations.insert(observable, observation);
30 }
31
32 pub fn with_observation(&self, observable: Observable, observation: Observation) -> Self {
34 let mut s = self.clone();
35 s.observations.insert(observable, observation);
36 s
37 }
38
39 pub fn observables(&self) -> Box<dyn Iterator<Item = Observable> + '_> {
42 Box::new(self.observations.keys().map(|obs| *obs).unique())
43 }
44
45 pub fn with_satellite_clock_offset(&self, clock_offset: ClockOffset) -> Self {
47 let mut s = self.clone();
48 s.satellite_clock_offset = Some(clock_offset);
49 s
50 }
51}