diff --git a/src/app/features/galaxy-system/star-readouts.spec.ts b/src/app/features/galaxy-system/star-readouts.spec.ts index e2f60ba..ddcf87f 100644 --- a/src/app/features/galaxy-system/star-readouts.spec.ts +++ b/src/app/features/galaxy-system/star-readouts.spec.ts @@ -130,6 +130,12 @@ describe('starSubtitle', () => { expect(starSubtitle(GAIA_STAR)).toBe('Spectral type ~K5, from colour'); }); + it('says an estimate came from the temperature where the colour was read off it', () => { + // PSR J1719-1438: no magnitude in any colour, st_teff 4 500 K, B−V 1.13 off the dwarf sequence. + const pulsar = { ...GAIA_STAR, source: 'exoplanet-archive', colorIndex: 1.128, colorSystem: 'B-V', colorFromTemperature: true } as const; + expect(starSubtitle(pulsar)).toBe('Spectral type ~K5, from its temperature'); + }); + it('prints nothing rather than "Unknown" when there is neither', () => { expect(starSubtitle({ ...GAIA_STAR, colorIndex: null, colorSystem: undefined })).toBe(''); }); diff --git a/src/app/features/galaxy-system/star-readouts.ts b/src/app/features/galaxy-system/star-readouts.ts index 0b39acb..a5725e5 100644 --- a/src/app/features/galaxy-system/star-readouts.ts +++ b/src/app/features/galaxy-system/star-readouts.ts @@ -21,11 +21,14 @@ export function describingCatalogue(star: StarRecord): string { /** * What the readout says a star is: the catalogue's classification, or — for the 83 % of stars * that have none, every Gaia star among them — the dwarf type its colour matches, marked as an - * estimate. Empty with neither, rather than the ETL's literal "Unknown". + * estimate. Empty with neither, rather than the ETL's literal "Unknown". Where the colour was itself + * read off the archive's temperature, the estimate says so: 30 archive hosts measured in no colour + * read "~X, from colour", PSR J1719-1438, a pulsar the archive gives 4 500 K, "~K5, from colour". */ export function starSubtitle(star: StarRecord): string { const classification = spectralClassification(star); - return !classification ? '' : `Spectral type ${classification}${classification.startsWith('~') ? ', from colour' : ''}`; + const basis = star.colorFromTemperature ? ', from its temperature' : ', from colour'; + return !classification ? '' : `Spectral type ${classification}${classification.startsWith('~') ? basis : ''}`; } /**