Skip to content

feat(wildfire): EFFIS perimeters from ms:modis.ba.poly, with the layer on every row - #760

Merged
gzileni merged 1 commit into
mainfrom
feat/effis-modis-layer
Nov 28, 2026
Merged

gzileni merged 1 commit into
mainfrom
feat/effis-modis-layer

Conversation

@gzileni

@gzileni gzileni commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Limen reads the EFFIS burnt-area layer ms:modis.ba.poly instead of nrt.ba.poly, as decided on 2026-11-28. The reason is in effis-client 0.3.0: the two layers do not count the same fires, and nrt.ba.poly also counts heat that is not burnt vegetation. On the summit of Etna it has 255 "burnt areas" from 2012 to 2026 (135,917 ha); ms:modis.ba.poly has 6 fires there. Accepted costs: the new layer starts in 2016, and its rows are revised over time.

This PR moves measured numbers: do not merge it without deciding to rerun the measures listed below.

What changes

  • Migration 104 (104_effis_layer.sql):
    • Adds a layer column to fire_perimeters, NOT NULL, with no default (whoever writes must say the layer) and a CHECK on the two names.
    • The key becomes (layer, id): ids of the two layers have the same shape and can collide.
    • Adds the columns only the new layer fills: municipality, final_date, last_update, land_cover_pct (jsonb, percent of the burnt area per cover), natura2000_pct.
  • Existing rows are kept and marked layer = 'nrt.ba.poly'. Nothing is deleted. Removing them is a separate step for the user to approve.
  • Readers read the new view v_fire_perimeters, which holds only Limen's layer:
    • the wildfire backtest truth (backtest_wildfire);
    • the post-fire severity (fire_check, perimeter_severity_at);
    • the FRP refresh (an UPDATE through the auto-updatable view; rows of the other layer keep their values);
    • the EFFIS/FIRMS agreement, frp_size_correlation, the measures (misure_repo), the data catalogue and the effis-sync fingerprint.
  • The map publishes the view: limen_tiles gets SELECT on v_fire_perimeters and loses it on the table, otherwise the map would draw both layers.
  • effis-sync reads MODIS_LAYER at EFFIS_WFS_URL through effis-client 0.3.0. _parse_feature now uses effis_client.perimeter_attributes, which removes Limen's own field lookup (id, date, area, country, province) and adds municipality, last update and land cover. The geometry handling stays in Limen.
  • STEP_VERSION["fire_perimeters"] goes from 1 to 2, so the static bootstrap syncs again.
  • One constant, fire_repo.PERIMETER_LAYER, is the layer of the writes; a unit test checks it is the client's layer and the one in the view's definition.

Severity anchors: to be measured again, values unchanged

post_fire.frp_floor_mw_per_ha: 0.08 and post_fire.frp_saturation_mw_per_ha: 0.88 are in src/limen/config/hazards/landslide.yaml, not in wildfire.yaml. They are the 10th and 90th percentile of the FRP density on 2,419 Italian EFFIS perimeters 2012-2024 of the old layer. Their values do not change here; the YAML now says they must be measured again, with the query. The original query is not in the repository (commit 6fd7556 has only the numbers); this one rebuilds it from the definition:

SELECT count(*),
       percentile_cont(ARRAY[0.10, 0.25, 0.50, 0.75, 0.90])
           WITHIN GROUP (ORDER BY frp_density_mw_per_ha),
       max(frp_density_mw_per_ha)
FROM v_fire_perimeters
WHERE frp_density_mw_per_ha IS NOT NULL;

The correlations with the area (0.63 for the sum, 0.26 for the density) come from fire_events_repo.frp_size_correlation().

Measures in docs/misure that used the old layer and must be rerun

After limen effis-sync with the history (LIMEN_EFFIS_GIORNI back to 2016) and the FRP refresh:

  1. The wildfire backtests with EFFIS truth, first. 94 files backtest_wildfire_*.md whose truth is "perimetri EFFIS" or "perimetri EFFIS e catasti regionali":

    • backtest_wildfire_italia_* (2024, 2025, 2026: High, VeryHigh, cancello 0.3/0.5, tetto 95-35);
    • the regional ones for Basilicata, Calabria, Puglia, Sardegna, Sicilia (June-September 2024 and 2025);
    • Emilia-Romagna, Friuli-Venezia Giulia, Liguria, Lombardia, Piemonte, Toscana, Trentino-Alto Adige, Valle d'Aosta, Veneto (2024, 2025, 2026; Moderate, mancati, tetto95-35).

    The ones with _catasti in the name and truth "catasti" alone do not read EFFIS and stay valid.

  2. misura_coltivi_2023_2024-2026.md: the verification truth is EFFIS perimeters 2024-2026.

  3. The severity anchors above, and with them every score that uses the post-fire factor F.

  4. The EFFIS/FIRMS agreement of limen ingest-fire-history (report in reports/, not in docs/misure): it compares FIRMS with the perimeters.

Not in this PR, as agreed: replacing fire_events_repo._REFRESH_FRP_SQL with limen_core.wildfire.seen_inside_all. It is a separate PR after this one, and the right place to measure the anchors again with the function that will compute the density.

Epic

Part of #714 (wildfire)

Type of change

  • Data source / ingestion
  • Scoring / thresholds

Verification

  • ruff check src tests, ruff format --check, mypy (strict, 475 files): clean.
  • Unit tests: 2224 passed, 1 failed: test_geoserver_dati_base.py::test_il_raster_corine_dallo_shapefile. It fails the same way on main in my local environment, so it is not caused by this PR.
  • Integration tests near fires, measures and bootstrap (backtest wildfire, effis client, fire history, perimeter severity, comune, static bootstrap, wildfire training data, catasti, tiles): 68 passed, against a Postgres testcontainer with every migration applied.
  • New tests:
    • the two layers can hold the same id;
    • a row without a layer and a row with an unknown layer are refused;
    • the view shows only Limen's layer;
    • effis-sync asks ms:modis.ba.poly on /effis and stores municipality, last update, land cover and Natura 2000;
    • the map role sees the view, not the table.
  • Not run: a real effis-sync against the live service on a database with data.

Risk/scoring impact

  • Until effis-sync runs with the history, the view is empty: the wildfire backtest has no truth and the post-fire factor F sees no perimeter, so F stays at its value without severity.
  • After the sync, every measure listed above changes.
  • The nrt.ba.poly rows stay in the table, invisible to every reader, until the user decides to remove them.

🤖 Generated with Claude Code

…r on every row (#714)

The two EFFIS burnt-area layers do not count the same fires, and
nrt.ba.poly also counts heat that is not burnt vegetation (255 burnt areas
on the summit of Etna). Limen now reads ms:modis.ba.poly.

Migration 104 adds the layer to every perimeter (key (layer, id), no
default), the attributes only the new layer has, and the view
v_fire_perimeters that every reader and the map go through. Existing rows
are kept and marked nrt.ba.poly. effis-sync reads the new layer through
effis-client 0.3.0. The severity anchors keep their values and are marked
to be measured again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-28T17:43:35.953480Z 318c6fb PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@gzileni
gzileni merged commit 84bb038 into main Nov 28, 2026
7 checks passed
@gzileni
gzileni deleted the feat/effis-modis-layer branch November 28, 2026 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant