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
//! IAU TDB model: the Fairhead & Bretagnon (1990) series.
//!
//! `TDB - TT` is the quasi-periodic term of the general-relativistic
//! transformation between the terrestrial and barycentric coordinate
//! scales. NAIF's `ET` approximates it with `K * sin(E)`, which NAIF
//! quotes as accurate to about 30 microseconds. The IAU/SOFA reference
//! implementation (`iauDtdb` / ERFA `dtdb`) uses the full
//! Fairhead & Bretagnon series of 787 terms, whose stated accuracy is
//! **better than ±3 nanoseconds over 1950-2050** against numerical
//! integrations based on JPL DE405.
//!
//! This module implements that series. It is a geocentric model: the
//! observer-dependent topocentric terms of `iauDtdb` (which need a
//! longitude and the observer's distance from the Earth's axis and
//! equator) are omitted, equivalent to zero `u` and `v`.
//!
//! # Relationship to the other TDB functions
//!
//! The crate exposes three distinct TDB-related quantities on purpose:
//!
//! * [`crate::convert::tai_to_et`] — NAIF `ET`, for SPICE interoperability
//! (~30 us).
//! * [`crate::tdb::tai_to_tdb`] — a compact two-term ESA approximation.
//! * [`tai_to_tdb_iau`] here — the IAU reference series (~3 ns), used by
//! [`crate::coord`] for TCB.
//!
//! They are not interchangeable; choose by the reference you must match.
//!
//! # Cost
//!
//! One conversion evaluates 787 sines. That is intentional and exact; it
//! is not on any inner loop of this crate.
use crate;
use crateFAIRHD;
use crateEpoch;
use crateLeapSecondTable;
use cratemath;
/// Julian Date of J2000.0.
const DJ00: f64 = 2_451_545.0;
/// Days per Julian millennium.
const DJM: f64 = 365_250.0;
/// Seconds per day.
const SEC_PER_DAY: f64 = 86_400.0;
/// `TDB - TT` in seconds for a TT Julian Date.
///
/// This is the geocentric Fairhead & Bretagnon series, i.e. ERFA `dtdb`
/// called with `u = v = 0`.
/// Converts a TAI epoch to IAU TDB seconds past `JD 2451545.0` on the TDB
/// scale.
/// Converts IAU TDB seconds past `JD 2451545.0` to a TAI epoch.
///
/// The series is evaluated at TT, so the fixed point is solved by
/// iteration; it converges immediately because `TDB - TT` is below 2 ms.