Skip to content

Reproducing the Comparisons

stone edited this page Nov 12, 2026 · 3 revisions

Reproducing the comparisons

This page gives the commands and the raw numbers behind the summary on Verification.

Two kinds of checks exist:

  • Offline — committed golden data, no network, part of cargo test.
  • External — needs a live service or a local data file.

Committed reference fixtures

Fixture Cases Reference Assertion
tests/golden/utc_to_et.csv 82 CSPICE 1.1e-12 s
tests/golden/contract_utc.csv 910 CSPICE N0067 STR2ET bit-exact
tests/golden/naif_numbers.csv 800 CSPICE N0067 PRSDP bit-exact
tests/golden/sclk.csv 10 871 CSPICE sct2e / sce2c bit-exact
tests/golden/dtdb_observer.csv 724 pyerfa observer oracle < 2e-17 s
tests/golden/pre_1972.csv 93 ERFA iauDat <= 2 ns
tests/golden/wgc2_kernel_selection.csv 4 epochs × 3 LSKs live WGC2 WGC2 rounding
tests/golden/tcg_tcb.csv, dtdb.csv 950 / 1218 ERFA/SOFA 2.384e-7 s / 4.6e-18 s
tests/reference/kernel-dates/native.tsv 416 CSPICE N0067 FURNSH bit-exact
cargo test

runs all of them; no network access is required.

CSPICE golden vectors (offline)

82 reference vectors generated offline with tools/gen_golden.py and committed as tests/golden/utc_to_et.csv. They cover UTC→ET for ordinary dates and for 23:59:60.x labels (27 of the 82 cases).

cargo test --test spice_golden

Result: maximum UTC→ET difference 1.1e-12 s.

CSPICE is not a build or runtime dependency. The vectors are data, and the test runs anywhere.

python tools/gen_golden.py     # regenerates the CSV; requires CSPICE + SpiceyPy

WebGeocalc API (external)

tools/wgc2_compare.py submits TIME_CONVERSION requests to the live WGC2 REST API, runs cargo run --bin wgc-compare on the same epochs, and compares both against WGC2 and against the golden CSV.

python tools/wgc2_compare.py

A representative run reports:

max WGC2 vs crate difference:        2.847e-07 s
max crate vs CSPICE golden difference: 9.095e-13 s

The first number is WGC2's output rounding: it prints fewer digits. WGC2 is a CSPICE front-end, so the underlying model is identical.

Two epochs from a live request:

UTC WGC2 ET (s) CSPICE / this crate ET (s) Difference
2016-12-31T23:59:60.5 536500868.68393 536500868.6839298 2.0e-7 s
2000-01-01T12:00:00 64.183927 64.18392728473108 2.8e-7 s

Kernel selection (external)

tools/wgc2_kernel_sweep.py selects individual LSKs through the WGC2 kernels parameter ({"type": "KERNEL", "path": "pds/wgc/kernels/lsk/naif0012.tls"}) and converts identical UTC epochs to TDB. Measured 2026-11-10 against WGC2 2.11.2 (build 5520 N67):

UTC naif0012 ET naif0011 ET naif0010 ET
2017-06-01T00:00:00 549547269.184903 549547268.184903 549547267.184903
2015-06-01T00:00:00 486388867.184915 486388867.184915 486388867.184915
2016-12-31T23:59:60.5 536500868.68393 536500868.68393 536500867.68393
2024-01-01T00:00:00 757339269.183906 757339268.183906 757339267.183906

After the 2015-07-01 leap second, naif0011 is one second behind naif0012, and naif0010 two seconds behind: exactly the leap seconds each kernel lacks. This crate reproduces every comparable value.

For 2016-12-31T23:59:60.5 under naif0011/naif0010, WGC2 still returned a number, but those kernels do not declare that leap second. This crate returns InvalidLeapSecond, which is SPICE's documented treatment of a label missing from the kernel. The result is not guessed.

The responses are committed as tests/golden/wgc2_kernel_selection.csv, so the check runs offline after the first capture.

python tools/wgc2_kernel_sweep.py --insecure   # --insecure only if TLS fails

SCLK (offline and external)

tests/sclk_spice.rs replays committed CSPICE references for two real mission kernels, in both directions:

Kernel Clock Forward (sct2e) Inverse (sce2c)
tests/kernels/MRO_SCLKSCET.00120.tsc -74 included included
tests/kernels/juice_step_250412_v01.tsc -28 included included
total 2 719 8 152

Every case compares f64 bit patterns:

cargo test --test sclk_spice

The fixtures include coefficient neighbours and the TDT/ET rounding cases that failed earlier (0.93 ns and 119.21 ns). Bit-exact agreement is agreement with the reference engine, not a physical clock-calibration claim.

tests/golden/naif_numbers.csv separately pins the decimal-token parser to CSPICE PRSDP for 800 tokens, including the JUICE coefficient 4.9260090394032E+13.

The external validator runs the same kernels through CSPICE directly:

python tools/validate_sclk.py \
    --sclk tests/kernels/MRO_SCLKSCET.00120.tsc --id -74

UT1 (external data, local run)

python tools/validate_ut1.py --eop data/finals2000A.all
00:00 UTC fidelity: 20037 days, max |crate - table| = 0.000e+00 s
leap-boundary days detected: 25
  max |leap-aware noon - day start| = 1.676e-03 s
  min |naive noon - day start|      = 4.983e-01 s

The second line is the point: on a leap-boundary day the leap-aware value drifts by the length of day, while naive interpolation is at least 0.498 s wrong.

python tools/validate_ut1_astropy.py

FinalPreferred against astropy's combined IERS column over 1 744 samples: 1.1e-16 s on ordinary days, exact on leap days.

TCG, TCB and IAU TDB (external)

python tools/gen_tcg_tcb_golden.py    # needs astropy and pyerfa
python tools/gen_dtdb_golden.py

Over 950 TAI epochs from 1972 to 2050:

  • TT agrees with ERFA exactly (0 s).
  • TCG agrees to 2.384e-7 s.
  • TCB agrees to 2.384e-7 s.

Both are the f64 spacing of a value near 1.6e9 seconds at 2050.

The IAU DTDB series agrees with ERFA dtdb to 4.6e-18 s over 1218 samples from 1950 to 2050.

TDB model comparison

The three TDB functions are not interchangeable, so their differences are measured rather than asserted:

Model Comparison Result
NAIF ET published accuracy (NAIF) about 30 µs
Compact two-term daily 1950-2050 vs ERFA dtdb max residual about 36.5 µs
IAU DTDB 1218 samples 1950-2050 vs ERFA 4.6e-18 s
printf '2000-01-01T12:00:00\n' | cargo run --release --bin tdb-compare

Kernel date literals (offline)

A text kernel may carry @date literals. The parser is checked against the native N0067 FURNSH/GDPOOL result for every captured input, comparing the binary64 bits directly.

cargo test --test kernel_dates
cargo test --test kernel_date_fractional_exact
cargo test --test kernel_date_grammar_exact

The first test retains the original eleven-literal checkpoint. The second pins the seven fractional-second cases that differed by one ULP before the arithmetic repair. The third compares the 416-input corpus: 345 numeric results and 71 explicit rejections. Original captures, the C oracle source and the toolchain profile are in docs/reference/kernel-date-native/ and docs/reference/kernel-date-grammar-native/. Inputs and native outputs are never adjusted; see the exact grammar scope.

Version consistency (offline)

tests/version_sync.rs fails the build when README.md, docs/API.md, CITATION.cff or the bug report template names a version other than the one in Cargo.toml, and requires install snippets to pin that exact release.

cargo test --test version_sync

Interpreting the numbers

  • e-12 to e-16 agreements mean the two implementations perform the same arithmetic; they are not evidence of physical accuracy.
  • e-7 figures at large magnitudes are f64 spacing.
  • e-5 to e-6 differences between TDB models are real model differences, not bugs.
  • UT1 agreement with a table does not include EOP measurement uncertainty.

Clone this wiki locally