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 ///
35 /// :type msr_type: MeasurementType
36 /// :rtype: float | None
37 #[pyo3(name = "observation")]
38 fn py_observation(&self, msr_type: MeasurementType) -> Option<f64> {
39 self.data.get(&msr_type).copied()
40 }
41
42 fn __str__(&self) -> String {
43 format!("{self}")
44 }
45
46 fn __repr__(&self) -> String {
47 format!("{self} @ {self:p}")
48 }
49}