1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
// SPDX-License-Identifier: AGPL-3.0-or-later
// Copyright (C) 2026 Vallés Puig, Ramon
//! Core observation trait, type aliases, and residual types.
use crateOrbitState;
use crateGeocentric;
use crateGCRS;
use crateJulianDate;
use PodObservationsError;
use ProviderBundle;
// ─── Type aliases ────────────────────────────────────────────────────────────
/// Geocentric inertial Cartesian orbit state, position + velocity in GCRS.
///
/// Equivalent to `OrbitState<Geocentric, GCRS>` from `siderust`.
///
/// # Examples
///
/// ```
/// use siderust::pod::observation::obs_trait::CartesianState;
/// use siderust::astro::dynamics::{Position, Velocity};
/// use siderust::coordinates::frames::GCRS;
/// use siderust::time::JulianDate;
///
/// let state: CartesianState = CartesianState::new(
/// JulianDate::new(2_451_545.0).to_j2000s(),
/// Position::<GCRS>::new(7_000.0, 0.0, 0.0),
/// Velocity::<GCRS>::new(0.0, 7.5, 0.0),
/// );
/// assert!((state.position.x().value() - 7_000.0).abs() < 1e-10);
/// ```
pub type CartesianState = ;
// ─── Sensor taxonomy ─────────────────────────────────────────────────────────
/// Observable type tag.
///
/// # Examples
///
/// ```
/// use siderust::pod::observation::obs_trait::ObsType;
/// assert_ne!(ObsType::GnssPseudorange, ObsType::SlrNormalPoint);
/// ```
// ─── Residual types ──────────────────────────────────────────────────────────
/// Carrier-phase residual carrying both the metric residual and the fractional
/// cycle count.
///
/// # Examples
///
/// ```
/// use siderust::pod::observation::obs_trait::PhaseResidual;
///
/// let r = PhaseResidual { residual_m: 0.5, cycles: 0.5 / 0.1903 };
/// assert!((r.residual_m).abs() < 1.0);
/// ```
/// Type-erased residual for use in heterogeneous [`crate::pod::observation::ObservationBatch`]
/// collections.
///
/// # Examples
///
/// ```
/// use siderust::pod::observation::obs_trait::{ObsResidual, PhaseResidual};
///
/// let r = ObsResidual::Scalar(3.0);
/// let p = ObsResidual::Phase(PhaseResidual { residual_m: 0.1, cycles: 0.5 });
/// assert!(matches!(r, ObsResidual::Scalar(_)));
/// assert!(matches!(p, ObsResidual::Phase(_)));
/// ```
// ─── Observation trait ───────────────────────────────────────────────────────
/// Typed observation model that connects a tracked spacecraft state to one
/// observable.
///
/// Implementors embed all measurement-specific data (observed value, noise
/// model, atmospheric parameters, satellite ephemeris, …) and expose a single
/// entry point that computes the O−C residual given the current estimated
/// state and an optional provider bundle for dynamic look-ups (clock biases,
/// station positions, …).
///
/// # Examples
///
/// ```
/// use siderust::pod::observation::obs_trait::{CartesianState, Observation, ObsType};
/// use siderust::pod::observation::provider_bundle::NullProviderBundle;
/// use siderust::pod::observation::PodObservationsError;
/// use siderust::astro::dynamics::{Position, Velocity};
/// use siderust::coordinates::frames::GCRS;
/// use siderust::time::JulianDate;
///
/// struct ConstantObs;
/// impl Observation for ConstantObs {
/// type Residual = f64;
/// fn residual(
/// &self,
/// _state: &CartesianState,
/// _providers: &dyn siderust::pod::observation::provider_bundle::ProviderBundle,
/// ) -> Result<f64, PodObservationsError> {
/// Ok(0.0)
/// }
/// fn obs_type(&self) -> ObsType { ObsType::GnssPseudorange }
/// fn epoch(&self) -> JulianDate { JulianDate::new(2_451_545.0) }
/// fn sigma(&self) -> siderust::qtty::Meters { siderust::qtty::Meters::new(1.0) }
/// }
/// let state: CartesianState = CartesianState::new(
/// JulianDate::new(2_451_545.0).to_j2000s(),
/// Position::<GCRS>::new(7_000.0, 0.0, 0.0),
/// Velocity::<GCRS>::new(0.0, 7.5, 0.0),
/// );
/// let r = ConstantObs.residual(&state, &NullProviderBundle).unwrap();
/// assert_eq!(r, 0.0);
/// ```
// ─── Object-safe erasure ─────────────────────────────────────────────────────
/// Object-safe version of [`Observation`] used inside
/// [`crate::pod::observation::ObservationBatch`].
///
/// This trait is blanket-implemented for every `T: Observation` whose
/// `Residual` type can be converted into [`ObsResidual`].
///
/// # Examples
///
/// ```
/// use siderust::pod::observation::obs_trait::{AnyObservation, ObsResidual};
/// // See ObservationBatch for a usage example.
/// let _: &dyn AnyObservation;
/// ```