feat: per-station flood thresholds and Chiang Mai inundation stages for P.1

Replace the network-wide (3.0, 4.5) m thresholds with per-station values
calibrated from the DB's discharge_percent (RID % of channel capacity):
warning = median level at 75-85% capacity, danger = median at 95-105%.
Fixes P.103 over-alerting (bank-full ~6.75 m, not 4.5) and P.67
under-alerting (overflow ~2.9 m). Requires a retrain to take effect in
the classifier heads.

P.1 uses the official Chiang Mai municipal inundation map instead:
warning 3.70 m (stage 1, city flooding begins), danger 4.20 m (stage 5),
with the full 7-stage table (3.70-4.60 m + discharge) in
features.P1_FLOOD_STAGES. Forecast rows for P.1 now include per-stage
exceedance probabilities computed from the regression head + calibration
sigma - available immediately without retraining.

Dashboard: "Chiang Mai city flood outlook" block above the forecast grid
(predicted peak + 7 stage-probability chips) and a toggleable
georeferenced overlay of the official flood-zone map
(static/flood-zones-p1.jpg, bounds tunable in FLOOD_ZONE_BOUNDS).
This commit is contained in:
2026-08-10 15:35:00 +07:00
parent 29f4b5818d
commit e4d5d274f0
6 changed files with 162 additions and 32 deletions
+13 -9
View File
@@ -328,15 +328,19 @@ river has spent 57 hours above 4.5 m historically, 0.144% of all hours — but n
out-of-sample number backs it. Treat `p_danger` at P.1 as indicative, not
validated.
**Thresholds are P.1-datum-specific but applied network-wide.** `THRESHOLDS`
carries a single default of (3.0, 4.5) m for every station, and gauge datums
differ enormously: P.5 spends 27.8% of all recorded hours above 3.0 m, P.103
11.1%, P.81 8.2%, P.77 7.6% — versus 0.95% at P.1. On those stations "warning" is
close to a normal wet-season level, so **P.103 currently over-alerts on the
default thresholds**. The models are calibrated to the labels they were given, so
the metrics are internally valid; it is the operational meaning of the label that
is wrong. Per-station calibration against RID's published flood stages is the
pending follow-up — it changes only `features.THRESHOLDS`, plus a retrain.
**Thresholds are per-station as of 2026-08-10.** `THRESHOLDS` now carries
calibrated (warning, danger) pairs for all 16 stations, derived from the DB's
`discharge_percent` (RID % of channel capacity): warning = median level at
7585% capacity, danger = median level at 95105%. P.1 instead uses the official
Chiang Mai inundation map (`P1_FLOOD_STAGES`): warning 3.70 m (city flooding
begins, stage 1) and danger 4.20 m (stage 5). The prior single default of
(3.0, 4.5) m made P.103 badly over-alert (its bank-full level is ~6.75 m) and
P.67 under-alert (overflow at ~2.9 m, 1.6 m below the old danger line).
**A retrain is required after any threshold change** — classifier labels depend
on them; until then, model rows report the thresholds baked into their bundle.
P.1 additionally reports `stages`: exceedance probability for each of the seven
official inundation stages (3.704.60 m), computed from the regression head and
its calibration sigma, so they need no retrain and no per-stage classifiers.
## 6. Deployment