Repository Public
1<!--2ORIX Cosmos3File: Documentation/modules/CosmosEphemeris.md4Description: Reference of the CosmosEphemeris module: file formats implemented, models, data files with source, licence and SHA-256, measured accuracy and throughput, limitations.5Author: Simon-Pierre Boucher6Contact: contact@spboucher.ai7-->8# CosmosEphemeris910Positions, velocities and orientations of solar-system bodies and spacecraft. Pure Swift (Foundation, simd,11CryptoKit); no CSPICE, no third-party code. Depends on `CosmosCore` only (the manifest also lists `CosmosMath`,12which is not imported).1314All numbers in this document were measured on 2026-11-24 by the test suite (`[CosmosEphemeris]` lines of its15output) against raw JPL Horizons answers stored in `Packages/CosmosEphemeris/Tests/Fixtures/horizons/`.1617```18swift build --scratch-path .build-eph --target CosmosEphemeris19swift test --scratch-path .build-eph --filter CosmosEphemerisTests # 37 tests, 10 suites20```2122Tests that need data look in `Resources/Packs/` (path derived from the test file, or `COSMOS_PACKS_DIR`) and23**fail** with the command to run when a pack is absent; they are never skipped.2425## 1. Quick start2627```swift28import CosmosCore29import CosmosEphemeris3031let packs = URL(fileURLWithPath: ".../Resources/Packs")32let core = try CoreEphemerisPack(packsRoot: packs) // DE440s + LSK + PCK + GM + osculating elements33let missions = try MissionsPack(packsRoot: packs) // spacecraft trajectories3435// High-accuracy planetary ephemeris (status .computed)36let s = try core.planets.state(of: .naif(4), relativeTo: .naif(399), at: instant) // Mars barycentre from Earth, m and m/s, ICRF37let seen = try core.planets.apparentState(of: .naif(4), relativeTo: .naif(399), at: instant, correction: .lightTimeAndStellar)3839// Everything, with the source of each answer40let all = try core.composite(adding: [missions.ephemeris])41let r = try all.resolve(of: .naif(606), relativeTo: .naif(399), at: instant) // Titan from Earth42r.status // .estimated: a Keplerian link is involved43r.links // [606→699 kepler-osculating(...), 699→6 planet centre from satellites, 6→0 DE440s, 399→3 DE440s, 3→0 DE440s]4445// Orientation and constants46let o = try core.constants.orientation(of: .naif(499), at: instant) // icrfToBody, icrfToBodyRate, pole α/δ, W, ω47let radii = core.constants.radii(of: .naif(499)) // Measured<Vec3d>? in metres (nil when the PCK has none)48let gm = core.constants.gm(of: .naif(499)) // Measured<Double>? in m³/s²49```5051## 2. Public API5253| Type | Role |54|---|---|55| `DAFFile` | NAIF DAF container: file record, summary/name records, both byte orders, structural validation |56| `SPKEphemeris` (`EphemerisProvider`) | One or more SPK kernels; types 2 and 3; centre-tree chaining; `segments`, `coverage(of:)`, `nativeCenter(of:at:)` |57| `TextKernel`, `LeapSecondKernel` | Text-kernel pool; LSK constants and TAI−UTC steps as stated by the kernel |58| `PlanetaryConstants`, `BodyConstants`, `BodyOrientation` | Radii, GM, derived mass/flattening; IAU rotation ICRF → body-fixed and its rate |59| `ApparentPosition`, `ApparentState`, `EphemerisProvider.apparentState(...)` | SPICE `LT` and `LT+S` for any provider |60| `OrbitalElements`, `KeplerOrbit`, `KeplerianEphemeris` | Two-body motion, all conics; approximate provider (`.estimated`, name `kepler-osculating…`) |61| `PlanetCenterFromSatellites` | Planet centre relative to its system barycentre from the satellites' two-body orbits (`.estimated`) |62| `SampledTrajectory`, `TrajectorySample`, `SampledTrajectoryEphemeris` | Tabulated states, format ORIXTRJ v1, cubic Hermite interpolation, gaps |63| `CompositeEphemeris`, `ResolvedState` | Priority routing across providers, per-answer list of sources and status |64| `AnchoredEphemerisProvider` | Optional protocol: a provider states the centre its data refer to, so that the composite can chain it |65| `CoreEphemerisPack`, `MissionsPack`, `OsculatingElementsFile`, `EphemerisPackManifest` | Pack loaders |66| `EphemerisFrames` | ICRF → ecliptic J2000 rotation (needed for SPK frame 17 and for validation; general frames belong to CosmosCoordinates) |6768Key signatures:6970```swift71SPKEphemeris(url:name:provenance:) SPKEphemeris(urls:name:provenance:) // later files take precedence72func state(of: ObjectID, relativeTo: ObjectID, at: Instant) throws -> StateVector // every provider73func coverage(of: ObjectID) -> [Coverage]74ApparentPosition.state(of:relativeTo:at:correction:using:inertialOrigin:iterations:) throws -> ApparentState75PlanetaryConstants(pck: URL, gm: URL?) .orientation(of:at:) throws -> BodyOrientation76 .radii(of:) / .gm(of:) / .constants(of:)77OrbitalElements(periapsisDistance:eccentricity:inclination:longitudeOfAscendingNode:argumentOfPeriapsis:periapsisTime:gm:)78OrbitalElements(position:velocity:gm:epoch:) .state(at:) throws -> (position, velocity)79SampledTrajectory(url:) / (data:) SampledTrajectory.encode(target:center:label:segments:) throws -> Data80CompositeEphemeris(sources:root:) .resolve(of:relativeTo:at:) throws -> ResolvedState81CoreEphemerisPack(packsRoot:) / (directory:) .planets .constants .leapSeconds .osculating .planetCenters .composite(adding:) .verifyChecksums()82MissionsPack(packsRoot:) / (directory:) .ephemeris .manifest.missions[..].events83```8485Errors (all `CosmosError`): `outOfCoverage` outside any validity interval (never extrapolated), `unknownObject`,86`unsupported` (SPK type or frame not implemented, future trajectory format), `corruptData` (truncated or damaged87files), `missingData` (absent file, with the fetch command; no orientation model; unrelated centres).8889Objects are `ObjectID`s: `naif:<code>` for NAIF codes (spacecraft are negative: `naif:-31`), and `mission:<slug>`90for the Apollo stages, which only have Horizons-internal numbers.9192## 3. Formats implemented9394### 3.1 DAF / SPK9596- DAF file record (ID word, ND, NI, internal name, FWARD/BWARD/FREE, binary format `LTL-IEEE` / `BIG-IEEE`, FTP97 validation string), doubly linked summary records, name records. Byte order is read from the format string, or98 inferred from ND for pre-N0052 files. The file is memory-mapped read-only.99- **SPK type 2** (Chebyshev position; velocity by differentiating the polynomial) and **type 3** (Chebyshev100 position and velocity), frames **1 (J2000/ICRF)** and **17 (ECLIPJ2000)**.101- Any other type or frame is listed in `segments` with `isSupported == false`; a request that needs it throws102 `unsupported` (tested with a type 13 segment). Nothing is ever read with the wrong layout.103- Validation at open: record pointers and data addresses inside the file, ND/NI, FTP string, cyclic lists,104 directory consistency (`N × RSIZE + 4` words, record size compatible with the type, records spanning the declared105 coverage). A truncated `de440s.bsp` (1 KB … 5 MB) is rejected; so are 30 targeted corruptions of a synthetic file.106- Segment priority as in SPICE: later file, then later segment. Chains go through the NAIF centre tree to the107 first common centre (Moon relative to Earth meets at the Earth–Moon barycentre and keeps full precision).108- Not implemented: types 1, 5, 8, 9, 10, 12, 13, 14, 15, 17, 18, 19, 20, 21; the DAF comment area is not parsed;109 VAX formats are refused.110111Every NAIF generic satellite kernel inspected on 2026-11-24 (jup365, sat441, mar099, nep097, nep105, plu060,112ura111xl-799, jup348, sat480) stores its bodies as **type 2**; only the tiny `sat393_daphnis.bsp` and one body of113`sat480.bsp` use type 17. No generic kernel of type 3 was found, so **type 3 is validated on synthetic kernels114only** (both byte orders, against a direct `cos(k·acos s)` evaluation: relative error 4e-16).115116### 3.2 Text kernels117118`\begindata` / `\begintext` sections, scalar and parenthesised vector assignments over several lines, `+=`,119blank- or comma-separated values, Fortran `D` exponents, quoted strings with `''`, `@` dates120(`@1972-JAN-1`, `@2000-JAN-01-12:00:00`; read as TDB calendar dates, proleptic Gregorian). Malformed input121(unterminated list or string, missing operator/value, unreadable date, name longer than 32 characters) is rejected122with the line number. Not supported: SPICE's other free-form date syntaxes, continuation markers of long strings.123124### 3.3 Sampled trajectory `ORIXTRJ` version 1125126Little-endian, IEEE 754 binary64.127128| offset | size | content |129|---|---|---|130| 0 | 8 | magic `ORIXTRJ\0` |131| 8 | 4 | format version = 1 |132| 12 | 4 | byte offset of the sample table |133| 16 | 4 | frame code (1 = ICRF) |134| 20 | 4 | number of segments S |135| 24 | 8 | number of samples N |136| 32 / 96 / 160 | 64 / 64 / 96 | target `ObjectID`, centre `ObjectID`, label (UTF-8, zero padded) |137| 256 | 16·S | segment table: first sample index, sample count |138| table | 56·N | samples: t (TDB s past J2000), x, y, z (m), vx, vy, vz (m/s) |139140Segments are runs of strictly increasing times; between segments there is a gap in which no state is returned.141Inside a segment the state is the cubic Hermite interpolant of the two neighbouring samples; the velocity is its142derivative. The reader checks magic, version, sizes, the segment table, monotonic times and finiteness of every value.143144## 4. Models145146- **Body orientation** (IAU WGCCRE 2015 as encoded in `pck00011.tpc`):147 α = Σ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^k148 (quadratic phase angles of the Martian system via `MAX_PHASE_DEGREE`), T in Julian centuries and d in days of TDB149 from J2000 (or from `CONSTANTS_JED_EPOCH`), R = R3(W)·R1(π/2 − δ)·R3(π/2 + α). The rate is the analytical time150 derivative; `angularVelocityICRF` is extracted from −RᵀṘ. 75 bodies have a model (Sun, planets, Moon, satellites,151 some asteroids and comets). The Earth model of the PCK is the low-precision IAU one (no nutation, no UT1): use152 CosmosCoordinates for the real Earth orientation.153- **Light time** (`.lightTime`): Newtonian, reception case, exactly SPICE `LT` (geometric light time, then one154 re-evaluation of the target); `iterations: 3` gives SPICE `CN`. Velocity = v_target(t − lt)(1 − dlt/dt) − v_observer.155- **Stellar aberration** (`.lightTimeAndStellar`): SPICE `stelab` (Newtonian rotation by asin|û × v/c|) applied156 to the light-time position; the velocity adds the derivative of the aberration displacement (central difference157 over ±1 s of the observer's velocity).158- **Two-body motion**: universal-variable Kepler equation measured from periapsis, q χ + e χ³ S(αχ²) = √μ Δt,159 solved by bracketed Newton iterations (the left side is monotonic, so the root is unique) with Stumpff series160 near zero; one code path for ellipses, parabolas and hyperbolas. Against an independent bisection solution:161 relative error ≤ 1e-12 for e from 0 to 12.162- **Planet centre from satellites**: r_planet − r_barycentre = −Σ(GM_i/GM_system)·r_i over the satellites of163 `kepler_elements.json` that have a GM in `gm_de440.tpc`.164- **Composite**: for each object the first source (priority order) that lists it and covers the instant answers;165 sources are chained through their native centres up to the first common one. The status of an answer is the166 weakest status among its links.167168## 5. Data169170### 5.1 Core pack `Resources/Packs/core-ephemeris/` (31 MB)171172Built by `DataPipeline/ephemeris/fetch_kernels.sh` (resumable curl, SHA-256, `manifest.json`) and173`DataPipeline/ephemeris/fetch_elements.py`. Retrieved 2026-11-24.174175`manifest.json` follows pack manifest schema v1 (`Documentation/modules/CosmosDataPacks.md`): `kind` `ephemeris`,176`files[]` with `path`, `size`, `sha256`, `url`, `role` (`spk`, `lsk`, `pck`, `gm`, `kepler-elements`) and `source`;177`sources[]` with one record per file (name, version, URL, retrieval date, licence, citation — the record of178`kepler_elements.json` is copied from the provenance block of that file); extension keys `retrieved`,179`acknowledgement`, `redistributionNote`. `build_core_manifest.py <root>` rewrites it offline. `redistribution` is180`localBuildOnly` while the pack contains `kepler_elements.json`: the NAIF rules quoted below permit redistributing the181four unmodified kernels, but no redistribution terms are quoted for Horizons output (owner's decision pending; without182that file the generator writes `redistributable`).183184| File | Bytes | SHA-256 | Source |185|---|---|---|---|186| `de440s.bsp` | 32 726 016 | `c1c7feeab882263fc493a9d5a5b2ddd71b54826cdf65d8d17a76126b260a49f2` | https://naif.jpl.nasa.gov/pub/naif/generic_kernels/spk/planets/de440s.bsp |187| `naif0012.tls` | 5 257 | `678e32bdb5a744117a467cd9601cd6b373f0e9bc9bbde1371d5eee39600a039b` | https://naif.jpl.nasa.gov/pub/naif/generic_kernels/lsk/naif0012.tls |188| `pck00011.tpc` | 131 226 | `3dff7b1dbeceaa01f25467767d3fa25816051c85d162d1edf04acb310ee28bb1` | https://naif.jpl.nasa.gov/pub/naif/generic_kernels/pck/pck00011.tpc |189| `gm_de440.tpc` | 12 406 | `924ddf4fb9ead9fe8a1aa55780bcabde40b09d00065d58226e24b68d8092f140` | https://naif.jpl.nasa.gov/pub/naif/generic_kernels/pck/gm_de440.tpc |190| `kepler_elements.json` | 61 115 | `eac846977ee2deb7c63d95cf3acbebfc060b8f6fcb206a7cf3810f9a054418cf` | JPL Horizons API, osculating elements (regenerated at each run: the SHA changes) |191192DE440s: 14 type 2 segments, bodies 1–10 relative to the SSB, 199/299 relative to 1/2, 301/399 relative to 3;193coverage JD 2396752.5 – 2506352.5 TDB (1849-12-26 – 2150-01-22). Reference: Park, Folkner, Williams, Boggs (2021),194AJ 161, 105. DE440s has **no planet centres for Mars to Pluto** (only the barycentres 4–9) and no satellites.195196**Usage and redistribution terms** (NAIF, https://naif.jpl.nasa.gov/naif/rules.html, read 2026-11-24):197198> "SPICE kernels placed on the NAIF server may be downloaded and used by anyone, consistent with the other rules found on this web page."199>200> "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."201>202> "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."203204The four kernels are shipped byte-for-byte unmodified. The test fixture `Tests/Fixtures/spk/mar099s_subset_orixcosmos.bsp`205is a *modified* kernel (24-hour extract); as the rule requires, it has another file name and its internal name says206who made it; it is a test fixture, not part of any pack.207208`kepler_elements.json`: 40 bodies at epoch JD 2461406.5 TDB (2027-01-01), elements referred to ICRF axes, GM =209Horizons' "Keplerian GM", Horizons solution named per body. Satellites about their planet's centre: Phobos, Deimos;210Io, Europa, Ganymede, Callisto; Mimas, Enceladus, Tethys, Dione, Rhea, Titan, Hyperion, Iapetus; Ariel, Umbriel,211Titania, Oberon, Miranda; Triton, Nereid; Charon. Heliocentric: Ceres, Pallas, Vesta, Hygiea, Eros, Apophis, Bennu,212Eris, Haumea, Makemake, Gonggong, Quaoar, Sedna, Orcus, 1P/Halley, 2P/Encke, 67P/Churyumov-Gerasimenko,213C/1995 O1 (Hale-Bopp). Small bodies use the NAIF extended numbering reported by Horizons (`naif:20000001` = Ceres;214`gm_de440.tpc` still names Ceres `BODY2000001`). The validity interval declared in the file (the DE440s span) only215says when the provider answers; it is not an accuracy claim (see 6.4).216217### 5.2 Missions pack `Resources/Packs/missions/` (12 MB)218219Built by `DataPipeline/ephemeris/fetch_missions.py` from the JPL Horizons API (state vectors relative to the solar220system barycentre, ICRF, TDB). These are trajectories **reconstructed — and, beyond the last tracking data,221predicted — by the navigation teams; they are not live telemetry.** The Horizons data sheet of each object, which222describes the origin of its trajectory, is stored verbatim in `sources/<key>.horizons.txt`.223224Sampling is adaptive: steps of 2880, 240, 20 and 2 minutes; an interval is re-sampled at the next finer step when225its estimated cubic-Hermite error exceeds 1 km. Where the trajectory served by Horizons is discontinuous (junction226of two trajectory solutions, joints of a patched-conic design trajectory) the finest step cannot resolve it: the2272-minute interval is removed and becomes a **gap** recorded in the manifest with the size of the jump.228229| Mission | ObjectID | Coverage (TDB) | Samples | Bytes | Gaps | Max interpolation error vs Horizons |230|---|---|---|---|---|---|---|231| Voyager 1 | `naif:-31` | 1977-09-05 14:00 → 2050-01-01 | 14 460 | 810 048 | 1 | 13.0 m |232| Voyager 2 | `naif:-32` | 1977-08-20 15:33 → 2049-12-31 | 15 211 | 852 104 | 1 | 26.1 m |233| Cassini | `naif:-82` | 1997-10-15 09:28 → 2017-09-15 11:58 | 99 918 | 5 595 840 | 12 | 382.4 m |234| New Horizons | `naif:-98` | 2006-01-19 19:52 → 2050-01-01 | 9 986 | 559 664 | 11 | 1.4 m |235| Parker Solar Probe | `naif:-96` | 2018-08-12 08:17 → 2030-01-01 | 42 369 | 2 373 048 | 7 | 277.4 m |236| James Webb Space Telescope | `naif:-170` | 2021-12-25 13:02 → 2031-11-16 | 2 282 | 128 064 | 0 | 730.6 m |237| 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 |238| 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 |239| 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 |240| 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 |241| 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 |242| 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 |243244The last column is the largest difference at 38–60 instants per mission taken *between* samples (midpoints of up245to 30 intervals of the finest step and 30 random intervals); the same figures are recomputed by the Swift test.246It measures the interpolation only. The trajectories themselves are much less certain in places — Horizons states247that Voyager 1 before 1981 and Voyager 2 before 1989-08-29 are "a patched conic mission-design type trajectory248[…] providing a rough accuracy".249250Gaps (each two minutes long, state unavailable): Voyager 1 1981-01-01 00:00 (64 342 km jump between its two251solutions); Voyager 2 1989-08-29 07:59 (13 931 km); Cassini 1998-05-28, 1999-07-06, 2001-03-07, 2002-04-10252(6 212 km), 2004-03-11, 2004-05-01 (2 883 km), 2004-07-01, 2004-07-17, 2004-09-03 and three consecutive intervals253during atmospheric entry on 2017-09-15 10:34–10:40; New Horizons 2007-01-01 (1 205 km), 2007-01-28, 2007-03-30,2542012-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; Parker255Solar Probe 2025-06-25 (79 880 km, junction between the nominal and the fitted trajectory), 2025-10-08, 2026-01-15,2562026-05-26, 2026-09-02, 2026-09-30, 2027-02-17. Most dates coincide with the file junctions listed in the Horizons257data sheets. Exact instants and jump sizes: `manifest.json`.258259What Horizons has for the Apollo era: the S-IVB third stages of Apollo 8, 9, 10, 11 and 12 and the Apollo 10 lunar260module ascent stage, each over the few days of its departure (reconstructions by D. R. Adamo, 2012, per the data261sheets). **Horizons has no trajectory of any crewed Apollo spacecraft (CSM/LM)**; none is in the pack.262263Mission events (`manifest.json`, `events`) are copied only when the Horizons data sheet states them (the quote is264checked verbatim by the script) — launches, flybys, Huygens landing, Cassini's atmospheric entry, PSP Venus flybys265and first perihelia, JWST launch and MCC2. One exception: the Voyager 1 data sheet prints its launch as 1977-Sep-06,266which contradicts the trajectory start (1977-Sep-05 13:59 TDB); the date used is the one of NASA's mission page267(https://science.nasa.gov/mission/voyager/voyager-1/, "Launch Date and Time Sept. 5, 1977 / 12:56:01 UT", read by268hand on 2026-11-24). Events not stated by those sources (Cassini's launch day and Saturn orbit insertion, Apollo269mission events other than launches) are left out.270271Licence: Horizons output is a work of NASA/JPL (U.S. Government); credit "NASA/JPL-Caltech Solar System Dynamics".272No licence or redistribution text of the source is quoted here, so the manifest says so and marks the pack273`redistribution: localBuildOnly` (owner's decision pending).274275`manifest.json` follows pack manifest schema v1: `kind` `missions`, `files[]` listing every `.trj` (role `trajectory`)276and every `sources/*.horizons.txt` (role `data-sheet`), one `sources[]` record277(`jpl-horizons-spacecraft-trajectories`), and the extension keys `retrieved`, `source`, `nature`, `file_format`,278`sampling`, `redistributionNote` and `missions` (the per-mission records read by `MissionsPack`).279`fetch_missions.py --manifest-only` rewrites it from the pack on disk without any request.280281### 5.3 Candidates for an optional "detailed solar system" pack282283Any type 2/3 SPK dropped next to the core kernel is usable: `SPKEphemeris(urls: [de440s, extra…])` (tested with a284real extract of `mar099s.bsp`). Sizes on https://naif.jpl.nasa.gov/pub/naif/generic_kernels/spk/satellites/ on2852026-11-24 (none downloaded):286287| Kernel | Size | Content |288|---|---|---|289| `mar099s.bsp` / `mar099.bsp` | 64 MB / 1.1 GB | Phobos, Deimos, Mars |290| `jup365.bsp` | 1.1 GB | Galilean moons, Amalthea, Thebe…, Jupiter |291| `jup347.bsp`, `jup348.bsp`, `jup349.bsp` | 879 MB, 57 MB, 93 MB | outer irregular satellites of Jupiter |292| `sat441.bsp` | 631 MB | main Saturnian satellites, Saturn |293| `sat455/456/457/459.bsp`, `sat415.bsp`, `sat480.bsp` | 278 / 115 / 190 / 80 MB, 595 MB, 12 MB | other Saturnian satellites |294| `ura111xl-701…705, -799`, `ura116xl.bsp`, `ura184_part-1…3.bsp` | 414 MB – 2.0 GB each | Uranian satellites, Uranus |295| `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 |296| `plu060.bsp` | 129 MB | Pluto, Charon, Nix, Hydra, Kerberos, Styx |297298A practical pack would be `mar099s` + `plu060` + `nep097` (≈ 290 MB) with time-windowed extracts of `jup365` and299`sat441`; `DataPipeline/ephemeris/spk_subset.py` already extracts a window of chosen bodies through HTTP range300requests without downloading the whole file (the result is a modified kernel and must be labelled as such).301302## 6. Measured accuracy303304### 6.1 DE440s through the reader, against Horizons (DE441), geometric states30530610 dates from 1850 to 2150, 25 target/centre/frame combinations (ICRF and ecliptic J2000).307308| Quantity | Largest difference |309|---|---|310| 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) |311| Mercury, Venus | < 0.1 mm |312| Earth (relative to SSB, Sun; Sun, Mars, Jupiter seen from Earth) | 0.20 m, 5.1e-7 m/s |313| Moon relative to Earth | 16.7 m, 4.2e-5 m/s |314315The Earth and Moon differences are DE440 versus DE441 (DE441 omits the lunar core–mantle damping term), not the316reader: 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 in3172025, 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 for318pairs without the Earth or Moon, 50 m / 5e-4 m/s otherwise.319320Real satellite kernel (extract of `mar099s.bsp`) against Horizons (`mar099`): Mars–barycentre < 0.01 mm,321Phobos 3.5 cm, Deimos 2.2 cm (mar099s is a reduced refit of mar099); Phobos from Earth across both kernels 0.23 m.322323### 6.2 Apparent positions324325| Comparison | Result |326|---|---|327| 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 |328| SPICE `LT` (one iteration, the default) vs Horizons | up to 1 049 m (Mars), 260 m (Jupiter), 57 m (Neptune): Horizons iterates to convergence |329| SPICE `LT+S` direction vs Horizons LT+S | ≤ 5.2e-4″ (planets); 5.3e-3″ for the Moon (DE difference) |330| Same, as a distance | 0.7 km at Mars, 2.3 km at Jupiter, 11.7 km at Neptune |331| Relativistic aberration formula applied to the module's light-time position vs Horizons | 0.13–0.76 m |332333So the kilometre-level differences in LT+S positions are entirely the Newtonian (`stelab`, what SPICE `LT+S` is)334versus relativistic (Horizons) aberration formula, ≈ (v/c)²/4 in angle. Horizons' printed velocities are335v_target(t − lt) − v_observer(t) without the light-time-rate and aberration-rate terms; the module's velocities336follow SPICE and are verified as derivatives of the apparent position (central differences, ≤ 2e-4 m/s).337338### 6.3 Orientation, against Horizons observer tables (geocentric, 5 dates 1900–2100)339340| Body | Pole (α, δ) | Sub-observer longitude | Sub-observer latitude |341|---|---|---|---|342| Sun, Mercury, Venus, Mars | ≤ 5.0e-6° | ≤ 5.0e-7° | ≤ 4.9e-7° |343| Jupiter, Saturn, Uranus, Neptune | ≤ 5.0e-6° | ≤ 6.6e-5° | ≤ 8.2e-5° |344| Phobos, Io, Titan, Triton | ≤ 4.9e-6° | not compared (no satellite ephemeris in DE440s) | — |345| Moon (IAU model vs Horizons' MOON_ME frame) | 2.1e-3° | 2.2e-3° | 1.7e-3° |346347Horizons prints 5 (pole) and 6 (sub-point) decimals; the giant planets are observed at their system barycentre,348which costs up to 1e-4°. Two conventions of Horizons had to be reproduced by the test: the planetodetic latitude,349and the rotation epoch t − lt + R/c (light leaving the sub-observer surface point, not the centre) — without the350latter the longitudes are off by ω·R/c (3.8e-4° for the Sun, 2.4e-3° for Jupiter). The Moon row is not an error351of the reader: the PCK's IAU lunar model and the DE-based mean-Earth frame differ by that amount. Limits in the352tests: 1e-4° (poles), 2e-4° (sub-points), 0.05° (Moon). The rotation rate is checked against central differences353of the matrix (≤ 1e-9 s⁻¹) for 17 bodies.354355### 6.4 Keplerian approximation: error against Horizons away from the epoch (2027-01-01)356357Position error of the osculating two-body orbit (relative to its centre):358359| Body | epoch | ±1 d | ±10 d | ±100 d | ±1000 d |360|---|---|---|---|---|---|361| Phobos (orbit radius 9 400 km) | 4 mm | 149 km | 1 540 km | 13 800 km (phase lost) | phase lost |362| Io (422 000 km) | 0.5 m | 2 100–2 200 km | 18 500–19 300 km | 182 000–186 000 km | phase lost |363| 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) |364| Titan (1 222 000 km) | 0.3 m | 6.9–7.4 km | 720–755 km | 6 100 km | 62 000–63 000 km |365| Triton (355 000 km) | 0.2 m | 4.7–5.1 km | 148–150 km | 1 340 km | 13 600–13 700 km |366| Charon (19 600 km) | 9 mm | 0.5–0.9 m | 66–78 m | 505–515 m | 4.9 km |367| Ceres (heliocentric) | 0.6 m | 1.0 km | 103–105 km | 10 000–11 500 km | 1.1–1.2 million km |368| 1P/Halley (heliocentric, near aphelion) | 3 cm | 0.9 km | 88 km | 8 400 km | 670 000–740 000 km |369370"Phase lost" means the error has reached the size of the orbit: the body is still on roughly the right ellipse but371anywhere along it. The inner satellites of Mars, Jupiter and Saturn precess quickly under the planet's oblateness;372their two-body orbit is only usable for hours to days around the epoch. This provider is an explicit373approximation: status `.estimated`, name `kepler-osculating(...)`, and the composite reports it in every answer374that uses it.375376Planet centre relative to the system barycentre, estimated from the satellites (true offset in brackets):377Jupiter 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 (offset378≈ 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 at379all dates (≈ 2 130 km; the small moons are not counted).380381## 7. Throughput382383Release build (`swift test -c release`), one thread, Apple M5 Max, random instants over 1850–2150, 3 000 000384calls per case. The machine was shared with other builds during the measurements; two runs are given.385386| Case | Run 1 | Run 2 |387|---|---|---|388| Mars barycentre relative to SSB (1 segment) | 3.30 M states/s | 2.25 M states/s |389| Moon relative to Earth (2 segments) | 2.14 M states/s | 1.44 M states/s |390| Mars barycentre relative to Earth (3 segments) | 2.39 M states/s | 2.15 M states/s |391| Mars relative to Earth with LT+S | 0.58 M/s | 0.51 M/s |392| IAU orientation of Mars (matrix + rate) | — (before model pre-compilation: 0.43 M/s) | 1.73 M/s |393394Debug build: 0.15–0.4 M states/s. `SPKEphemeris` is immutable after loading and safe to call from any number of395threads (tested with 16 concurrent tasks).396397## 8. Data pipeline398399`DataPipeline/ephemeris/` — bash and Python 3 standard library only; sequential requests with a one-second delay400and an on-disk cache of raw answers (`DataPipeline/raw/ephemeris/`, git-ignored); generic User-Agent, no personal data.401402| Script | Output |403|---|---|404| `fetch_kernels.sh` | downloads the four NAIF kernels, assembles the core pack, calls `build_core_manifest.py` |405| `build_core_manifest.py` | `core-ephemeris/manifest.json`, schema v1 (sizes, SHA-256, `sources[]`, licence, redistribution, coverage read from the SPK); offline |406| `fetch_elements.py` | `core-ephemeris/kepler_elements.json` + fixtures `kep_*` |407| `fetch_missions.py [key…]` / `--manifest-only` | `missions/*.trj`, `missions/manifest.json`, `missions/sources/*`, fixtures `chk_*` |408| `fetch_validation.py` | fixtures `vec_*`, `obs_*`, `sat_*` and `index.json` (exact query of each fixture) |409| `spk_subset.py` | time-window extract of a remote SPK via HTTP range requests (test fixture `Tests/Fixtures/spk/`) |410| `horizons.py` | shared Horizons client and parsers |411412## 9. Limitations413414- SPK types other than 2 and 3 are not read; type 3 is validated on synthetic data only.415- DE440s does not contain the centres of Mars, Jupiter, Saturn, Uranus, Neptune and Pluto, nor any satellite.416 In the composite they come from the Keplerian approximation (section 6.4) unless a satellite kernel is added.417- SPICE `LT+S` is the Newtonian aberration; it differs from Horizons' relativistic one by ≤ 5.2e-4″. Light418 bending and the relativistic light-time delay are not modelled. Transmission-case corrections (`XLT`) are not implemented.419- The Earth orientation of the PCK is the low-precision IAU model; the Moon model is the IAU one, 2e-3° from the420 DE mean-Earth frame. Binary PCKs are not read.421- `LeapSecondKernel` only exposes what `naif0012.tls` states; time-scale conversion belongs to CosmosTime.422- Text-kernel dates accept `YYYY-MON-DD[-HH:MM:SS]` forms only.423- Mission trajectories are JPL reconstructions and predictions sampled with a 1 km interpolation target; coverage424 ends where stated, and 2-minute gaps exist at the discontinuities of the source. Mission events are limited to425 those the cited sources state.426- `kepler_elements.json` is regenerated from the live Horizons service: elements change when JPL updates an427 orbit solution.428