bloc.plotting.trajectory_dashboard#
General-purpose Trajectory Dashboard (Bloc analysis toolbox).
A standalone Dash/Plotly app that reads the cached scenarios of a running Bloc
GUI (via its REST API) and plots every reactor trajectory in
(temperature, residence-time) space. Clicking a trajectory drives the open
GUI to load that scenario (the scenario-focus channel), and the clicked path is
highlighted with a gold halo.
It is config-agnostic: the title is taken from the loaded YAML’s name (e.g.
SPRING_A3 Stability Map) and it plots whatever scenarios the GUI exposes.
Single-user by design: the app keeps its rows/focus/theme in one server-side
state dict, so it serves ONE local analyst next to ONE GUI. Opening it from
two browsers would share focus/theme; that trade-off is deliberate (no session
plumbing) — don’t expose it beyond localhost.
Launch it together with the GUI via the CLI:
bloc <config>.yaml --trajectories # starts the GUI *and* this dashboard
or standalone against an already-running GUI:
python -m bloc.plotting.trajectory_dashboard --gui http://127.0.0.1:8050
────────────────────────────────────────────────────────────────────────────
WHAT THIS DASHBOARD CLASSIFIES — carbon-species dominance, hardcoded
────────────────────────────────────────────────────────────────────────────
The coloured trajectories + isolines are carbon-specific. To generalise to other
species or metrics, edit only the block marked CLASSIFIER below:
categories + colours →
CATEGORY_COLORS, frombloc.plotting.stability_map.mass vs mole fraction →
classify_series()uses mass fractions (bloc.chem.carbon_dominance.category_mass_fractions→gas.Y). For mole fractions, sumgas.Xover each category’s species instead (or add acategory_mole_fractionshelper incarbon_dominance).isoline scalar → currently solid-carbon yield %. Swap for any per-point scalar (e.g. a temperature, a conversion, a selectivity).
Everything below the classifier (figure assembly, click→focus) is species-agnostic.
Functions#
|
Recompute per-point (dominant category, isoline scalar) for one trajectory. |
|
Fetch every cached scenario from the GUI API and classify each trajectory. |
|
One Plotly figure: segment-coloured trajectories + scalar isolines. |
|
Build the Dash app that reads |
|
Module Contents#
- bloc.plotting.trajectory_dashboard.classify_series(gas, category_map, series)#
Recompute per-point (dominant category, isoline scalar) for one trajectory.
Returns arrays aligned by sample:
T_C(°C),tau(s),cat(str),scalar(%, the isoline metric).Xcarries full mole fractions;Yis derived by Cantera from(T, P, X).GENERALISE HERE:
category_mass_fractionsuses mass fractions (gas.Y). For a mole-based map, sumgas.Xover each category’s species instead.
- bloc.plotting.trajectory_dashboard.fetch_trajectories(gui)#
Fetch every cached scenario from the GUI API and classify each trajectory.
Returns
(rows, listing). Raises on a non-reachable GUI.
- bloc.plotting.trajectory_dashboard.build_figure(rows, listing, highlight_id=None, theme='light')#
One Plotly figure: segment-coloured trajectories + scalar isolines.
Each trajectory contributes 2-point segments to a per-category trace; every point carries
customdata = scenario idso a click resolves the scenario.highlight_iddraws the currently-overlaid scenario with a gold halo.theme(light/dark) selects the Plotly template + line ink.
- bloc.plotting.trajectory_dashboard.build_app(gui)#
Build the Dash app that reads
guiand drives it on click.
- bloc.plotting.trajectory_dashboard.main(argv=None)#