Merge the solar-system branch, so the star catalogue lands on the sky it now shares

Both branches changed the system view's star, the body card's provenance line, the exoplanet
fetch and the ETL's validators. Resolved by keeping both sides:

- The system view's star is the catalogue's (its own radius and temperature, a limb-darkened
  surface in its colour) and turns like a planet when it is the Sun (the solar branch's IAU pole
  and 25.38-day turn), keyed on SUN_STAR_ID, since the catalogue branch dropped the scene's own
  SOL_STAR_ID. Framing takes the outermost thing drawn (an eccentric orbit's aphelion, from the
  solar branch) and the star's radius for a giant (from the catalogue). The solar branch's comment
  about a halo is dropped: there has been none since #33.
- The card's no-temperature sentence is the catalogue's (the host's luminosity or the orbit's size,
  not "not in the catalogue", which holds for 27 planets) and ends with the solar branch's reason
  why no image is used (a point of light for the 101 imaged planets, none for the rest).
- fetchExoplanets reads the composite table and the distance errors (catalogue) and the imaged
  list (solar); build.ts runs both branches' validators.

The data were regenerated by the full ETL on the merged code, from cache (nothing refetched):
stars.bin, stars-meta.bin, stars-index.json and deepsky.json come out byte for byte the catalogue
branch's, bodies.json the solar branch's, and exoplanets.json the catalogue branch's but for the
imaged flag on 101 planets, WASP-108 b not among them. Unit suite 977 passed, the two branches'
870 and 837 over their shared 730, so no test was lost.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-30 22:07:34 +02:00
co-authored by Claude Opus 5.5
67 changed files with 6791 additions and 593 deletions
+357 -6
View File
@@ -1,12 +1,17 @@
import { statSync } from 'node:fs';
import { BodyRecord } from '../../src/app/shared/models/body.model';
import { BodyRecord, OrbitalElements, RotationalElements } from '../../src/app/shared/models/body.model';
import { eclipticToEquatorial, laplacePlaneToEquatorial, raDecToUnitVector } from '../../src/app/shared/astro/coordinates';
import { meanElementsAt, positionAtEpoch } from '../../src/app/shared/astro/kepler';
import { orientationAt } from '../../src/app/shared/astro/rotational-elements';
import { DeepSkyRecord } from '../../src/app/shared/models/deepsky.model';
import { ExoplanetRecord } from '../../src/app/shared/models/exoplanet.model';
import { StarRecord, SUN_STAR_ID } from '../../src/app/shared/models/star.model';
import { fetchDeepSky } from './fetchDeepSky';
import { fetchExoplanets } from './fetchExoplanets';
import { fetchSolarSystem } from './fetchSolarSystem';
import { fetchSolarSystem, FREELY_SPINNING_MOONS, offsetFromTrackDeg } from './fetchSolarSystem';
import { TrackPoint } from './lib/horizons';
import { subPlanetLongitudeDeg } from './lib/locked-spin';
import { BYTES_PER_STAR_META, BYTES_PER_STAR_POSITION, decodeStarCatalog, encodeStarCatalog, isDesignation } from '../../src/app/shared/models/star-catalog';
import { fetchStars, glieseGaiaDesignations } from './fetchStars';
import { ARCHIVE_EPOCH, archiveStarId, CATALOGUE_EPOCH } from '../../src/app/shared/astro/host-star-matching';
@@ -354,23 +359,353 @@ function validateMerge(stars: StarRecord[], gaiaDesignationById: ReadonlyMap<num
console.log(` ${survivors} HYG stars have no Gaia counterpart; ${twins} unmerged cross-catalogue pairs within an arcsecond; ${beside.length} Gliese stars beside their own Gaia source.`);
}
function validateBodies(bodies: BodyRecord[]): void {
/**
* How far a body's mean elements may put it from where Horizons has it, on the one date the ETL
* asks Horizons about (2025-01-01), seen from the Sun for a planet and from its planet for a moon.
*
* Measured on this catalogue: the planets at most 0.10 degrees (Uranus; Standish's own stated
* error for his fit is 2 000 arcseconds, 0.56 degrees), the moons at most 1.41 (the Moon, whose
* evection and variation, 1.27 and 0.66 degrees, no mean ellipse has). What this catches is a
* table read wrongly: a moon read against the ecliptic instead of its Laplace plane, a node run the
* wrong way, or a column taken for its neighbour, which put Triton 26 degrees out. Io's periapsis
* run forwards put it 0.9 out here, which passes; {@link TRACK_OFFSET_CEILINGS_DEG} catches that.
*/
const MAX_PLANET_OFFSET_DEG = 0.25;
/** Measured on this catalogue: at most 0.0151 (Phoebe and the Moon) once Hyperion prints its current 0.105. */
const MAX_ECCENTRICITY_OFFSET = 0.03;
const MAX_MOON_OFFSET_DEG = 2.5;
const KM_PER_AU = 149597870.7;
const DEG_TO_RAD = Math.PI / 180;
/**
* The moons whose table row cannot come within that on this one date, each with a ceiling just
* above its offset here (Hyperion 9.41, Iapetus 9.56, Nereid 2.58); see
* {@link TRACK_OFFSET_CEILINGS_DEG} for what they reach from 1950 to 2100. Hyperion's was 21, its
* worst over twelve dates, which let a row misread by twice its offset through.
*/
const MOON_OFFSET_CEILINGS_DEG: Record<string, number> = { hyperion: 10, iapetus: 11, nereid: 3 };
/**
* How far a moon's or dwarf planet's orbit may stray from Horizons from 1950 to 2100, sampled every
* other day (Nereid and Hyperion daily). One date showed each at its best: twelve New Year's Days
* gave Nereid 2.6 degrees, and 2025-01-01 alone is all the check above sees. Each card says how
* far its own orbit strays over the span (`fetchSolarSystem`), and this holds that figure to
* account.
*
* Measured on this catalogue: at most 2.62 degrees (the Moon, 2010 March 27: no mean ellipse has
* its evection or variation; Phoebe reaches 2.58 in 1969, where "within 2.0" was once claimed for
* it). Five need their own:
*
* - Hyperion, 22.23 (2055 Feb 26): held in a 4:3 resonance by Titan; the row's eccentricity,
* 0.0232, is less than a quarter of the 0.105 JPL's current table gives.
* - Nereid, 11.19 (2039 Nov 1): an eccentricity of 0.75, the largest here, which a mean ellipse
* follows least well near periapsis, where the true anomaly runs ten times faster than the mean;
* its 360-day year kept every New Year's Day far from one.
* - Iapetus, 10.34: the row sits 9.4 degrees behind Horizons at its own epoch, 2000 Jan 1.5, and
* keeps that offset; its plane agrees with Horizons' to 0.07 degrees and its period to 0.001 per
* cent, so the fault is in the row's longitude, which this has no second source to correct.
* - Mimas, 7.42: its orbit carries the 44-degree libration of its resonance with Tethys (see
* `orbitFromW` in `fetchSolarSystem.ts`), but not the rest of what Horizons integrates.
* - Ceres, 7.12 (1953): the SBDB's elements are osculating, exact at 2026 Jun 9 and drifting
* either side; 1.9 by 2050, 5.3 by 2100, and 39 at 1600 on Horizons' own figures.
*
* And four are held tighter than the rest, each where one reading of its row is all that keeps it
* close, and without it the card would quietly restate itself under the general ceiling:
*
* - Tethys, 0.28, which takes the other half of that libration, 2.23 degrees, from its W. Without
* it Tethys strays 2.09.
* - Io, 0.07, and Europa, 0.23, whose periapses turn backwards, held by the Laplace resonance at
* 2n(Europa) - n(Io), -0.7395 degrees a day (`apsidesRegress`). Read as advancing, Io strays 0.96
* and Europa 2.24, and their cards said "within 1.0" and "within 2.3".
* - Callisto, 0.08, whose node turns at JPL's current rate and its periapsis's longitude at the
* row's (`nodePeriodYears`). On the row's argument its periapsis moves 44 degrees by 2100 and it
* strays 0.71; on the row's node, 0.19.
*/
const MAX_TRACK_OFFSET_DEG = 3;
const TRACK_OFFSET_CEILINGS_DEG: Record<string, number> = { hyperion: 23, nereid: 12, iapetus: 11, mimas: 8, ceres: 8, tethys: 0.5, io: 0.2, europa: 0.5, callisto: 0.15 };
/**
* The bodies the IAU WGCCRE 2015 report gives no rotational elements for: Hyperion tumbles, and
* Nereid, Eris, Haumea and Makemake have no model. Every other body must carry them, or the
* kernel was read wrongly and the body would be drawn on an invented pole.
*/
const WITHOUT_ROTATIONAL_ELEMENTS = new Set(['hyperion', 'nereid', 'eris', 'haumea', 'makemake']);
/**
* The one moon drawn still: Hyperion, whose page says "Rotational period = Chaotic". Every other
* moon without a lock has a measured day; Nereid's page states none, and it was drawn still until
* its K2 light curve's 11.594 hours was taken (see its spec).
*/
const TUMBLING = new Set(['hyperion']);
/**
* How far the IAU's day, 360 degrees over W's rate, may be from the period the body's record
* carries, as a fraction of it. That period is not always a second source:
*
* - The eight planets and Phoebe: the one Horizons states. Measured on this catalogue: at most
* 1.8e-5 (Jupiter's System III, 9.92492 hours against 9.92510). Neptune is 0.89 per cent out,
* because the report takes 15.9663 hours from the cloud features Karkoschka (2011) tracked, where
* Horizons keeps Voyager's radio period, 16.11.
* - Pluto and Ceres: the IAU's own rate restated. Horizons' 153.29335198 hours for Pluto is 360 over
* its W (8.5e-12), and the SBDB's 9.074170 for Ceres, which Horizons prints too, is noted as
* derived from the report's 952.1532 degrees a day (3.3e-10).
* - The 22 locked moons: their orbit's period, from JPL's satellite table, not a figure from their
* Horizons pages ("Synchronous" on eighteen of them, nothing on Titan's or Proteus's). Their W is
* turned at that rate (see `lockedToOrbit`, which first holds the kernel's own rate to it within
* 1e-5), so here they are 0, but for the Moon and Phobos, whose W keeps its own rate and its
* quadratic (1.1e-8 and 3.1e-7).
*
* What this catches is a rate read in the wrong unit or for the wrong body: Oberon's day for
* Titania's is 55 per cent out.
*/
const MAX_DAY_OFFSET = 1e-4;
const DAY_OFFSET_CEILINGS: Record<string, number> = { neptune: 0.01 };
/**
* How far the tilt of the IAU's spin axis from the orbit may be from the obliquity Horizons
* states. The axis is the IAU's pole, turned end for end where W runs backwards: the report names
* a planet's north pole by the side of the solar system it lies on, whichever way the planet turns.
* Measured on this catalogue: at most 0.058 degrees (Venus, 177.358 against 177.3). Taken as the
* pole alone, Venus comes out at 2.6 degrees and Uranus at 82.2, which is what this catches.
*
* Pluto's Horizons page states no obliquity: its 119.6 is worked out from the IAU pole itself (see
* `BodySpec.obliquityDeg`), so for Pluto this checks only that the kernel's pole and W were read as
* written, not the pole against a second source.
*/
const MAX_OBLIQUITY_OFFSET_DEG = 0.1;
/**
* How far from its planet a locked moon's drawn face may turn: the east longitude, on the IAU's
* body-fixed frame, of the direction to the planet from where the mean elements put the moon,
* sampled every 135 days over the clock's AD 1 to 3000. Every locked moon's W turns at its orbit's
* own rate (see `lockedToOrbit`); at the IAU's own rates, and sampled only from 1950 to 2100, this
* let Proteus turn its far side to Neptune at AD 1 (146 degrees), Iapetus 87 degrees, Mimas 52 and
* Miranda 23, on dates the clock offers.
*
* Measured on this catalogue: at most 5.36 degrees (Titan) but for three. The Moon 7.62, at AD 1:
* its longitude swings 6.3 either way with its eccentricity, Horizons' too, and W's quadratic, the
* tidal slowing its orbit here does not carry, adds 0.75 by then. Mimas 8.89: about 6.3 off on
* average because the IAU's W and JPL's mean longitude disagree, and swung 2.3 either way (2e) by
* its eccentricity. None of that is Mimas: its measured physical libration is 0.84 degrees
* (Tajeddine et al. 2014, Science 346, 322), and W carries none; Horizons, on the same W against its
* integrated orbit, runs from -2.7 to 12.7 degrees over 1950-2100 with the 71-year S5 term the
* orbit here cancels. Iapetus 15.95, whose row sits 9.4 degrees behind Horizons. What this catches
* is an orbit and a W that go round at different rates: the tidal acceleration W carried and the
* orbit did not turned Phobos 13.8 degrees from Mars by 2100, and the Mimas-Tethys libration Mimas
* 54.5.
*/
const MAX_SUB_PLANET_LONGITUDE_DEG = 7;
const SUB_PLANET_CEILINGS_DEG: Record<string, number> = { moon: 8, mimas: 9.5, iapetus: 16.5 };
/**
* How far a locked moon's spin axis may lean from the normal of the orbit it is drawn going round,
* over the same dates. A locked moon sits in a Cassini state, its axis on its orbit normal as the
* node carries both round the Laplace pole, and the IAU's pole goes round on a term of the node's
* angle; at the rate the IAU's source had for it and not the drawn orbit's, Rhea's axis is 0.77
* degrees off by AD 1 and Triton's 0.51, and an Iapetus pole left on the Laplace pole is 8.30 off
* at every date (see `lockedToOrbit`).
*
* Measured on this catalogue: at most 0.97 degrees (Tethys, whose IAU pole sits 0.69 from its orbit
* normal today; Titan 0.94, whose pole the IAU holds still while its node turns in 687 years) but
* for four. The Moon 6.98, its real 6.7-degree tilt to its orbit. Phobos 1.81 and Deimos 1.74, and
* Proteus 1.09: their IAU poles nod with Mars's and Neptune's precessing poles, the Laplace poles
* their orbits are drawn round are fixed.
*
* And six are held tighter, each where its node terms turned at the node's rate, or its node at
* JPL's current rate, are what keep it close: Europa 0.13, Ganymede 0.16, Callisto 0.22, Rhea 0.17,
* Miranda 0.23 and Triton 0.15. On the IAU's rates they are 0.33, 0.21, 0.33, 0.77, 0.59 and 0.51,
* on a tolerance of 1 per cent Callisto and Rhea are left there, on the node's angle alone and not
* its harmonics Triton is 0.29, and on the archived table's node periods Callisto is 0.56 and
* Miranda 0.42: all under the general ceiling.
*/
const MAX_AXIS_FROM_ORBIT_DEG = 1;
const AXIS_FROM_ORBIT_CEILINGS_DEG: Record<string, number> = {
moon: 7.1,
phobos: 2,
deimos: 2,
proteus: 1.2,
europa: 0.25,
ganymede: 0.25,
callisto: 0.25,
rhea: 0.25,
miranda: 0.25,
triton: 0.25
};
/** The clock's window, AD 1 to 3000 (`CLOCK_WINDOW` in `time.store.ts`), as Julian dates. */
const CLOCK_START_JD = Date.parse('0001-01-01T00:00Z') / 86400000 + 2440587.5;
const CLOCK_END_JD = Date.parse('3000-01-01T00:00Z') / 86400000 + 2440587.5;
const LOCK_DATES_JD = Array.from({ length: Math.floor((CLOCK_END_JD - CLOCK_START_JD) / 135) + 1 }, (_, index) => CLOCK_START_JD + index * 135);
function angleBetweenDeg(a: { x: number; y: number; z: number }, b: { x: number; y: number; z: number }): number {
const cosine = (a.x * b.x + a.y * b.y + a.z * b.z) / (Math.hypot(a.x, a.y, a.z) * Math.hypot(b.x, b.y, b.z));
return (Math.acos(Math.min(1, Math.max(-1, cosine))) * 180) / Math.PI;
}
/** Degrees between a body's spin axis — its IAU pole, turned over where W runs backwards — and the normal of the orbit it is drawn going round, at a TDB date. */
function axisFromOrbitDeg(body: BodyRecord, rotation: RotationalElements, jd: number): number {
const pole = orientationAt(rotation, jd);
const pointing = raDecToUnitVector(pole.poleRaDeg / 15, pole.poleDecDeg);
const sense = Math.sign(rotation.primeMeridianDeg[1]);
const axis = { x: sense * pointing.x, y: sense * pointing.y, z: sense * pointing.z };
const { inclinationDeg, longitudeOfAscendingNodeDeg } = meanElementsAt(body.orbit, body.rates, jd);
const tilt = inclinationDeg * DEG_TO_RAD;
const node = longitudeOfAscendingNodeDeg * DEG_TO_RAD;
const normal = { x: Math.sin(tilt) * Math.sin(node), y: -Math.sin(tilt) * Math.cos(node), z: Math.cos(tilt) };
return angleBetweenDeg(axis, body.laplacePole ? laplacePlaneToEquatorial(normal, body.laplacePole) : eclipticToEquatorial(normal));
}
function validateBodies(bodies: BodyRecord[], horizonsOrbits: Map<string, OrbitalElements>, horizonsTracks: Map<string, TrackPoint[]>): void {
assertCondition(bodies.length > 0, 'No solar-system bodies were produced.');
const ids = new Set(bodies.map((body) => body.id));
assertCondition(ids.size === bodies.length, 'Duplicate body ids were found.');
const offsets: string[] = [];
const spins: string[] = [];
for (const body of bodies) {
const orbitValues = Object.values(body.orbit);
assertCondition(orbitValues.every(Number.isFinite), `Body ${body.id} has non-finite orbital elements.`);
assertCondition(body.rates.meanMotionDegPerDay > 0, `Body ${body.id} has no mean motion.`);
// Horizons' elements are osculating, exact at their own epoch; both sets are placed there.
const horizons = horizonsOrbits.get(body.id);
assertCondition(horizons !== undefined, `Body ${body.id} has no Horizons elements to be checked against.`);
const truth = eclipticToEquatorial(positionAtEpoch(horizons!));
const mean = positionAtEpoch(meanElementsAt(body.orbit, body.rates, horizons!.epochJd));
const offset = angleBetweenDeg(body.laplacePole ? laplacePlaneToEquatorial(mean, body.laplacePole) : eclipticToEquatorial(mean), truth);
const ceiling = body.kind === 'moon' ? (MOON_OFFSET_CEILINGS_DEG[body.id] ?? MAX_MOON_OFFSET_DEG) : MAX_PLANET_OFFSET_DEG;
assertCondition(
offset <= ceiling,
`${body.name}'s mean elements put it ${offset.toFixed(2)} degrees from where Horizons has it (at most ${ceiling} expected) — the elements were read wrongly.`
);
offsets.push(`${body.id} ${offset.toFixed(3)}`);
// Standish's fit names its own span; every other orbit is measured over 1950-2100, and says so.
const track = horizonsTracks.get(body.id);
assertCondition(
(track !== undefined) === !body.orbitSource.startsWith('JPL approximate mean elements (Standish)'),
`${body.name}'s orbit, "${body.orbitSource}", ${track ? 'names its own span' : 'names no span it holds over'}.`
);
// JPL's satellite table carries no periodic terms: a moon's are from its IAU W, and its card
// names the kernel they come from as well as the table.
assertCondition(
!body.parentBodyId || !body.rates.meanAnomalyTerms || body.orbitSource.includes('NAIF pck00011'),
`${body.name}'s orbit carries terms taken from its IAU W, and its card, "${body.orbitSource}", credits only the table.`
);
if (track) {
const worst = Math.max(...track.map((point) => offsetFromTrackDeg(body, point)));
const trackCeiling = TRACK_OFFSET_CEILINGS_DEG[body.id] ?? MAX_TRACK_OFFSET_DEG;
const stated = Number(body.orbitSource.match(/within ([\d.]+) degrees of Horizons/)?.[1]);
assertCondition(
worst <= trackCeiling && stated >= worst,
`${body.name}'s mean elements put it up to ${worst.toFixed(2)} degrees from Horizons between 1950 and 2100 (at most ${trackCeiling} expected), and its card says "${body.orbitSource}".`
);
offsets.push(`${body.id} ${worst.toFixed(2)} at worst`);
}
// The card prints this under "Measured". An osculating eccentricity swings about its mean — the
// Moon's by 0.015 here, Phoebe's by as much — but not by the 0.087 Hyperion's older row was out.
const printed = body.measuredEccentricity ?? body.orbit.eccentricity;
assertCondition(
Math.abs(printed - horizons!.eccentricity) <= MAX_ECCENTRICITY_OFFSET,
`${body.name}'s card gives an eccentricity of ${printed}, where Horizons' osculating orbit has ${horizons!.eccentricity.toFixed(4)} (at most ${MAX_ECCENTRICITY_OFFSET} apart expected).`
);
// A radius of 0 is what a page whose radius no pattern reads comes out as — Charon's did.
assertCondition(body.radiusKm > 0, `Body ${body.id} has no radius; its page states it in a form the ETL does not read.`);
// A triaxial body's card gives its mean radius beside its semi-axes, so the two must agree: the
// radius of the sphere of the same volume. Measured: Haumea's 797.6 against 797.62.
if (body.semiAxesKm) {
const volumeRadius = Math.cbrt(body.semiAxesKm[0] * body.semiAxesKm[1] * body.semiAxesKm[2]);
assertCondition(
Math.abs(volumeRadius / body.radiusKm - 1) < 0.001,
`${body.name}'s radius, ${body.radiusKm} km, is not the mean of its semi-axes ${body.semiAxesKm.join(' x ')}, ${volumeRadius.toFixed(1)} km.`
);
}
const rotation = body.rotationalElements;
assertCondition(
(rotation === undefined) === WITHOUT_ROTATIONAL_ELEMENTS.has(body.id),
`Body ${body.id} ${rotation ? 'has' : 'has no'} IAU rotational elements, which the report ${rotation ? 'does not give' : 'gives'} for it.`
);
if (rotation) {
const rate = rotation.primeMeridianDeg[1];
if (body.rotationPeriodHours !== undefined) {
const dayOffset = Math.abs(((360 / Math.abs(rate)) * 24) / Math.abs(body.rotationPeriodHours) - 1);
const dayCeiling = DAY_OFFSET_CEILINGS[body.id] ?? MAX_DAY_OFFSET;
assertCondition(
dayOffset <= dayCeiling,
`${body.name}'s IAU day, ${((360 / Math.abs(rate)) * 24).toFixed(5)} hours, is ${dayOffset.toExponential(2)} of its length from the ${Math.abs(body.rotationPeriodHours).toFixed(5)} its record carries (at most ${dayCeiling} expected).`
);
spins.push(`${body.id} day ${dayOffset.toExponential(1)}`);
}
if (body.obliquityDeg !== undefined) {
const obliquity = axisFromOrbitDeg(body, rotation, horizons!.epochJd);
assertCondition(
Math.abs(obliquity - body.obliquityDeg) <= MAX_OBLIQUITY_OFFSET_DEG,
`${body.name}'s IAU spin axis is ${obliquity.toFixed(3)} degrees from its orbit's pole, where ${body.id === 'pluto' ? 'its IAU pole' : 'Horizons'} gives an obliquity of ${body.obliquityDeg} (at most ${MAX_OBLIQUITY_OFFSET_DEG} apart expected) — the pole or the sense of W was read wrongly.`
);
spins.push(`${body.id} tilt ${obliquity.toFixed(3)}`);
}
}
if (body.kind === 'moon') {
assertCondition(!!body.parentBodyId && ids.has(body.parentBodyId), `Moon ${body.id} has no valid parentBodyId.`);
const parent = bodies.find((candidate) => candidate.id === body.parentBodyId);
assertCondition(parent !== undefined, `Moon ${body.id} has no valid parentBodyId.`);
const orbitHours = (360 / body.rates.meanMotionDegPerDay) * 24;
if (FREELY_SPINNING_MOONS.has(body.id)) {
// Hyperion tumbles, and has no period; Nereid turns in 11.594 hours against a 360-day orbit,
// and Phoebe in 9.27 against 550 days. A lock here would be the rule below misapplied.
assertCondition(
body.rotationPeriodHours !== undefined || TUMBLING.has(body.id),
`Moon ${body.id} is drawn not turning, and is not known to tumble: its day was measured somewhere, find it.`
);
assertCondition(
body.rotationPeriodHours === undefined || Math.abs(body.rotationPeriodHours - orbitHours) > orbitHours * 0.1,
`Moon ${body.id} does not keep one face to its planet, yet turns once in ${body.rotationPeriodHours} hours against an orbit of ${orbitHours}.`
);
} else {
// Every other moon here is tidally locked, and drawn by its orbit and its IAU W: the two
// have to agree, or its face turns away from its planet.
assertCondition(rotation !== undefined, `Moon ${body.id} is locked but has no W to keep its face to its planet by.`);
const ceiling = SUB_PLANET_CEILINGS_DEG[body.id] ?? MAX_SUB_PLANET_LONGITUDE_DEG;
const worst = Math.max(...LOCK_DATES_JD.map((jd) => Math.abs(subPlanetLongitudeDeg(body, rotation!, jd))));
assertCondition(
worst <= ceiling,
`Moon ${body.id} turns its face up to ${worst.toFixed(2)} degrees from its planet between AD 1 and 3000 (at most ${ceiling} expected) — its orbit and its W disagree.`
);
spins.push(`${body.id} faces ${worst.toFixed(2)}`);
const axisCeiling = AXIS_FROM_ORBIT_CEILINGS_DEG[body.id] ?? MAX_AXIS_FROM_ORBIT_DEG;
const worstAxis = Math.max(...LOCK_DATES_JD.map((jd) => axisFromOrbitDeg(body, rotation!, jd)));
assertCondition(
worstAxis <= axisCeiling,
`Moon ${body.id}'s spin axis leans up to ${worstAxis.toFixed(2)} degrees from its orbit's normal between AD 1 and 3000 (at most ${axisCeiling} expected) — its pole does not go round with its node.`
);
spins.push(`${body.id} axis ${worstAxis.toFixed(2)}`);
}
if (body.massRatio !== undefined) {
// The pair's barycentre, which the planet's elements place, must lie outside the planet —
// that is why the two are drawn going round it — and nearer the planet than the moon.
const offsetKm = (body.orbit.semiMajorAxisAu * KM_PER_AU * body.massRatio) / (1 + body.massRatio);
assertCondition(
body.massRatio > 0 && body.massRatio < 1 && offsetKm > parent!.radiusKm,
`${body.name}'s mass ratio ${body.massRatio} puts its barycentre ${offsetKm.toFixed(0)} km from ${parent!.name}'s centre, which is not between its surface, ${parent!.radiusKm} km out, and the moon.`
);
}
}
}
const planetCount = bodies.filter((body) => body.kind === 'planet').length;
assertCondition(planetCount === 8, `Expected 8 planets, found ${planetCount}.`);
const dwarfCount = bodies.filter((body) => body.kind === 'dwarf').length;
assertCondition(dwarfCount === 5, `Expected the IAU's 5 dwarf planets, found ${dwarfCount}.`);
// Eris keeps one face to Dysnomia, whose orbit takes 15.78590 days (Holler et al. 2021); its light
// curve gives 15.771 +/- 0.008 (Bernstein et al. 2023). The SBDB still gives 25.9 hours.
const erisDays = (bodies.find((body) => body.id === 'eris')?.rotationPeriodHours ?? NaN) / 24;
assertCondition(
Math.abs(erisDays / 15.7859 - 1) < 0.002,
`Eris turns once in ${erisDays.toFixed(3)} days; it is locked to Dysnomia's 15.786-day orbit — the SBDB's 25.9-hour period, which it flags as possibly 30 per cent wrong, was taken.`
);
console.log(` mean elements against Horizons, degrees: ${offsets.join(', ')}.`);
console.log(` IAU rotation against each record's day and tilt (see MAX_DAY_OFFSET for where each comes from; day as a fraction of it, tilt and a locked moon's face in degrees): ${spins.join(', ')}.`);
}
/**
@@ -503,8 +838,24 @@ function validateExoplanets(exoplanets: ExoplanetRecord[], stars: StarRecord[]):
const withPeriod = exoplanets.filter((exoplanet) => exoplanet.periodDays !== undefined).length;
const withHostMass = exoplanets.filter((exoplanet) => exoplanet.hostStarMassSolar !== undefined).length;
console.log(` ${withPeriod}/${exoplanets.length} have a measured period, ${withHostMass} a host star mass.`);
// The planets photographed by direct imaging, whose card must not say no image of them exists.
// Measured: 101 of 101 flagged in the archive, and not transiting, are in the catalogue. What this
// catches is the join by name failing, which would put every one of them back under "no image".
const imaged = exoplanets.filter((exoplanet) => exoplanet.imaged).length;
assertCondition(imaged >= MIN_IMAGED_EXOPLANETS, `Only ${imaged} exoplanets are marked as imaged (at least ${MIN_IMAGED_EXOPLANETS} expected).`);
// And the one the flag is wrong on, which the count cannot see: a 2.68-day transiting hot Jupiter
// 0.15 mas from its star, flagged for the companion star a survey imaged beside it. Its record
// carries neither a period nor an axis, so no separation check could catch it either.
assertCondition(
!exoplanets.some((exoplanet) => exoplanet.id === 'WASP-108 b' && exoplanet.imaged),
'WASP-108 b is marked as imaged; it transits, and only a companion star beside it was imaged (Bohn et al. 2020).'
);
console.log(` ${imaged} were imaged directly.`);
}
const MIN_IMAGED_EXOPLANETS = 95;
const UNIT_VECTOR_TOLERANCE = 1e-6;
/**
@@ -573,7 +924,7 @@ async function build(): Promise<void> {
const catalogueStars = await fetchStars();
console.log();
const bodies = await fetchSolarSystem();
const { bodies, horizonsOrbits, horizonsTracks } = await fetchSolarSystem();
console.log();
// Adds the hosts the catalogue lacks, so it is this list, not the one above, that is published.
const { exoplanets, stars } = await fetchExoplanets(catalogueStars);
@@ -584,7 +935,7 @@ async function build(): Promise<void> {
console.log('Validating output...');
validateStars(stars);
validateMerge(stars, await glieseGaiaDesignations());
validateBodies(bodies);
validateBodies(bodies, horizonsOrbits, horizonsTracks);
validateExoplanets(exoplanets, stars);
validateDeepSky(deepSky);