parse_monitors/cfd/
y2025.rs

1use std::path::PathBuf;
2
3use super::{Baseline, BaselineTrait, CfdCase, CfdDataFile, CfdError};
4
5type Result<T> = std::result::Result<T, CfdError>;
6
7impl CfdDataFile<2025> {
8    pub fn pattern(self) -> String {
9        use CfdDataFile::*;
10        String::from(match self {
11            M1Pressure => "M1p_M1p_",
12            M2Pressure => "M2p_M2p_",
13            TemperatureField => "optvol_optvol_",
14            OpticalPathDifference => "optvol_optvol_",
15            TelescopePressure => "Telescope_p_table_",
16        })
17    }
18    pub fn glob(self, cfd_case: CfdCase<2025>) -> Result<Vec<PathBuf>> {
19        use CfdDataFile::*;
20        let cfd_path = Baseline::<2025>::path()?.join(cfd_case.to_string());
21        let paths = match self {
22            M1Pressure => glob::glob(
23                cfd_path
24                    .join("pressures")
25                    .join("M1p_M1p_*.csv.z")
26                    .to_str()
27                    .unwrap(),
28            ),
29            M2Pressure => glob::glob(
30                cfd_path
31                    .join("pressures")
32                    .join("M2p_M2p_*.csv.z")
33                    .to_str()
34                    .unwrap(),
35            ),
36            TemperatureField => glob::glob(
37                cfd_path
38                    .join("optvol")
39                    .join("optvol_optvol_*.csv.gz")
40                    .to_str()
41                    .unwrap(),
42            ),
43            OpticalPathDifference => glob::glob(
44                cfd_path
45                    .join("optvol")
46                    .join("optvol_optvol_*.npz")
47                    .to_str()
48                    .unwrap(),
49            ),
50            TelescopePressure => glob::glob(
51                cfd_path
52                    .join("pressures")
53                    .join("Telescope_p_table_*.csv.z")
54                    .to_str()
55                    .unwrap(),
56            ),
57        }?;
58        Ok(paths.collect::<std::result::Result<Vec<PathBuf>, glob::GlobError>>()?)
59    }
60}