Store a star's distance error in two bytes, so the card prints the error its catalogue published

a81dd49 kept the square root of the relative error in 255ths. A step was a few per cent of the
error itself, which moved the last digit the card prints: over the cached Gaia answers, 2 822 of
the 53 209 stars whose card prints an error printed another one than their published parallax
error gives (Gaia DR3 1415230383034813824 "112 +- 2 pc" for 3), and Rigel, 3.78 +- 0.34 mas in van
Leeuwen 2007, read "265 +- 23 pc" for 23.8.

The column is now a Uint16 in 65 535ths, placed before the photometry byte so its view stays
two-byte aligned whatever the star count; BYTES_PER_STAR_META goes from 16 to 17, the build.ts
round trip tolerance to half a 65 535th, and the README names the column. The same count gives 12,
each on a rounding half. In the running app Rigel reads "265 +- 24 pc".

The cost: stars-meta.bin goes from 7 288 512 to 7 744 044 bytes, and gzip -9 from 3 117 639 to
3 623 379, half a megabyte more to download, since the extra byte is noise-like. One reviewer
judged the one-byte figure within the errors' own accuracy; this takes the other two's view that
the card should print the published number.

Control: 255 steps again fails "keeps an error close enough that the card prints the published
one" alone.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-30 17:43:54 +02:00
co-authored by Claude Opus 5.5
parent 4d47896b4a
commit f31ffe1425
5 changed files with 29 additions and 14 deletions
+2 -2
View File
@@ -120,10 +120,10 @@ function validateStars(stars: StarRecord[]): void {
decoded[i].colorFromTemperature === !!stars[i].colorFromTemperature,
`Star catalogue round-trip changed the photometry of star ${stars[i].id}.`
);
// Stored as its square root in 255ths, up to 100 %; see `star-catalog.ts`.
// Stored as its square root in 65 535ths, up to 100 %; see `star-catalog.ts`.
const error = stars[i].distanceError;
assertCondition(
error === undefined ? decoded[i].distanceError === undefined : Math.abs(Math.sqrt(decoded[i].distanceError!) - Math.sqrt(Math.min(1, error))) <= 0.5 / 255 + 1e-9,
error === undefined ? decoded[i].distanceError === undefined : Math.abs(Math.sqrt(decoded[i].distanceError!) - Math.sqrt(Math.min(1, error))) <= 0.5 / 65_535 + 1e-9,
`Star catalogue round-trip changed the distance error of star ${stars[i].id}.`
);
}