An open storm-and-grid instrument, taken apart
How LiveLines is built: one patch, six modules, a register for every number, and comparisons that are never tuned away
LiveLines asks one question: when this storm passes, which transmission lines are likely to fail, hour by hour, and how much of each substation’s load can the remaining grid still serve? The Maria article takes apart the physics of one such run. This one takes apart the instrument: how it is built so that every step can be opened, every number traced, and every comparison kept honest.
Built with AI coding tools: I set the direction, tested and decided; the tools wrote the code and the first draft of this article. The reference list was checked against Crossref, and what I say about each source against its abstract or an open copy.
One question, one chain
LiveLines runs one calculation in six modules: place, grid, storm, fragility, power flow and outcome. The kernel runs them in the order of their cables: the grid feeds the storm module, which needs to know where the lines are. Where only the power lines are known, as in most of the world from OpenStreetMap, the chain stops after fragility: it shows which lines break, not who loses supply. Where a full grid model exists, with plants and load, it runs to the end. Every result is labelled transmission level: the model stops at the substation, and the distribution lines beyond it, where storms do much of their damage, are not in it.
Figure 1 shows how the parts fit together.
Cables that check themselves
Modules do not call each other. Each one takes cables in and puts cables out: plain arrays with a fixed meaning and fixed units. The sample axis always comes first, power is in MW, positions are in degrees, hours count from the start of the storm’s window. Six cables carry everything: place, grid, wind, failures, flow and supply.
Each cable is a frozen dataclass that checks its own shapes and ranges when it is made, so a module cannot pass on something malformed. The cable that carries line failures, for example, refuses failure hours outside the window (and, in the lines cut here, repair hours before the failure) (from src/kritis/chain/contracts.py at commit b367912, shortened):
@dataclass(frozen=True)
class Failures:
"""Failure hour per (sample, line). ``n_hour`` means the line never fails.
…
"""
t_fail_hour: IntArray
n_hour: int
seed: int
t_repair_hour: IntArray | None = None
# …
def __post_init__(self) -> None:
_need(self.t_fail_hour.ndim == 2, "t_fail_hour: expected (sample, line)")
_need(self.t_fail_hour.dtype.kind in "iu", "t_fail_hour: expected integer hours")
lo, hi = 0, self.n_hour
ok = bool(np.all((self.t_fail_hour >= lo) & (self.t_fail_hour <= hi)))
_need(ok, f"t_fail_hour: values must lie in {lo}..{hi} (n_hour = never)")
# … the same checks for the repair hoursA failure hour equal to the window’s length means “never fails”. That one convention lets every later module treat “out” as a simple comparison of hours.
The same code, in the kernel and in the browser
The modules that do the arithmetic of the chain, storm, fragility, the DC power flow and outcome, are written in numpy and the standard library. That rule is what lets the same functions run in the kernel and in a visitor’s browser, through Pyodide, a build of Python for the browser (pinned to version 0.29.5 and loaded on first use). In the app, fragility, the DC power flow and outcome are the modules a visitor can edit and run in the browser; the storm module is browser-ready too, but the app takes the track and the wind from the kernel, where the track is built. A first test checks that the chain needs none of the heavy packages: it hides six of them and checks that the chain still imports (from tests/chain/test_contracts.py):
def test_chain_imports_without_heavy_packages() -> None:
code = (
"import sys\n"
"for m in ('geopandas', 'pyproj', 'pandas', 'pypsa', 'shapely', 'scipy'):\n"
" sys.modules[m] = None\n"
"import kritis.chain.contracts\n"
"import kritis.chain.powerflow_dc\n"
"import kritis.chain.geodesy\n"
"import kritis.chain.storm\n"
"import kritis.chain.fragility\n"
"import kritis.chain.outcome\n"
"print('ok')\n"
)
# … runs this in a fresh Python and asserts that it prints "ok"Setting a module to None in sys.modules makes any import of it fail, so if one chain module quietly started to use pandas, this test would break. Two stronger tests go further: one compares the kernel’s results with the browser chain’s bit for bit (tests/contracts/test_browser_golden.py), and one runs the chain in a real Pyodide (viewer/tests/browser_kernel.pyodide.test.ts).
Three other engines never reach the browser. PyPSA (Brown, Hörsch, and Schlachtberger 2018), with the HiGHS solver, is the only one the kernel imports, inside one adapter: it reads the grid files and solves the second power flow, an optimum with a perfect operator. CLIMADA (Aznar-Siguan and Bresch 2019), an open platform for weather and climate risk, computes a second wind field as a cross-check; it runs in its own environment, as a separate process, and the kernel never imports it. PyPSA-Earth (Parzen et al. 2023) builds the grid models for other parts of the world, offline, also as a separate program. The rule that follows: code a visitor edits runs in their browser, or in a notebook on their own machine.
One patch, three views
Everything a visitor chooses is one patch: a small JSON file with the modules, their knobs, the cables between them, a random seed, the number of samples, and any evidence values set for this run. The Maria showcase is one such patch (from patches/chain_maria_pr.json, shortened):
{
"schema_version": "rack_patch.v1",
"id": "chain.maria_pr",
"title": "Maria 2017 over Puerto Rico, PyPSA-Earth with the 2017 plants",
"seed": 42,
"n_samples": 8,
"nodes": [ … ],
"cables": [
{
"id": "c_grid_storm",
"cable_type": "grid",
"from_port": { "node": "grid_1", "port": "out" },
"to_port": { "node": "storm_1", "port": "grid" }
},
…
],
"refs": []
}The app shows the same patch at three depths. Steps puts the six modules as boxes over the map, with an hour slider. Rack shows every module with its cables, knobs and scopes, like a modular synthesiser. Code shows the chain as a live notebook (Marimo): change a setting in the notebook and the map follows, change it in the app and the notebook follows.
The same patch with the same seed gives the same numbers, bit for bit. A command-line run writes a result folder with a manifest (the patch, the code version, a hash of the evidence files, the seed, the data licences), and the same run on the same code and evidence writes byte-identical files. When the kernel runs a patch, it walks the modules in cable order and caches each module’s output under a hash of its inputs, its knobs and a fingerprint of the code and evidence, so a changed knob reruns only that module and the ones after it.
A home for every number
No physical or economic number is meant to be typed into the chain’s own code, and review checks that none is. Every one lives in a folder called evidence/, with its unit, its source and a status. For single values the status is sourced, placeholder, or one of two others described below. A placeholder is a question, not an answer, and the app marks every result that read one. Here is one entry, the threshold of the collapse rule that the Maria showcase discusses (from evidence/params.yaml, the long fields shortened):
powerflow.collapse_imbalance:
value: 0.25
unit: "1"
distribution: {kind: deterministic, params: {}}
source: "nerc_prc006: NERC PRC-006-5, Requirement R3. UFLS programs must meet … up to 25 percent …"
status: placeholder
note: "Used by powerflow_dc's collapse rule … Transferred: 25 % is the North American design basis, …"The value has a source and is still a placeholder, because it was transferred: a North American design rule applied to an island grid that is not bound by it. The note says so.
The kernel checks these files when it loads them: a value marked sourced without a source, a missing unit or an unknown field is an error, not a warning. And every module’s result carries a trace of the values it read, so the Rack can answer “why is this number what it is?” by pointing to the entry. At this commit, params.yaml holds 157 single values: 112 are marked placeholder and 33 sourced; two more are numerical settings chosen by benchmark against an exact computation, and ten freeze an earlier model so that its old results stay reproducible. That is the honest state of a young model.
Comparing, not tuning
LiveLines grades each module: placeholder, literature, or validated. Validated means checked against observations, with the result recorded and judged. None of the six modules is validated yet.
Two kinds of check are kept apart on purpose:
- Model against model. The numpy DC power flow against PyPSA on the same inputs; the kernel’s wind against CLIMADA’s on the same track. These are comparisons. They tell how much of an answer is the choice of model, not whether the answer is right.
- Model against observation. The Maria run against satellite night lights and the U.S. Department of Energy’s outage reports, recorded as comparison records. Only checks of this kind can lead to validated.
And a difference is never tuned away. It is investigated, explained if it can be, and written down. The Maria article shows what this looks like in practice: the model misses the island-wide blackout; the record says so, and a session note ranks the likely causes.
The caution has a long pedigree. Oreskes, Shrader-Frechette, and Belitz (1994) argue that numerical models of natural systems cannot be verified or validated in a strict sense, because such systems are never closed; agreement with observations confirms a model only in part. LiveLines uses “validated” in a narrower, practical sense, and keeps model-to-model agreement out of it.
When the middle hides the answer
One recent change shows why the records matter. With a collapse rule on, the eight samples of the Maria run split into two groups: some end with the island dark at transmission level (below 5 % of the load served), others keep about a third to a half of the load, and the median lies in one group only. So the outcome module now also counts how many samples end dark (from src/kritis/chain/outcome.py):
def samples_dark(share_end: np.ndarray, below: float) -> int:
"""How many samples end with a served share below ``below`` (strictly)."""
if not 0 <= below <= 1:
raise ValueError("samples_dark: below must be in [0, 1]")
return int(np.count_nonzero(np.asarray(share_end, dtype=float) < below))The threshold for “dark”, 5 %, is itself an entry in evidence/, marked placeholder: a reporting definition, not physics.
Starting from the place
Few people know storm names. So LiveLines starts from the place: which storms passed here, how strong were they here, how often does this happen, and which would hurt the lines most?
- A storm counts as near when its track came within 150 km. That radius is a setting for the list, not physics, and has no source yet.
- Each storm carries the Saffir–Simpson category of its peak wind over its whole life, a label for people, not the strength at the place. The model uses the wind itself.
- “Gust here” is the strongest modelled 3-second gust at the place, from the same wind code as the chain: a modelled value for sorting, not an observation.
- “How often here” counts storms per decade, and one sentence counts the storms that peaked at Category 3 or above since 1980. The start year and the category are settings without a source yet. It is a count, not a return period: the record is short and the climate changes.
- The ranking runs the chain up to fragility for every storm near the place, on today’s lines, and sorts by the line length that fails (the median over the samples). A storm from 1926 is run on the lines of today.
The storm tracks come from IBTrACS (Knapp et al. 2010); the wind at each line comes from the profile of Holland (1980).
How it is built
LiveLines is built the same way as this site: with AI coding tools, by an owner who sets the direction, tests and decides. Three habits carry most of the weight.
- Decisions are written down with their reasons, and the work of each session ends in a short note: what changed, what is unverified, what is next.
- Independent reviewers check a change before it counts as done: read-only reviews for the physics, for the provenance of every number and source, and for determinism (does the same patch still give the same numbers?).
- Licences come first. A grid model whose licence is not settled is used for internal research only. LiveLines has such a model for the Philippines; nothing from it is shown on this site.
What it cannot tell you
Transmission, not streets. A substation that keeps supply in the model can sit in an area that is dark.
Modelled, not observed. Gusts, failures and supply are modelled. Observations are kept apart and compared, never mixed in.
One curve for all lines. Every line uses one tower fragility curve fitted to one cyclone in India, applied per piece of line.
One wind model. One parametric profile, one surface factor and one gust factor for all terrain; one best track per storm. A second model (CLIMADA) runs as a cross-check only.
Two power flows, neither real. The DC flow has no operator and cascades; PyPSA has a perfect one. Reality lies between, and the model does not say where.
Not in the model at all. Rain, storm surge, flooding and landslides; trees and debris; substations and generators failing; fuel supply; people’s response; costs.
Data and sources
- Storm tracks: IBTrACS, Knapp et al. (2010); Gahtan, J., K. R. Knapp, C. J. Schreck, H. J. Diamond, J. P. Kossin and M. C. Kruk (2024): International Best Track Archive for Climate Stewardship (IBTrACS) Project, Version 4r01, NOAA National Centers for Environmental Information, doi:10.25921/82ty-9e16. In the Maria example, the subset MARIA 2017 (SID 2017260N12310), US agency columns only, from a local copy dated 30 April 2026 (access date not recorded). No endorsement by NOAA implied.
- The Puerto Rico grid in the Maria example: © OpenStreetMap contributors, ODbL 1.0, built with PyPSA-Earth; power plants from Global Energy Monitor’s trackers (CC BY 4.0) and, for three units, data obtained from GlobalEnergyObservatory.org (CC BY 3.0 US), matched with powerplantmatching (Gotzens et al. 2019, doi:10.1016/j.esr.2018.11.004); hourly demand from DemandCast, version 1.0.0 (doi:10.5281/zenodo.18374352, CC BY 4.0), split over the substations by PyPSA-Earth. The split over buses uses GADM 4.1 administrative units (gadm.org) as weights. GADM allows free academic and other non-commercial use; whether numbers weighted by its units count as redistribution is not settled, and GADM has not been asked. The full credits, with tracker releases, are on the Maria showcase.
A reading guide
The engines. PyPSA (Brown, Hörsch, and Schlachtberger 2018), PyPSA-Earth (Parzen et al. 2023), CLIMADA (Aznar-Siguan and Bresch 2019).
Storms. The tracks (Knapp et al. 2010) and the wind profile (Holland 1980).
Grids under weather. A framework with fragility curves and sequential Monte Carlo simulation (Panteli and Mancarella 2017).
What a model can claim. (Oreskes, Shrader-Frechette, and Belitz 1994).
LiveLines’ own handbook, part of the app (in development), has a chapter per module with its formula, its values and its limits.