Package: display#

display draws. It takes a run that is already computed, or data that is already loaded, and writes PNG figures, HTML pages and the tables behind them. It never runs a solver and never writes into the storage of a run. It reads only core and results, and everything it reads from a run goes through subject.py.

A figure is a FigureRequest from request.py. It names a variable, a preset, a list of panels or a special figure. render.py expands it against PRESETS, draws each panel with a frame of frames/ (map, series, section, xy, distribution, groups, table, volume) and then the overlays of overlays.py. A special figure is a function of special/ for a case no frame expresses, and request.SPECIALS lists them.

output.py writes the files, stamps each PNG with the identity of the run and records the request in figures/index.json, so hmp export <run> --regen figures draws it again. A figure that cannot draw a run is refused with a sentence and never leaves a placeholder file. tests/ports/test_figure.py plays every preset and every drawable variable on the subjects of a frozen example.

The package page in the developer docs lists the modules and holds the import rules and where to add a frame, a variable or a preset.

Modules#

top level

Module

What it does

Lines

catalog_figures.py

List what can be drawn, draw again the figures of a run found through its project index.

184

cohort.py

Draw the cohort figures of a campaign summary: one PNG per figure and variable.

283

config.py

Pydantic schema for the [display] TOML section.

125

interactive.py

Interactive engine: the plotly template, the assembly of a figure and its HTML file.

176

output.py

Figure files: written through static.save, stamped with the run identity, entered in the ledger.

148

overlays.py

Named context layers drawn over a map or a section.

369

presets.py

Shipped presets: named figure requests whose panels list the holes a user fills.

106

render.py

The one door of the figures: a request and a subject in, a figure or its tables out.

482

request.py

Figure requests: what a figure shows, in the same words for TOML, the CLI and Python.

989

run_comparison.py

Figures of a comparison of sealed runs: their series and their maps against a reference.

83

runs.py

Figures of a run: draw requests at the end of a run, draw the recorded ones again.

313

static.py

Matplotlib template of the static figures: figure, axes, colorbar, legend and files.

462

subject.py

The reads a frame or an overlay makes of a subject.

619

theme.py

Publication theme: tokens, colour roles, ramps and the unit text helper.

313

variables.py

What a frame asks about a variable: its label, display unit, scale and ramp.

160

frames/

Module

What it does

Lines

distribution.py

Distribution frame: the values of one variable against how often they occur.

280

groups.py

Groups frame: named categories against a value, as bars or as boxes.

443

map.py

Map frame: one value per mesh cell, drawn as filled polygons in the mesh CRS.

491

section.py

Section frame: a vertical cut through the model along a line, distance against elevation.

445

series.py

Series frame: values along an ordered axis, the time of a run.

534

table.py

Table frame: rows of text, a label and a value for each column a panel names.

131

volume.py

Volume frame: the block of the model in 3D, coloured by one variable at one instant.

172

xy.py

XY frame: one variable against another, one point per matched row.

317

overview/

Module

What it does

Lines

config.py

Pydantic configuration for the data-overview report (display layer).

113

location.py

Where an overview writes: the run directory of the overview, like any producer.

62

panels.py

Panel rendering functions for the overview report.

741

report.py

Draw the panels of the data-overview report, one PNG per enabled panel.

580

summary.py

What the panels read: stats card, station table, outlet, titles.

148

quicklook/

Module

What it does

Lines

animation.py

Animation builders that stitch pre-rendered PNG frames together.

141

scalable.py

Scalable rasterization helpers for dense meshes and large 2D fields.

84

viz.py

The show dispatcher: one call that picks a plot for what Run.read returns.

178

report/

Module

What it does

Lines

engine.py

One report engine: blocks in, static HTML pages and report.json out.

490

pages.py

The blocks of the report pages: a sealed run, its data overview and a calibration session.

1 078

presets.py

The report presets and the text the caller gives to the engine.

155

special/

Module

What it does

Lines

calibration_landscape.py

Cost over the plane of each pair of searched parameters, one marker per trial.

106

calibration_progress.py

Cost of each trial of a calibration, the best so far and the trial the session returned.

112

ensemble_band.py

The 10 to 90 % band and the median of one series across the runs of a set, at one station.

73

flow_directions.py

Where each cell sends its water on the descent, drawn as binned arrows over the relief.

83

lake_abacus_comparison.py

Stage-volume and stage-area curves of a lake, as stored and as the simulation followed.

106

network_comparison.py

The mapped and the generated networks matched at the tolerance of the run.

85

observed_network_heads.py

The mapped network drawn from its heads, and how each head landed.

97

parameter_space.py

Two parameters of a run set on log axes, each run coloured by one score.

124

particle_tracks.py

Pathlines of the particle table in plan, coloured along their way by the age of the water.

131

recession.py

Recession rate against discharge on the Brutsaert-Nieber plane, at one station.

189

recharge_estimates.py

Yearly recharge of each method of [recharge_estimates], beside the run’s own.

66

recharge_regime.py

The mean year of each method: rain and ETP, recharge, runoff, month by month.

72

recharge_signals.py

Monthly rain and ETP, then the recharge and the runoff of each method, month by month.

87

records.py

Records of a run or a session that more than one special figure reads or marks.

143

residence_time_distribution.py

Survival function of the particle travel times against the exponential of the turnover time.

80

root_search.py

The distances of a root search against the parameter it searched, one point per evaluation.

185

sfr_longitudinal_profile.py

Streambed, stream stage and aquifer head along the main stem of the SFR network.

88

water_balance_loop.py

Monthly rain minus evapotranspiration against the gauged discharge, the storage loop.

74

Inside the package#

A render leaves nothing in the process. A figure is drawn on its own Agg canvas (new_figure and new_subplots in static.py), so no backend is switched, no figure sits in the pyplot registry and no rcParams is written. The Theme of theme.py carries the colours, the fonts and the dpi of one render, so two renders in two threads meet the style each asked for. pyplot is imported only by quicklook/viz.py and by the window [display] show opens.

Four rules hold for the user.

  • A figure shows a quantity and never tests a solver name, so the same figure works for MODFLOW-NWT, MODFLOW 6 and Boussinesq when the run holds the field.

  • A figure is refused with a sentence when the run lacks what it needs. A lumped run has no grid, so every map is refused and the discharge figures stay drawn.

  • An instant is a date. A figure is asked for it by time (a date, "first" or "last"), and a file that writes timestep is refused.

  • A figure has one name on every surface. A name of a pre-release figure is refused with the request that replaces it, from retired_figures.toml.

display never imports schema, so project/report.py gathers the texts and the pages of a report and hands display.report the texts and the Block objects. report/pages.py builds blocks from a sealed run, a data overview or a calibration session, and report/engine.py writes the HTML pages. The engine knows no run, so the overview and the session report use it too.

The import rules are in tests/unit/architecture/display_layout.yaml and the generated layers page. Outside the package, display imports only core and results, and calibration does not import display. Inside, only render.py names a frame or a special figure as text, by its key in request.FRAMES or request.SPECIALS. display draws a session or an unsealed run that project and workflow open, and opens neither. A read of a run that a figure needs goes in results, never in display. A panel of the overview is a boolean of OverviewPanelsConfig, its drawing function in overview/panels.py and its line in PANEL_FILES. A block of a report page is a function of report/pages.py, and its words are a field of ReportTexts.

The request path draws a figure from the name of a variable. request.py holds the request and its checks and imports no plotting library. subject.py is the only module that reads a run, variables.py converts to the display unit, and a frame of frames/ has a data that returns a table and a draw that puts it on one axes. render.py draws the overlays of overlays.py after the frame, and output.py writes the files and the ledger entry that hmp export --regen figures replays. The frames are map, series, section, xy, distribution, groups, table and volume. The interactive engine of interactive.py draws map, series and volume as plotly figures of up to 100 000 cells, and output.py writes them as HTML. Plotly is imported only when such a figure is drawn. A table column is a name of COLUMN_REGISTRY, and a session is drawn by series, xy and distribution from its trials.<column> names. A map panel that gives a run name to against subtracts that run, which render receives resolved. A frame lists the panel fields it reads in FIELDS and refuses the others by name through subject.refuse_fields, so a new panel field cannot be ignored without a test failing. The colour norm and the colours of a budget term are written once in variables.py, the scores of a run and the area of a zone once in frames/series.py. A new frame is a module of frames/ named as its key of request.FRAMES, and a new context layer is a key of request.OVERLAY_FIELDS with the function of the same name in overlays.py.

A special figure is a function draw(subject, ax, theme) that draws one axes for a case no frame expresses, such as a fit, a matching of two networks or the trace of a root search. It lives in a module of special/ that also holds SUBJECT (run, session or runset) and may hold WIDTH. The function may take the keywords station and time, and without them it reads the station the run scored. presets.py lists the modules, so each one is a preset named as its module, and render refuses a subject of another kind, except a run given to a session figure, which stands for the session that promoted it. special/records.py holds the reads that several of them share and draws nothing. The list is closed at twelve, and a thirteenth figure is a frame, a variable or a preset first.