Skip to content

src/core/ldest.js ​

text
Limb darkening coefficients from stellar parameters.

EXOTIC gets these from PHOENIX model atmospheres through LDTK, which needs
a download of several GB that a web page cannot make. Two routes are offered:

1. LD grids: a table of coefficients on (Teff, logg, [Fe/H]), interpolated
   trilinearly. The app bundles one (src/data/ld_table.js, built from PHOENIX
   specific intensities by tools/build_ld_table.py and checked against
   ExoTETHyS in test/limbdark.test.mjs); a user can load another (Claret's
   tables, LDTK or ExoTETHyS exports). Outside the table the nearest edge is
   used and the result is flagged `clamped`.
2. greyProfile(): the emergent intensity of a grey atmosphere in radiative
   equilibrium, I_lambda(mu) = int B_lambda(T(tau)) exp(-tau/mu) dtau/mu, with
   T^4 = 3/4 Teff^4 (tau + q(tau)), averaged over the bandpass. It captures the
   two dominant trends (stronger darkening for cooler stars and bluer bands)
   from Teff and wavelength alone. It has no line blanketing and no opacity
   physics, so it cannot respond to log g or [Fe/H]. With the table bundled it
   is only needed for a band the table does not hold (a custom wavelength
   range) or when no table is loaded.

fitLaw() is the port of the coefficient fit in EXOTIC's gael_ld.py: a
least-squares fit of the chosen law to I(mu), without the constraint that
forces the limb intensity to zero.

Import: import { … } from './src/core/ldest.js' — no DOM, runs in Node and the browser.

FILTERS ​

js
const FILTERS

Band edges in nm. The first block is EXOTIC's filter table (api/filters.py). The keys are also the filter names of the bundled table (tools/build_ld_table.py uses the same list), so a band picked here selects its table column by name. For the grey fallback only the edges matter; the table uses a measured response curve where one was available (see bands[name].passband on the expanded table).

greyProfile ​

js
function greyProfile(teff, wlMin, wlMax, { nmu = 60, eddington = false } = {})

Band-averaged I(mu)/I(1) for a grey atmosphere. Returns { mu, I }.

fitLaw ​

js
function fitLaw(law, prof)

Least-squares coefficients of law for a profile { mu, I }. Returns { coeffs, rms }.

parseLDGrid ​

js
function parseLDGrid(text)

Parse a table with a header row. Needs columns named teff, logg and feh (or mh / [fe/h] / z); an optional filter/band column; every other numeric column is treated as a coefficient, in file order.

interpLDGrid ​

js
function interpLDGrid(grid, teff, logg, feh, filter = '')

Trilinear interpolation on a rectilinear grid. Outside the grid each coordinate is clamped to the nearest edge and clamped is true. Where a cell lacks a corner, one coordinate is clamped to a bracketing node that completes it (also clamped); only if that fails is the nearest node returned. The filter name is matched exactly, then case-insensitively; a grid with one filter ignores it.

gridFromTable ​

js
function gridFromTable(table, law)

A JSON table carries linear, quadratic and nonlinear coefficients per node. Returns a grid in the shape interpLDGrid() expects for the requested law. Laws the table does not hold (kipping, sqrt) are obtained from its nonlinear profile, so every law describes the same star. The grid for a (table, law) pair is built once and reused; treat it as read-only.

expandLDTable ​

js
function expandLDTable(t)
text
Expand the compact table written by tools/build_ld_table.py (format 'esl-ld-compact-1': per filter
the four Claret coefficients on a rectilinear Teff x log g x [Fe/H] grid, as integers in units of the
filter's `scale`, either a plain array `a` or base64 little-endian int16 `a16`) into the row format
gridFromTable() reads. The linear and quadratic coefficients are least-squares fits to the stored
four-coefficient profile on `nmu` points between mu = 1 and mu_min (the range the builder fitted),
evenly spaced in radius when `sampling` is 'r' (the bundled table; this is ExoTETHyS's choice and
suits transits better than even spacing in mu), else evenly spaced in mu. The fits are constrained
to profiles that stay non-negative and do not brighten toward the limb (see physicalFromClaret);
for most nodes that changes nothing. The same points (`muFit`) and the same constraint are used by
gridFromTable() for the square-root law, so every law of a table is fitted alike.
Besides `rows` the result has `axes` { teff, logg, feh } and `bands` { name: { band, passband, dataset } }.

readLDTable ​

js
function readLDTable(text)

Recognise either table format from file text. Returns { kind: 'json', table } or { kind: 'csv', grid }.

makeLDTie ​

js
function makeLDTie(tie)
text
Build a fast (Teff, [Fe/H]) -> coefficients function for use inside the
likelihood, by tabulating the estimator on a small grid and interpolating.
tie = { law, source: 'grey' | 'grid', band: [nm, nm], grid, filter, logg, teffRange: [lo, hi], fehRange: [lo, hi] }

tabulatedTie ​

js
function tabulatedTie({ teff, feh, nc, tab })
text
The function a fit calls: (teff, feh, out) -> out, coefficients interpolated bilinearly in a table
{ teff: knots, feh: knots or null, nc, tab } with tab[(iTeff * nFeh + iFeh) * nc + k]. Knots need not be
evenly spaced; arguments outside them are clamped. It allocates nothing and costs about 10 ns a call:
the interval is found from an evenly spaced index (four cells per knot) and at most a few steps.

MIT licensed · Kyle A. Pearson