Skip to content

Kernels

stone edited this page Nov 12, 2026 · 3 revisions

Kernels

Three kinds of data drive this crate. Two are kernel files, one is an IERS product:

Data File Needed for Bundled
Leap seconds KPL/LSK (for example naif0012.tls) every UTC conversion, TT, ET, GPS yes, naif0012.tls
Spacecraft clock KPL/SCLK (mission) SCLK encoding and tick conversion no
Earth orientation IERS finals2000A.all UT1 no

The crate performs no network I/O. Loading is explicit:

let lsk = LeapSecondTable::from_lsk(&std::fs::read_to_string("naif0012.tls")?)?;
let sclk = SclkKernel::parse(&std::fs::read_to_string("mro_sclk.tsc")?, -74)?;
let eop = EopTable::from_finals2000a(&std::fs::read_to_string("finals2000A.all")?)?;

Kernel date literals

A text kernel may write an epoch as EPOCH = @2000-JAN-01-12:00:00. NAIF resolves such a literal with TPARSE into seconds past J2000. It is a bare kernel constant: no UTC, TT or TDB conversion is implied, and no leap-second kernel is consulted, so a pre-1972 literal is an ordinary value rather than HistoricalUtcRequiresExplicitModel.

use stkcraft_time::kernel_date::parse_kernel_date;

let epoch = parse_kernel_date("@2001-FEB-29")?;
assert_eq!(epoch.seconds_past_j2000, 36_676_800.0);
assert_eq!((epoch.year, epoch.month, epoch.day), (2001, 3, 1));
# Ok::<(), stkcraft_time::TimeError>(())

A month name is any prefix of at least three letters, in any case. A day past the end of its month rolls forward (@2001-FEB-29 is 2001-03-01).

Year selection follows N0067 TPARTV token precedence, not an assumed DD-MON-YY reading. An integer token of at least 1000 is a year; a year token in 0..=99 expands over the native 1969--2068 window. So @31-JAN-1987 is 1987-01-31, while @19-JAN-87 is 2019-03-28 (token 19 is the year and token 87 is an out-of-range day). Mixed dash/slash separators, JD-marked Julian dates and the exercised ISO ordinal forms are supported.

Standalone @2000-060, empty literals and free text return KernelDateUnsupported. That error is deliberately separate from LskMissing/SclkMissing: a present literal must never be reported as an absent variable or replaced by a default epoch. Full TPARSE grammar conformance is not claimed; see the exact scope.

LSK DELTET/DELTA_AT dates are stricter: an impossible calendar day makes the kernel invalid (LskParse) instead of rolling forward.

LSK

See Leap seconds and the LSK for the parsed variables, assignment semantics, validation, coverage and policies.

SCLK

A type-1 spacecraft clock kernel supplies:

Variable Meaning
SCLK_DATA_TYPE_ss clock type; only 1 is supported
SCLK01_TIME_SYSTEM_ss 1 = TDB, 2 = TDT (TT); default TDB
SCLK01_N_FIELDS_ss number of fields
SCLK01_MODULI_ss modulus of each field
SCLK01_OFFSETS_ss first displayed value of each field
SCLK01_OUTPUT_DELIM_ss output delimiter code
SCLK01_COEFFICIENTS_ss (ticks, parallel_seconds, rate) triplets
SCLK_PARTITION_START_ss / _END_ss partition bounds

Parsing validates:

  • n_fields matches the lengths of moduli and offsets;
  • coefficients are ordered by increasing ticks and increasing parallel seconds, and every rate is finite and positive;
  • finite values everywhere;
  • partition arrays have equal length and each partition satisfies start <= end.

Cross-partition ordering is not required: a clock may jump ahead or regress, which is exactly why a new partition starts. Partition bounds are parsed but are not applied by any conversion, so rejecting such a kernel would only prevent it from loading.

See Spacecraft clocks for the model and its limits.

EOP

finals2000A.all is a fixed-column format, not whitespace-delimited. When month and day have two digits, year, month and day run together: the row beginning 73 110 is 1973-01-10. Splitting on whitespace shifts every later column and silently reads a different quantity.

Columns read (1-based):

Field Columns
Year 1-2
Month 3-4
Day 5-6
MJD 7-15
Flag (I observed, P predicted) 58
UT1 - UTC (Bulletin A) 59-68
UT1 - UTC (Bulletin B) 156-165

Rows with a blank UT1 - UTC column are skipped: the IERS formatter appends placeholder rows for dates that have no measurement.

Three series can be selected:

EopSeries Source
BulletinA rapid service and predictions, columns 59-68
BulletinB final solution, columns 156-165
FinalPreferred Bulletin B where present, else Bulletin A; reproduces astropy's combined column

EopTable::observed_only() drops predicted samples when predictions are inappropriate for the analysis.

Parsing rejects non-finite MJD or UT1 - UTC values (EopParse), sorts by MJD, and removes duplicate samples.

No EOP file is bundled. Fetch it at deployment time:

python tools/fetch_eop.py --out data/finals2000A.all
# or point at a mirror:
python tools/fetch_eop.py --out data/finals2000A.all --url MIRROR_URL

The script accepts --url or STKCRAFT_EOP_URL; tools/validate_ut1.py accepts the same options. Downloaded bytes are written verbatim, so the file matches the upstream product.

See UT1 and EOP for the interpolation model.

Kernel selection is explicit

The crate never infers a convention from a date or a filename. Selecting an older LSK changes results by exactly the leap seconds it lacks; this is demonstrated in Verification with three kernels and the same UTC input.

Clone this wiki locally