Read an archive host's colour off the dwarf sequence at its temperature, and say it was not measured
For an archive-placed host with a temperature and no B magnitude, fetchExoplanets took B−V from Ballesteros' blackbody fit, which runs 0.1 to 0.2 redder than Pecaut & Mamajek's dwarf sequence below 3 800 K, and the luminosity then read its correction off that sequence at that colour: 3 500 K came back as 3 102 K with a correction 1.15 magnitudes too large, anything under about 3 170 K was clamped to B−V 2.00, and the card printed it as a measured "Colour B−V 2.00". CFBDSIR J145829+101343, a 580 K brown dwarf, read "Spectral type ~M6, from colour". temperatureToColorIndex now reads the table itself backwards, interpolating B−V between the two types the temperature falls between, so the temperature and correction read back off the colour are the table's at that temperature; it has no answer outside 2 420 to 31 400 K. The colour is flagged colorFromTemperature, a fifth bit in the photometry byte (the format, README and the ETL's round-trip check follow), and the card prints it "B−V 1.66, from its temperature", marked derived. From cache: 57 archive stars change colour; 54 carry the flag and 3, CFBDSIR J145829+101343 among them, now have none. For the 47 of them the archive gives a luminosity, the one derived from magnitude and colour moves from a median 0.228 dex off it to 0.124; Kepler-445 (3 157 K) from 0.0282 L☉ to 0.0080 against the archive's 0.0079. Its colour goes from 2.00 to 1.67. The card shows the archive's luminosity where it has one since earlier on this branch, so this is the figure used for the rest and for their radii. Controls, each failing its named test: the nearest hotter row taken without interpolating (2 of 803 failed), no refusal outside the table, the flag not encoded, and the card calling the colour measured (1 of 803 each). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -99,19 +99,22 @@ describe('spectralTypeToColorIndex', () => {
|
||||
});
|
||||
|
||||
describe('temperatureToColorIndex', () => {
|
||||
it("puts the Sun's temperature at its own B-V and a cool dwarf redder", () => {
|
||||
it("puts the Sun's temperature at its own B-V and a cool dwarf where the dwarf sequence has it", () => {
|
||||
expect(temperatureToColorIndex(5772)).toBeCloseTo(0.65, 2);
|
||||
expect(temperatureToColorIndex(3400)).toBeCloseTo(1.79, 2);
|
||||
// Two thirds of the way from M2 (3 560 K, B−V 1.505) to M2.5 (3 470 K, 1.522).
|
||||
expect(temperatureToColorIndex(3500)).toBeCloseTo(1.5163, 4);
|
||||
});
|
||||
|
||||
it('stays inside the range the spectral classes span', () => {
|
||||
expect(temperatureToColorIndex(2566)).toBe(2);
|
||||
expect(temperatureToColorIndex(50000)).toBe(-0.33);
|
||||
it('reads back as the temperature it came from, so the correction is the one at that temperature', () => {
|
||||
for (const temperatureK of [31400, 12000, 7000, 5772, 4000, 3500, 3157, 2566, 2420]) {
|
||||
expect(dwarfSequenceAtColor(temperatureToColorIndex(temperatureK))!.temperatureK).toBeCloseTo(temperatureK, 6);
|
||||
}
|
||||
});
|
||||
|
||||
it('has no answer for a temperature that is not one', () => {
|
||||
expect(temperatureToColorIndex(0)).toBeNull();
|
||||
expect(temperatureToColorIndex(Number.NaN)).toBeNull();
|
||||
it('has no answer outside the table, nor for a temperature that is not one', () => {
|
||||
for (const temperatureK of [580, 2419, 31401, 50000, 0, Number.NaN]) {
|
||||
expect(temperatureToColorIndex(temperatureK)).toBeNull();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -104,22 +104,23 @@ export function spectralTypeToColorIndex(spectralType: string | null | undefined
|
||||
|
||||
/**
|
||||
* B-V colour index for an effective temperature, for stars the Exoplanet Archive gives a
|
||||
* temperature but no B magnitude. Inverts Ballesteros (2012), T = 4600 K · (1 / (0.92 (B-V) +
|
||||
* 1.7) + 1 / (0.92 (B-V) + 0.62)), a blackbody fit good to a few per cent from A to early M: it
|
||||
* puts the Sun's 5 772 K at 0.65, which is the Sun's own. Clamped to the range the class anchors
|
||||
* above span, because the fit runs on past it — TRAPPIST-1's 2 566 K would come out at 2.7.
|
||||
* temperature but no B magnitude: the dwarf sequence below read the other way, interpolated
|
||||
* between the two types the temperature falls between, so that the correction and the temperature
|
||||
* read back off the colour are the table's at that temperature. Ballesteros' blackbody fit, used
|
||||
* before, runs 0.1 to 0.2 redder than the table below 3 800 K, and the colour it gave was read on
|
||||
* the table: 3 500 K came back as 3 102 K with a correction 1.15 magnitudes too large, and the 57
|
||||
* hosts placed this way were off the archive's own luminosity by 0.23 dex at the median. `null`
|
||||
* outside the table, 2 420 to 31 400 K, rather than a colour clamped to its end — CFBDSIR
|
||||
* J145829+101343, a 580 K brown dwarf, read as B−V 2.00 and "~M6".
|
||||
*/
|
||||
export function temperatureToColorIndex(temperatureK: number): number | null {
|
||||
if (!Number.isFinite(temperatureK) || temperatureK <= 0) {
|
||||
const [hottest, coolest] = [DWARF_SEQUENCE[0], DWARF_SEQUENCE[DWARF_SEQUENCE.length - 1]];
|
||||
if (!(temperatureK <= hottest[3] && temperatureK >= coolest[3])) {
|
||||
return null;
|
||||
}
|
||||
// With x = 0.92 (B-V) and k = T / 4600 the fit is k x² + (2.32 k - 2) x + (1.054 k - 2.32) = 0,
|
||||
// whose larger root is the physical one.
|
||||
const k = temperatureK / 4600;
|
||||
const b = 2.32 * k - 2;
|
||||
const c = 1.054 * k - 2.32;
|
||||
const x = (-b + Math.sqrt(b * b - 4 * k * c)) / (2 * k);
|
||||
return Math.min(BEYOND_M, Math.max(COLOR_INDEX_ANCHORS.O, x / 0.92));
|
||||
const cooler = Math.max(1, DWARF_SEQUENCE.findIndex((row) => row[3] <= temperatureK));
|
||||
const [hot, cool] = [DWARF_SEQUENCE[cooler - 1], DWARF_SEQUENCE[cooler]];
|
||||
return hot[1] + ((cool[1] - hot[1]) * (hot[3] - temperatureK)) / (hot[3] - cool[3]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user