Repository navigation
feat(alluvione): acqua EMS contro il PAI e registro per comune (#713) - #740
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 779bad41d2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| LATERAL ST_Subdivide(ST_ClipByBox2D(z.geom, r.b), 256) s | ||
| WHERE z.geom && r.b |
There was a problem hiding this comment.
Expand the zone query bounds by the configured tolerance
When a PAI zone lies just outside the activation's water bounding box but within tolleranza_m of the water, this query discards it before ripartisci can apply the distance filter. For example, water beginning 10 m beyond a zone boundary should have its first 40 m excluded with the default 50 m tolerance, but the zone is never loaded and that strip remains in fuori_filtrato_m2, potentially also changing which patches exceed the minimum area. Expand the query and clipping envelope by the configured metric tolerance before fetching the zones.
Useful? React with 👍 / 👎.
| toccati = [acqua[i] for i in idx] | ||
| pezzi = shapely.intersection(confine, shapely.union_all(geom_acqua[idx])) | ||
| if pezzi.area <= 0: |
There was a problem hiding this comment.
Exclude boundary-only polygons from municipality metadata
When one water polygon overlaps a municipality and another only touches its boundary, predicate="intersects" includes both in toccati. The subsequent area check tests their combined intersection, so the overlapping polygon lets the boundary-only polygon contribute its product and observation timestamp to the municipality's JSON and CSV. This can falsely extend osservato_dal/osservato_al and attribute products that observed no flooded area there. Filter individual polygon intersections to positive area before deriving the metadata.
Useful? React with 👍 / 👎.
`limen ems-confronto-pai`: per attivazione, l'acqua osservata (unione dei
prodotti non di monitoraggio) divisa fra P3/P2/P1 del mosaico idraulico
ISPRA in `sorgenti`, vince la classe più alta, e il fuori da ogni zona
grezzo e filtrato (oltre 50 m, macchie da 5 ha). Aree in EPSG:3035, sola
lettura, report con provenienza.
`GET /api/ems/attivazioni` e `/api/ems/attivazioni/{codice}/comuni`
(JSON o `?formato=csv`): comuni ISTAT toccati, km² per comune, inizio
evento, osservazione, prodotti, attribuzione CEMS su ogni riga. Calcolo al
volo in shapely, in memoria sei ore; nessuna migrazione.
Il mosaico si taglia al riquadro e a pezzi da 256 vertici prima di uscire
dal database: poligoni da 3,5 milioni di vertici non finivano in dieci
minuti.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VFEUmbtBQgrNQpKGm9kXCu
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VFEUmbtBQgrNQpKGm9kXCu
e7a770b to
fef0306
Compare
Parte di #713.
Due analisi sull'acqua osservata Copernicus EMS che il curatore di
copernicus-emsha deciso stiano in Limen. Solo misura e lettura: nessun cambio a punteggio, YAML, migrazioni.A.
limen ems-confronto-paiPer attivazione (
--attivazionioLIMEN_EMS_PAI_ATTIVAZIONI, nessuna ⇒ tutte): acqua = unione dei prodotti non di monitoraggio (DEL0,GRA0,FEP0; mai la somma deiDEL1..n), divisa fra P3/P2/P1 del mosaico idraulico ISPRA insorgenti(classi esclusive, vince la più alta) e il fuori da ogni zona, grezzo e filtrato (oltre--tolleranza-m50, macchie da--patch-minima-ha5). Aree in EPSG:3035. Report inLIMEN_REPORTS_DIRconprovenienza.scrivi_report.Misurato sul DB di produzione di questa macchina (sola lettura,
default_transaction_read_only=on), mosaico ISPRA 2020 (mosaicatura_ispra_2020_aree_pericolosita_idraulica_{hph,mph,lph}):EMSR705 differisce per un buco dell'ingest, non della misura:
flood_eventsnon haEMSR705-aoi02-DEL0. Le sue 85 feature hannonotation = "Not Applicable", e l'ingest tiene soloFLOOD_NOTATIONS. Va deciso a parte se includerle: cambierebbe la verità del backtest.Il mosaico ISPRA ha poligoni da 3,5 milioni di vertici: si tagliano al riquadro dell'attivazione e a pezzi da 256 vertici (
ST_ClipByBox2D+ST_Subdivide) prima di uscire dal DB, e l'acqua si taglia in tessere da 2 km in shapely. Fatta tutta in SQL, la stessa misura non finiva in dieci minuti.B. Registro per comune
GET /api/ems/attivazioni— attivazioni inflood_events, con l'attribuzione per anno.GET /api/ems/attivazioni/{codice}/comuni(JSON) e?formato=csv(download) — comuni ISTAT (comuni) toccati dall'acqua, km² per comune (EPSG:3035, unione non somma), inizio evento, osservato dal/al, prodotti EMS, attribuzione.«Contains modified Copernicus Emergency Management Service information, {anno}» sta nel JSON e su ogni riga del CSV; il JSON porta un'avvertenza: acqua osservata dopo, limite inferiore, non un'allerta né una previsione. Endpoint →
core/ems_registro.py→flood_events_repo; niente logica nella route. Calcolo al volo (EMSR664: 35 comuni, 279,96 km², ~50 s su questa macchina carica), in memoria 6 h; i codici inesistenti non si memorizzano. Nessuna migrazione.Saltato
limen-opsnon esponeflood_eventsoggi, non era banale.Gate
ruff check,ruff format --check src tests: puliti.mypy --strict src: pulito trannepyarrowmancante (gruppoml, non installabile su questo Mac x86).pytest tests/unit: 2166 passati, 3 falliti preesistenti per l'ambiente (test_radice_datimlflow);test_pluviometri_trentinoescluso (pyarrow).🤖 Generated with Claude Code
https://claude.ai/code/session_01VFEUmbtBQgrNQpKGm9kXCu