/** * spk.ts — JPL SPK Type 2 binary ephemeris reader * * Reads de440s.bsp (NAIF DAF/SPK format) to extract planet positions as * barycentric rectangular coordinates in the J2000.0 equatorial frame. * * Supported: SPK Type 2 only (Chebyshev polynomials, position only). * DE440s uses Type 2 for all bodies. * * Format reference: * https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/req/daf.html * https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/req/spk.html * * Data source: NASA/JPL public domain * https://ssd.jpl.nasa.gov/ftp/eph/planets/bsp/de440s.bsp */ import { type Vec3 } from './chebyshev.js'; /** * NAIF integer body codes present in de440s.bsp. * Positions are barycentric (relative to Solar System Barycenter = 0) * except 301/399 which are relative to the Earth-Moon Barycenter (3). */ export declare const NAIF: { readonly SSB: 0; readonly Mercury: 1; readonly Venus: 2; readonly EMB: 3; readonly Mars: 4; readonly Jupiter: 5; readonly Saturn: 6; readonly Uranus: 7; readonly Neptune: 8; readonly Pluto: 9; readonly Sun: 10; readonly Moon: 301; readonly Earth: 399; }; interface SpkSegment { target: number; center: number; frame: number; type: number; startET: number; endET: number; initAddr: number; finalAddr: number; } export declare class SpkFile { private readonly buf; private readonly littleEnd; private readonly segments; constructor(filePath: string); private detectEndian; private readF64; private readI32; /** Parse the linked list of summary records and build segment index. */ private parseSegments; /** * Get the barycentric position (and velocity) of a body at ephemeris time `et`. * * @param target NAIF body ID (see NAIF constants above) * @param center NAIF center body ID (must match a segment in the file) * @param et Ephemeris time in seconds from J2000.0 TDB * @returns Vec3 Position in km, velocity in km/s (J2000 equatorial rectangular) */ getState(target: number, center: number, et: number): Vec3; /** * Return geocentric J2000 equatorial rectangular position (km) + velocity (km/s). * * Computes: body_SSB − Earth_SSB using the available SSB and EMB segments. * * For de440s.bsp: * Earth_SSB = EMB_SSB + Earth_EMB (body 3 + body 399) * Moon_SSB = EMB_SSB + Moon_EMB (body 3 + body 301) */ getGeocentric(naifBody: number, et: number): Vec3; /** * Return solar-system-barycentric J2000 equatorial rectangular position (km) * and velocity (km/s) for a body. * * Light-time and aberration corrections require the body and the observer to * be evaluated at *different* epochs, so callers need the barycentric states * separately rather than a pre-differenced geocentric vector. * * For de440s.bsp: * Earth_SSB = EMB_SSB + Earth_EMB (body 3 + body 399) * Moon_SSB = EMB_SSB + Moon_EMB (body 3 + body 301) */ getBarycentric(naifBody: number, et: number): Vec3; private findSegment; /** * Evaluate a Type 2 segment at ephemeris time `et`. * * SPK Type 2 segment layout (all doubles, 1-indexed addresses in file): * [initAddr … finalAddr-4] : N coefficient records, each RSIZE doubles * [finalAddr-3] : INIT (segment start, ET seconds) * [finalAddr-2] : INTLEN (sub-interval length, seconds) * [finalAddr-1] : RSIZE (doubles per record) * [finalAddr] : N (number of records) */ private evalSegment; /** Expose segment list for diagnostics. */ get segmentList(): readonly SpkSegment[]; } /** * Load (and cache) a SpkFile from the given path. * Subsequent calls with the same path return the cached instance. */ export declare function loadSpk(filePath: string): SpkFile; /** Reset the singleton cache (useful for testing). */ export declare function resetSpkCache(): void; export {};