CosmosEphemeris
Positions, velocities and orientations of solar-system bodies and spacecraft. Pure Swift (Foundation, simd,
CryptoKit); no CSPICE, no third-party code. Depends on CosmosCore only (the manifest also lists CosmosMath,
which is not imported).
All numbers in this document were measured on 2026-11-24 by the test suite ([CosmosEphemeris] lines of its
output) against raw JPL Horizons answers stored in Packages/CosmosEphemeris/Tests/Fixtures/horizons/.
swift build --scratch-path .build-eph --target CosmosEphemeris
swift test --scratch-path .build-eph --filter CosmosEphemerisTests # 37 tests, 10 suitesTests that need data look in Resources/Packs/ (path derived from the test file, or COSMOS_PACKS_DIR) and
fail with the command to run when a pack is absent; they are never skipped.
1. Quick start
import CosmosCore
import CosmosEphemeris
let packs = URL(fileURLWithPath: ".../Resources/Packs")
let core = try CoreEphemerisPack(packsRoot: packs) // DE440s + LSK + PCK + GM + osculating elements
let missions = try MissionsPack(packsRoot: packs) // spacecraft trajectories
// High-accuracy planetary ephemeris (status .computed)
let s = try core.planets.state(of: .naif(4), relativeTo: .naif(399), at: instant) // Mars barycentre from Earth, m and m/s, ICRF
let seen = try core.planets.apparentState(of: .naif(4), relativeTo: .naif(399), at: instant, correction: .lightTimeAndStellar)
// Everything, with the source of each answer
let all = try core.composite(adding: [missions.ephemeris])
let r = try all.resolve(of: .naif(606), relativeTo: .naif(399), at: instant) // Titan from Earth
r.status // .estimated: a Keplerian link is involved
r.links // [606→699 kepler-osculating(...), 699→6 planet centre from satellites, 6→0 DE440s, 399→3 DE440s, 3→0 DE440s]
// Orientation and constants
let o = try core.constants.orientation(of: .naif(499), at: instant) // icrfToBody, icrfToBodyRate, pole α/δ, W, ω
let radii = core.constants.radii(of: .naif(499)) // Measured<Vec3d>? in metres (nil when the PCK has none)
let gm = core.constants.gm(of: .naif(499)) // Measured<Double>? in m³/s²2. Public API
| Type | Role |
|---|---|
DAFFile |
NAIF DAF container: file record, summary/name records, both byte orders, structural validation |
SPKEphemeris (EphemerisProvider) |
One or more SPK kernels; types 2 and 3; centre-tree chaining; segments, coverage(of:), nativeCenter(of:at:) |
TextKernel, LeapSecondKernel |
Text-kernel pool; LSK constants and TAI−UTC steps as stated by the kernel |
PlanetaryConstants, BodyConstants, BodyOrientation |
Radii, GM, derived mass/flattening; IAU rotation ICRF → body-fixed and its rate |
ApparentPosition, ApparentState, EphemerisProvider.apparentState(...) |
SPICE LT and LT+S for any provider |
OrbitalElements, KeplerOrbit, KeplerianEphemeris |
Two-body motion, all conics; approximate provider (.estimated, name kepler-osculating…) |
PlanetCenterFromSatellites |
Planet centre relative to its system barycentre from the satellites' two-body orbits (.estimated) |
SampledTrajectory, TrajectorySample, SampledTrajectoryEphemeris |
Tabulated states, format ORIXTRJ v1, cubic Hermite interpolation, gaps |
CompositeEphemeris, ResolvedState |
Priority routing across providers, per-answer list of sources and status |
AnchoredEphemerisProvider |
Optional protocol: a provider states the centre its data refer to, so that the composite can chain it |
CoreEphemerisPack, MissionsPack, OsculatingElementsFile, EphemerisPackManifest |
Pack loaders |
EphemerisFrames |
ICRF → ecliptic J2000 rotation (needed for SPK frame 17 and for validation; general frames belong to CosmosCoordinates) |
Key signatures:
SPKEphemeris(url:name:provenance:) SPKEphemeris(urls:name:provenance:) // later files take precedence
func state(of: ObjectID, relativeTo: ObjectID, at: Instant) throws -> StateVector // every provider
func coverage(of: ObjectID) -> [Coverage]
ApparentPosition.state(of:relativeTo:at:correction:using:inertialOrigin:iterations:) throws -> ApparentState
PlanetaryConstants(pck: URL, gm: URL?) .orientation(of:at:) throws -> BodyOrientation
.radii(of:) / .gm(of:) / .constants(of:)
OrbitalElements(periapsisDistance:eccentricity:inclination:longitudeOfAscendingNode:argumentOfPeriapsis:periapsisTime:gm:)
OrbitalElements(position:velocity:gm:epoch:) .state(at:) throws -> (position, velocity)
SampledTrajectory(url:) / (data:) SampledTrajectory.encode(target:center:label:segments:) throws -> Data
CompositeEphemeris(sources:root:) .resolve(of:relativeTo:at:) throws -> ResolvedState
CoreEphemerisPack(packsRoot:) / (directory:) .planets .constants .leapSeconds .osculating .planetCenters .composite(adding:) .verifyChecksums()
MissionsPack(packsRoot:) / (directory:) .ephemeris .manifest.missions[..].eventsErrors (all CosmosError): outOfCoverage outside any validity interval (never extrapolated), unknownObject,
unsupported (SPK type or frame not implemented, future trajectory format), corruptData (truncated or damaged
files), missingData (absent file, with the fetch command; no orientation model; unrelated centres).
Objects are ObjectIDs: naif:<code> for NAIF codes (spacecraft are negative: naif:-31), and mission:<slug>
for the Apollo stages, which only have Horizons-internal numbers.
3. Formats implemented
3.1 DAF / SPK
- DAF file record (ID word, ND, NI, internal name, FWARD/BWARD/FREE, binary format
LTL-IEEE/BIG-IEEE, FTP validation string), doubly linked summary records, name records. Byte order is read from the format string, or inferred from ND for pre-N0052 files. The file is memory-mapped read-only. - SPK type 2 (Chebyshev position; velocity by differentiating the polynomial) and type 3 (Chebyshev position and velocity), frames 1 (J2000/ICRF) and 17 (ECLIPJ2000).
- Any other type or frame is listed in
segmentswithisSupported == false; a request that needs it throwsunsupported(tested with a type 13 segment). Nothing is ever read with the wrong layout. - Validation at open: record pointers and data addresses inside the file, ND/NI, FTP string, cyclic lists,
directory consistency (
N × RSIZE + 4words, record size compatible with the type, records spanning the declared coverage). A truncatedde440s.bsp(1 KB … 5 MB) is rejected; so are 30 targeted corruptions of a synthetic file. - Segment priority as in SPICE: later file, then later segment. Chains go through the NAIF centre tree to the first common centre (Moon relative to Earth meets at the Earth–Moon barycentre and keeps full precision).
- Not implemented: types 1, 5, 8, 9, 10, 12, 13, 14, 15, 17, 18, 19, 20, 21; the DAF comment area is not parsed; VAX formats are refused.
Every NAIF generic satellite kernel inspected on 2026-11-24 (jup365, sat441, mar099, nep097, nep105, plu060,
ura111xl-799, jup348, sat480) stores its bodies as type 2; only the tiny sat393_daphnis.bsp and one body of
sat480.bsp use type 17. No generic kernel of type 3 was found, so type 3 is validated on synthetic kernels
only (both byte orders, against a direct cos(k·acos s) evaluation: relative error 4e-16).
3.2 Text kernels
\begindata / \begintext sections, scalar and parenthesised vector assignments over several lines, +=,
blank- or comma-separated values, Fortran D exponents, quoted strings with '', @ dates
(@1972-JAN-1, @2000-JAN-01-12:00:00; read as TDB calendar dates, proleptic Gregorian). Malformed input
(unterminated list or string, missing operator/value, unreadable date, name longer than 32 characters) is rejected
with the line number. Not supported: SPICE's other free-form date syntaxes, continuation markers of long strings.
3.3 Sampled trajectory ORIXTRJ version 1
Little-endian, IEEE 754 binary64.
| offset | size | content |
|---|---|---|
| 0 | 8 | magic ORIXTRJ\0 |
| 8 | 4 | format version = 1 |
| 12 | 4 | byte offset of the sample table |
| 16 | 4 | frame code (1 = ICRF) |
| 20 | 4 | number of segments S |
| 24 | 8 | number of samples N |
| 32 / 96 / 160 | 64 / 64 / 96 | target ObjectID, centre ObjectID, label (UTF-8, zero padded) |
| 256 | 16·S | segment table: first sample index, sample count |
| table | 56·N | samples: t (TDB s past J2000), x, y, z (m), vx, vy, vz (m/s) |
Segments are runs of strictly increasing times; between segments there is a gap in which no state is returned. Inside a segment the state is the cubic Hermite interpolant of the two neighbouring samples; the velocity is its derivative. The reader checks magic, version, sizes, the segment table, monotonic times and finiteness of every value.
4. Models
- Body orientation (IAU WGCCRE 2015 as encoded in
pck00011.tpc): α = ΣRA_k T^k + Σa_i sin θ_i, δ = ΣDEC_k T^k + Σd_i cos θ_i, W = ΣPM_k d^k + Σw_i sin θ_i, θ_i = Σθ_ik T^k (quadratic phase angles of the Martian system viaMAX_PHASE_DEGREE), T in Julian centuries and d in days of TDB from J2000 (or fromCONSTANTS_JED_EPOCH), R = R3(W)·R1(π/2 − δ)·R3(π/2 + α). The rate is the analytical time derivative;angularVelocityICRFis extracted from −RᵀṘ. 75 bodies have a model (Sun, planets, Moon, satellites, some asteroids and comets). The Earth model of the PCK is the low-precision IAU one (no nutation, no UT1): use CosmosCoordinates for the real Earth orientation. - Light time (
.lightTime): Newtonian, reception case, exactly SPICELT(geometric light time, then one re-evaluation of the target);iterations: 3gives SPICECN. Velocity = v_target(t − lt)(1 − dlt/dt) − v_observer. - Stellar aberration (
.lightTimeAndStellar): SPICEstelab(Newtonian rotation by asin|û × v/c|) applied to the light-time position; the velocity adds the derivative of the aberration displacement (central difference over ±1 s of the observer's velocity). - Two-body motion: universal-variable Kepler equation measured from periapsis, q χ + e χ³ S(αχ²) = √μ Δt, solved by bracketed Newton iterations (the left side is monotonic, so the root is unique) with Stumpff series near zero; one code path for ellipses, parabolas and hyperbolas. Against an independent bisection solution: relative error ≤ 1e-12 for e from 0 to 12.
- Planet centre from satellites: r_planet − r_barycentre = −Σ(GM_i/GM_system)·r_i over the satellites of
kepler_elements.jsonthat have a GM ingm_de440.tpc. - Composite: for each object the first source (priority order) that lists it and covers the instant answers; sources are chained through their native centres up to the first common one. The status of an answer is the weakest status among its links.
5. Data
5.1 Core pack Resources/Packs/core-ephemeris/ (31 MB)
Built by DataPipeline/ephemeris/fetch_kernels.sh (resumable curl, SHA-256, manifest.json) and
DataPipeline/ephemeris/fetch_elements.py. Retrieved 2026-11-24.
manifest.json follows pack manifest schema v1 (Documentation/modules/CosmosDataPacks.md): kind ephemeris,
files[] with path, size, sha256, url, role (spk, lsk, pck, gm, kepler-elements) and source;
sources[] with one record per file (name, version, URL, retrieval date, licence, citation — the record of
kepler_elements.json is copied from the provenance block of that file); extension keys retrieved,
acknowledgement, redistributionNote. build_core_manifest.py <root> rewrites it offline. redistribution is
localBuildOnly while the pack contains kepler_elements.json: the NAIF rules quoted below permit redistributing the
four unmodified kernels, but no redistribution terms are quoted for Horizons output (owner's decision pending; without
that file the generator writes redistributable).
| File | Bytes | SHA-256 | Source |
|---|---|---|---|
de440s.bsp |
32 726 016 | c1c7feeab882263fc493a9d5a5b2ddd71b54826cdf65d8d17a76126b260a49f2 |
https://naif.jpl.nasa.gov/pub/naif/generic_kernels/spk/planets/de440s.bsp |
naif0012.tls |
5 257 | 678e32bdb5a744117a467cd9601cd6b373f0e9bc9bbde1371d5eee39600a039b |
https://naif.jpl.nasa.gov/pub/naif/generic_kernels/lsk/naif0012.tls |
pck00011.tpc |
131 226 | 3dff7b1dbeceaa01f25467767d3fa25816051c85d162d1edf04acb310ee28bb1 |
https://naif.jpl.nasa.gov/pub/naif/generic_kernels/pck/pck00011.tpc |
gm_de440.tpc |
12 406 | 924ddf4fb9ead9fe8a1aa55780bcabde40b09d00065d58226e24b68d8092f140 |
https://naif.jpl.nasa.gov/pub/naif/generic_kernels/pck/gm_de440.tpc |
kepler_elements.json |
61 115 | eac846977ee2deb7c63d95cf3acbebfc060b8f6fcb206a7cf3810f9a054418cf |
JPL Horizons API, osculating elements (regenerated at each run: the SHA changes) |
DE440s: 14 type 2 segments, bodies 1–10 relative to the SSB, 199/299 relative to 1/2, 301/399 relative to 3; coverage JD 2396752.5 – 2506352.5 TDB (1849-12-26 – 2150-01-22). Reference: Park, Folkner, Williams, Boggs (2021), AJ 161, 105. DE440s has no planet centres for Mars to Pluto (only the barycentres 4–9) and no satellites.
Usage and redistribution terms (NAIF, https://naif.jpl.nasa.gov/naif/rules.html, read 2026-11-24):
"SPICE kernels placed on the NAIF server may be downloaded and used by anyone, consistent with the other rules found on this web page."
"Redistribution of SPICE kernels distributed by NAIF is permitted as long as they have not been modified. If a kernel distributed by NAIF has been modified in any way, any embedded or otherwise allied attribution of the original kernel producer must be replaced with the name and institution of whomever has made the last modification."
"Use of SPICE components in commercial products is allowed […] No fees or licensing are required. Acknowledgement of the use of NASA's SPICE system is encouraged."
The four kernels are shipped byte-for-byte unmodified. The test fixture Tests/Fixtures/spk/mar099s_subset_orixcosmos.bsp
is a modified kernel (24-hour extract); as the rule requires, it has another file name and its internal name says
who made it; it is a test fixture, not part of any pack.
kepler_elements.json: 40 bodies at epoch JD 2461406.5 TDB (2027-01-01), elements referred to ICRF axes, GM =
Horizons' "Keplerian GM", Horizons solution named per body. Satellites about their planet's centre: Phobos, Deimos;
Io, Europa, Ganymede, Callisto; Mimas, Enceladus, Tethys, Dione, Rhea, Titan, Hyperion, Iapetus; Ariel, Umbriel,
Titania, Oberon, Miranda; Triton, Nereid; Charon. Heliocentric: Ceres, Pallas, Vesta, Hygiea, Eros, Apophis, Bennu,
Eris, Haumea, Makemake, Gonggong, Quaoar, Sedna, Orcus, 1P/Halley, 2P/Encke, 67P/Churyumov-Gerasimenko,
C/1995 O1 (Hale-Bopp). Small bodies use the NAIF extended numbering reported by Horizons (naif:20000001 = Ceres;
gm_de440.tpc still names Ceres BODY2000001). The validity interval declared in the file (the DE440s span) only
says when the provider answers; it is not an accuracy claim (see 6.4).
5.2 Missions pack Resources/Packs/missions/ (12 MB)
Built by DataPipeline/ephemeris/fetch_missions.py from the JPL Horizons API (state vectors relative to the solar
system barycentre, ICRF, TDB). These are trajectories reconstructed — and, beyond the last tracking data,
predicted — by the navigation teams; they are not live telemetry. The Horizons data sheet of each object, which
describes the origin of its trajectory, is stored verbatim in sources/<key>.horizons.txt.
Sampling is adaptive: steps of 2880, 240, 20 and 2 minutes; an interval is re-sampled at the next finer step when its estimated cubic-Hermite error exceeds 1 km. Where the trajectory served by Horizons is discontinuous (junction of two trajectory solutions, joints of a patched-conic design trajectory) the finest step cannot resolve it: the 2-minute interval is removed and becomes a gap recorded in the manifest with the size of the jump.
| Mission | ObjectID | Coverage (TDB) | Samples | Bytes | Gaps | Max interpolation error vs Horizons |
|---|---|---|---|---|---|---|
| Voyager 1 | naif:-31 |
1977-09-05 14:00 → 2050-01-01 | 14 460 | 810 048 | 1 | 13.0 m |
| Voyager 2 | naif:-32 |
1977-08-20 15:33 → 2049-12-31 | 15 211 | 852 104 | 1 | 26.1 m |
| Cassini | naif:-82 |
1997-10-15 09:28 → 2017-09-15 11:58 | 99 918 | 5 595 840 | 12 | 382.4 m |
| New Horizons | naif:-98 |
2006-01-19 19:52 → 2050-01-01 | 9 986 | 559 664 | 11 | 1.4 m |
| Parker Solar Probe | naif:-96 |
2018-08-12 08:17 → 2030-01-01 | 42 369 | 2 373 048 | 7 | 277.4 m |
| James Webb Space Telescope | naif:-170 |
2021-12-25 13:02 → 2031-11-16 | 2 282 | 128 064 | 0 | 730.6 m |
| Apollo 8 S-IVB stage | mission:apollo-8-s-ivb |
1968-12-21 16:05 → 1968-12-31 00:05 | 241 | 13 768 | 0 | 112.8 m |
| Apollo 9 S-IVB stage | mission:apollo-9-s-ivb |
1969-03-03 23:39 → 1969-03-11 00:05 | 111 | 6 488 | 0 | 124.9 m |
| Apollo 10 S-IVB stage | mission:apollo-10-s-ivb |
1969-05-18 19:45 → 1969-05-29 00:05 | 220 | 12 592 | 0 | 322.0 m |
| Apollo 10 LM ascent stage "Snoopy" | mission:apollo-10-lm-ascent-stage |
1969-05-23 05:38 → 1969-05-28 00:06 | 100 | 5 872 | 0 | 125.7 m |
| Apollo 11 S-IVB stage | mission:apollo-11-s-ivb |
1969-07-16 16:41 → 1969-07-28 00:05 | 228 | 13 040 | 0 | 299.3 m |
| Apollo 12 S-IVB stage | mission:apollo-12-s-ivb |
1969-11-14 19:33 → 1969-12-06 00:05 | 292 | 16 624 | 0 | 36.2 m |
The last column is the largest difference at 38–60 instants per mission taken between samples (midpoints of up to 30 intervals of the finest step and 30 random intervals); the same figures are recomputed by the Swift test. It measures the interpolation only. The trajectories themselves are much less certain in places — Horizons states that Voyager 1 before 1981 and Voyager 2 before 1989-08-29 are "a patched conic mission-design type trajectory […] providing a rough accuracy".
Gaps (each two minutes long, state unavailable): Voyager 1 1981-01-01 00:00 (64 342 km jump between its two
solutions); Voyager 2 1989-08-29 07:59 (13 931 km); Cassini 1998-05-28, 1999-07-06, 2001-03-07, 2002-04-10
(6 212 km), 2004-03-11, 2004-05-01 (2 883 km), 2004-07-01, 2004-07-17, 2004-09-03 and three consecutive intervals
during atmospheric entry on 2017-09-15 10:34–10:40; New Horizons 2007-01-01 (1 205 km), 2007-01-28, 2007-03-30,
2012-05-01, 2014-11-29, 2014-12-08, 2015-09-27, 2016-02-17, 2019-02-07, 2021-10-01 (4 719 km), 2024-06-05; Parker
Solar Probe 2025-06-25 (79 880 km, junction between the nominal and the fitted trajectory), 2025-10-08, 2026-01-15,
2026-05-26, 2026-09-02, 2026-09-30, 2027-02-17. Most dates coincide with the file junctions listed in the Horizons
data sheets. Exact instants and jump sizes: manifest.json.
What Horizons has for the Apollo era: the S-IVB third stages of Apollo 8, 9, 10, 11 and 12 and the Apollo 10 lunar module ascent stage, each over the few days of its departure (reconstructions by D. R. Adamo, 2012, per the data sheets). Horizons has no trajectory of any crewed Apollo spacecraft (CSM/LM); none is in the pack.
Mission events (manifest.json, events) are copied only when the Horizons data sheet states them (the quote is
checked verbatim by the script) — launches, flybys, Huygens landing, Cassini's atmospheric entry, PSP Venus flybys
and first perihelia, JWST launch and MCC2. One exception: the Voyager 1 data sheet prints its launch as 1977-Sep-06,
which contradicts the trajectory start (1977-Sep-05 13:59 TDB); the date used is the one of NASA's mission page
(https://science.nasa.gov/mission/voyager/voyager-1/, "Launch Date and Time Sept. 5, 1977 / 12:56:01 UT", read by
hand on 2026-11-24). Events not stated by those sources (Cassini's launch day and Saturn orbit insertion, Apollo
mission events other than launches) are left out.
Licence: Horizons output is a work of NASA/JPL (U.S. Government); credit "NASA/JPL-Caltech Solar System Dynamics".
No licence or redistribution text of the source is quoted here, so the manifest says so and marks the pack
redistribution: localBuildOnly (owner's decision pending).
manifest.json follows pack manifest schema v1: kind missions, files[] listing every .trj (role trajectory)
and every sources/*.horizons.txt (role data-sheet), one sources[] record
(jpl-horizons-spacecraft-trajectories), and the extension keys retrieved, source, nature, file_format,
sampling, redistributionNote and missions (the per-mission records read by MissionsPack).
fetch_missions.py --manifest-only rewrites it from the pack on disk without any request.
5.3 Candidates for an optional "detailed solar system" pack
Any type 2/3 SPK dropped next to the core kernel is usable: SPKEphemeris(urls: [de440s, extra…]) (tested with a
real extract of mar099s.bsp). Sizes on https://naif.jpl.nasa.gov/pub/naif/generic_kernels/spk/satellites/ on
2026-11-24 (none downloaded):
| Kernel | Size | Content |
|---|---|---|
mar099s.bsp / mar099.bsp |
64 MB / 1.1 GB | Phobos, Deimos, Mars |
jup365.bsp |
1.1 GB | Galilean moons, Amalthea, Thebe…, Jupiter |
jup347.bsp, jup348.bsp, jup349.bsp |
879 MB, 57 MB, 93 MB | outer irregular satellites of Jupiter |
sat441.bsp |
631 MB | main Saturnian satellites, Saturn |
sat455/456/457/459.bsp, sat415.bsp, sat480.bsp |
278 / 115 / 190 / 80 MB, 595 MB, 12 MB | other Saturnian satellites |
ura111xl-701…705, -799, ura116xl.bsp, ura184_part-1…3.bsp |
414 MB – 2.0 GB each | Uranian satellites, Uranus |
nep097.bsp, nep104.bsp, nep105.bsp, nep098_part-1…3 |
100 MB, 318 MB, 201 MB, 0.8–1.7 GB | Triton, Nereid, others, Neptune |
plu060.bsp |
129 MB | Pluto, Charon, Nix, Hydra, Kerberos, Styx |
A practical pack would be mar099s + plu060 + nep097 (≈ 290 MB) with time-windowed extracts of jup365 and
sat441; DataPipeline/ephemeris/spk_subset.py already extracts a window of chosen bodies through HTTP range
requests without downloading the whole file (the result is a modified kernel and must be labelled as such).
6. Measured accuracy
6.1 DE440s through the reader, against Horizons (DE441), geometric states
10 dates from 1850 to 2150, 25 target/centre/frame combinations (ICRF and ecliptic J2000).
| Quantity | Largest difference |
|---|---|
| Sun and barycentres 1–9 relative to the SSB, Mars/Jupiter barycentre relative to the Sun (ecliptic), EMB from the Mars barycentre | 1.2 mm, 8e-11 m/s (rounding of Horizons' 16 digits) |
| Mercury, Venus | < 0.1 mm |
| Earth (relative to SSB, Sun; Sun, Mars, Jupiter seen from Earth) | 0.20 m, 5.1e-7 m/s |
| Moon relative to Earth | 16.7 m, 4.2e-5 m/s |
The Earth and Moon differences are DE440 versus DE441 (DE441 omits the lunar core–mantle damping term), not the reader: for the Moon relative to the Earth they are 0.0007 m in 1970, 0.33 m in 1950, 0.67 m in 2000, 2.2 m in 2025, 4.4 m in 2050, 5.3 m in 1900, 10.4 m in 2100, 16.3–16.7 m at 1850 and 2150. Test limits: 1 cm / 1e-9 m/s for pairs without the Earth or Moon, 50 m / 5e-4 m/s otherwise.
Real satellite kernel (extract of mar099s.bsp) against Horizons (mar099): Mars–barycentre < 0.01 mm,
Phobos 3.5 cm, Deimos 2.2 cm (mar099s is a reduced refit of mar099); Phobos from Earth across both kernels 0.23 m.
6.2 Apparent positions
| Comparison | Result |
|---|---|
Light time, converged (iterations: 3) vs Horizons LT vectors |
0.13 m for Sun, Mars, Jupiter, Neptune; 10.4 m for the Moon (DE difference); light time within 8e-10 s |
SPICE LT (one iteration, the default) vs Horizons |
up to 1 049 m (Mars), 260 m (Jupiter), 57 m (Neptune): Horizons iterates to convergence |
SPICE LT+S direction vs Horizons LT+S |
≤ 5.2e-4″ (planets); 5.3e-3″ for the Moon (DE difference) |
| Same, as a distance | 0.7 km at Mars, 2.3 km at Jupiter, 11.7 km at Neptune |
| Relativistic aberration formula applied to the module's light-time position vs Horizons | 0.13–0.76 m |
So the kilometre-level differences in LT+S positions are entirely the Newtonian (stelab, what SPICE LT+S is)
versus relativistic (Horizons) aberration formula, ≈ (v/c)²/4 in angle. Horizons' printed velocities are
v_target(t − lt) − v_observer(t) without the light-time-rate and aberration-rate terms; the module's velocities
follow SPICE and are verified as derivatives of the apparent position (central differences, ≤ 2e-4 m/s).
6.3 Orientation, against Horizons observer tables (geocentric, 5 dates 1900–2100)
| Body | Pole (α, δ) | Sub-observer longitude | Sub-observer latitude |
|---|---|---|---|
| Sun, Mercury, Venus, Mars | ≤ 5.0e-6° | ≤ 5.0e-7° | ≤ 4.9e-7° |
| Jupiter, Saturn, Uranus, Neptune | ≤ 5.0e-6° | ≤ 6.6e-5° | ≤ 8.2e-5° |
| Phobos, Io, Titan, Triton | ≤ 4.9e-6° | not compared (no satellite ephemeris in DE440s) | — |
| Moon (IAU model vs Horizons' MOON_ME frame) | 2.1e-3° | 2.2e-3° | 1.7e-3° |
Horizons prints 5 (pole) and 6 (sub-point) decimals; the giant planets are observed at their system barycentre, which costs up to 1e-4°. Two conventions of Horizons had to be reproduced by the test: the planetodetic latitude, and the rotation epoch t − lt + R/c (light leaving the sub-observer surface point, not the centre) — without the latter the longitudes are off by ω·R/c (3.8e-4° for the Sun, 2.4e-3° for Jupiter). The Moon row is not an error of the reader: the PCK's IAU lunar model and the DE-based mean-Earth frame differ by that amount. Limits in the tests: 1e-4° (poles), 2e-4° (sub-points), 0.05° (Moon). The rotation rate is checked against central differences of the matrix (≤ 1e-9 s⁻¹) for 17 bodies.
6.4 Keplerian approximation: error against Horizons away from the epoch (2027-01-01)
Position error of the osculating two-body orbit (relative to its centre):
| Body | epoch | ±1 d | ±10 d | ±100 d | ±1000 d |
|---|---|---|---|---|---|
| Phobos (orbit radius 9 400 km) | 4 mm | 149 km | 1 540 km | 13 800 km (phase lost) | phase lost |
| Io (422 000 km) | 0.5 m | 2 100–2 200 km | 18 500–19 300 km | 182 000–186 000 km | phase lost |
| Europa (671 000 km) | 0.5 m | 270–320 km | 5 800–8 400 km | 47 000–76 000 km | 590 000 km (phase lost) |
| Titan (1 222 000 km) | 0.3 m | 6.9–7.4 km | 720–755 km | 6 100 km | 62 000–63 000 km |
| Triton (355 000 km) | 0.2 m | 4.7–5.1 km | 148–150 km | 1 340 km | 13 600–13 700 km |
| Charon (19 600 km) | 9 mm | 0.5–0.9 m | 66–78 m | 505–515 m | 4.9 km |
| Ceres (heliocentric) | 0.6 m | 1.0 km | 103–105 km | 10 000–11 500 km | 1.1–1.2 million km |
| 1P/Halley (heliocentric, near aphelion) | 3 cm | 0.9 km | 88 km | 8 400 km | 670 000–740 000 km |
"Phase lost" means the error has reached the size of the orbit: the body is still on roughly the right ellipse but
anywhere along it. The inner satellites of Mars, Jupiter and Saturn precess quickly under the planet's oblateness;
their two-body orbit is only usable for hours to days around the epoch. This provider is an explicit
approximation: status .estimated, name kepler-osculating(...), and the composite reports it in every answer
that uses it.
Planet centre relative to the system barycentre, estimated from the satellites (true offset in brackets): Jupiter 0.3 m at epoch, 0.1 km at ±1 d, 0.9–1.4 km at ±10 d, 5.6–8.6 km at ±100 d, 68–75 km at ±1000 d (offset ≈ 100–200 km); Saturn 160 m at epoch, 1.1–1.6 km at ±100 d, 16–17 km at ±1000 d (≈ 290 km); Pluto 4.5–4.8 km at all dates (≈ 2 130 km; the small moons are not counted).
7. Throughput
Release build (swift test -c release), one thread, Apple M5 Max, random instants over 1850–2150, 3 000 000
calls per case. The machine was shared with other builds during the measurements; two runs are given.
| Case | Run 1 | Run 2 |
|---|---|---|
| Mars barycentre relative to SSB (1 segment) | 3.30 M states/s | 2.25 M states/s |
| Moon relative to Earth (2 segments) | 2.14 M states/s | 1.44 M states/s |
| Mars barycentre relative to Earth (3 segments) | 2.39 M states/s | 2.15 M states/s |
| Mars relative to Earth with LT+S | 0.58 M/s | 0.51 M/s |
| IAU orientation of Mars (matrix + rate) | — (before model pre-compilation: 0.43 M/s) | 1.73 M/s |
Debug build: 0.15–0.4 M states/s. SPKEphemeris is immutable after loading and safe to call from any number of
threads (tested with 16 concurrent tasks).
8. Data pipeline
DataPipeline/ephemeris/ — bash and Python 3 standard library only; sequential requests with a one-second delay
and an on-disk cache of raw answers (DataPipeline/raw/ephemeris/, git-ignored); generic User-Agent, no personal data.
| Script | Output |
|---|---|
fetch_kernels.sh |
downloads the four NAIF kernels, assembles the core pack, calls build_core_manifest.py |
build_core_manifest.py |
core-ephemeris/manifest.json, schema v1 (sizes, SHA-256, sources[], licence, redistribution, coverage read from the SPK); offline |
fetch_elements.py |
core-ephemeris/kepler_elements.json + fixtures kep_* |
fetch_missions.py [key…] / --manifest-only |
missions/*.trj, missions/manifest.json, missions/sources/*, fixtures chk_* |
fetch_validation.py |
fixtures vec_*, obs_*, sat_* and index.json (exact query of each fixture) |
spk_subset.py |
time-window extract of a remote SPK via HTTP range requests (test fixture Tests/Fixtures/spk/) |
horizons.py |
shared Horizons client and parsers |
9. Limitations
- SPK types other than 2 and 3 are not read; type 3 is validated on synthetic data only.
- DE440s does not contain the centres of Mars, Jupiter, Saturn, Uranus, Neptune and Pluto, nor any satellite. In the composite they come from the Keplerian approximation (section 6.4) unless a satellite kernel is added.
- SPICE
LT+Sis the Newtonian aberration; it differs from Horizons' relativistic one by ≤ 5.2e-4″. Light bending and the relativistic light-time delay are not modelled. Transmission-case corrections (XLT) are not implemented. - The Earth orientation of the PCK is the low-precision IAU model; the Moon model is the IAU one, 2e-3° from the DE mean-Earth frame. Binary PCKs are not read.
LeapSecondKernelonly exposes whatnaif0012.tlsstates; time-scale conversion belongs to CosmosTime.- Text-kernel dates accept
YYYY-MON-DD[-HH:MM:SS]forms only. - Mission trajectories are JPL reconstructions and predictions sampled with a 1 km interpolation target; coverage ends where stated, and 2-minute gaps exist at the discontinuities of the source. Mission events are limited to those the cited sources state.
kepler_elements.jsonis regenerated from the live Horizons service: elements change when JPL updates an orbit solution.