Repository navigation
New parameter spreadClimateSplit: the spread climate as a between-year and a within-year term - #108
Open
eliotmcintire wants to merge 2 commits into
Open
eliotmcintire wants to merge 2 commits into
eliotmcintire wants to merge 2 commits into
Conversation
…etween-year and a within-year term Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6
…me from fireSenseUtils::climateSplitRefPixels(); cell labels from elfCellLabels() Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6
This branch has not been deployed
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.
The fire spread model uses one climate coefficient for both how dry a year is overall and how one place differs from the rest of the region within a year. This adds an option, off by default, that gives each its own coefficient, so a run can test whether year-to-year climate then explains more of the variation in fire size.
Affects: nothing changes unless a run sets
spreadClimateSplit = TRUE; then the spread model has two climate terms in place of one, and the fit data are rebuilt.Depends-on: PredictiveEcology/fireSenseUtils#244
Technical details
Part of one change with PredictiveEcology/fireSenseUtils#244, fireSense_spreadFit (PredictiveEcology/fireSense_spreadFit#132) and fireSense_spreadPredict (PredictiveEcology/fireSense_spreadPredict#44). Motivation: in ELF 6.6.2 the
l_pow05fit gives climate 2% of the between-year variance of the spread linear predictor (the random year effect takes the rest), although annual climate correlates 0.47-0.60 with annual fire size and area. The single coefficient is also pulled by the spatial gradient, which is confounded with fuel.New parameter
spreadClimateSplit(defaultFALSE).FALSEgives the same formula string as before (spreadFormula(RHS)is unchanged, so cache keys that hold it do not move; the parameter itself is in theprepSpreadFitDatakey, so that event re-runs once).TRUE:<C>_yr + <C>_devwhere it had<C>(fireSenseUtils::climateSplitCols()), for example~ 1 + CMD_yr + CMD_dev + youngAge + ...;annualSpreadCovariates(climateSplit = TRUE)replacesCin each year's table byC_yr, the year's median ofCover that year's burnable pixels (burnablePixels, the ELF's flammable pixels: the pixels a prediction has), andC_dev = C - C_yr, withfireSenseUtils::splitSpreadClimate().Design choice to confirm: the median is taken over the ELF's burnable pixels (the data year's
landcoverDTs: flammable, land cover not 0; chosen withfireSenseUtils::climateSplitRefPixels(), the same function the prediction uses), not over the fitted fire-buffer pixels. A buffer median would be biased toward where fires occurred and a prediction cannot reproduce it, so the fit and the prediction would use different between-year values. The cost is one moreclimateRasterToDataTable()call (cached) over the burnable pixels, only when the option is on. WithwholeLandscapeSpreadCovariatesthe two pixel sets are the same.Sign rule and ranges: see fireSense_spreadFit#132 (names with
CMD/MDCkeep the lower bound 0 on both terms;Tmaxsmterms stay free; fixed ranges for both).Checked, no change:
fireSense_dataPrepPredict(its covariate table has the base climate; the ledger row's names carry the split).mod$spreadFormulaClimateand the hindcast path read the climate variable from the ledger throughspreadFitLedgerInputs(), fixed in fireSenseUtils#244. A prediction needs nospreadClimateSplitsetting. A fit reused from the ledger (doFitFALSE, e.g. a predict-only or hindcast job) keeps its own split:Init()setsmod$spreadClimateSplitfrom the ledger row's coefficient names (isClimateSplitCol()), anduseClimateSplit(mod, Par)makes that win over the parameter when building the formula and the tables. A reused unsplit fit stays unsplit even with the parameterTRUE; a refit follows the parameter.Overlap with the
spreadInteractionswork: that one also edits the formula builder (RHS, about line 1070) and the fit tables. This diff changes only the climate part ofRHS:paste0(<climate terms>, collapse = " + "). It also addsclimateSplitColsandsplitSpreadClimateto theprepSpreadFitData.cacheExtra.Merge order with the interaction PRs (PredictiveEcology/fireSenseUtils#242, #107, PredictiveEcology/fireSense_spreadFit#131, PredictiveEcology/fireSense_spreadPredict#43), whichever merges first: interaction terms must use
fireSenseUtils::climateSplitCols(spreadVars), soCMD_yr:fuelandCMD_dev:fuel; and in fireSense_spreadPredict the interaction PR'sneeded <- spreadSourceCols(fitted)must come after the split block ofspreadProbOneELF(), which makesCMD_yrandCMD_devfromCMD.Reuses:
fireSenseUtils::climateSplitCols(),splitSpreadClimate(),climateSplitRefPixels(),isClimateSplitCol(),climateRasterToDataTable()(the call is now a small local functionclimateAt()used for the fitted pixels and the burnable pixels),burnablePixelsByFireYear()output; new: nothing in this module (the shared logic is in fireSenseUtils).Tests (in
test-wholeLandscapeSpreadCovariates.R, which has the annual-table fixture): with the split, the tables haveCMD_yr(the median over burnable pixels 1:16, not over the buffer pixels), constant within a year,CMD_dev = CMD - CMD_yr, noCMD, and the same rows; the default formula string~ 1 + CMD + youngAge + class1 + class2is unchanged andTRUEgives~ 1 + CMD_yr + CMD_dev + youngAge + ...; the parameter defaults toFALSE.test-metadata.Rhas the new parameter name. Reuse tests intest-spreadClimateOwnELF.R(a ledger fit withCMD_yr/CMD_devand the parameter FALSE gets the split; an unsplit fit with TRUE stays unsplit; a refit follows the parameter) and the formula test withmod$spreadClimateSplit. Full suite on the branch: 0 failures, 0 errors, 1 skip (dataPrepBuildcold/warm cache, as on base), 563 passed. On base (origin/development with the new tests copied in): 2 failures and 5 errors, all in the new tests, 1 skip, 526 passed. Ran against the fireSenseUtils branch loaded withpkgload::load_all(), in aSpaDES.core::convertToPackage()copy.No version bump. The
reqdPkgsfloor on fireSenseUtils is set after #244 merges and its version is bumped.🤖 Generated with Claude Code
https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6