Skip to main content

lox_frames/iers/nutation/iau2000/
iau2000b.rs

1// SPDX-FileCopyrightText: 2023 Angus Morrison <github@angus-morrison.com>
2// SPDX-FileCopyrightText: 2024 Helge Eichhorn <git@helgeeichhorn.de>
3//
4// SPDX-License-Identifier: MPL-2.0
5
6use lox_time::Time;
7use lox_time::julian_dates::JulianDate;
8use lox_time::time_scales::Tdb;
9
10use crate::iers::fundamental::simon1994::{
11    d_simon1994, f_simon1994, l_simon1994, lp_simon1994, omega_simon1994,
12};
13use crate::iers::nutation::Nutation;
14use crate::iers::nutation::iau2000::{DelaunayArguments, luni_solar_nutation};
15
16mod luni_solar;
17mod planetary;
18
19impl Nutation {
20    /// Computes nutation using the IAU 2000B model.
21    pub fn iau2000b(time: Time<Tdb>) -> Nutation {
22        let t = time.centuries_since_j2000();
23        let luni_solar_args = DelaunayArguments {
24            l: l_simon1994(t),
25            lp: lp_simon1994(t),
26            f: f_simon1994(t),
27            d: d_simon1994(t),
28            om: omega_simon1994(t),
29        };
30
31        luni_solar_nutation(t, &luni_solar_args, &luni_solar::COEFFICIENTS) + planetary::OFFSETS
32    }
33}
34
35#[cfg(test)]
36mod tests {
37    use lox_core::units::AngleUnits;
38    use lox_test_utils::assert_approx_eq;
39    use lox_time::{Time, time_scales::Tdb};
40
41    use crate::iers::nutation::Nutation;
42
43    #[test]
44    fn test_nutation_iau2000b() {
45        let time = Time::from_two_part_julian_date(Tdb, 2400000.5, 53736.0);
46        let expected = Nutation {
47            dpsi: -9.632_552_291_148_363e-6.rad(),
48            deps: 4.063_197_106_621_159e-5.rad(),
49        };
50        let actual = Nutation::iau2000b(time);
51        assert_approx_eq!(expected, actual, rtol <= 1e-13);
52    }
53}