Skip to main content

nyx_space/od/msr/
python.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 pyo3::pymethods;
20
21use crate::od::msr::MeasurementType;
22
23use super::Measurement;
24use hifitime::Epoch;
25
26#[pymethods]
27impl Measurement {
28    #[new]
29    fn py_new(tracker: String, epoch: Epoch) -> Self {
30        Self::new(tracker, epoch)
31    }
32
33    /// Returns the floating point value of this observation if this measurement contains the provided measurement type
34    #[pyo3(name = "observation")]
35    fn py_observation(&self, msr_type: MeasurementType) -> Option<f64> {
36        self.data.get(&msr_type).copied()
37    }
38
39    fn __str__(&self) -> String {
40        format!("{self}")
41    }
42
43    fn __repr__(&self) -> String {
44        format!("{self} @ {self:p}")
45    }
46}