gmt_dos_clients_domeseeing/
lib.rs

1use glob::{GlobError, PatternError};
2use serde::{Deserialize, Serialize};
3use std::num::ParseFloatError;
4#[cfg(not(feature = "object_store"))]
5use std::path::PathBuf;
6
7#[derive(Debug, thiserror::Error)]
8pub enum DomeSeeingError {
9    #[error("failed to load dome seeing data {1}")]
10    Load(#[source] std::io::Error, String),
11    #[error("failed to get dome seeing data path")]
12    Glob(#[from] GlobError),
13    #[error("failed to find dome seeing file pattern")]
14    Pattern(#[from] PatternError),
15    #[cfg(feature = "bincode")]
16    #[error("failed to read dome seeing file")]
17    Bincode(#[from] bincode::Error),
18    #[error("dome seeing index {0} is out-of-bounds")]
19    OutOfBounds(usize),
20    #[error("failed to parse CFD optvol files timestamp: {1}")]
21    TimeStamp(#[source] ParseFloatError, String),
22    #[error("the remote store is missing")]
23    MissingStore,
24    #[cfg(feature = "object_store")]
25    #[error("failed to access remote data")]
26    Store(#[from] object_store::Error),
27    #[cfg(feature = "object_store")]
28    #[error("no dome seeing data found in {0}")]
29    MissingData(String),
30}
31
32mod builder;
33mod dome_seeing;
34pub use builder::DomeSeeingBuilder;
35pub use dome_seeing::DomeSeeing;
36
37
38type Counter = Box<dyn Iterator<Item = usize> + Send>;
39
40//const CFD_SAMPLING_FREQUENCY: f64 = 5f64; // Hz
41
42#[derive(Debug, Default, Clone)]
43pub enum OpdMapping {
44    #[default]
45    Whole,
46    Masked,
47}
48
49/// Dome seeing OPD
50///
51/// The OPD `values` are given only inside the `mask` (i.e. where the mask is `true`)
52#[derive(Serialize, Deserialize, Debug, Default, Clone)]
53pub struct Opd {
54    pub mean: f64,
55    pub values: Vec<f64>,
56    pub mask: Vec<bool>,
57}
58
59#[derive(Debug, Default, Clone, PartialEq)]
60pub struct DomeSeeingData {
61    pub time_stamp: f64,
62    #[cfg(not(feature = "object_store"))]
63    pub file: PathBuf,
64    #[cfg(feature = "object_store")]
65    pub file: object_store::path::Path,
66}
67
68impl PartialOrd for DomeSeeingData {
69    fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
70        self.time_stamp.partial_cmp(&other.time_stamp)
71    }
72}