River Outfall Status Visualizer
Core Goal
- Convert one Excel workbook into:
- A scenario-aware river outfall status summary.
- A standalone HTML chart suitable for briefing and review.
- A reusable mock workbook that follows the same template.
- Keep the chart vertically truthful.
Y values must always use real elevation.
- Allow horizontal zoom without resizing outfall symbols. Only the outfall anchor positions move with the river layout.
- Distinguish left-bank and right-bank outfalls with side-specific offset, connector direction, label placement, and legend.
Required Inputs
- Start from a
.xlsx workbook.
- Prefer the mixed single-sheet format documented in references/data-schema.md:
- Outfall rows carry code, size, base elevation, mileage, bank side, and scenario water levels.
- Control-node rows carry reach or gate names, mileage, scenario water levels, and optionally
河底高程 / 堤顶高程.
- If
当前水位 is missing, ask for it or state clearly that the output only supports the available scenarios.
- If the workbook lacks riverbed or channel-bottom data, describe the output as a river outfall status chart, not a true riverbed longitudinal profile.
Quick Start
- Generate a directly usable input template:
python3 scripts/generate_input_template_excel.py \
--output assets/templates/river-outfall-input-template.xlsx
- Generate or inspect a mock workbook:
python3 scripts/generate_mock_example_excel.py \
--output assets/examples/example-river-sample.xlsx
- Compute scenario summaries:
python3 scripts/calc_submergence.py \
--input assets/examples/example-river-sample.xlsx \
--pretty
- Render a standalone HTML report:
python3 scripts/render_status_report.py \
--input assets/examples/example-river-sample.xlsx \
--output assets/examples/example-river-sample-report.html
Workflow
- Read references/data-schema.md before touching the workbook schema.
- Read references/status-rules.md before changing status logic.
- Read references/visual-spec.md before changing the chart layout or legend.
- Use
scripts/calc_submergence.py first when the request is analytical.
- Use
scripts/render_status_report.py when the request needs a deliverable chart.
- Use
scripts/generate_mock_example_excel.py to create a regression fixture or explain the expected workbook shape.
- Use
scripts/generate_input_template_excel.py when the user needs a blank workbook they can fill directly in Excel.
- Report validation warnings explicitly. Do not silently coerce missing elevations, missing sizes, or ambiguous bank-side values.
Visual Rules
- Keep
Y coordinates in true elevation. Do not vertically exaggerate.
- Use mileage for ordering and anchor positioning.
- Keep the page free of browser-level horizontal scrolling. Use wheel zoom in the chart plus the timeline overview for navigation.
- Allow horizontal zoom or compression for layout, but keep outfall symbol widths fixed during zoom.
- Anchor each outfall at its true mileage and base elevation.
- When
河底高程 is present, draw a brown riverbed step profile and fill the active scenario water body above it with blue.
- When
堤顶高程 is present, draw the levee crest as a separate contextual step profile.
- Draw the outfall crown from true geometry height when size data is available.
- Use shape to distinguish geometry type:
- Rectangle for box culverts or rectangular outfalls.
- Circle for circular pipes. Do not flatten circular pipes into ellipses.
- Use bank-side offset to distinguish left-bank and right-bank outfalls:
- Left-bank outfalls offset to the left of the river axis.
- Right-bank outfalls offset to the right of the river axis.
- Reinforce bank side with connector direction, label placement, and legend text.
- Use status as the dominant semantic encoding:
未受淹
部分受淹
完全淹没
- Make the selected scenario visually dominant and keep non-selected scenarios visible but weaker.
- Prefer code plus size on the chart. Keep full outfall names in the detail table when the chart is dense enough that names would harm readability.
Scripts
scripts/generate_mock_example_excel.py
- Create an anonymized example workbook with mixed outfall and control-node rows.
scripts/generate_input_template_excel.py
- Create a multi-sheet Excel template whose first sheet can be filled directly and whose second sheet explains the fields.
scripts/calc_submergence.py
- Read a workbook, normalize the rows, compute scenario statuses, and print or export a summary.
scripts/render_status_report.py
- Generate a standalone HTML report with scenario switching and horizontal zoom.
scripts/river_outfall_status_lib.py
- Shared parser, validator, geometry, summary, and
.xlsx read/write helpers.
References
- references/data-schema.md
- Workbook shape, column aliases, and row classification rules.
- references/status-rules.md
- Water-level interpretation, crown inference, and tri-state status logic.
- references/visual-spec.md
- Chart semantics, left/right bank encoding, and layout constraints.
Output Checklist
- State which scenarios were actually present in the source workbook.
- Report total outfall count and counts by status for the highlighted scenario.
- List fully submerged outfall codes explicitly.
- Call out left-bank and right-bank counts when they matter to the request.
- Mention whether
河底高程 / 堤顶高程 were present, because that determines whether the chart includes channel background context or only water lines plus outfalls.
1---2name: river-outfall-status-visualizer3description: Analyze river outfall Excel workbooks and build report-ready river outfall status visualizations that compare current, normal, 20-year, and 50-year water levels, distinguish left-bank and right-bank outfalls, and identify which outfalls are safe, partially submerged, or fully submerged. Use when Codex needs to turn a river longitudinal-profile or outfall inventory workbook into a briefing chart, status summary, mock dataset, or reusable HTML report.4---5
6# River Outfall Status Visualizer
7
8## Core Goal
9
10- Convert one Excel workbook into:
11- A scenario-aware river outfall status summary.
12- A standalone HTML chart suitable for briefing and review.
13- A reusable mock workbook that follows the same template.
14- Keep the chart vertically truthful. `Y` values must always use real elevation.
15- Allow horizontal zoom without resizing outfall symbols. Only the outfall anchor positions move with the river layout.
16- Distinguish left-bank and right-bank outfalls with side-specific offset, connector direction, label placement, and legend.
17
18## Required Inputs
19
20- Start from a `.xlsx` workbook.
21- Prefer the mixed single-sheet format documented in [references/data-schema.md](references/data-schema.md):
22- Outfall rows carry code, size, base elevation, mileage, bank side, and scenario water levels.
23- Control-node rows carry reach or gate names, mileage, scenario water levels, and optionally `河底高程` / `堤顶高程`.
24- If `当前水位` is missing, ask for it or state clearly that the output only supports the available scenarios.
25- If the workbook lacks riverbed or channel-bottom data, describe the output as a river outfall status chart, not a true riverbed longitudinal profile.
26
27## Quick Start
28
291. Generate a directly usable input template:
30
31```bash
32python3 scripts/generate_input_template_excel.py \
33 --output assets/templates/river-outfall-input-template.xlsx
34```
35
362. Generate or inspect a mock workbook:
37
38```bash
39python3 scripts/generate_mock_example_excel.py \
40 --output assets/examples/example-river-sample.xlsx
41```
42
433. Compute scenario summaries:
44
45```bash
46python3 scripts/calc_submergence.py \
47 --input assets/examples/example-river-sample.xlsx \
48 --pretty
49```
50
514. Render a standalone HTML report:
52
53```bash
54python3 scripts/render_status_report.py \
55 --input assets/examples/example-river-sample.xlsx \
56 --output assets/examples/example-river-sample-report.html
57```
58
59## Workflow
60
611. Read [references/data-schema.md](references/data-schema.md) before touching the workbook schema.
622. Read [references/status-rules.md](references/status-rules.md) before changing status logic.
633. Read [references/visual-spec.md](references/visual-spec.md) before changing the chart layout or legend.
644. Use `scripts/calc_submergence.py` first when the request is analytical.
655. Use `scripts/render_status_report.py` when the request needs a deliverable chart.
666. Use `scripts/generate_mock_example_excel.py` to create a regression fixture or explain the expected workbook shape.
677. Use `scripts/generate_input_template_excel.py` when the user needs a blank workbook they can fill directly in Excel.
688. Report validation warnings explicitly. Do not silently coerce missing elevations, missing sizes, or ambiguous bank-side values.
69
70## Visual Rules
71
72- Keep `Y` coordinates in true elevation. Do not vertically exaggerate.
73- Use mileage for ordering and anchor positioning.
74- Keep the page free of browser-level horizontal scrolling. Use wheel zoom in the chart plus the timeline overview for navigation.
75- Allow horizontal zoom or compression for layout, but keep outfall symbol widths fixed during zoom.
76- Anchor each outfall at its true mileage and base elevation.
77- When `河底高程` is present, draw a brown riverbed step profile and fill the active scenario water body above it with blue.
78- When `堤顶高程` is present, draw the levee crest as a separate contextual step profile.
79- Draw the outfall crown from true geometry height when size data is available.
80- Use shape to distinguish geometry type:
81- Rectangle for box culverts or rectangular outfalls.
82- Circle for circular pipes. Do not flatten circular pipes into ellipses.
83- Use bank-side offset to distinguish left-bank and right-bank outfalls:
84- Left-bank outfalls offset to the left of the river axis.
85- Right-bank outfalls offset to the right of the river axis.
86- Reinforce bank side with connector direction, label placement, and legend text.
87- Use status as the dominant semantic encoding:
88- `未受淹`
89- `部分受淹`
90- `完全淹没`
91- Make the selected scenario visually dominant and keep non-selected scenarios visible but weaker.
92- Prefer code plus size on the chart. Keep full outfall names in the detail table when the chart is dense enough that names would harm readability.
93
94## Scripts
95
96- `scripts/generate_mock_example_excel.py`
97- Create an anonymized example workbook with mixed outfall and control-node rows.
98- `scripts/generate_input_template_excel.py`
99- Create a multi-sheet Excel template whose first sheet can be filled directly and whose second sheet explains the fields.
100- `scripts/calc_submergence.py`
101- Read a workbook, normalize the rows, compute scenario statuses, and print or export a summary.
102- `scripts/render_status_report.py`
103- Generate a standalone HTML report with scenario switching and horizontal zoom.
104- `scripts/river_outfall_status_lib.py`
105- Shared parser, validator, geometry, summary, and `.xlsx` read/write helpers.
106
107## References
108
109- [references/data-schema.md](references/data-schema.md)
110- Workbook shape, column aliases, and row classification rules.
111- [references/status-rules.md](references/status-rules.md)
112- Water-level interpretation, crown inference, and tri-state status logic.
113- [references/visual-spec.md](references/visual-spec.md)
114- Chart semantics, left/right bank encoding, and layout constraints.
115
116## Output Checklist
117
118- State which scenarios were actually present in the source workbook.
119- Report total outfall count and counts by status for the highlighted scenario.
120- List fully submerged outfall codes explicitly.
121- Call out left-bank and right-bank counts when they matter to the request.
122- Mention whether `河底高程` / `堤顶高程` were present, because that determines whether the chart includes channel background context or only water lines plus outfalls.