Repository navigation
refactor(wildfire): the FRP of a perimeter from limen-core's seen_inside_all - #763
Merged
Merged
Conversation
…een_inside_all (#714) refresh_perimeter_frp reads the perimeters of v_fire_perimeters and the hotspots that can count, one year at a time, lets limen_core.wildfire.seen_inside_all apply the rule, and writes only where a value changes. The SQL it replaces stays as _REFRESH_FRP_SQL_LEGACY for the parity test. Parity on real rows: 12,399 perimeters of ms:modis.ba.poly (2016-2026) and 198,235 FIRMS vegetation detections (2015-2025), 4,831 perimeters measured by both, 0 differ. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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. |
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
fire_events_repo.refresh_perimeter_frpno longer computes the severity of a burnt perimeter in SQL. It reads the perimeters ofv_fire_perimetersand the FIRMS detections that can count, one year at a time.limen_core.wildfire.seen_inside_all(limen-core 0.4.0, already pinned) applies the rule, and Limen writes the result.The rule is the same as before: a vegetation detection (type 0) with a power, within 5 days of the fire's date, inside the perimeter or on its edge. The density is the sum over the area, and is NULL when the area is missing or zero.
The numbers do not change. This PR moves who computes them, not what they are. The severity anchors are measured again on the new layer in a separate PR, which moves numbers and is left to the user.
Parity on real rows
Both implementations ran on the same throwaway database:
ms:modis.ba.poly, fires from 2016-05-13 to 2026-11-24, loaded with Limen's ownrun_effis_syncon the 20 region boxes.fetch_archive_year(MODIS and VIIRS S-NPP, Italy).Result:
seen_inside_all4,831;The 2026 perimeters have no detection here, because the FIRMS archive stops at 2025; in production they come from the NRT feed.
The edge cases, in a test
tests/integration/test_frp_parity.pyruns the old SQL (kept as_REFRESH_FRP_SQL_LEGACY) and the new path on the same rows, and fixes the expected values too, so that a mistake shared by both is not taken for parity. The cases:Two behaviours that are not the same, on purpose
updated_atno longer moves on every nightly run, so the fingerprints that read it see a change only when there is one.Epic
Part of #714 (wildfire)
Type of change
Verification
ruff,mypyclean.Risk/scoring impact
None on the values: 0 differences on 4,831 measured perimeters. Memory: one year of detections at a time, about 25,000 rows.
🤖 Generated with Claude Code