Ship the data-pipeline chain: local geocoding, Meteostat gusts, NASA POWER primary, ERA5 seed #10

Closed
admin_emi wants to merge 9 commits from ship-data-pipeline into dev

9 commits

Author SHA1 Message Date
Emi Griffith
7f35332f4f Merge dev into the data-pipeline chain (CI tag-keying fixes)
All checks were successful
PR build (required check) / changes (pull_request) Successful in 7s
secrets-guard / encrypted (pull_request) Successful in 6s
PR build (required check) / build-backend (pull_request) Has been skipped
PR build (required check) / build-frontend (pull_request) Has been skipped
PR build (required check) / validate-observability (pull_request) Has been skipped
PR build (required check) / gate (pull_request) Successful in 3s
2026-07-23 09:07:17 -07:00
Emi Griffith
9567c51783 Subtree-merge thermograph-backend era5-seed into backend/ 2026-07-22 22:26:27 -07:00
Emi Griffith
ffcb25885f Subtree-merge thermograph-backend nasa-primary-flip into backend/
Conflict resolved (UNVERIFIED -- tests not runnable locally, docker blocked):
tests/data/test_climate.py keeps BOTH appended test blocks (dev's
forecast-cooldown tests + this branch's NASA-primary tests). Same conflict
exists merging this branch into the split repo's dev.

# Conflicts:
#	backend/tests/data/test_climate.py
2026-07-22 22:26:17 -07:00
Emi Griffith
8301d5c7d9 Subtree-merge thermograph-backend history-meteostat-gusts into backend/
Conflict resolved (UNVERIFIED -- tests not runnable locally, docker blocked):
data/climate.py combines dev's hardened _request signature
(ARCHIVE_FETCH_TIMEOUTS + phase) with this branch's Meteostat gust-fill wrap.
Same conflict exists merging this branch into the split repo's dev.

# Conflicts:
#	backend/data/climate.py
2026-07-22 22:26:03 -07:00
Emi Griffith
6eff3ba3a7 Subtree-merge thermograph-backend geocode-local into backend/ 2026-07-22 22:24:31 -07:00
Emi Griffith
24d8cd9ba1 Add one-time ERA5 seed for curated-city cells (keyless Icechunk)
seed_era5.py backfills the curated-city cells with true ERA5 data from the
Earthmover Icechunk ERA5 archive on AWS Open Data (anonymous, keyless), so
high-traffic pages keep ERA5 fidelity now that NASA POWER is the live primary.
It aggregates the hourly ERA5 point series to the daily store schema in polars
(no pandas), derives feels-like via the existing heat-index/wind-chill path, and
writes straight to the history store via climate._write_history_backed, bypassing
the live fetch. ERA5 carries real gusts (i10fg), so seeded cells keep measured
gusts rather than the Meteostat fallback.

The icechunk/xarray/zarr stack is isolated in requirements-seed.txt (not the app
image or CI) and lazy-imported, so the module and its unit-tested hourly->daily
transform load without those deps. The S3 access layer targets a young API and is
verified via `--dry-run` on the seed box, not in tests. Idempotent by default
(skips already-cached cells; --overwrite to reseed).
2026-07-22 22:07:00 -07:00
Emi Griffith
30153dbc64 Flip history primary to NASA POWER, Open-Meteo to fallback
The live history path now tries NASA POWER first (keyless, independent of
Open-Meteo) and falls back to the Open-Meteo archive only when NASA is
unavailable — the reverse of before. Gusts NASA lacks are filled from Meteostat
inside _fetch_history_nasa (added in the prior change). Both sources must still
return a plausibly-full span (MIN_ARCHIVE_DAYS) before being cached as complete;
a short/partial response is rejected and the other source is tried.

_fetch_history_nasa now accepts a start/end range so it also serves the recent
tail top-up: _topup_tail fetches NASA-first via the new _fetch_history_tail
helper (Open-Meteo range as fallback, skipped during its rate-limit cooldown),
removing the last per-active-cell Open-Meteo call from the history path. The
Open-Meteo cooldown no longer gates the top-up, since NASA is not subject to it.

Open-Meteo remains wired as the fallback (deletion is a later step). Tests
updated to the new source order plus tail-fetch coverage.
2026-07-22 22:02:30 -07:00
Emi Griffith
b4d8d67825 Add Meteostat gust supplier for the gust-less backup sources
NASA POWER (history) and MET Norway (forecast) carry no wind gusts, but gust is
a graded metric. This adds data/meteostat.py, which finds the nearest Meteostat
station to a cell and reads its daily peak gust (wpgt) from the keyless gzipped
bulk endpoints, filling the gust column on the NASA POWER history frame. Where no
station is within ~100 km it estimates from sustained wind (wind * GUST_FACTOR).

Bulk files (station list + per-station daily) are cached on disk so steady-state
network IO is near zero, and any lookup/fetch failure degrades to pure estimation
so a history fetch never fails. A constant estimate factor makes an estimated
gust redundant with wind, so real signal comes only where a station backs it.

Activates once NASA POWER becomes the primary history source; Open-Meteo already
carries its own gusts. New history_gust / meteostat_stations metrics phases map
to the meteostat source.
2026-07-22 21:39:09 -07:00
Emi Griffith
db86277103 Move forward geocoding off Open-Meteo to local index + Nominatim
/suggest is now served purely from the local GeoNames index — no external
geocoder call per keystroke. /geocode answers from the local index first and
falls back to OSM Nominatim /search only on a miss (or while the index is still
loading), covering the neighbourhood/postcode/tiny-village/native-name long tail
the cities dump lacks.

Nominatim shares the reverse geocoder's lock and ~1/sec pacing since both hit
the same host, and only the low-volume /geocode miss path reaches it. Removes
the Open-Meteo geocoding dependency entirely; the "geocode" metrics phase now
maps to the nominatim source.
2026-07-22 21:29:26 -07:00