Draw the whole catalogue, and build the aggregation the rest would need
Two things, one verified and one that cannot be. The render budget is now the whole catalogue: 68388 stars, one instanced draw call, which is what a GPU should be asked to do. The budget itself stays, because the catalogue is meant to grow past what any machine should draw at once — Gaia alone could contribute a million — and at that point the selection is what keeps the field legible rather than a grey wash. A `?stars=` override handles the machines that cannot, including the software rasterizer the end-to-end suite runs against, whose frame rate is two orders of magnitude below a real GPU's and which was measuring the rasterizer rather than the app. The aggregation is the second thing, and none of it has run. Every ESA, NOIRLab, SDSS and Euclid endpoint is unreachable from here — only GitHub raw is, which is why HYG and OpenNGC are the current sources. So this is infrastructure and a Gaia query written against the published DR3 schema, not data. What the framework encodes is that these surveys are not interchangeable. The distinction is not size but whether a catalogue knows how far away its objects are, because a 3D map cannot place a star it only has a direction for. Gaia is the only one of the five that can add stars here, because it is the only one that measures parallaxes. DECaPS2 has fifty times Gaia's object count and photometry alone — not one of its 3.32 billion objects can be placed in depth. Euclid's bulge is 8 kpc away, where a parallax is microarcseconds; its contribution would be imagery. SDSS-V and SAGA are keyed to stars something else already places, so they enrich rather than extend. Those roles are recorded as data the ETL prints, not as prose that can drift. Overlapping catalogues are reconciled on direction rather than on 3D proximity, which is the one non-obvious part. Two surveys agree on a star's direction to within an arcsecond and disagree on its distance by tens of per cent, so a star at 200 pc is 50 pc from itself between catalogues while being unmistakably the same object. Matching in 3D would need a tolerance so loose it swallowed real neighbours. The better parallax wins where both reach; where only one does, the star stays. Names become dense-with-holes with a source dictionary, because a survey catalogue has no proper names — writing "Gaia DR3 4472832130942575872" once per star would cost 25 MB per million to repeat what two adjacent fields already say. An empty entry costs three bytes and is regenerated on load. The Sun needed its own case in the merge: it sits at the origin, has no direction to compare, and appears in every catalogue. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WaySiNst4HhDXBHnMy8p5G
This commit is contained in:
@@ -54,11 +54,15 @@ describe('encodeStarCatalog / decodeStarCatalog', () => {
|
||||
});
|
||||
|
||||
it('keeps the index free of anything that is not a string, since the numbers are elsewhere', () => {
|
||||
expect(Object.keys(encoded.index).sort()).toEqual(['count', 'names', 'spectralTypes']);
|
||||
expect(encoded.index.count).toBe(STARS.length);
|
||||
expect(encoded.index.names).toEqual(STARS.map((star) => star.name));
|
||||
});
|
||||
|
||||
it('writes no per-star source column when every star came from the same place', () => {
|
||||
// It would be a couple of hundred kilobytes to say nothing.
|
||||
expect(encoded.index.sourceIndices).toEqual([]);
|
||||
});
|
||||
|
||||
it('is smaller than the array of objects it replaced', () => {
|
||||
// The whole reason for the format: the old encoding repeated eight key names per star.
|
||||
const asObjects = JSON.stringify(STARS).length;
|
||||
@@ -91,3 +95,40 @@ describe('encodeStarCatalog / decodeStarCatalog', () => {
|
||||
expect(round[4999].id).toBe(4999);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('star catalogue provenance and derived names', () => {
|
||||
const MIXED: StarRecord[] = [
|
||||
{ id: 5, name: 'Sirius', x: 1, y: 0, z: 0, magnitude: -1.4, spectralType: 'A0', colorIndex: 0.0, source: 'hyg' },
|
||||
// A survey star with no name of its own: what it is called is its catalogue designation.
|
||||
{ id: 900, name: 'Gaia DR3 900', x: 0, y: 2, z: 0, magnitude: 11, spectralType: 'Unknown', colorIndex: 1.2, source: 'gaia' },
|
||||
{ id: 901, name: 'Gaia DR3 901', x: 0, y: 0, z: 3, magnitude: 11.5, spectralType: 'Unknown', colorIndex: 1.3, source: 'gaia' }
|
||||
];
|
||||
|
||||
const encoded = encodeStarCatalog(MIXED);
|
||||
const decoded = decodeStarCatalog(encoded.index, encoded.positions, encoded.meta);
|
||||
|
||||
it('stores nothing for a name that is just the catalogue designation', () => {
|
||||
// 25 bytes per star, per million stars, to repeat what two adjacent fields already say.
|
||||
expect(encoded.index.names).toEqual(['Sirius', '', '']);
|
||||
});
|
||||
|
||||
it('regenerates those names exactly on the way back', () => {
|
||||
expect(decoded.map((star) => star.name)).toEqual(['Sirius', 'Gaia DR3 900', 'Gaia DR3 901']);
|
||||
});
|
||||
|
||||
it('carries each star provenance through', () => {
|
||||
expect(decoded.map((star) => star.source)).toEqual(['hyg', 'gaia', 'gaia']);
|
||||
});
|
||||
|
||||
it('writes the source column only once the stars differ', () => {
|
||||
expect(encoded.index.sources.map((source) => source.id)).toEqual(['hyg', 'gaia']);
|
||||
expect(encoded.index.sourceIndices).toEqual([0, 1, 1]);
|
||||
});
|
||||
|
||||
it('keeps a real name even when the star has a source that could generate one', () => {
|
||||
const named = encodeStarCatalog([{ ...MIXED[1], name: 'Some Proper Name' }]);
|
||||
expect(named.index.names).toEqual(['Some Proper Name']);
|
||||
expect(decodeStarCatalog(named.index, named.positions, named.meta)[0].name).toBe('Some Proper Name');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -37,12 +37,42 @@ export const BYTES_PER_STAR_META =
|
||||
/** `stars-index.json`: everything that is a string, plus the count the columns are sized by. */
|
||||
export interface StarCatalogIndex {
|
||||
count: number;
|
||||
/** One per star, in catalogue order. */
|
||||
/**
|
||||
* One per star, in catalogue order — but empty where the name is simply the star's catalogue
|
||||
* designation, which is regenerated on load from the source and the id.
|
||||
*
|
||||
* A survey-scale catalogue has no proper names to speak of. Gaia's designations are its
|
||||
* 19-digit source ids, so writing "Gaia DR3 4472832130942575872" once per star would cost
|
||||
* 25 MB per million stars — more than the whole rest of the catalogue — to store a string that
|
||||
* is already implied by two fields next to it. An empty entry costs three bytes.
|
||||
*
|
||||
* Dense with holes rather than a list of pairs, because which one is smaller depends entirely
|
||||
* on the catalogue: every HYG star has a designation worth keeping, and paying an index per
|
||||
* entry to say so would be 60% larger than just writing them in order.
|
||||
*/
|
||||
names: string[];
|
||||
/** Distinct spectral classifications; the meta column holds indices into this. */
|
||||
spectralTypes: string[];
|
||||
/**
|
||||
* Distinct source ids, in the same dictionary form as the spectral types, plus the designation
|
||||
* prefix each one names its unnamed stars with.
|
||||
*/
|
||||
sources: { id: string; designationPrefix: string }[];
|
||||
/**
|
||||
* One per star: an index into `sources`. Empty when every star came from the same place, which
|
||||
* would otherwise cost a couple of hundred kilobytes to say nothing.
|
||||
*/
|
||||
sourceIndices: number[];
|
||||
}
|
||||
|
||||
/**
|
||||
* How a source names a star that has no name of its own. `Gaia DR3 <id>` for Gaia; HYG's own
|
||||
* fallbacks already produce real designations, so it never needs this.
|
||||
*/
|
||||
const DESIGNATION_PREFIXES: Readonly<Record<string, string>> = {
|
||||
gaia: 'Gaia DR3'
|
||||
};
|
||||
|
||||
interface StarMetaColumns {
|
||||
ids: Int32Array;
|
||||
magnitudes: Float32Array;
|
||||
@@ -85,13 +115,29 @@ export function encodeStarCatalog(stars: readonly StarRecord[]): {
|
||||
const spectralTypes: string[] = [];
|
||||
const spectralTypeIds = new Map<string, number>();
|
||||
const names: string[] = [];
|
||||
const sources: { id: string; designationPrefix: string }[] = [];
|
||||
const sourceIds = new Map<string, number>();
|
||||
const sourceIndices: number[] = [];
|
||||
|
||||
stars.forEach((star, index) => {
|
||||
positions[index * 3] = star.x;
|
||||
positions[index * 3 + 1] = star.y;
|
||||
positions[index * 3 + 2] = star.z;
|
||||
|
||||
names.push(star.name);
|
||||
let sourceIndex = -1;
|
||||
if (star.source !== undefined) {
|
||||
const known = sourceIds.get(star.source);
|
||||
if (known === undefined) {
|
||||
sourceIndex = sources.push({ id: star.source, designationPrefix: DESIGNATION_PREFIXES[star.source] ?? star.source }) - 1;
|
||||
sourceIds.set(star.source, sourceIndex);
|
||||
} else {
|
||||
sourceIndex = known;
|
||||
}
|
||||
}
|
||||
sourceIndices.push(sourceIndex);
|
||||
|
||||
// Left empty when it is simply the designation the source would generate anyway.
|
||||
names.push(star.name === designationFor(sources[sourceIndex]?.designationPrefix, star.id) ? '' : star.name);
|
||||
|
||||
let spectralTypeId = spectralTypeIds.get(star.spectralType);
|
||||
if (spectralTypeId === undefined) {
|
||||
@@ -105,7 +151,14 @@ export function encodeStarCatalog(stars: readonly StarRecord[]): {
|
||||
columns.spectralTypeIndices[index] = spectralTypeId;
|
||||
});
|
||||
|
||||
return { index: { count, names, spectralTypes }, positions, meta };
|
||||
// A per-star column is only worth writing when the stars actually differ.
|
||||
const mixedSources = sources.length > 1;
|
||||
return { index: { count, names, spectralTypes, sources, sourceIndices: mixedSources ? sourceIndices : [] }, positions, meta };
|
||||
}
|
||||
|
||||
/** The name a source gives a star it has no other name for. */
|
||||
function designationFor(prefix: string | undefined, id: number): string | undefined {
|
||||
return prefix === undefined ? undefined : `${prefix} ${id}`;
|
||||
}
|
||||
|
||||
/** Rebuilds the star records the app works with from the three loaded assets. */
|
||||
@@ -115,15 +168,20 @@ export function decodeStarCatalog(index: StarCatalogIndex, positions: Float32Arr
|
||||
|
||||
for (let i = 0; i < index.count; i++) {
|
||||
const colorIndex = columns.colorIndices[i];
|
||||
const id = columns.ids[i];
|
||||
const sourceIndex = index.sourceIndices.length > 0 ? index.sourceIndices[i] : index.sources.length === 1 ? 0 : -1;
|
||||
const source = index.sources[sourceIndex];
|
||||
|
||||
stars[i] = {
|
||||
id: columns.ids[i],
|
||||
name: index.names[i],
|
||||
id,
|
||||
name: index.names[i] || designationFor(source?.designationPrefix, id) || `HYG ${id}`,
|
||||
x: positions[i * 3],
|
||||
y: positions[i * 3 + 1],
|
||||
z: positions[i * 3 + 2],
|
||||
magnitude: columns.magnitudes[i],
|
||||
spectralType: index.spectralTypes[columns.spectralTypeIndices[i]],
|
||||
colorIndex: Number.isNaN(colorIndex) ? null : colorIndex
|
||||
colorIndex: Number.isNaN(colorIndex) ? null : colorIndex,
|
||||
...(source ? { source: source.id } : {})
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,12 @@ export interface StarRecord {
|
||||
* `colorIndexToRgb`.
|
||||
*/
|
||||
colorIndex: number | null;
|
||||
/**
|
||||
* Which catalogue this star's position came from, once more than one contributes. Absent for a
|
||||
* single-source build; see `star-merge.ts`, where overlapping catalogues are reconciled and
|
||||
* the better-measured parallax wins.
|
||||
*/
|
||||
source?: string;
|
||||
}
|
||||
|
||||
/** HYG id used for the Sun itself, so solar-system bodies can reference their host star. */
|
||||
|
||||
Reference in New Issue
Block a user