Skip to content

src/core/exportScript.js ​

Text exports of a session (docs/FORMAT.md): a Python script that reproduces the analysis with the exoplanet-science-lab package (python/, import name esl), a Markdown report, and LaTeX tables. Pure functions of the session: no DOM, no I/O. The application offers the strings as downloads.

The Python package runs this same JavaScript core (bundled by tools/build_core_bundle.mjs), so a script written here gives the numbers the browser gave. Measured between Node 22 (V8 12.4) and the package's default runtime (V8 14.4): the same number of likelihood calls and posterior medians equal to 1e-15 relative; the last digits differ because the engines' Math functions do. Another engine family may round differently enough to change the sampler's path, and then the agreement is within sampling noise.

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

describeKey ​

js
function describeKey(key, session)
text
Label and unit of a parameter key ("per@c" -> "P (c)", "jit@rv2" -> "jitter (rv2)"), from the registry of model.js.

formatValue ​

js
function formatValue(median, plus, minus)

"111.436807 +0.000071 −0.000070" pieces for a value with asymmetric errors.

dataSummary ​

js
function dataSummary(session)

Rows describing the data of a session: [{ kind, name, n, from, to, medianErr, unit }].

pyLiteral ​

js
function pyLiteral(x, indent = '', width = 100)

A Python literal for JSON-like data.

pythonScriptFor ​

js
function pythonScriptFor(session, opts = {})
text
A standalone, commented Python script that rebuilds the session with the package's classes (so every value,
prior and setting is a line that can be edited), runs it, compares with the result stored in the session
when there is one, and draws the figures.
opts: { embedData = true: the data arrays are written into the script; false: they are read from `sessionFile`,
        sessionFile = 'session.json', figures = true, prefix = file-name prefix of the figures }

markdownReportFor ​

js
function markdownReportFor(session, opts = {})
text
A Markdown report: system, data, priors, sampler, results (fitted and derived parameters), warnings,
software version and how to reproduce the analysis with the Python package.
opts: { sessionFile = 'session.json' } named in the reproduction recipe.

latexTablesFor ​

js
function latexTablesFor(session)

Two LaTeX tables (plain table / tabular): fitted and derived parameters, and the priors. Returns one string.

MIT licensed · Kyle A. Pearson