src/core/pyentry.js
The core as a service: what the Python package (python/esl) calls. No DOM, no Node API.
tools/build_core_bundle.mjs bundles every module of src/core with this file into one script,
python/esl/_core/esl_core.js, which defines globalThis.ESL = createApi(...). Python (an embedded V8, QuickJS or
a Node subprocess) then talks to it in JSON:
ESL.call(name, argsJson) -> '{"ok": value}' | '{"error": message}' synchronous functions (`api` below)
ESL.start(name, argsJson) -> job id asynchronous ones (`jobs` below)
ESL.poll(id) -> '{"done", "progress": [...], "requests": [...], "result" | "error"}'
ESL.stop(id), ESL.resolve(requestId, json), ESL.reject(requestId, message)
ESL.invoke via call('invoke', [path, args]) reaches ANY export of ANY core module ("kepler.eventTimes"),
so a function added to the core is callable from Python after a rebuild, with no change here.
The sampler loop runs here, inside one job (runSession -> runFit -> MiniNest); Python only polls. A job that
needs a file (the catalogue) asks for it through `requests`, and the host answers with resolve().
Numbers cross as JSON text. JSON.stringify writes the shortest decimal that reads back to the same double and
Python's json does the same, so values are bit-identical on both sides; NaN and infinities arrive as null.
Also here, because specFromSession leaves them to the application: limb darkening that follows the star
(the equivalent of tieSpec / syncStarLD / gridFor in src/main.js), as pure functions of a session.Import: import { … } from './src/core/pyentry.js' — no DOM, runs in Node and the browser.
plain
function plain(x, depth = 0, seen = new Set()Anything -> plain JSON-able data: typed arrays become arrays, Maps objects, functions and cycles are dropped.ldSourceFor
function ldSourceFor(session, tables, law = lawOf((session.limb_darkening || {})Where a session's limb darkening coefficients come from when they follow the star.
tables = { ld: the expanded 37-band table or null, spectral: the expanded wavelength-resolved table or null }
Returns { law, band (name), range: [nm, nm], custom: bool, grid (or null: grey atmosphere), filter, source: 'table' | 'spectral' | 'grey' }.ldFromStar
function ldFromStar(src, star)Coefficients a star implies: { coeffs, source, clamped, rms? }. star = { teff, logg, feh }.followsStar
const followsStarTrue when a session's coefficients follow the star.
prepareSession
function prepareSession(session, tables)A session ready for specFromSession: the law name normalised and, in "star" mode, the coefficients set to what the star implies (they are not parameters there). Returns the same object when nothing changes.
ldTieForSession
function ldTieForSession(session, tables, free = session.fit.free)The ldTie entry of a fit specification for a session in "star" mode, or null. free is session.fit.free (the range tabulated is the prior of teff and feh when they are free, a point otherwise), as tieSpec in main.js.
unregisteredFree
function unregisteredFree(session)Free parameters of a session that the parameter registry of model.js does not know. A model that is in the core but not yet read by specFromSession / buildProblem (phase curves, moons, ...) shows up here: such a parameter is sampled, but if the likelihood does not read it its posterior is just its prior.
createApi
function createApi({ modules, tables = {}, stamp = {} })modules: { name: module namespace } for every file of src/core; tables: { ld }; stamp: { version, commit, sourceHash, ... }.