Skip to content

lunartrace.workbench.figures

Deterministic publication Figures for a Workbench ROI.

A Figure is regenerated by Python from the exact numeric source and method rows; it is never a screenshot of an interactive view. Output bytes are deterministic for the same inputs (fixed SVG hash salt, no creation dates).

attribute

FigureKind

Figure kinds accepted by render.

attribute

FigureFormat

Output formats accepted by render.

attribute

KINDS

All supported figure kinds, in API order.

attribute

FORMATS

Map from figure format to its HTTP media type.

function

def histogram_xlim(
histograms: Sequence[npt.ArrayLike],
edges: Sequence[float],
) -> tuple[float, float]

Compute the deterministic slope-axis limit of the histogram figure.

NameTypeDescription
histogramssequence of array-likePer-tau slope histograms (included-cell counts per bin).
edgessequence of floatBin edges in degrees, one more than the number of bins.
  • tuple of float — (lower, upper) in degrees, with lower always 0.0.

Let kk be the last bin that is non-empty for any tau. The upper limit is

xmax⁡=min⁡(90, max⁡(5, 5⌈ek+1/5⌉)),x_{\max} = \min\bigl(90,\ \max\bigl(5,\ 5\lceil e_{k+1} / 5 \rceil\bigr)\bigr),

where ek+1e_{k+1} is the right edge of that bin. If every bin is empty the limit is (0.0, 90.0).

function

def render(
site: wroi.Site,
body: dict[str, object],
kind: FigureKind,
fmt: FigureFormat,
tau: float | None = None,
) -> bytes

Render one publication Figure from exact evaluation rows.

NameTypeDescription
sitelunartrace.workbench.roi.SiteThe Site; used only by the "map" kind to rebuild the ROI mask.
bodydictThe result of lunartrace.workbench.roi.evaluate_ring, which supplies the roi, rows, taus, provenance, status and admission fields.
kind('histogram', 'inclusion', 'map')Figure kind. Default "histogram".
fmt('svg', 'png', 'pdf')Output format. PNG is written at 200 dpi. Default "svg".
taufloatSlope-RMS cutoff in degrees for the "map" kind. Defaults to the first tau in body["taus"]. Ignored by the other kinds. Default None.
  • bytes — The encoded figure.
  • TypeError — If body lacks the expected structure: a required field is missing or is not a mapping or list as the figure needs. The checks are explicit, so they still run under python -O.

Output is deterministic for the same inputs. Creation dates and the generator software string are removed from the metadata, and the SVG hash salt is fixed. Each figure carries a stamp with the method id, status, admission, ROI and source witness, and states that valid-cell fraction is not lunar area. In the inclusion figure an undefined fraction (no jointly valid cells) is drawn as no bar and labelled as undefined, never as zero.