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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
//! Ephemeris request builder and output-kind trait.
//!
//! This module contains everything needed to describe *what* to compute and
//! *when* to compute it. The typical workflow is:
//!
//! 1. **Build a request** — create an [`EphemerisRequest`] with the desired
//! output kind as a type parameter, then chain [`EphemerisRequest::add`]
//! calls to attach `(observer, mode)` pairs.
//! 2. **Call compute** — pass the request to
//! [`OrbitalElements::compute`](crate::OrbitalElements::compute) together
//! with a [`JPLEphem`] and a UT1 provider.
//! 3. **Consume the result** — iterate over the returned
//! [`EphemerisResult`](super::result::EphemerisResult) using
//! [`successes`](super::result::EphemerisResult::successes),
//! [`errors`](super::result::EphemerisResult::errors), or
//! [`by_observer`](super::result::EphemerisResult::by_observer).
//!
//! Errors that occur at individual epochs are recorded inside the result
//! rather than short-circuiting the whole computation: every requested
//! `(epoch, observer)` pair always produces an entry, either `Ok` or `Err`.
//!
//! # Output kinds
//!
//! Three zero-sized marker types select what is computed at each epoch:
//!
//! | Marker | Physical quantities | Output type per epoch |
//! |---|---|---|
//! | [`Position`] | Apparent sky coordinates (RA, Dec), geocentric and heliocentric distances | [`ApparentPosition`] |
//! | [`Geometry`] | Phase angle, solar elongation, radial velocity, apparent angular rates | [`BodyGeometry`] |
//! | [`Combined`] | All of the above from a single orbit propagation | `(`[`ApparentPosition`]`, `[`BodyGeometry`]`)` |
//!
//! # Generation modes
//!
//! Each observer is paired with an [`EphemerisMode`] that describes *when* to
//! compute:
//!
//! | Variant | Epochs generated |
//! |---|---|
//! | [`EphemerisMode::Single`] | Exactly one epoch |
//! | [`EphemerisMode::Range`] | Uniform grid from `start` to `end` |
//! | [`EphemerisMode::At`] | Arbitrary list of epochs |
//!
//! Different observers may use different modes in the same request.
//!
//! # Example
//!
//! ```rust,ignore
//! use outfit::{
//! EphemerisConfig, EphemerisRequest, EphemerisMode,
//! ephemeris::request::Combined,
//! };
//! use hifitime::{Epoch, Duration};
//!
//! let result = elements.compute(
//! &EphemerisRequest::<Combined>::new(EphemerisConfig::default())
//! .add(observer_a, EphemerisMode::Range {
//! start: Epoch::from_mjd_tt(60310.0),
//! end: Epoch::from_mjd_tt(60340.0),
//! step: Duration::from_days(1.0),
//! })
//! .add(observer_b, EphemerisMode::At(vec![t1, t2, t3])),
//! &jpl,
//! &ut1,
//! );
//! ```
use ;
use Observer;
use PhantomData;
use ;
use crate::;
use Ut1Provider;
// ---------------------------------------------------------------------------
// Output-kind sealed trait
// ---------------------------------------------------------------------------
/// Trait implemented by [`Position`], [`Geometry`], and [`Combined`].
///
/// This uses the *sealed trait* pattern: because `Sealed` is private, no
/// external crate can implement `EphemerisOutputKind` for its own types.
/// Use one of the three provided marker types to select what an
/// [`EphemerisRequest`] computes.
// ---------------------------------------------------------------------------
// Marker types
// ---------------------------------------------------------------------------
/// Output-kind marker: compute only the apparent sky position.
///
/// Use this when you need `(RA, Dec)` and distances but not the geometric
/// quantities (phase angle, elongation, …).
///
/// Produces [`ApparentPosition`] per epoch.
;
/// Output-kind marker: compute only the geometric quantities.
///
/// Use this when you need the phase angle, solar elongation, radial velocity
/// and apparent angular rates but not the full sky-coordinate conversion.
///
/// Produces [`BodyGeometry`] per epoch.
;
/// Output-kind marker: compute both apparent position and geometric quantities
/// from a **single orbit propagation** per epoch.
///
/// More efficient than computing [`Position`] and [`Geometry`] separately:
/// the orbit is propagated once and the results are split into the two output
/// types.
///
/// Produces `(`[`ApparentPosition`]`, `[`BodyGeometry`]`)` per epoch.
;
// ---------------------------------------------------------------------------
// EphemerisMode
// ---------------------------------------------------------------------------
/// Describes *when* to compute ephemerides for one observer.
///
/// Different observers in the same [`EphemerisRequest`] may use different
/// modes freely — for instance, a topocentric site can use [`Single`] while a
/// geocentric site uses [`Range`].
///
/// [`Single`]: EphemerisMode::Single
/// [`Range`]: EphemerisMode::Range
// ---------------------------------------------------------------------------
// ObserverRequest
// ---------------------------------------------------------------------------
/// A single `(observer, mode)` slot inside an [`EphemerisRequest`].
// ---------------------------------------------------------------------------
// EphemerisRequest
// ---------------------------------------------------------------------------
/// A typed ephemeris generation request.
///
/// Collects any number of `(`[`Observer`]`, `[`EphemerisMode`]`)` pairs and
/// carries the desired output kind `O` as a compile-time type parameter.
/// `O` is encoded via [`PhantomData`] — it is a zero-cost, zero-size
/// compile-time marker with no runtime overhead.
///
/// Build the request with [`new`](Self::new) and chain [`add`](Self::add)
/// calls, then pass it to [`crate::OrbitalElements::compute`].
///
/// # Type parameter
///
/// `O` must be one of [`Position`], [`Geometry`], or [`Combined`]. The
/// choice is enforced at compile time: it is impossible to mix output kinds
/// within one request.
///
/// # Example
///
/// ```rust,ignore
/// let request = EphemerisRequest::<Combined>::new(EphemerisConfig::default())
/// .add(observer_a, EphemerisMode::Range { start, end, step })
/// .add(observer_b, EphemerisMode::At(vec![t1, t2, t3]))
/// .add(observer_c, EphemerisMode::Single(t));
///
/// let result = elements.compute(&request, &jpl, &ut1);
/// ```