Repository navigation
TDB Models
TDB - TT is the periodic term of the general-relativistic transformation
between terrestrial and barycentric coordinate time. There is more than one
published way to evaluate it, and they are not interchangeable. This
crate implements three, on purpose, and keeps them visibly distinct.
| API | Model | Stated accuracy | Intended use |
|---|---|---|---|
convert::tai_to_et / et_to_tai
|
NAIF ET: K*sin(E)
|
about 30 µs (NAIF) | SPICE interoperability |
tdb::tai_to_tdb / tdb_to_tai
|
HEASARC two-term | measured 36.5 µs residual vs ERFA, 1950-2050 | lightweight approximation |
dtdb::tai_to_tdb_iau / tdb_iau_to_tai
|
Fairhead & Bretagnon 787 terms | better than 3 ns, 1950-2050 | IAU/SOFA pipelines, TCB |
The accuracy figures are the published ones (NAIF, ERFA/SOFA) or a residual measured in this repository. They are not interchangeable, and mixing them is a modelling error, not a rounding difference.
TDB - TT = K * sin(E)
E = M + EB * sin(M)
M = M0 + M1 * t
with K, EB, M0, M1 read from DELTET in the LSK (nominals
1.657e-3, 1.671e-2, 6.239996, 1.99096871e-7) and t in TDB seconds
past J2000. tai_to_et solves the implicit dependence by iteration. This is
the model CSPICE uses, so it is the right choice when the reference is a SPICE
product.
The inverse et_to_tai evaluates the same expression directly.
TDB - TT = 0.001658 * sin(g) + 0.000014 * sin(2g)
g = 357.53 deg + 0.9856003 deg * (JD_TT - 2451545.0)
This is the NASA HEASARC ABC of XTE approximation. It is not a
guaranteed improvement over NAIF: a daily 1950-2050 comparison with
geocentric ERFA dtdb has a maximum residual of about 36.5 µs, slightly
worse than the NAIF model's stated 30 µs. It exists because some reference
chains use exactly this formula.
src/dtdb_table.rs contains the 787-term table extracted from ERFA dtdb.c
(pinned commit and SHA-256 recorded in the generated file and in
ATTRIBUTION.md). The geocentric series is
TDB - TT = sum over terms of A_i * sin(f_i * T + p_i) (plus powers of T)
with T in Julian millennia from J2000, followed by the ERFA adjustments
for JPL planetary masses. Groups of terms are multiplied by successive powers
of T; the implementation follows ERFA exactly and is committed so the crate
builds without network access.
Accuracy: the series is stated by the IAU/ERFA to be better than ±3 ns
over 1950-2050 against numerical integrations based on JPL DE405. In this
repository it agrees with ERFA dtdb to 4.6e-18 s over 1218 samples from
1950 to 2050.
The geocentric series is the correct choice for TCB and for comparisons with SOFA-based software. It is not a universal bound for observer corrections or arbitrary ephemerides.
dtdb::dtdb_minus_tt_at_observer adds the ERFA/SOFA diurnal terms:
dtdb_minus_tt_at_observer(jd1, jd2, ut1_fraction, east_longitude_rad, u_km, v_km)?-
jd1 + jd2is a split TT Julian Date. -
ut1_fractionis UT1 time of day in[0, 1), obtained independently. -
east_longitude_radiansis east-positive. -
u_kmis the nonnegative distance from Earth's spin axis;v_kmis the signed distance north of the equatorial plane (cylindrical coordinates, not geodetic latitude and height).
The call rejects non-finite input, a UT1 fraction outside [0, 1), a negative
u_km, and TT dates outside the inclusive interval
JD 2433282.5 to JD 2469807.5 (1950-01-01 to 2050-01-01). That interval is
an explicit library guard around the published comparison range, not a
physical discontinuity.
The observer terms approximate Earth's barycentric velocity projected on the
observer position, divided by c^2. The geocentric DE405 statement does not
bound observer or EOP errors.
Mixing models silently is the failure mode this module prevents. It is a type-level separation, not a convention:
use stkcraft_time::contract::{NaifEt, ScientificContext};
fn query_spice_geometry(_: NaifEt) {}
let scientific = ScientificContext::new().to_tdb(epoch)?; // IauTdb
query_spice_geometry(scientific); // does not compile| Type | Meaning |
|---|---|
NaifEt |
ET from the NAIF LSK model, for SPICE-compatible geometry |
IauTdb |
TDB from an explicitly selected scientific model |
ScientificModel |
GeocentricFairheadBretagnon or ObserverFairheadBretagnon
|
CalculationProfile |
NaifSpice (default) or IauScientific
|
There is deliberately no From<IauTdb> for NaifEt. Converting between the
two requires an explicit decision by the caller, so a 30 µs model cannot be
mistaken for a 3 ns one.
ContractError reports the failure separately from TimeError:
| Variant | Meaning |
|---|---|
Time(TimeError) |
civil time or kernel coverage problem |
Scientific(DtdbError) |
model domain or observer input problem |
NonFinite |
input or evaluated output is not finite |
EpochOutOfRange |
the continuous epoch cannot be represented |
HistoricalUtcRequiresExplicitModel |
pre-1972 UTC needs the SOFA API |
Reference is SPICE (CK, SPK, WebGeocalc, mission products) -> NAIF ET
Reference is ERFA/SOFA, VLBI, pulsar timing, relativity -> IAU DTDB
Reference is a paper using the HEASARC formula -> compact model
When in doubt, state which one was used. In mission planning the difference between 30 µs and 3 ns is far below every other error term; in a reference chain anchored to SOFA it is the difference between agreeing and not.
One IAU DTDB evaluation computes 787 sines. It is exact and intentional, and it is not on any inner loop of this crate.
