Skip to main content

nyx_space/od/process/
rejectcrit.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 crate::io::ConfigRepr;
20use serde::{Deserialize, Serialize};
21
22#[cfg(feature = "python")]
23use pyo3::prelude::*;
24
25/// Reject measurements if the prefit is greater than the provided sigmas deviation from the measurement noise.
26///
27/// # Important
28/// Some software, like ODTK, processes each measurement as a scalar. Nyx can process the measurements together.
29/// As such, if the prefit on range is bad, then the Doppler measurement with the same time stamp will also be rejected.
30/// This can lead to better convergence of the filter, and more appropriate results.
31///
32/// :type num_sigmas: float
33#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq)]
34#[cfg_attr(feature = "python", pyclass(from_py_object, get_all, set_all))]
35pub struct SigmaRejection {
36    /// Number of sigmas for a measurement to be considered an outlier.
37    pub num_sigmas: f64,
38}
39
40impl Default for SigmaRejection {
41    /// By default, a measurement is rejected if its prefit residual is greater the 3-sigma value of the measurement noise at that time step.
42    /// This corresponds to [1 chance in in 370](https://en.wikipedia.org/wiki/68%E2%80%9395%E2%80%9399.7_rule).
43    fn default() -> Self {
44        Self { num_sigmas: 3.0 }
45    }
46}
47
48impl ConfigRepr for SigmaRejection {}
49
50#[cfg(feature = "python")]
51#[cfg_attr(feature = "python", pymethods)]
52impl SigmaRejection {
53    #[new]
54    fn py_new(num_sigmas: f64) -> Self {
55        Self { num_sigmas }
56    }
57
58    fn __str__(&self) -> String {
59        format!("{self:?}")
60    }
61
62    fn __repr__(&self) -> String {
63        format!("{self:?} @ {self:p}")
64    }
65}