Skip to content

Commit 6aee19b

Browse files
authored
Merge pull request #213 from CU-ESIIL/codex/restore-coherent-fire-plot-architecture
Clarify fire visualization architecture and define fire_plot recovery path
2 parents c5b0c6d + 90be573 commit 6aee19b

7 files changed

Lines changed: 75 additions & 3 deletions

File tree

AGENTS.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,18 @@ Docs checks:
179179
- Preserve backward compatibility unless explicitly instructed otherwise.
180180
- Add a focused regression test for every bug fix.
181181
- Use synthetic small cubes for deterministic unit tests.
182+
183+
## 13) Visualization architecture and fire plot recovery plan
184+
185+
The repository currently contains more than one visualization backend. Treat this as a transition state, not as permission to let them drift further apart. The custom HTML/CSS/JS cube viewer exposed through v.plot() is the canonical interactive viewer for general cube rendering. The fire-specific v.fire_plot() workflow currently still exposes a Plotly-based hull figure as its primary interactive display. Future work should move toward shared space-time semantics and clearer renderer boundaries, not ad hoc backend switching.
186+
187+
When touching visualization code, separate four concerns: (1) event or cube data construction, (2) geometry generation, (3) scene or adapter packaging, and (4) rendering backend. Changes that blur those layers tend to create regressions and make migration harder.
188+
189+
Implementation rules for agents:
190+
- Do not silently replace one viewer system with another without also updating docs, tests, and architectural notes.
191+
- If you touch axis placement, time-depth direction, cube-attached labels, or camera semantics, read `docs/dev/cube_viewer_invariants.md` first and keep those invariants aligned.
192+
- Fire-plot work must preserve separation between event geometry generation, climate/event data fusion, and rendering backend.
193+
- Do not claim fire_plot is fully migrated unless rendering actually runs through the custom cube-viewer path.
194+
- Do not update screenshots/docs only while leaving contradictory code behavior.
195+
- Do not change coordinate conventions without updating `docs/dev/cube_viewer_invariants.md` and relevant tests together.
196+
- When in doubt, prefer an adapter layer over duplicating geometry logic in two renderers.

docs/api/verbs.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ Plot inside/outside climate distributions for a fire event; side-effecting
7474
viewer verb.
7575

7676
### ``fire_plot(...)``
77-
High-level convenience verb that renders time-hull geometry and climate fields
78-
as a multi-panel visualization.
77+
High-level fire workflow that returns event/hull/summary outputs and a Plotly-based interactive hull figure (`fig_hull`).
7978

8079
### ``fire_panel(...)``
8180
Compact panel combining time-hull outlines and climate histograms.

docs/dev/fire_plot_architecture.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Fire plot architecture and migration path
2+
3+
## 1) Purpose
4+
5+
This note documents the current fire-visualization architecture and gives a safe migration path toward shared viewer semantics.
6+
7+
A successful migration will not begin by swapping plotting libraries. It will begin by making the fire-event products renderer-neutral enough that the same event geometry can drive either the existing Plotly hull figure or a future custom cube-viewer scene.
8+
9+
## 2) Current state
10+
11+
- `v.plot()` is the canonical custom HTML/CSS/JS cube viewer for general cube rendering.
12+
- `v.fire_plot()` currently returns a fire-event analysis bundle and uses a Plotly hull figure (`fig_hull`) as the supported interactive fire-specific display.
13+
- Fire geometry and climate sampling logic live in backend-agnostic parts of the fire workflow, while the final figure is currently Plotly-specific.
14+
15+
## 3) Stable separations of concern
16+
17+
Keep these layers distinct when modifying fire visualization:
18+
19+
1. Event or cube data construction
20+
2. Geometry generation
21+
3. Scene/adapter packaging
22+
4. Rendering backend
23+
24+
This separation enables one event product to feed multiple renderers and reduces regression risk.
25+
26+
## 4) Migration strategy
27+
28+
1. Make docs and interfaces honest about current backend status.
29+
2. Factor fire-event outputs into a renderer-neutral scene description or data adapter.
30+
3. Implement a custom-viewer renderer for that adapter.
31+
4. Only then consider changing the default fire viewer backend.
32+
33+
## 5) Anti-patterns to avoid
34+
35+
- Swapping rendering libraries before adapter/data boundaries are stable.
36+
- Duplicating geometry logic independently in multiple renderers.
37+
- Claiming migration is complete while `v.fire_plot()` still returns a Plotly-only interactive path.
38+
- Changing coordinate or axis conventions without updating invariants and tests together.
39+
40+
## 6) Recommended next incremental PRs
41+
42+
- Introduce a thin renderer-neutral adapter object for fire scene payloads (without changing current return keys).
43+
- Add tests that validate adapter payload shape and mapping from hull/summary outputs.
44+
- Implement an experimental custom-viewer renderer behind a non-default option.
45+
- Compare semantic parity (axes, time-depth direction, labels, camera defaults) before any default switch.

docs/recipes/fire_event_vase_hull.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ print("Cube:", getattr(cube, "da", None).shape if hasattr(cube, "da") else type(
7575
`fire_plot` requests daily gridMET/PRISM data for event windows. Explicitly pass
7676
`freq="D"` to emphasize daily sampling or a different frequency if needed.
7777

78+
79+
## Current viewer status
80+
81+
`fire_plot` currently returns a fire-event analysis bundle plus a Plotly-based interactive hull figure. This is the supported fire-specific viewer path today. It is not yet rendered through the same custom HTML/CSS/JS viewer backend used by `v.plot()`. The long-term goal is to align fire-event visualization with the cube viewer’s shared space-time conventions so that fire-specific displays and generic cube displays live in the same visual grammar.
82+
83+
Developer note: `If you are working on fire visualization internals, treat event construction, hull generation, climate/event fusion, and rendering as separable layers. The safest near-term improvements are the ones that preserve those boundaries.`
84+
7885
## What you get back
7986
`v.fire_plot` returns a dictionary with:
8087

docs/viz/cube_viewer.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ The cube viewer turns a 3D climate cube into an interactive HTML scene. Call
44
`v.plot()` on an `xarray.DataArray` with dims like `(time, y, x)` to render the
55
cube inline in Jupyter or export standalone HTML.
66

7+
8+
> **Transition note:** `v.plot()` is the canonical custom viewer for general cubes. Some specialized visualization workflows may still expose separate rendering backends during the transition period (including the current fire hull path in `v.fire_plot()`). The intended direction is convergence on shared spatial and temporal conventions, not necessarily immediate backend unification.
9+
710
The viewer is designed to:
811

912
- show temporal slices along one axis and spatial slices on the other faces;

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ nav:
5353
- Contributing: dev/contributing.md
5454
- CI and Testing: dev/ci_testing.md
5555
- Cube viewer invariants: dev/cube_viewer_invariants.md
56+
- Fire plot architecture: dev/fire_plot_architecture.md
5657
- Figure backend (v.plot): dev/figure_backend.md
5758
- Viewer backend: dev/viewer_backend.md
5859
- Legacy reference: dev/legacy_reference.md

src/cubedynamics/verbs/fire.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,11 @@ def fire_plot(
4747
allow_synthetic: bool = False,
4848
prefer_streaming: bool = True,
4949
) -> Dict[str, Any]:
50-
"""Fire time-hull + climate visualization verb.
50+
"""Fire time-hull + climate visualization workflow.
5151
5252
Supports cube-first (preferred) and legacy fire-first invocation styles.
53+
Returns a fire analysis bundle and a Plotly hull figure (`fig_hull`) as the
54+
current interactive backend for fire-specific visualization.
5355
"""
5456

5557
cube_first = da is not None

0 commit comments

Comments
 (0)