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
//! Coordinate time scales: TCG and TCB.
//!
//! TCG (Geocentric Coordinate Time) and TCB (Barycentric Coordinate Time)
//! are the IAU 2000/2006 coordinate time scales. They are linear
//! functions of TT and TDB:
//!
//! ```text
//! TCG - TT = L_G / (1 - L_G) * (JD_TT - T0) * 86400
//! TCB - TDB = (L_B * (JD_TDB - T0) * 86400 - TDB0) / (1 - L_B)
//! ```
//!
//! where `T0 = 1977-01-01T00:00:00 TAI` (`JD 2443144.5003725` in TT),
//! `L_G = 6.969290134e-10`, `L_B = 1.550519768e-8` and
//! `TDB0 = -6.55e-5 s` are the IAU/SOFA constants (ERFA `tttcg`,
//! `tcgtt`, `tcbtdb`, `tdbtcb`).
//!
//! Coordinates here are seconds past the Julian Date `2451545.0`
//! (`2000-01-01T12:00:00`) on the respective scale, so they line up with
//! [`crate::convert::tai_to_tt`] and [`crate::convert::tai_to_et`].
//!
//! Because `JD - T0 = (JD_J2000 - T0) + t/86400`, the relations are
//! exactly linear in `t`, the seconds past J2000. They are evaluated that
//! way; reconstructing an absolute Julian Date from a value near 5e8
//! seconds would lose about `1e-4 s` to `f64` rounding.
//!
//! # Precision, stated honestly
//!
//! TCG depends only on TT, which is `TAI + 32.184 s`; the TCG result is
//! limited only by the constants and `f64` arithmetic.
//!
//! TCB uses the IAU Fairhead-Bretagnon TDB model in [`crate::dtdb`],
//! accurate to better than 3 nanoseconds over 1950-2050, so TCB matches
//! the IAU/SOFA definition to the `f64` representation limit.
//!
//! These values are `f64` seconds near 5e8 at modern epochs, so their
//! spacing is about 60 ns. Neither scale depends on an ephemeris kernel.
use crate;
use crate;
use crateEpoch;
use crateLeapSecondTable;
/// IAU 2000 `L_G` (exact): the TCG/TT rate ratio.
pub const L_G: f64 = 6.969_290_134e-10;
/// IAU 2006 `L_B` (exact): the TCB/TDB rate ratio.
pub const L_B: f64 = 1.550_519_768e-8;
/// Defining offset of the IAU TCB/TDB affine relation, in seconds.
///
/// This is the SOFA/ERFA `TDB0` constant used by the TCB alignment.
pub const TDB0: f64 = -6.55e-5;
/// Julian Date of `2000-01-01T12:00:00`, the coordinate origin.
const JD_J2000: f64 = 2_451_545.0;
/// Julian Date of `1977-01-01T00:00:00 TAI` expressed in TT.
const JD_T0_TT: f64 = 2_443_144.500_372_5;
/// Days from T0 to the J2000 origin (`JD_J2000 - T0`).
const J2000_MINUS_T0_DAYS: f64 = JD_J2000 - JD_T0_TT;
/// Seconds per day, as a multiplier.
const SEC_PER_DAY: f64 = 86_400.0;
/// `L_G / (1 - L_G)`, the TT-to-TCG rate used by ERFA `tttcg`.
/// `L_B / (1 - L_B)`, the TDB-to-TCB rate used by ERFA `tdbtcb`.
/// Constant term of the TCB linear relation.
/// `TCG - TT` in seconds at a TAI epoch.
/// Converts a TAI epoch to TCG seconds past `JD 2451545.0` on the TCG
/// scale.
///
/// The value is zero at the TCG instant whose Julian Date is
/// `2451545.0`; at the physical J2000 TT instant it reads about
/// `+0.5058 s` because TCG runs faster than TT.
/// Converts TCG seconds past `JD 2451545.0` on the TCG scale to a TAI
/// epoch.
/// `TCB - TDB` in seconds for a TDB value in seconds past `JD 2451545.0`.
/// Converts a TAI epoch to TCB seconds past `JD 2451545.0` on the TCB
/// scale.
///
/// This uses the IAU Fairhead-Bretagnon TDB model from [`crate::dtdb`],
/// so it matches the IAU/SOFA definition of TCB rather than NAIF `ET`.
/// Converts TCB seconds past `JD 2451545.0` on the TCB scale to a TAI
/// epoch.