Skip to main content

nyx_space/od/msr/
mod.rs

1/*
2    Nyx, blazing fast astrodynamics
3    Copyright (C) 2018-onwards Christopher Rabotin <christopher.rabotin@gmail.com>
4
5    This program is free software: you can redistribute it and/or modify
6    it under the terms of the GNU Affero General Public License as published
7    by the Free Software Foundation, either version 3 of the License, or
8    (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU Affero General Public License for more details.
14
15    You should have received a copy of the GNU Affero General Public License
16    along with this program.  If not, see <https://www.gnu.org/licenses/>.
17*/
18
19use std::str::FromStr;
20
21use serde::{Deserialize, Serialize};
22
23pub mod measurement;
24pub mod sensitivity;
25mod trackingdata;
26pub mod two_way;
27mod types;
28
29pub use crate::od::ground_station::DopplerConfig;
30pub use measurement::Measurement;
31pub use trackingdata::TrackingDataArc;
32pub use types::MeasurementType;
33
34#[cfg(feature = "python")]
35mod python;
36
37#[cfg(feature = "python")]
38use pyo3::prelude::*;
39
40use crate::io::InputOutputError;
41
42#[cfg_attr(feature = "python", pyclass(from_py_object))]
43#[derive(Copy, Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize, der::Enumerated)]
44#[repr(u8)]
45pub enum IntegrationRef {
46    Start = 0,
47    #[default]
48    Middle = 1,
49    End = 2,
50}
51
52impl FromStr for IntegrationRef {
53    type Err = InputOutputError;
54    fn from_str(s: &str) -> Result<Self, Self::Err> {
55        match s.trim().to_lowercase().as_str() {
56            "middle" => Ok(Self::Middle),
57            "start" => Ok(Self::Start),
58            "end" => Ok(Self::End),
59            _ => Err(InputOutputError::UnsupportedData {
60                which: format!("`{s}` is not a valid integration reference"),
61            }),
62        }
63    }
64}