Skip to content

add partitionBurnRateMultiplier() and fireMultiplier for calcZonalRegimePars() - #18

Open
AllenLarocque wants to merge 3 commits into
PredictiveEcology:developmentfrom
AllenLarocque:feature/partitionBurnRateMultiplier
Open

AllenLarocque wants to merge 3 commits into
PredictiveEcology:developmentfrom
AllenLarocque:feature/partitionBurnRateMultiplier

Conversation

@AllenLarocque

@AllenLarocque AllenLarocque commented Oct 24, 2026 •

Copy link
Copy Markdown

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 targetBurnRate per 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 by multiplier^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 existing ratioPartition2(), the same split targetBurnRate uses. Because ratioPartition2() caps escape at 1, ignition changes once the multiplier exceeds 4 * min(4, 1 / pEscape) (16 when pEscape <= 0.25).
  • Special cases: a multiplier of 1 returns the inputs; 0 means no fire (ignition rate and escape set to 0); pEscape = 0 warns and returns the inputs unchanged.

New arguments for calcZonalRegimePars(), all of which do nothing at their defaults:

Argument Default Effect
fireMultiplier 1 Applies partitionBurnRateMultiplier() to the polygon's ignition rate, escape probability and mean fire size
fireMultiplierMethod "weighted" Passed to partitionBurnRateMultiplier()
fireMultiplierWeights c(ignition = 1/3, escape = 1/3, size = 1/3) Passed to partitionBurnRateMultiplier()
scaleMaxFireSize FALSE If TRUE, xMax and emfs_ha are scaled by the same factor as the mean fire size

targetBurnRate keeps its current behaviour and takes priority: in a polygon with a targetBurnRate, fireMultiplier is ignored, with a message. If that targetBurnRate is below the empirical rate, it is ignored as before (existing warning), and the message says that neither is applied. targetMaxFireSize still overrides the maximum fire size, including after scaleMaxFireSize. empiricalBurnRate in the output stays the unscaled rate from the data.

The @param entries of calcZonalRegimePars(), 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

  • Existing calls are unchanged: the new arguments come after the existing ones and do nothing at their defaults. The tests pin the outputs of 2.0.9.9009 (calcZonalRegimePars() is unchanged since 2.0.9.9005) on a synthetic polygon for the defaults, for targetBurnRate (above and below the empirical rate) and for targetMaxFireSize.
  • No existing function, default or output column changes. 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 to ratioPartition2(); pEscape = 0; invalid multipliers and weights; weights in any order.
  • test-calcZonalRegimePars.R: defaults and targetBurnRate match 2.0.9.9009; targetBurnRate priority (with message), and neither applied when the target is below the empirical rate; the multiplier applied via the partition; weights passed through; scaleMaxFireSize; targetMaxFireSize priority; 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).
  • The package tests pass locally at 48ee0ae (205 passed, 2 skipped, 0 failed; 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

  • A scfm PR will add the matching parameters to scfmDataPrep once this is merged (scfm CI installs scfmutils @development).
  • fireMultiplier and fireMultiplierWeights per polygon (by PolyID, like targetBurnRate): a separate PR after this one.

🤖 Generated with Claude Code

@achubaty

Copy link
Copy Markdown
Contributor

Code review

Found 2 issues:

  1. The weights docs say the default "follows a national-scale reading of the literature", but cite nothing. Please add the reference(s) behind c(ignition = 0.3, escape = 0.4, size = 0.3), or describe the default as a modelling choice.

#' component; names `ignition`, `escape`, and `size`, in any order, non-negative, summing to 1.
#' The default follows a national-scale reading of the literature that escape contributes
#' slightly more than ignition and size to changes in area burned.
#'

  1. The stepwise docs say ignition rate "changes only when multiplier > 16". That holds only while escape probability stays below 1. ratioPartition2() shrinks any escape step that would take pEscape above 1 and passes the unused factor to later steps, so ignition changes sooner. For example, with pEscape = 1 and multiplier = 5, escape stays at 1, mean size is doubled twice, and ignition rate is multiplied by 1.25. The same happens whenever pEscape > 0.25.

#' Uses [ratioPartition2()], as `calcZonalRegimePars()` does for `targetBurnRate`:
#' the components are multiplied in steps of up to 2, in the order escape, size, escape, size,
#' ignition, and any remainder goes to mean fire size. Ignition rate therefore changes only when
#' `multiplier > 16`. Below 1, the whole reduction is applied to escape probability.
#'

step <- min(remains, 2)
#peEscape can't exceed 1
newEscape <- pmin(pEscape * step, 1)
step <- pmin(step, newEscape/pEscape)
pEscape <- newEscape
remains <- remains/step
step <- min(remains, 2)
xBar <- xBar * step
remains <- remains / step
step <- min(remains, 2)
newEscape <- pmin(pEscape * step, 1)
step <- pmin(step, newEscape/pEscape)
pEscape <- newEscape

Minor:

  • If targetBurnRate is below the empirical rate, it is ignored with a warning, and fireMultiplier is then skipped too, with a message saying the target is set. So neither applies in that polygon.

## TODO: improve messaging for users
warning("ratio cannot be < 1. Please make sure this does not happen.")
}
}
if (!isTRUE(fireMultiplier == 1)) {
if (!is.na(targetBurnRate)) {
message("fireMultiplier is ignored in polygon ", polygonID, " because targetBurnRate is set.")
} else {

  • fireMultiplier takes one value for all polygons, but targetBurnRate and targetMaxFireSize take one value per polygon, named by PolyID. Should the multiplier also be set per polygon?

## check for user supplied defaults
targetBurnRate <- targetBurnRate[polygonID]
targetMaxFireSize <- targetMaxFireSize[polygonID]

  • The description says both "Includes a rework of ratioPartition2()" and "ratioPartition() / ratioPartition2() are untouched". The diff agrees with the second.

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 #___ in the description should be #17.

🤖 Generated with Claude Code

- If this code review was useful, please react with 👍. Otherwise, react with 👎.

@AllenLarocque

Copy link
Copy Markdown
Author

Thanks Alex for the careful review. Changes are in 90653e8 and 48ee0ae:

  1. Default weights. Nothing published decomposes a burn-rate change into ignition, escape and size, so there is no reference to add - these numbers were a guestimate based on the literature and brief review. I think this deserves separate investigation and indeed is one of the motivating ideas behind these changes. The docs now call the default a modelling choice. I also changed the default itself, from 0.3/0.4/0.3 to an equal split (1/3 each): we expect the split to differ among regions and fire regimes, and an equal default doesn't favour one component so seems like a good default without further information. Since nothing is merged yet, this changes no existing results. Tests, NEWS and the description are updated. Regional weights are something we want to explore separately.

  2. Stepwise docs. You're right. The docs now say ignition changes once multiplier > 4 * min(4, 1 / pEscape): above 16 only while pEscape <= 0.25, and above 8 at pEscape = 0.5, for example. Checked numerically for pEscape of 0.1, 0.25, 0.3, 0.5 and 1.

  3. targetBurnRate below the empirical rate. targetBurnRate still takes priority and is still ignored with the existing warning. The message now says that neither targetBurnRate nor fireMultiplier is applied in that polygon, and a test covers the case. I kept the priority rather than falling back to fireMultiplier, so the existing targetBurnRate behaviour is unchanged.

  4. Per-polygon multiplier. Agreed, it should follow targetBurnRate (named by PolyID), and so should the weights. I'd rather do it as a separate PR after this one, to keep this one reviewable. Added under "Follow-up" in the description.

  5. Description. The "rework of ratioPartition2()" line is gone; ratioPartition() and ratioPartition2() are untouched. #___ is now Bug fix: calcZonalRegimePars(): treat NULL targetBurnRate / targetMaxFireSize … #17.

Merge order: I'll rebase this onto development once #17 is merged and resolve the DESCRIPTION, NEWS.md and test-file conflicts then.

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.

agent-allen-larocque and others added 3 commits November 5, 2026 13:58
…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>

This branch has not been deployed

No deployments
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.

3 participants