Reading a finished run¶
aeolus1d run case.toml --out run.h5 writes the final state of every pipe and
component, and with --trace-dt a time series. aeolus1d.io.results reads that
file back into plain dataclasses of numpy arrays, without Qt and without running
the case again. It is the reader the GUI uses; it lived in the GUI package until
2026-11-24 (roadmap 0h 2.5).
from aeolus1d.io.results import load_run
run = load_run("run.h5")
snap = run.pipes["tube"] # final state: snap.x, snap.rho, snap.u, snap.p
if run.time_series is not None: # traced with --trace-dt
t = run.time_series.t # (n_samples,)
p = run.time_series.pipes["tube"]["p"] # (n_samples, N)
examples/plots/plot_from_result.py plots a result file this way. Everything is
SI as written (Pa, K, kg/m³, m/s); a final-state-only file is a normal result
(time_series is None).
aeolus1d.io.results ¶
Read an aeolus1d HDF5 run output.
The schema is the one aeolus1d.io.writer.write_hdf5 produces —
root attrs (case_name, t_final), pipes/<id>/{rho,u,p,
U,x,A_cell,A_face}, optional junctions/junction_NN/<attrs>,
and (when the run was traced with --trace-dt) a time_series
group with t plus per-pipe rho/u/p arrays of shape
(n_samples, N).
Headless: nothing here imports Qt or PyVista. Called by the GUI's network-view dock and by notebook users alike.
Moved from aeolus1d_gui/io/h5_reader.py into the library on 2026-11-24
(roadmap 0h 2.5): it was the only reader of a finished run and needed nothing of
the GUI, so a script can read a run without running it again
(examples/plots/plot_from_result.py). The GUI imports it from here.
RunResult
dataclass
¶
Full deserialised run.
TimeSeries
dataclass
¶
Trace data when --trace-dt was set on the run.
PipeSnapshot
dataclass
¶
Final-time pipe state.
JunctionSnapshot
dataclass
¶
CylinderSnapshot
dataclass
¶
Final-state thermodynamic snapshot for one cylinder.
Phase-A41 — when the HDF5 was written by aeolus1d ≥ schema v2 the
final-state junctions/junction_NN group carries kind ==
"cylinder" + id == "<user_id>" attrs, so the loader can
pull cylinder volumes out of the junction list and key them by
their case-defined id (e.g. "cyl1"). v1 files don't carry
these attrs → the cylinder dict stays empty and the GUI falls
back to the port-pipe-average colour heuristic.
ComponentSnapshot
dataclass
¶
Final-state snapshot for a non-cylinder, non-junction component (compressor / turbine / shaft).
Phase-A42 — schema v2 already tags these with kind /
id; the writer also dumps their dummy-volume p / T / rho
/ m / V (compressors and turbines hold a placeholder Volume
for timeloop compatibility, shafts likewise). The fields
are constants for compressor / turbine / shaft today, but
the partition exists so the GUI / notebooks know which
junction-list entry was which kind without re-walking the
case spec — and so future per-component diagnostics
(last_mdot / omega / ...) can land here without a
second schema bump.
load_run ¶
load_run(path: str | Path) -> RunResult
Read an aeolus1d HDF5 file. Missing optional groups are silently skipped — the GUI handles a final-state-only file as well as a traced one.
Inputs
path: the result HDF5 as str or Path (spaces and non-ASCII are fine); any file
write_hdf5 wrote, including one still being appended to.
Returns:
a RunResult: case_name ("(unknown)" when the attribute is absent) and
t_final [s] (0.0 when absent), the final-state partitions (see
_read_final_state) and time_series (None when the file has no
time_series group OR that group has no t dataset, the writer's commit marker,
written last). Traced pipes, junctions and kinds are read whole, re-keyed as in
_pipe_series / _junction_series. Everything is SI as written: Pa, K, kg/m^3,
m/s; nothing is converted. A final-state-only file is a normal result.
Refuses:
a missing path raises FileNotFoundError, a folder IsADirectoryError, an empty,
truncated or not-HDF5 file OSError (all from h5py, naming the path). A file another
process holds open for writing can raise OSError (lock). A pipe, or a traced pipe,
without a primitive raises KeyError. Callers: RunModel.load_now lets it out;
Load Results and Reload show a critical box naming the file, the auto-load after a
run writes a console line "(network view: failed to load RunModel._poll_tick (the live watcher) swallows everything and retries next tick.
Edges:
missing, empty, truncated and folder paths
(test_load_run_missing_file_raises_filenotfound,
test_load_run_empty_file_raises_oserror,
test_load_run_truncated_file_raises_oserror,
test_load_run_a_folder_raises_oserror).
a str path with spaces and non-ASCII
(test_load_run_accepts_a_str_path_with_spaces_and_unicode).
a bare HDF5 file (test_load_run_bare_hdf5_gives_unknown_case_and_no_pipes).
no time_series group (test_load_run_without_time_series_is_final_state_only).
a time_series without t is not read
(test_load_run_time_series_without_t_is_treated_as_not_written).
a traced pipe missing a primitive
(test_load_run_traced_pipe_missing_a_primitive_raises_keyerror).
t is resized last, so a read caught in a flush sees series longer than t; they are
clipped to t (test_load_run_clips_traced_arrays_longer_than_t).
load_run_incremental ¶
load_run_incremental(
path: str | Path, prev: RunResult | None
) -> RunResult
Incremental re-read for live-watch polling (audit 2026-06-10 batch B item 2).
A streaming run only ever APPENDS time-series samples; the cold
load_run re-reads the whole O(T) trace on every poll tick —
O(T²) cumulative as the run grows. Given the previously loaded
prev, this reads only dset[n_read:] for every time-series
dataset and concatenates onto the cached arrays (the final-state
groups are O(network) small and re-read fully). Falls back to a
full cold load when:
previsNoneor carries no time series,- the on-disk
tis shorter than the cached one (file replaced by a new run), - the cached tail sample doesn't bit-match the on-disk value at the same index (new run that already overtook the old length),
- the trace's group/dataset structure changed (new pipes / fields
/ partitions), or any per-field length disagrees with
t.
Returns a NEW RunResult (the cached one is never mutated —
GUI consumers may still hold references to it).
Inputs
path: the result HDF5, as for load_run.
prev: the RunResult of the previous poll, or None. Never mutated; the caller
(RunModel._poll_tick) keeps it.
Returns:
a NEW RunResult equal to load_run(path): the final state re-read, the trace is the
cached arrays plus dset[n_read:] of every field (concatenated). Cold load_run
when prev is None or untraced, when the file has no time_series / t,
when t is shorter than the cache (a new run replaced the file), when the cached
last t or the first field's last value no longer matches, when a pipe, a junction,
a partition entry or a field appeared or vanished, or a field's length plus the cached
length is not the length of t.
Refuses:
an error opening the file (missing, locked, truncated: FileNotFoundError / OSError)
is NOT caught here; _poll_tick swallows it and retries next tick. Only the internal
structure-changed signal falls back to a cold load, whose own errors (KeyError for
a missing primitive) escape.
Edges:
no previous run or an untraced one -> cold
(test_incremental_without_a_previous_run_is_a_cold_load).
growth reads the tail, equals a cold read, and leaves the cache untouched
(test_incremental_appends_only_the_new_samples_and_never_mutates_the_cache).
a shrunk file (test_incremental_falls_back_to_a_cold_load_when_the_file_shrank).
a new run that overtook the old length
(test_incremental_falls_back_when_a_new_run_overtook_the_old_length).
the trace vanished (test_incremental_falls_back_when_the_trace_vanished).
a pipe appeared (test_incremental_falls_back_when_a_pipe_appears).
a missing file raises (test_incremental_on_a_missing_file_raises_filenotfound).
variable_names ¶
variable_names(run: RunResult | None = None) -> list[str]
Variables the GUI exposes for colouring + plotting.
The base set is the four primitives the writer always emits.
When a RunResult is supplied AND any pipe in it carries
species datasets (Phase-49 — the writer emits them when
pipe.has_species was true at run time), the Y_<name>
series are appended in network order so the user can pick e.g.
Y_CO from the same combo. Species missing from a given
pipe simply render a "variable not present" message — the
combo is shared across all pipes.
Inputs
run: a RunResult or None.
Returns:
the variables to offer in the plot and colour pickers, in order: rho, u, p,
T always; then, per pipe in network order, its final-state Y_<species> (once
each), q_rxn, T_solid and surface/<name> when any pipe has them, and the
same names from the trace; then, when the
run has cylinders, m and V and whichever of T_burnt, T_unburnt, xb,
q_wiebe a cylinder's trace has; then (since 2026-11-21) whichever of the
JUNCTION_RESULT_KEYS (wall_T_inner, wall_heat_power, mdot,
passed) a plain junction has, in its final state or its trace; then (since
2026-11-23) bc/<key> for each key a traced boundary condition has. A fresh list
each call. The names are labels only: the unit is looked up elsewhere (p Pa, T K).
Refuses:
none.
Edges:
no run -> the four primitives (test_variable_names_without_a_run_is_the_four_primitives).
species deduplicated across pipes, in network order, before q_rxn of the pipe that has
it (test_variable_names_adds_species_once_in_network_order_then_q_rxn).
traced species and cylinder variables
(test_variable_names_takes_traced_species_and_cylinder_variables).
the solid temperature and the coverages, final or traced
(test_variable_names_offers_the_solid_temperature_and_the_coverages).
a dynamic wall's and an orifice's results, final or traced, and none for a plain plenum
(test_variable_names_offers_the_wall_and_orifice_results_a_junction_has).