Skip to content

Split the spread climate covariate into a between-year and a within-year term - #244

Open
eliotmcintire wants to merge 2 commits into
developmentfrom
climateSplit
Open

eliotmcintire wants to merge 2 commits into
developmentfrom
climateSplit

Conversation

@eliotmcintire

@eliotmcintire eliotmcintire commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

The fire spread model uses one climate coefficient for both the year-to-year swings and the differences between places within a year. This adds the shared tools to give each its own coefficient, so a run can test it as a separate arm.

Affects: nothing changes unless a run turns on the new split-climate option in fireSense_dataPrepFit; then the spread model has two climate terms instead of one.

Technical details

Part of one change with PredictiveEcology/fireSense_dataPrepFit, fireSense_spreadFit and fireSense_spreadPredict (the other three PRs Depends-on this one). In ELF 6.6.2 the l_pow05 fit gives climate 2% of the between-year variance of the spread linear predictor, although annual climate correlates 0.47-0.60 with annual fire size. One coefficient serves the spatial gradient (confounded with fuel) and the year-to-year swings.

Fix: new R/spreadClimateSplit.R.

  • splitSpreadClimate(dt, vars, ref, by) replaces climate C by C_yr (the year's median of C over the ELF's burnable pixels, stats::median(na.rm = TRUE) at full precision, same value for every pixel of a year) and C_dev (C - C_yr). The fit calls it per year (by = "year"), the prediction once for the year's layer. This is the one place the median is computed.
  • climateSplitCols(), climateSplitBase(), isClimateSplitCol() and the suffixes climateSplitYrSuffix, climateSplitDevSuffix are the one definition of the names.
  • climateSplitRanges(ranges) adds fixed rescaling ranges: _yr has the variable's range, _dev the same width centred on 0 (c(-w/2, w/2)), so one unit of each is the same amount of climate. A range already given for a split name is kept.
  • climateSplitRefPixels(pixelID, flammableRTM, elfPixels) is the one choice of the pixels the median is over: the ELF's flammable pixels. The fit passes its burnable pixels; the prediction passes its table's rows with flammableRTM and the ELF's own cells.
  • elfCellLabels(r) is the one lookup of the ELF of each cell of rasterToMatchLargeELF (category labels, else values), used by fireSense_spreadPredict and fireSense_dataPrepPredict.
  • spreadFitLedgerInputs() took the climate variable of a fit from its parameter names, which would not find CMD in CMD_yr/CMD_dev. It now strips the suffixes (climateSplitBase()).

Sign rule (applied by name in fireSense_spreadFit, no change there): names with CMD or MDC are bounded below by 0, so CMD_yr, CMD_dev, cumMDC_yr are >= 0. Tmaxsm terms are not constrained today, so Tmaxsm_yr/Tmaxsm_dev are not either. Bounds are not narrowed otherwise.

Consumers checked and unchanged because they read the design columns generically: spreadDesignCols(), covariate rescaling and centring, objFunSpread.R, spreadProbGates, spreadClimateCols() (both terms count as climate for the climateOutside link).

Overlap with the spreadInteractions work: that one also touches the formula and design columns. This diff adds one new file and a one-line change in spreadFitLedgerInputs().

Merge order with the interaction PRs (#242, PredictiveEcology/fireSense_dataPrepFit#107, PredictiveEcology/fireSense_spreadFit#131, PredictiveEcology/fireSense_spreadPredict#43), whichever merges first: interaction terms must use fireSenseUtils::climateSplitCols(spreadVars), so CMD_yr:fuel and CMD_dev:fuel; and in fireSense_spreadPredict the interaction PR's needed <- spreadSourceCols(fitted) must come after the split block of spreadProbOneELF(), which makes CMD_yr and CMD_dev from CMD.

Reuses: stats::median, data.table update join, climateCovRanges, spreadFitLedgerInputs(), the label lookup of ELFblendWeights() (moved here as elfCellLabels(), and fireSense_dataPrepPredict's second copy now calls it); new: splitSpreadClimate, climateSplitCols, climateSplitBase, isClimateSplitCol, climateSplitRanges, climateSplitRefPixels (nothing existing builds or names the two terms, derives their ranges, or picks the reference pixels), elfCellLabels (the moved lookup, one copy).

Tests (new test-spreadClimateSplit.R, 20 expectations): names; the between term is constant within a year and equals the median over the reference pixels (not the fitted buffer's); C_dev = C - C_yr; a fit-style call (by year, buffer pixels) and a prediction-style call (one year, whole ELF) give the same values; NA is ignored; ranges; a split fit's variable is found in spreadFitLedgerInputs(). Also: reference pixels drop non-flammable and blend-zone cells; a fit-style table and a prediction table with an extra non-flammable row give the same C_yr; elfCellLabels(). Full suite: base 0 failures, 0 errors, 16 skips, 3138 passed; branch 0 failures, 0 errors, 16 skips, 3167 passed. On base the new file errors (the functions do not exist). rcmdcheck (--no-manual --no-tests, _R_CHECK_FORCE_SUGGESTS_=false, scratch library libClimSplit + lib9175): 0 errors, 0 warnings, 2 notes, neither from this change (the worktree's .git; objFunInner, which this diff does not touch).

No version bump. The module reqdPkgs floors are raised after this merges.

🤖 Generated with Claude Code

https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6

…ear term: splitSpreadClimate(), climateSplitRanges() and helpers; spreadFitLedgerInputs() finds a split fit's climate variable

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6
@eliotmcintire eliotmcintire added enhancement New feature or request backwards compatible Existing code and results keep working unchanged labels Nov 16, 2026
@codecov

codecov Bot commented Nov 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.54%. Comparing base (0ab500d) to head (2dc8809).
⚠️ Report is 1 commits behind head on development.

Additional details and impacted files
@@               Coverage Diff               @@
##           development     #244      +/-   ##
===============================================
+ Coverage        93.52%   93.54%   +0.02%     
===============================================
  Files               67       68       +1     
  Lines             5265     5285      +20     
===============================================
+ Hits              4924     4944      +20     
  Misses             341      341              

☔ 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.

…r fit and prediction) and elfCellLabels() (one cell-label lookup)

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