Files
star-map/tools/etl/lib/mean-elements.ts
SenrokaiandClaude Opus 5.5 b0d7989c6f Read moons given against their planet's equator, and dwarf planets from the Small-Body Database
Two sources the missing bodies need, read and tested before any body uses them.

JPL's satellite table gives Uranus's and Pluto's moons against the planet's equator ("Mean
equatorial orbital elements") rather than a Laplace plane, and does not print that equator's
pole. parseSatelliteMeanElements now takes the pole from its caller for such a section and reads
the row against it exactly as against a Laplace plane's; it throws if a section is equatorial and
no pole was given, or a pole was given for a section that is not. Read as ecliptic elements, which
is what the old code would have done, Titania is 88 degrees from Horizons on 2025-01-01. The
section's plane is now the nearest heading above the row, with the ecliptic as before where there
is none.

Ceres, Eris, Haumea and Makemake are in none of Standish's tables. parseSmallBodyElements reads a
JPL SBDB answer (sbdb.api?sstr=...&phys-par=1&full-prec=1): the osculating heliocentric elements
against the J2000 ecliptic, carried round at their own n with nothing turning, and half the
published diameter and the rotation period where the answer has them. full-prec matters: without
it SBDB rounds to three figures, Ceres's n to 0.214 degrees a day for 0.2143045, 1.1 degrees out
within a decade. The fetcher, tools/etl/lib/mean-elements.ts, caches the answer like the others.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 21:47:55 +02:00

42 lines
2.5 KiB
TypeScript

import { SbdbAnswer } from '../../../src/app/shared/astro/mean-elements';
import { fetchJsonCached, fetchTextCached } from './http';
/**
* Standish's "Keplerian Elements for Approximate Positions of the Major Planets", Table 2a/2b:
* elements against the J2000 ecliptic and their rates per century, fit to the JPL ephemeris for
* 3000 BC to AD 3000. Table 1 is closer near the present — Saturn within 0.23 degrees of Horizons
* from 1950 to 2100 against this table's 0.32 — but it is only fit for 1800-2050, which the clock
* leaves in minutes, and by AD 3000 it has Saturn 4.3 degrees out where this one is within 0.3
* of every planet. The page at ssd.jpl.nasa.gov/planets/approx_pos.html carries the same numbers but has
* dropped Pluto, so this reads the plain-text file as JPL last published it, from the Internet
* Archive's copy — pinned to one capture, so the numbers cannot move under the cache.
*/
const PLANET_ELEMENTS_URL = 'https://web.archive.org/web/20210420020242id_/https://ssd.jpl.nasa.gov/txt/p_elem_t2.txt';
/**
* JPL SSD's planetary satellite mean elements, as the page stood until 2021: each moon's elements,
* its sidereal mean motion to ten figures, and how fast its node and periapsis turn, against its
* local Laplace plane (the Moon against the ecliptic). The current page, ssd.jpl.nasa.gov/sats/elem,
* has dropped the mean motion and rounds the period to four or five figures — 0.3187 days for
* Phobos, which is a revolution out within a decade — so a period from it would not hold. Pinned
* to one Internet Archive capture for the same reason as the planets.
*/
const SATELLITE_ELEMENTS_URL = 'https://web.archive.org/web/20210203000649id_/https://ssd.jpl.nasa.gov/?sat_elem';
export async function fetchPlanetMeanElementsText(): Promise<string> {
return fetchTextCached(PLANET_ELEMENTS_URL, 'jpl-planet-mean-elements-t2.txt');
}
export async function fetchSatelliteMeanElementsHtml(): Promise<string> {
return fetchTextCached(SATELLITE_ELEMENTS_URL, 'jpl-satellite-mean-elements.html');
}
/**
* A small body's answer from JPL's Small-Body Database: osculating elements to full precision
* (without `full-prec` they come rounded to three figures: Ceres's n as 0.214 degrees a day for
* 0.2143045, which is 1.1 degrees out within a decade) and its physical parameters.
*/
export async function fetchSmallBodyAnswer(designation: string, cacheKey: string): Promise<SbdbAnswer> {
return fetchJsonCached<SbdbAnswer>(`https://ssd-api.jpl.nasa.gov/sbdb.api?sstr=${encodeURIComponent(designation)}&phys-par=1&full-prec=1`, cacheKey);
}