Skip to content

calibratePowerLaw(): gamma and p_c50 of the powerLaw link from an ELF's flammable map - #168

Merged
eliotmcintire merged 2 commits into
developmentfrom
feat/powerlaw-calibrate
Oct 19, 2026
Merged

eliotmcintire merged 2 commits into
developmentfrom
feat/powerlaw-calibrate

Conversation

@eliotmcintire

Copy link
Copy Markdown
Contributor

Adds a way to set the spread model's one fixed shape number for each ELF from that ELF's own landscape, instead of one value for all ELFs. Nothing changes until fireSense_spreadFit calls it (PredictiveEcology/fireSense_spreadFit, same change).

Affects: nothing existing; new functions and constants only.

Technical details

gamma of the "powerLaw" link was the fixed spreadPowerLawGamma (1.9, R/constants.R:116), although it is confounded with the coefficient scale and depends on the landscape. New calibratePowerLaw() (R/calibratePowerLaw.R) spreads fires with SpaDES.tools::spreadCpp() as the fit and fireSense_burn do (8 directions, escapeSizePixels(), jumpTries, jumpMeanDist) at constant p on the flammable pixels from random starts in the largest connected patch, finds p_c50 where half the fires burn at least 25% of that patch (isotonic regression, interpolated), and gives gamma as the slope of log mean ha on log(p_c50 - p) below p_c50, with R2 and the per-p table. Results are set by the seed only (one L'Ecuyer-CMRG stream per fire), not by cores, and the caller's RNG state is restored. New powerLawPcBounds() (floor + 0.01 to p_c50 + margin; spreadPowerLawPcBounds stays as the outer limits), spreadPowerLawPGrid, and ledger column names spreadFitPowerLawPc50Txt, spreadFitPowerLawR2Txt, spreadFitPowerLawPcMarginTxt. On a real ELF mask (14.3, 100 fires per p, 16 cores, 80 s) it gave p_c50 0.264, gamma 3.08, R2 0.98, against 0.265 / 3.25 from the original GAM scripts. Tests: test-calibratePowerLaw.R (uniform map p_c50 near 0.25, breaks raise it, seed and cores, RNG state, error cases, bounds). Full suite 2168 passed, 0 failed (base 2150); R CMD check --no-manual --no-build-vignettes (scratch library): 0 errors, 0 notes, 2 vignette warnings that come only from skipping the vignette build.

🤖 Generated with Claude Code

https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6

…'s flammable map; powerLawPcBounds()

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6
@codecov

codecov Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.83051% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.48%. Comparing base (bd81487) to head (a5db849).

Files with missing lines Patch % Lines
R/calibratePowerLaw.R 89.83% 6 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           development     #168   +/-   ##
============================================
  Coverage        89.47%   89.48%           
============================================
  Files               51       52    +1     
  Lines             4466     4525   +59     
============================================
+ Hits              3996     4049   +53     
- Misses             470      476    +6     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…(Windows)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6
@eliotmcintire
eliotmcintire merged commit ab5c521 into development Oct 19, 2026
16 checks passed
@eliotmcintire
eliotmcintire deleted the feat/powerlaw-calibrate branch October 19, 2026 03:06
eliotmcintire added a commit that referenced this pull request Oct 19, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backwards compatible Existing code and results keep working unchanged enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant