brahe 1.4.0

Brahe is a modern satellite dynamics library for research and engineering applications designed to be easy-to-learn, high-performance, and quick-to-deploy. The north-star of the development is enabling users to solve meaningful problems and answer questions quickly, easily, and correctly.
Documentation
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
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
/*!
 * Solar-system body position queries backed by NAIF DE ephemeris kernels.
 */

use nalgebra::{Matrix3, Vector3};

use anise::constants::frames as anise_frames;

use crate::constants::AS2RAD;
use crate::time::Epoch;
use crate::utils::BraheError;

use super::almanac::{brahe_epoch_to_anise, ensure_kernel_loaded};
use super::kernels::SPKKernel;

// ============================================================================
// J2000 → ICRF Frame Bias (private)
// ============================================================================

/// Fixed rotation matrix transforming J2000-aligned (EME2000) coordinates to ICRF/GCRF.
///
/// This is the IAU 2006 frame bias — constant, independent of epoch.
///
/// TODO: This function duplicates `rotation_eme2000_to_gcrf()` in `src/frames/eme_2000.rs`.
/// It is re-implemented here rather than imported because `*_position_de()` functions
/// should not depend on modules outside `spice`; it can be removed once we settle on a
/// clearer boundary between `frames/` and `spice/`.
///
/// # References
/// - IERS Conventions (2010), IERS TN 36, §5
#[inline]
#[allow(non_snake_case)]
fn j2000_to_icrf() -> Matrix3<f64> {
    let dxi = -16.6170e-3 * AS2RAD; // Frame bias in ξ.  Units: [rad]
    let deta = -6.8192e-3 * AS2RAD; // Frame bias in η.  Units: [rad]
    let dalpha = -14.6e-3 * AS2RAD; // Frame bias in α₀. Units: [rad]

    // Second-order approximation of bias matrix B (GCRF → EME2000).
    let b = Matrix3::new(
        1.0 - 0.5 * (dxi * dxi + deta * deta),
        dalpha,
        -dxi,
        -dalpha - dxi * deta,
        1.0 - 0.5 * (dalpha * dalpha + deta * deta),
        -deta,
        dxi + dalpha * deta,
        deta + dalpha * dxi,
        1.0 - 0.5 * (deta * deta + dxi * dxi),
    );
    b.transpose() // EME2000 → GCRF, i.e. J2000 → ICRF
}

// ============================================================================
// DE Position Functions
// ============================================================================

/// Calculate the position of the Sun in the GCRF frame using NAIF DE ephemeris.
///
/// # Arguments
///
/// * `epc` - Epoch at which to calculate the Sun's position
/// * `kernel` - Which DE kernel to use
///
/// # Returns
///
/// * `Ok(Vector3<f64>)` - Position of the Sun in the GCRF frame. Units: [m]
/// * `Err(BraheError)` - If the ephemeris kernel cannot be loaded or queried
///
/// # Example
///
/// ```
/// use brahe::spice::{SPKKernel, sun_position_de};
/// use brahe::time::Epoch;
/// use brahe::TimeSystem;
///
/// let epc = Epoch::from_date(2024, 2, 25, TimeSystem::UTC);
/// let r_sun = sun_position_de(epc, SPKKernel::DE440s)?;
/// # Ok::<(), brahe::utils::BraheError>(())
/// ```
pub fn sun_position_de(epc: Epoch, kernel: SPKKernel) -> Result<Vector3<f64>, BraheError> {
    let ctx = ensure_kernel_loaded(kernel)?;
    let anise_epoch = brahe_epoch_to_anise(epc);

    let r_j2000 = ctx
        .translate(
            anise_frames::SUN_J2000,
            anise_frames::EME2000,
            anise_epoch,
            None,
        )
        .map_err(|e| BraheError::Error(format!("Failed to query Sun position: {}", e)))?;

    let r_m = Vector3::new(
        r_j2000.radius_km[0] * 1.0e3,
        r_j2000.radius_km[1] * 1.0e3,
        r_j2000.radius_km[2] * 1.0e3,
    );

    Ok(j2000_to_icrf() * r_m)
}

/// Calculate the position of the Moon in the GCRF frame using NAIF DE ephemeris.
///
/// # Arguments
///
/// * `epc` - Epoch at which to calculate the Moon's position
/// * `kernel` - Which DE kernel to use
///
/// # Returns
///
/// * `Ok(Vector3<f64>)` - Position of the Moon in the GCRF frame. Units: [m]
/// * `Err(BraheError)` - If the ephemeris kernel cannot be loaded or queried
///
/// # Example
///
/// ```
/// use brahe::spice::{SPKKernel, moon_position_de};
/// use brahe::time::Epoch;
/// use brahe::TimeSystem;
///
/// let epc = Epoch::from_date(2024, 2, 25, TimeSystem::UTC);
/// let r_moon = moon_position_de(epc, SPKKernel::DE440s)?;
/// # Ok::<(), brahe::utils::BraheError>(())
/// ```
pub fn moon_position_de(epc: Epoch, kernel: SPKKernel) -> Result<Vector3<f64>, BraheError> {
    let ctx = ensure_kernel_loaded(kernel)?;
    let anise_epoch = brahe_epoch_to_anise(epc);

    let r_j2000 = ctx
        .translate(
            anise_frames::IAU_MOON_FRAME,
            anise_frames::EME2000,
            anise_epoch,
            None,
        )
        .map_err(|e| BraheError::Error(format!("Failed to query Moon position: {}", e)))?;

    let r_m = Vector3::new(
        r_j2000.radius_km[0] * 1.0e3,
        r_j2000.radius_km[1] * 1.0e3,
        r_j2000.radius_km[2] * 1.0e3,
    );

    Ok(j2000_to_icrf() * r_m)
}

/// Calculate the position of Jupiter in the GCRF frame using NAIF DE ephemeris.
///
/// # Arguments
///
/// * `epc` - Epoch at which to calculate Jupiter's position
/// * `kernel` - Which DE kernel to use
///
/// # Returns
///
/// * `Ok(Vector3<f64>)` - Position of Jupiter in the GCRF frame. Units: [m]
/// * `Err(BraheError)` - If the ephemeris kernel cannot be loaded or queried
///
/// # Example
///
/// ```
/// use brahe::spice::{SPKKernel, jupiter_position_de};
/// use brahe::time::Epoch;
/// use brahe::TimeSystem;
///
/// let epc = Epoch::from_date(2024, 2, 25, TimeSystem::UTC);
/// let r_jupiter = jupiter_position_de(epc, SPKKernel::DE440s)?;
/// # Ok::<(), brahe::utils::BraheError>(())
/// ```
pub fn jupiter_position_de(epc: Epoch, kernel: SPKKernel) -> Result<Vector3<f64>, BraheError> {
    let ctx = ensure_kernel_loaded(kernel)?;
    let anise_epoch = brahe_epoch_to_anise(epc);

    let r_j2000 = ctx
        .translate(
            anise_frames::JUPITER_BARYCENTER_J2000,
            anise_frames::EME2000,
            anise_epoch,
            None,
        )
        .map_err(|e| BraheError::Error(format!("Failed to query Jupiter position: {}", e)))?;

    let r_m = Vector3::new(
        r_j2000.radius_km[0] * 1.0e3,
        r_j2000.radius_km[1] * 1.0e3,
        r_j2000.radius_km[2] * 1.0e3,
    );

    Ok(j2000_to_icrf() * r_m)
}

/// Calculate the position of Mars in the GCRF frame using NAIF DE ephemeris.
///
/// # Arguments
///
/// * `epc` - Epoch at which to calculate Mars' position
/// * `kernel` - Which DE kernel to use
///
/// # Returns
///
/// * `Ok(Vector3<f64>)` - Position of Mars in the GCRF frame. Units: [m]
/// * `Err(BraheError)` - If the ephemeris kernel cannot be loaded or queried
///
/// # Example
///
/// ```
/// use brahe::spice::{SPKKernel, mars_position_de};
/// use brahe::time::Epoch;
/// use brahe::TimeSystem;
///
/// let epc = Epoch::from_date(2024, 2, 25, TimeSystem::UTC);
/// let r_mars = mars_position_de(epc, SPKKernel::DE440s)?;
/// # Ok::<(), brahe::utils::BraheError>(())
/// ```
pub fn mars_position_de(epc: Epoch, kernel: SPKKernel) -> Result<Vector3<f64>, BraheError> {
    let ctx = ensure_kernel_loaded(kernel)?;
    let anise_epoch = brahe_epoch_to_anise(epc);

    let r_j2000 = ctx
        .translate(
            anise_frames::MARS_BARYCENTER_J2000,
            anise_frames::EME2000,
            anise_epoch,
            None,
        )
        .map_err(|e| BraheError::Error(format!("Failed to query Mars position: {}", e)))?;

    let r_m = Vector3::new(
        r_j2000.radius_km[0] * 1.0e3,
        r_j2000.radius_km[1] * 1.0e3,
        r_j2000.radius_km[2] * 1.0e3,
    );

    Ok(j2000_to_icrf() * r_m)
}

/// Calculate the position of Mercury in the GCRF frame using NAIF DE ephemeris.
///
/// # Arguments
///
/// * `epc` - Epoch at which to calculate Mercury's position
/// * `kernel` - Which DE kernel to use
///
/// # Returns
///
/// * `Ok(Vector3<f64>)` - Position of Mercury in the GCRF frame. Units: [m]
/// * `Err(BraheError)` - If the ephemeris kernel cannot be loaded or queried
///
/// # Example
///
/// ```
/// use brahe::spice::{SPKKernel, mercury_position_de};
/// use brahe::time::Epoch;
/// use brahe::TimeSystem;
///
/// let epc = Epoch::from_date(2024, 2, 25, TimeSystem::UTC);
/// let r_mercury = mercury_position_de(epc, SPKKernel::DE440s)?;
/// # Ok::<(), brahe::utils::BraheError>(())
/// ```
pub fn mercury_position_de(epc: Epoch, kernel: SPKKernel) -> Result<Vector3<f64>, BraheError> {
    let ctx = ensure_kernel_loaded(kernel)?;
    let anise_epoch = brahe_epoch_to_anise(epc);

    let r_j2000 = ctx
        .translate(
            anise_frames::MERCURY_J2000,
            anise_frames::EME2000,
            anise_epoch,
            None,
        )
        .map_err(|e| BraheError::Error(format!("Failed to query Mercury position: {}", e)))?;

    let r_m = Vector3::new(
        r_j2000.radius_km[0] * 1.0e3,
        r_j2000.radius_km[1] * 1.0e3,
        r_j2000.radius_km[2] * 1.0e3,
    );

    Ok(j2000_to_icrf() * r_m)
}

/// Calculate the position of Neptune in the GCRF frame using NAIF DE ephemeris.
///
/// # Arguments
///
/// * `epc` - Epoch at which to calculate Neptune's position
/// * `kernel` - Which DE kernel to use
///
/// # Returns
///
/// * `Ok(Vector3<f64>)` - Position of Neptune in the GCRF frame. Units: [m]
/// * `Err(BraheError)` - If the ephemeris kernel cannot be loaded or queried
///
/// # Example
///
/// ```
/// use brahe::spice::{SPKKernel, neptune_position_de};
/// use brahe::time::Epoch;
/// use brahe::TimeSystem;
///
/// let epc = Epoch::from_date(2024, 2, 25, TimeSystem::UTC);
/// let r_neptune = neptune_position_de(epc, SPKKernel::DE440s)?;
/// # Ok::<(), brahe::utils::BraheError>(())
/// ```
pub fn neptune_position_de(epc: Epoch, kernel: SPKKernel) -> Result<Vector3<f64>, BraheError> {
    let ctx = ensure_kernel_loaded(kernel)?;
    let anise_epoch = brahe_epoch_to_anise(epc);

    let r_j2000 = ctx
        .translate(
            anise_frames::NEPTUNE_BARYCENTER_J2000,
            anise_frames::EME2000,
            anise_epoch,
            None,
        )
        .map_err(|e| BraheError::Error(format!("Failed to query Neptune position: {}", e)))?;

    let r_m = Vector3::new(
        r_j2000.radius_km[0] * 1.0e3,
        r_j2000.radius_km[1] * 1.0e3,
        r_j2000.radius_km[2] * 1.0e3,
    );

    Ok(j2000_to_icrf() * r_m)
}

/// Calculate the position of Saturn in the GCRF frame using NAIF DE ephemeris.
///
/// # Arguments
///
/// * `epc` - Epoch at which to calculate Saturn's position
/// * `kernel` - Which DE kernel to use
///
/// # Returns
///
/// * `Ok(Vector3<f64>)` - Position of Saturn in the GCRF frame. Units: [m]
/// * `Err(BraheError)` - If the ephemeris kernel cannot be loaded or queried
///
/// # Example
///
/// ```
/// use brahe::spice::{SPKKernel, saturn_position_de};
/// use brahe::time::Epoch;
/// use brahe::TimeSystem;
///
/// let epc = Epoch::from_date(2024, 2, 25, TimeSystem::UTC);
/// let r_saturn = saturn_position_de(epc, SPKKernel::DE440s)?;
/// # Ok::<(), brahe::utils::BraheError>(())
/// ```
pub fn saturn_position_de(epc: Epoch, kernel: SPKKernel) -> Result<Vector3<f64>, BraheError> {
    let ctx = ensure_kernel_loaded(kernel)?;
    let anise_epoch = brahe_epoch_to_anise(epc);

    let r_j2000 = ctx
        .translate(
            anise_frames::SATURN_BARYCENTER_J2000,
            anise_frames::EME2000,
            anise_epoch,
            None,
        )
        .map_err(|e| BraheError::Error(format!("Failed to query Saturn position: {}", e)))?;

    let r_m = Vector3::new(
        r_j2000.radius_km[0] * 1.0e3,
        r_j2000.radius_km[1] * 1.0e3,
        r_j2000.radius_km[2] * 1.0e3,
    );

    Ok(j2000_to_icrf() * r_m)
}

/// Calculate the position of Uranus in the GCRF frame using NAIF DE ephemeris.
///
/// # Arguments
///
/// * `epc` - Epoch at which to calculate Uranus' position
/// * `kernel` - Which DE kernel to use
///
/// # Returns
///
/// * `Ok(Vector3<f64>)` - Position of Uranus in the GCRF frame. Units: [m]
/// * `Err(BraheError)` - If the ephemeris kernel cannot be loaded or queried
///
/// # Example
///
/// ```
/// use brahe::spice::{SPKKernel, uranus_position_de};
/// use brahe::time::Epoch;
/// use brahe::TimeSystem;
///
/// let epc = Epoch::from_date(2024, 2, 25, TimeSystem::UTC);
/// let r_uranus = uranus_position_de(epc, SPKKernel::DE440s)?;
/// # Ok::<(), brahe::utils::BraheError>(())
/// ```
pub fn uranus_position_de(epc: Epoch, kernel: SPKKernel) -> Result<Vector3<f64>, BraheError> {
    let ctx = ensure_kernel_loaded(kernel)?;
    let anise_epoch = brahe_epoch_to_anise(epc);

    let r_j2000 = ctx
        .translate(
            anise_frames::URANUS_BARYCENTER_J2000,
            anise_frames::EME2000,
            anise_epoch,
            None,
        )
        .map_err(|e| BraheError::Error(format!("Failed to query Uranus position: {}", e)))?;

    let r_m = Vector3::new(
        r_j2000.radius_km[0] * 1.0e3,
        r_j2000.radius_km[1] * 1.0e3,
        r_j2000.radius_km[2] * 1.0e3,
    );

    Ok(j2000_to_icrf() * r_m)
}

/// Calculate the position of Venus in the GCRF frame using NAIF DE ephemeris.
///
/// # Arguments
///
/// * `epc` - Epoch at which to calculate Venus' position
/// * `kernel` - Which DE kernel to use
///
/// # Returns
///
/// * `Ok(Vector3<f64>)` - Position of Venus in the GCRF frame. Units: [m]
/// * `Err(BraheError)` - If the ephemeris kernel cannot be loaded or queried
///
/// # Example
///
/// ```
/// use brahe::spice::{SPKKernel, venus_position_de};
/// use brahe::time::Epoch;
/// use brahe::TimeSystem;
///
/// let epc = Epoch::from_date(2024, 2, 25, TimeSystem::UTC);
/// let r_venus = venus_position_de(epc, SPKKernel::DE440s)?;
/// # Ok::<(), brahe::utils::BraheError>(())
/// ```
pub fn venus_position_de(epc: Epoch, kernel: SPKKernel) -> Result<Vector3<f64>, BraheError> {
    let ctx = ensure_kernel_loaded(kernel)?;
    let anise_epoch = brahe_epoch_to_anise(epc);

    let r_j2000 = ctx
        .translate(
            anise_frames::VENUS_J2000,
            anise_frames::EME2000,
            anise_epoch,
            None,
        )
        .map_err(|e| BraheError::Error(format!("Failed to query Venus position: {}", e)))?;

    let r_m = Vector3::new(
        r_j2000.radius_km[0] * 1.0e3,
        r_j2000.radius_km[1] * 1.0e3,
        r_j2000.radius_km[2] * 1.0e3,
    );

    Ok(j2000_to_icrf() * r_m)
}

/// Calculate the position of the Solar System Barycenter in the GCRF frame using NAIF DE ephemeris.
///
/// # Arguments
///
/// * `epc` - Epoch at which to calculate the SSB position
/// * `kernel` - Which DE kernel to use
///
/// # Returns
///
/// * `Ok(Vector3<f64>)` - Position of the SSB in the GCRF frame. Units: [m]
/// * `Err(BraheError)` - If the ephemeris kernel cannot be loaded or queried
///
/// # Example
///
/// ```
/// use brahe::spice::{SPKKernel, solar_system_barycenter_position_de};
/// use brahe::time::Epoch;
/// use brahe::TimeSystem;
///
/// let epc = Epoch::from_date(2024, 2, 25, TimeSystem::UTC);
/// let r_ssb = solar_system_barycenter_position_de(epc, SPKKernel::DE440s)?;
/// # Ok::<(), brahe::utils::BraheError>(())
/// ```
pub fn solar_system_barycenter_position_de(
    epc: Epoch,
    kernel: SPKKernel,
) -> Result<Vector3<f64>, BraheError> {
    let ctx = ensure_kernel_loaded(kernel)?;
    let anise_epoch = brahe_epoch_to_anise(epc);

    let r_j2000 = ctx
        .translate(
            anise_frames::SSB_J2000,
            anise_frames::EME2000,
            anise_epoch,
            None,
        )
        .map_err(|e| {
            BraheError::Error(format!(
                "Failed to query Solar System Barycenter position: {}",
                e
            ))
        })?;

    let r_m = Vector3::new(
        r_j2000.radius_km[0] * 1.0e3,
        r_j2000.radius_km[1] * 1.0e3,
        r_j2000.radius_km[2] * 1.0e3,
    );

    Ok(j2000_to_icrf() * r_m)
}

/// Calculate the position of the Solar System Barycenter in the GCRF frame using NAIF DE ephemeris.
///
/// Convenience alias for [`solar_system_barycenter_position_de`].
///
/// # Arguments
///
/// * `epc` - Epoch at which to calculate the SSB position
/// * `kernel` - Which DE kernel to use
///
/// # Returns
///
/// * `Ok(Vector3<f64>)` - Position of the SSB in the GCRF frame. Units: [m]
/// * `Err(BraheError)` - If the ephemeris kernel cannot be loaded or queried
///
/// # Example
///
/// ```
/// use brahe::spice::{SPKKernel, ssb_position_de};
/// use brahe::time::Epoch;
/// use brahe::TimeSystem;
///
/// let epc = Epoch::from_date(2024, 2, 25, TimeSystem::UTC);
/// let r_ssb = ssb_position_de(epc, SPKKernel::DE440s)?;
/// # Ok::<(), brahe::utils::BraheError>(())
/// ```
pub fn ssb_position_de(epc: Epoch, kernel: SPKKernel) -> Result<Vector3<f64>, BraheError> {
    solar_system_barycenter_position_de(epc, kernel)
}

#[cfg(test)]
#[cfg_attr(coverage_nightly, coverage(off))]
mod tests {
    use approx::assert_abs_diff_eq;
    use rstest::rstest;

    use super::*;
    use crate::orbit_dynamics::ephemerides::{moon_position, sun_position};
    use crate::utils::testing::setup_global_test_almanac;

    #[rstest]
    #[case(2025, 1, 1)]
    #[case(2025, 2, 15)]
    #[case(2025, 3, 30)]
    #[case(2025, 5, 15)]
    #[case(2025, 7, 1)]
    #[case(2025, 8, 15)]
    #[case(2025, 10, 1)]
    #[case(2025, 11, 15)]
    #[case(2025, 12, 31)]
    fn test_sun_position_de(#[case] year: u32, #[case] month: u8, #[case] day: u8) {
        setup_global_test_almanac();

        let epc = Epoch::from_date(year, month, day, crate::time::TimeSystem::UTC);
        let r_analytical = sun_position(epc);
        let r_de = sun_position_de(epc, SPKKernel::DE440s).unwrap();

        let dot = r_analytical.dot(&r_de) / (r_analytical.norm() * r_de.norm());
        let angle = dot.acos() * (180.0 / std::f64::consts::PI);
        assert_abs_diff_eq!(angle, 0.0, epsilon = 1.0e-1);
    }

    #[rstest]
    #[case(2025, 1, 1)]
    #[case(2025, 2, 15)]
    #[case(2025, 3, 30)]
    #[case(2025, 5, 15)]
    #[case(2025, 7, 1)]
    #[case(2025, 8, 15)]
    #[case(2025, 10, 1)]
    #[case(2025, 11, 15)]
    #[case(2025, 12, 31)]
    fn test_moon_position_de(#[case] year: u32, #[case] month: u8, #[case] day: u8) {
        setup_global_test_almanac();

        let epc = Epoch::from_date(year, month, day, crate::time::TimeSystem::UTC);
        let r_analytical = moon_position(epc);
        let r_de = moon_position_de(epc, SPKKernel::DE440s).unwrap();

        let dot = r_analytical.dot(&r_de) / (r_analytical.norm() * r_de.norm());
        let angle = dot.acos() * (180.0 / std::f64::consts::PI);
        assert_abs_diff_eq!(angle, 0.0, epsilon = 1.0e-1);
    }

    #[rstest]
    #[case(2025, 1, 1)]
    #[case(2025, 2, 15)]
    #[case(2025, 3, 30)]
    #[case(2025, 5, 15)]
    #[case(2025, 7, 1)]
    #[case(2025, 8, 15)]
    #[case(2025, 10, 1)]
    #[case(2025, 11, 15)]
    #[case(2025, 12, 31)]
    fn test_jupiter_position_de(#[case] year: u32, #[case] month: u8, #[case] day: u8) {
        setup_global_test_almanac();
        let epc = Epoch::from_date(year, month, day, crate::time::TimeSystem::UTC);
        let _r = jupiter_position_de(epc, SPKKernel::DE440s).unwrap();
    }

    #[rstest]
    #[case(2025, 1, 1)]
    #[case(2025, 2, 15)]
    #[case(2025, 3, 30)]
    #[case(2025, 5, 15)]
    #[case(2025, 7, 1)]
    #[case(2025, 8, 15)]
    #[case(2025, 10, 1)]
    #[case(2025, 11, 15)]
    #[case(2025, 12, 31)]
    fn test_mars_position_de(#[case] year: u32, #[case] month: u8, #[case] day: u8) {
        setup_global_test_almanac();
        let epc = Epoch::from_date(year, month, day, crate::time::TimeSystem::UTC);
        let _r = mars_position_de(epc, SPKKernel::DE440s).unwrap();
    }

    #[rstest]
    #[case(2025, 1, 1)]
    #[case(2025, 2, 15)]
    #[case(2025, 3, 30)]
    #[case(2025, 5, 15)]
    #[case(2025, 7, 1)]
    #[case(2025, 8, 15)]
    #[case(2025, 10, 1)]
    #[case(2025, 11, 15)]
    #[case(2025, 12, 31)]
    fn test_mercury_position_de(#[case] year: u32, #[case] month: u8, #[case] day: u8) {
        setup_global_test_almanac();
        let epc = Epoch::from_date(year, month, day, crate::time::TimeSystem::UTC);
        let _r = mercury_position_de(epc, SPKKernel::DE440s).unwrap();
    }

    #[rstest]
    #[case(2025, 1, 1)]
    #[case(2025, 2, 15)]
    #[case(2025, 3, 30)]
    #[case(2025, 5, 15)]
    #[case(2025, 7, 1)]
    #[case(2025, 8, 15)]
    #[case(2025, 10, 1)]
    #[case(2025, 11, 15)]
    #[case(2025, 12, 31)]
    fn test_neptune_position_de(#[case] year: u32, #[case] month: u8, #[case] day: u8) {
        setup_global_test_almanac();
        let epc = Epoch::from_date(year, month, day, crate::time::TimeSystem::UTC);
        let _r = neptune_position_de(epc, SPKKernel::DE440s).unwrap();
    }

    #[rstest]
    #[case(2025, 1, 1)]
    #[case(2025, 2, 15)]
    #[case(2025, 3, 30)]
    #[case(2025, 5, 15)]
    #[case(2025, 7, 1)]
    #[case(2025, 8, 15)]
    #[case(2025, 10, 1)]
    #[case(2025, 11, 15)]
    #[case(2025, 12, 31)]
    fn test_saturn_position_de(#[case] year: u32, #[case] month: u8, #[case] day: u8) {
        setup_global_test_almanac();
        let epc = Epoch::from_date(year, month, day, crate::time::TimeSystem::UTC);
        let _r = saturn_position_de(epc, SPKKernel::DE440s).unwrap();
    }

    #[rstest]
    #[case(2025, 1, 1)]
    #[case(2025, 2, 15)]
    #[case(2025, 3, 30)]
    #[case(2025, 5, 15)]
    #[case(2025, 7, 1)]
    #[case(2025, 8, 15)]
    #[case(2025, 10, 1)]
    #[case(2025, 11, 15)]
    #[case(2025, 12, 31)]
    fn test_uranus_position_de(#[case] year: u32, #[case] month: u8, #[case] day: u8) {
        setup_global_test_almanac();
        let epc = Epoch::from_date(year, month, day, crate::time::TimeSystem::UTC);
        let _r = uranus_position_de(epc, SPKKernel::DE440s).unwrap();
    }

    #[rstest]
    #[case(2025, 1, 1)]
    #[case(2025, 2, 15)]
    #[case(2025, 3, 30)]
    #[case(2025, 5, 15)]
    #[case(2025, 7, 1)]
    #[case(2025, 8, 15)]
    #[case(2025, 10, 1)]
    #[case(2025, 11, 15)]
    #[case(2025, 12, 31)]
    fn test_venus_position_de(#[case] year: u32, #[case] month: u8, #[case] day: u8) {
        setup_global_test_almanac();
        let epc = Epoch::from_date(year, month, day, crate::time::TimeSystem::UTC);
        let _r = venus_position_de(epc, SPKKernel::DE440s).unwrap();
    }

    #[rstest]
    #[case(2025, 1, 1)]
    #[case(2025, 2, 15)]
    #[case(2025, 3, 30)]
    #[case(2025, 5, 15)]
    #[case(2025, 7, 1)]
    #[case(2025, 8, 15)]
    #[case(2025, 10, 1)]
    #[case(2025, 11, 15)]
    #[case(2025, 12, 31)]
    fn test_solar_system_barycenter_position_de(
        #[case] year: u32,
        #[case] month: u8,
        #[case] day: u8,
    ) {
        setup_global_test_almanac();
        let epc = Epoch::from_date(year, month, day, crate::time::TimeSystem::UTC);
        let _r = solar_system_barycenter_position_de(epc, SPKKernel::DE440s).unwrap();
    }
}