1pub enum ExperimentType {
3 Xrr,
4 Xrs,
5 All,
6}
7
8impl ExperimentType {
9 pub fn from_str(exp_type: &str) -> Result<Self, crate::errors::FitsLoaderError> {
11 match exp_type.to_lowercase().as_str() {
12 "xrr" => Ok(ExperimentType::Xrr),
13 "xrs" => Ok(ExperimentType::Xrs),
14 "other" => Ok(ExperimentType::All),
15 _ => Err(crate::errors::FitsLoaderError::InvalidExperimentType(
16 exp_type.to_string(),
17 )),
18 }
19 }
20
21 pub fn get_keys(&self) -> Vec<HeaderValue> {
23 let mut keys = match self {
24 ExperimentType::Xrr => vec![
25 HeaderValue::SampleTheta,
26 HeaderValue::CCDTheta,
27 HeaderValue::BeamlineEnergy,
28 HeaderValue::BeamCurrent,
29 HeaderValue::EPUPolarization,
30 HeaderValue::HorizontalExitSlitSize,
31 HeaderValue::HigherOrderSuppressor,
32 HeaderValue::Exposure,
33 ],
34 ExperimentType::Xrs => vec![HeaderValue::BeamlineEnergy],
35 ExperimentType::All => vec![],
36 };
37
38 keys.push(HeaderValue::Date);
40 keys
41 }
42
43 pub fn names(&self) -> Vec<&str> {
45 match self {
46 ExperimentType::Xrr => vec![
47 "Sample Theta",
48 "CCD Theta",
49 "Beamline Energy",
50 "Beam Current",
51 "EPU Polarization",
52 "Horizontal Exit Slit Size",
53 "Higher Order Suppressor",
54 "EXPOSURE",
55 ],
56 ExperimentType::Xrs => vec!["Beamline Energy"],
57 ExperimentType::All => vec![],
58 }
59 }
60}
61
62pub enum HeaderValue {
64 SampleTheta,
65 CCDTheta,
66 BeamlineEnergy,
67 EPUPolarization,
68 BeamCurrent,
69 HorizontalExitSlitSize,
70 HigherOrderSuppressor,
71 Exposure,
72 Date,
73}
74
75impl HeaderValue {
76 pub fn unit(&self) -> &str {
78 match self {
79 HeaderValue::SampleTheta => "[deg]",
80 HeaderValue::CCDTheta => "[deg]",
81 HeaderValue::BeamlineEnergy => "[eV]",
82 HeaderValue::BeamCurrent => "[mA]",
83 HeaderValue::EPUPolarization => "[deg]",
84 HeaderValue::HorizontalExitSlitSize => "[um]",
85 HeaderValue::HigherOrderSuppressor => "[mm]",
86 HeaderValue::Exposure => "[s]",
87 HeaderValue::Date => "",
88 }
89 }
90
91 pub fn hdu(&self) -> &str {
93 match self {
94 HeaderValue::SampleTheta => "Sample Theta",
95 HeaderValue::CCDTheta => "CCD Theta",
96 HeaderValue::BeamlineEnergy => "Beamline Energy",
97 HeaderValue::BeamCurrent => "Beam Current",
98 HeaderValue::EPUPolarization => "EPU Polarization",
99 HeaderValue::HorizontalExitSlitSize => "Horizontal Exit Slit Size",
100 HeaderValue::HigherOrderSuppressor => "Higher Order Suppressor",
101 HeaderValue::Exposure => "EXPOSURE",
102 HeaderValue::Date => "DATE",
103 }
104 }
105
106 pub fn name(&self) -> &str {
108 match self {
109 HeaderValue::SampleTheta => "Sample Theta [deg]",
110 HeaderValue::CCDTheta => "CCD Theta [deg]",
111 HeaderValue::BeamlineEnergy => "Beamline Energy [eV]",
112 HeaderValue::BeamCurrent => "Beam Current [mA]",
113 HeaderValue::EPUPolarization => "EPU Polarization [deg]",
114 HeaderValue::HorizontalExitSlitSize => "Horizontal Exit Slit Size [um]",
115 HeaderValue::HigherOrderSuppressor => "Higher Order Suppressor [mm]",
116 HeaderValue::Exposure => "EXPOSURE [s]",
117 HeaderValue::Date => "DATE",
118 }
119 }
120
121 pub fn snake_case_name(&self) -> &str {
123 match self {
124 HeaderValue::SampleTheta => "sample_theta",
125 HeaderValue::CCDTheta => "ccd_theta",
126 HeaderValue::BeamlineEnergy => "beamline_energy",
127 HeaderValue::BeamCurrent => "beam_current",
128 HeaderValue::EPUPolarization => "epu_polarization",
129 HeaderValue::HorizontalExitSlitSize => "horizontal_exit_slit_size",
130 HeaderValue::HigherOrderSuppressor => "higher_order_suppressor",
131 HeaderValue::Exposure => "exposure",
132 HeaderValue::Date => "date",
133 }
134 }
135}