Repository navigation
add partitionBurnRateMultiplier() and fireMultiplier for calcZonalRegimePars() - #18
Conversation
Code reviewFound 2 issues:
scfmutils/R/partitionBurnRateMultiplier.R Lines 39 to 42 in c6ba1e1
scfmutils/R/partitionBurnRateMultiplier.R Lines 21 to 25 in c6ba1e1 Lines 102 to 116 in c6ba1e1 Minor:
scfmutils/R/utils_scfmRegime.R Lines 139 to 147 in c6ba1e1
scfmutils/R/utils_scfmRegime.R Lines 63 to 66 in c6ba1e1
Merge note: this branch conflicts with #17 in DESCRIPTION, NEWS.md and tests/testthat/test-calcZonalRegimePars.R (both PRs create that file). The 2.0.9.9012 bump assumes #17 merges first, so please rebase after it does. The 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
|
Thanks Alex for the careful review. Changes are in 90653e8 and 48ee0ae:
Merge order: I'll rebase this onto Tests at 48ee0ae: package 205 passed, 2 skipped (interactive only), 0 failed; the scfm module tests (8 modules, 139 tests) pass with this branch installed. |
…imePars() - new partitionBurnRateMultiplier() splits a burn rate multiplier among ignition rate, escape probability and mean fire size: weighted (default weights 0.3 / 0.4 / 0.3, escape capped at 1 with the excess redistributed) or stepwise (calls ratioPartition2() unchanged); 0 means no fire, negative values are an error - calcZonalRegimePars() gets fireMultiplier, fireMultiplierMethod, fireMultiplierWeights and scaleMaxFireSize; the defaults change nothing, and targetBurnRate keeps its behaviour and priority - document calcZonalRegimePars() arguments - tests, including a regression test against 2.0.9.9005 outputs - bump version to 2.0.9.9007 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- describe the default weights as a modelling choice, not a published estimate - stepwise docs: ignition changes once multiplier > 4 * min(4, 1 / pEscape), because pEscape is capped at 1 - calcZonalRegimePars(): when targetBurnRate is below the empirical rate and fireMultiplier is set, say that neither is applied (targetBurnRate still takes priority); add a test Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The split of a burn-rate change among ignition, escape and size is expected to differ among regions; an equal split is the neutral default. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
48ee0ae to
d2f411b
Compare
Part of my build to allow for either 'more fire' or 'less fire' than that which is estimated from historical data. It needs #17 merged first.
Now the precise partitions are made out to be parameters so that you can tune how much of the total fire increase (or decrease) comes from changes in ignition or escape or spread.
Note that ratioPartition() has been busted since ~2022 but I haven't removed it here... It probably should be.
What
A way to scale each fire regime polygon's empirical burn rate by a factor (e.g. ×2 for a scenario with more fire), as an alternative to setting an absolute
targetBurnRateper polygon.New function
partitionBurnRateMultiplier(). scfm's burn rate is approximately ignition rate × escape probability × mean fire size. This splits a multiplier among the three so that their product is exactly the multiplier:method = "weighted"(default): each component is multiplied bymultiplier^weight. The default weights are equal (1/3 each), so ×2 multiplies each component by about 1.26. The split is expected to differ among regions; the equal default is a neutral modelling choice, not a published estimate. If escape would exceed 1, it is capped and the remainder goes to ignition and size in proportion to their weights, so the product is still exact.method = "stepwise": calls the existingratioPartition2(), the same splittargetBurnRateuses. BecauseratioPartition2()caps escape at 1, ignition changes once the multiplier exceeds4 * min(4, 1 / pEscape)(16 whenpEscape <= 0.25).pEscape = 0warns and returns the inputs unchanged.New arguments for
calcZonalRegimePars(), all of which do nothing at their defaults:fireMultiplier1partitionBurnRateMultiplier()to the polygon's ignition rate, escape probability and mean fire sizefireMultiplierMethod"weighted"partitionBurnRateMultiplier()fireMultiplierWeightsc(ignition = 1/3, escape = 1/3, size = 1/3)partitionBurnRateMultiplier()scaleMaxFireSizeFALSETRUE,xMaxandemfs_haare scaled by the same factor as the mean fire sizetargetBurnRatekeeps its current behaviour and takes priority: in a polygon with atargetBurnRate,fireMultiplieris ignored, with a message. If thattargetBurnRateis below the empirical rate, it is ignored as before (existing warning), and the message says that neither is applied.targetMaxFireSizestill overrides the maximum fire size, including afterscaleMaxFireSize.empiricalBurnRatein the output stays the unscaled rate from the data.The
@paramentries ofcalcZonalRegimePars(), which were TODOs, are filled in.Why in
calcZonalRegimePars()The three components are computed there, and both scfmDataPrep and scfmRegime call it, so the multiplier goes beside
targetBurnRate, which already adjusts the same values.Backward compatibility
calcZonalRegimePars()is unchanged since 2.0.9.9005) on a synthetic polygon for the defaults, fortargetBurnRate(above and below the empirical rate) and fortargetMaxFireSize.ratioPartition()/ratioPartition2()are untouched.Tests
test-partitionBurnRateMultiplier.R: identity; zero; exact product across weight sets and multipliers from 0.25 to 20; the documented ×2 factors; escape cap and redistribution; the warning when the target cannot be reached;"stepwise"equal toratioPartition2();pEscape = 0; invalid multipliers and weights; weights in any order.test-calcZonalRegimePars.R: defaults andtargetBurnRatematch 2.0.9.9009;targetBurnRatepriority (with message), and neither applied when the target is below the empirical rate; the multiplier applied via the partition; weights passed through;scaleMaxFireSize;targetMaxFireSizepriority; zero; negative multiplier errors.devtools::check()at c6ba1e1: 0 errors, 0 warnings (run locally without examples or vignettes, since the sandbox cannot reach the example download hosts or run pandoc).NOT_CRAN=true; the skips need an interactive session). The tests of the scfm modules (PredictiveEcology/scfm@development f5a7748 plus the scfm fireMultiplier branch) pass with this branch installed (build c6ba1e1; the later commits change only docs, a message and the default weights, which scfmDataPrep passes explicitly): 8 modules, 139 tests, rerun 2026-11-02 (scfmDriver, deprecated, not run).Version
2.0.9.9010 → 2.0.9.9012 (2.0.9.9011 is the separate NULL-target fix PR, #17; if this PR merges first, that one is bumped to 2.0.9.9013). NEWS entry added.
Follow-up
@development).fireMultiplierandfireMultiplierWeightsper polygon (byPolyID, liketargetBurnRate): a separate PR after this one.🤖 Generated with Claude Code