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#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq)]
32#[cfg_attr(feature = "python", pyclass(from_py_object, get_all, set_all))]
33pub struct SigmaRejection {
34    /// Number of sigmas for a measurement to be considered an outlier.
35    pub num_sigmas: f64,
36}
37
38impl Default for SigmaRejection {
39    /// By default, a measurement is rejected if its prefit residual is greater the 3-sigma value of the measurement noise at that time step.
40    /// This corresponds to [1 chance in in 370](https://en.wikipedia.org/wiki/68%E2%80%9395%E2%80%9399.7_rule).
41    fn default() -> Self {
42        Self { num_sigmas: 3.0 }
43    }
44}
45
46impl ConfigRepr for SigmaRejection {}
47
48#[cfg(feature = "python")]
49#[cfg_attr(feature = "python", pymethods)]
50impl SigmaRejection {
51    #[new]
52    fn py_new(num_sigmas: f64) -> Self {
53        Self { num_sigmas }
54    }
55
56    fn __str__(&self) -> String {
57        format!("{self:?}")
58    }
59
60    fn __repr__(&self) -> String {
61        format!("{self:?} @ {self:p}")
62    }
63}