Give a luminosity below a hundredth of the Sun's two figures, so Proxima reads 0.0015 L☉ not 0.002

formatLuminosity printed three decimals from a thousandth to 1 L☉, which leaves one figure below
a hundredth. d94451e put the archive's own luminosity on the card, and Proxima's 1.51×10⁻³ L☉
(st_lum −2.821 ± 0.02 dex) read 0.002, 32 % over and six times the archive's error bar, while
8.9×10⁻⁴ just below the cut kept its two figures. Below 0.01 it is now two significant figures.

Over the 4 440 hosts exoplanets.json gives a luminosity for: 23 printed more than 10 % off it and
43 more than 5 % before (worst 32.5 %); none more than 5 % after (worst 4.4 %). In the app on
:4302, Proxima's card reads "Luminosity 0.0015 L☉".

Tests: quantity.spec now expects 0.0017 → "0.0017 L☉" and Proxima's figure → "0.0015 L☉", and
keeps 0.0523 and 0.523 at three decimals; star-readouts.spec and the scene spec now expect
"0.0015 L☉" where they pinned "0.002". Controls: three decimals below a hundredth, and two figures
reaching up to 1, each fail the named test.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-30 00:04:47 +02:00
co-authored by Claude Opus 5.5
parent 95ffb009a2
commit 8f99335bae
4 changed files with 14 additions and 5 deletions
@@ -1010,7 +1010,7 @@ describe('GalaxySystemSceneComponent camera-flight transitions', () => {
expectColour(scene.starTint.value, blackbodyColor(2900)); expectColour(scene.starTint.value, blackbodyColor(2900));
const light = scene.systemRenderer.object.children.find((child): child is THREE.PointLight => child instanceof THREE.PointLight)!; const light = scene.systemRenderer.object.children.find((child): child is THREE.PointLight => child instanceof THREE.PointLight)!;
expectColour(light.color, blackbodyColor(2900, SOLAR_EFFECTIVE_TEMPERATURE_K)); expectColour(light.color, blackbodyColor(2900, SOLAR_EFFECTIVE_TEMPERATURE_K));
expect(scene.hudReadouts().find((readout) => readout.label === 'Luminosity')).toEqual({ label: 'Luminosity', value: '0.002 L☉' }); expect(scene.hudReadouts().find((readout) => readout.label === 'Luminosity')).toEqual({ label: 'Luminosity', value: '0.0015 L☉' });
expect(scene.hudReadouts().find((readout) => readout.label === 'Radius')?.value).toBe('0.141 solar radii'); expect(scene.hudReadouts().find((readout) => readout.label === 'Radius')?.value).toBe('0.141 solar radii');
}); });
@@ -96,7 +96,7 @@ describe('starReadouts', () => {
it('marks a derived luminosity so, and a published one not', () => { it('marks a derived luminosity so, and a published one not', () => {
const surface = { radiusSolar: null, radiusDerived: true, temperatureK: null }; const surface = { radiusSolar: null, radiusDerived: true, temperatureK: null };
expect(starReadouts(HYG_STAR, { ...surface, luminositySolar: 25.4, luminosityDerived: true }).find((readout) => readout.label === 'Luminosity')).toEqual({ label: 'Luminosity', value: '25.40 L☉', derived: true }); expect(starReadouts(HYG_STAR, { ...surface, luminositySolar: 25.4, luminosityDerived: true }).find((readout) => readout.label === 'Luminosity')).toEqual({ label: 'Luminosity', value: '25.40 L☉', derived: true });
expect(starReadouts(PLACED_BY_GAIA, { ...surface, luminositySolar: 0.00151, luminosityDerived: false }).find((readout) => readout.label === 'Luminosity')).toEqual({ label: 'Luminosity', value: '0.002 L☉' }); expect(starReadouts(PLACED_BY_GAIA, { ...surface, luminositySolar: 0.00151, luminosityDerived: false }).find((readout) => readout.label === 'Luminosity')).toEqual({ label: 'Luminosity', value: '0.0015 L☉' });
expect(starReadouts(HYG_STAR, { ...surface, luminositySolar: null, luminosityDerived: true }).some((readout) => readout.label === 'Luminosity')).toBe(false); expect(starReadouts(HYG_STAR, { ...surface, luminositySolar: null, luminosityDerived: true }).some((readout) => readout.label === 'Luminosity')).toBe(false);
}); });
}); });
+5 -1
View File
@@ -103,7 +103,11 @@ describe('formatTemperature and formatDensity', () => {
describe('formatLuminosity', () => { describe('formatLuminosity', () => {
it('stays decimal across the ordinary range', () => { it('stays decimal across the ordinary range', () => {
expect(formatLuminosity(1)).toBe('1.00 L☉'); expect(formatLuminosity(1)).toBe('1.00 L☉');
expect(formatLuminosity(0.0017)).toBe('0.002 L☉'); expect(formatLuminosity(0.0017)).toBe('0.0017 L☉');
// Proxima's archive figure, which three decimals read as 0.002, a third over.
expect(formatLuminosity(0.0015100106)).toBe('0.0015 L☉');
expect(formatLuminosity(0.0523)).toBe('0.052 L☉');
expect(formatLuminosity(0.523)).toBe('0.523 L☉');
}); });
it('goes to powers of ten at the extremes', () => { it('goes to powers of ten at the extremes', () => {
+7 -2
View File
@@ -96,13 +96,18 @@ export function formatDensity(gramsPerCm3: number): string {
return `${gramsPerCm3.toFixed(2)} g/cm³`; return `${gramsPerCm3.toFixed(2)} g/cm³`;
} }
/** Bolometric luminosity in solar units, which spans many orders of magnitude. */ /**
* Bolometric luminosity in solar units, which spans many orders of magnitude. Two figures below a
* hundredth, as in the ×10ⁿ form below a thousandth: three decimals left one there, and Proxima's
* archive luminosity, 1.51×10⁻³ L☉, read 0.002, a third over; 23 of the 4 440 hosts the archive
* gives one for read more than 10 % off it.
*/
export function formatLuminosity(solar: number): string { export function formatLuminosity(solar: number): string {
if (solar >= 1000 || (solar > 0 && solar < 0.001)) { if (solar >= 1000 || (solar > 0 && solar < 0.001)) {
const exponent = Math.floor(Math.log10(solar)); const exponent = Math.floor(Math.log10(solar));
return `${(solar / Math.pow(10, exponent)).toFixed(1)}×10${superscript(exponent)} L☉`; return `${(solar / Math.pow(10, exponent)).toFixed(1)}×10${superscript(exponent)} L☉`;
} }
return `${solar.toFixed(solar < 1 ? 3 : 2)} L☉`; return `${solar < 0.01 ? solar.toPrecision(2) : solar.toFixed(solar < 1 ? 3 : 2)} L☉`;
} }
function superscript(value: number): string { function superscript(value: number): string {