diff --git a/src/app/shared/astro/star-merge.spec.ts b/src/app/shared/astro/star-merge.spec.ts index 3858bcd..16ac695 100644 --- a/src/app/shared/astro/star-merge.spec.ts +++ b/src/app/shared/astro/star-merge.spec.ts @@ -192,6 +192,15 @@ describe('mergeStarCatalogues', () => { expect(merged).toMatchObject({ magnitude: 11.01, magnitudeBand: 'V', colorIndex: 1.807, colorSystem: 'B-V', distanceError: 0.000065, distanceFromGaia: true }); }); + it("keeps Gaia's colour where the description has none", () => { + // HD 45951: HYG gives V 6.20 and K2III but no B−V; Gaia DR3 3369454521490604416 has BP−RP 1.248. + const hyg = at(119622, 97.79164, 16.93863, 112, { name: 'HD 45951', magnitude: 6.2, magnitudeBand: 'V', spectralType: 'K2III', colorIndex: null }); + const gaia = at(1000004369, 97.79164, 16.93863, 112, { name: 'Gaia DR3 3369454521490604416', magnitude: 5.898, magnitudeBand: 'G', colorIndex: 1.248, colorSystem: 'BP-RP', source: 'gaia' }); + const [merged] = mergeStarCatalogues([{ ...HIPPARCOS, stars: [hyg] }, { ...GAIA, stars: [gaia] }]).stars; + + expect(merged).toMatchObject({ name: 'HD 45951', magnitude: 6.2, magnitudeBand: 'V', colorIndex: 1.248, colorSystem: 'BP-RP' }); + }); + it("takes a Hipparcos distance more precise than the Gaia entry it folds into, along Gaia's direction", () => { // Schedar: 71.0 pc ±3.5 % in Gaia, which saturates on it, and 70.0 pc ±1.0 % in Hipparcos. const hyg = at(3179, 10.1268, 56.5373, 70.0, { name: 'Schedar', magnitude: 2.24, distanceError: 0.0105, distanceFromGaia: false }); @@ -366,6 +375,8 @@ describe('foldByIdentity', () => { expect(stars).toHaveLength(1); expect(stars[0]).toMatchObject({ id: 119589, name: 'Gl 905.2B', spectralType: 'DA4', magnitude: 12.9, colorIndex: 0.15, source: 'gaia' }); expect(Math.hypot(stars[0].x, stars[0].y, stars[0].z)).toBeCloseTo(18.6, 9); + // Nor the M5's B−V where the row has no colour of its own (Gl 225.2C, beside HD 40887's). + expect(foldByIdentity([...merged, { ...gl905b, colorIndex: null }], identities).stars[0].colorIndex).toBeNull(); }); it('leaves a star with a Hipparcos error alone, and one of another brightness than the HYG star already there', () => { diff --git a/src/app/shared/astro/star-merge.ts b/src/app/shared/astro/star-merge.ts index bcbe699..2c0ee01 100644 --- a/src/app/shared/astro/star-merge.ts +++ b/src/app/shared/astro/star-merge.ts @@ -262,14 +262,21 @@ export function isSameStar(kept: StarRecord, entry: StarRecord): boolean { * unless the other entry's distance is the more precise, as the Hipparcos one of a bright star * `placementDistancePc` keeps at it is, which then sets the distance along Gaia's direction. * `described` overrides that choice where an identity settles it (see {@link foldByIdentity}). + * + * A colour the description lacks comes from the other entry, in its own system: HYG has none for + * HD 45951, HD 45291 and HD 124953, three naked-eye giants Gaia measures at BP−RP 1.25, 1.19 and + * 0.37, and each card showed no colour at all. */ function combine(kept: StarRecord, other: StarRecord, described = isDesignation(kept) && !isDesignation(other) ? other : kept): StarRecord { const otherBetter = other.distanceError !== undefined && kept.distanceError !== undefined && other.distanceError < kept.distanceError; const placed = otherBetter ? other : kept; const scale = otherBetter ? distanceOf(other) / distanceOf(kept) : 1; const gaiaDesignation = kept.gaiaDesignation ?? other.gaiaDesignation; + const coloured = described.colorIndex !== null ? described : described === kept ? other : kept; return { ...described, + colorIndex: coloured.colorIndex, + colorSystem: coloured.colorSystem, x: kept.x * scale, y: kept.y * scale, z: kept.z * scale, @@ -339,9 +346,10 @@ export function foldByIdentity(stars: readonly StarRecord[], gaiaDesignationById } const describer = gaiaDesignationById.get(result[target].id); const { magnitude, magnitudeBand, colorIndex, colorSystem } = result[target]; + // Where the Gliese row is the star, its colour too, or none: not the one of the star SIMBAD puts elsewhere. result[target] = describer !== undefined && describer !== designation - ? combine(result[target], star, star) + ? { ...combine(result[target], star, star), colorIndex: star.colorIndex, colorSystem: star.colorSystem } : { ...combine(result[target], star), magnitude, magnitudeBand, colorIndex, colorSystem }; // One star each: a second Gliese row naming the same source is another star SIMBAD has not split. byDesignation.delete(designation!); diff --git a/src/assets/data/stars-meta.bin b/src/assets/data/stars-meta.bin index a8bea5a..5e04ad6 100644 Binary files a/src/assets/data/stars-meta.bin and b/src/assets/data/stars-meta.bin differ