From a7096403b155d7dac6c2311bc5337e562cafcb9d Mon Sep 17 00:00:00 2001 From: Eliot McIntire Date: Wed, 25 Nov 2026 15:44:17 -0700 Subject: [PATCH 1/5] Apply an escape fit's year climate term to the expected escapes Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01Lx3DXhXsFis2pbqBTh2PPh --- NEWS.md | 1 + fireSense_ignitionPredict.R | 19 ++++++++++--------- tests/testthat/test-run-values.R | 30 ++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 9 deletions(-) diff --git a/NEWS.md b/NEWS.md index 9d49cf2..df88296 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,6 @@ # fireSense_ignitionPredict (development version) +* An escape fit with a year climate term (`modelList$yearClimate` of fireSense_ignitionFit's new `escapeYearClimate`) has its expected escapes multiplied by it, from the same year mean of the covariates as the ignitions' term (`yearClimateMultiplierOf()` now takes either fit). With the hinge (`beta2`, fireSense_ignitionFit's `yearClimateHinge`) the dry half is steeper. A fit without the term is unchanged. Needs fireSenseUtils (>= 0.2.3.9193). * A fit with a year climate term (`modelList$yearClimate` of fireSense_ignitionFit's new `ignitionYearClimate`) has its expected ignitions multiplied by `exp(beta * z)`, `z` this year's standardised mean of the climate covariate over the ELF's pixels (`fireSenseUtils::yearClimateMultiplier()`; the fit and the prediction take the same unweighted mean over the rows with the covariate and core, `fireSenseUtils::yearClimateMeans()`, in the predict taken before `na.omit()` so a pixel with an NA in another column still counts, and the multiplier averages 1 over the fit years). The covariates must carry `coreFraction` (added by fireSense_dataPrepPredict, in the same way as for the fit): without it a fit that has the term stops with a message. Escapes are untouched; fits without the term are unchanged. Needs fireSenseUtils (>= 0.2.3.9183). * The yearly ignition and escape probability map (`.plots = "png"`) is bigger. Its png is now 10 x 8 inches at 144 dpi (1440 x 1152 pixels), as fireSense_burn's; it was R's `png()` default of 480 x 480, which looked small in `SpaDES.shiny::shine()`. * The yearly map shows the escape probability beside the ignition probability (`IgnitionEscapeProbability_yr`, was `IgnitionProbability_yr`), both layers of `fireSense_IgAndEscapeProbRas`, and their product, the expected number of escaped fires starting in each pixel that year (`expectedEscapes`). diff --git a/fireSense_ignitionPredict.R b/fireSense_ignitionPredict.R index d0958b8..f8330d2 100644 --- a/fireSense_ignitionPredict.R +++ b/fireSense_ignitionPredict.R @@ -20,7 +20,7 @@ defineModule(sim, list( "data.table", "magrittr", "terra", "xgboost (>= 3.0.0)", "PredictiveEcology/SpaDES.core@development (>= 3.0.4)", "PredictiveEcology/reproducible@development", - "PredictiveEcology/fireSenseUtils@development (>= 0.2.3.9184)" # 9184: yearClimateMeans(covariates, variable) unweighted, yearClimateMultiplier() norm; 9182: yearClimateColumn(), yearClimateMultiplier(); 9177: storedFitProblem(); 9168: foldModels(), foldMeanPrediction() + "PredictiveEcology/fireSenseUtils@development (>= 0.2.3.9193)" # 9193: yearClimateMultiplier() reads beta2; 9184: yearClimateMeans(covariates, variable) unweighted, yearClimateMultiplier() norm; 9182: yearClimateColumn(), yearClimateMultiplier(); 9177: storedFitProblem(); 9168: foldModels(), foldMeanPrediction() ), loadOrder = list(after = "fireSense_dataPrepPredict"), parameters = bindrows( @@ -145,8 +145,8 @@ doEvent.fireSense_ignitionPredict <- function(sim, eventTime, eventType, debug = #' Averages the per-fold predictions of the ignition models and of the escape models, for every coarse #' pixel with covariates (`fireSenseUtils::foldMeanPrediction()`), and gives each pixel its fits' year-effect sd #' (`yearSDOf()`) and, when they have one, their fitted effect of this year (`yearEffectOf()`). A fit with a year -#' climate term (`modelList$yearClimate`, `fireSense_ignitionFit`'s `ignitionYearClimate`) has its expected ignitions -#' multiplied by `yearClimateMultiplierOf()`; escapes have none. Nothing is +#' climate term (`modelList$yearClimate`, `fireSense_ignitionFit`'s `ignitionYearClimate` and `escapeYearClimate`) has its +#' expected ignitions, or escapes, multiplied by `yearClimateMultiplierOf()`, the same year's mean for both. Nothing is #' drawn: `fireSense_burn` draws ignitions and escapes from these means, #' with the distribution named in `fireSense_IgAndEscapeDistribution`. #' @@ -188,8 +188,9 @@ IgnitionPredictRun <- function(sim) { # own mean and sd would make every year look average. covsIgn <- if (rescaleVars) scaleAsFit(covsHere, f$ign$scaleData, "fireSense_IgnitionFitted") else covsHere covsEsc <- if (rescaleVars) scaleAsFit(covsHere, f$esc$scaleData, "fireSense_EscapeFitted") else covsHere - predsIgns[f$rows] <- fireSenseUtils::foldMeanPrediction(f$ign, covsIgn) * yearClimateMultiplierOf(f$ign, if (!is.null(f$ign$modelList$yearClimate)) igCovAll[f$allRows]) - predsEscs[f$rows] <- fireSenseUtils::foldMeanPrediction(f$esc, covsEsc) + ## `covariates` of `yearClimateMultiplierOf()` is read only by a fit with a term (lazy), the same year mean for both + predsIgns[f$rows] <- fireSenseUtils::foldMeanPrediction(f$ign, covsIgn) * yearClimateMultiplierOf(f$ign, igCovAll[f$allRows]) + predsEscs[f$rows] <- fireSenseUtils::foldMeanPrediction(f$esc, covsEsc) * yearClimateMultiplierOf(f$esc, igCovAll[f$allRows]) sdIgns[f$rows] <- yearSDOf(f$ign) sdEscs[f$rows] <- yearSDOf(f$esc) effIgns[f$rows] <- yearEffectOf(f$ign, year) @@ -332,16 +333,16 @@ yearSDOf <- function(fit) { if (is.null(sd)) 0 else sd } -#' The year climate multiplier of a fit's expected ignitions +#' The year climate multiplier of a fit's expected ignitions or escapes #' #' `fireSense_ignitionFit` stores `modelList$yearClimate` (`list(variable, center, scale, beta, norm)`) with a year #' climate term; the multiplier is `fireSenseUtils::yearClimateMultiplier()` of this year's mean of the raw covariate -#' over the fit's pixels, `fireSenseUtils::yearClimateMeans()`, the same definition the fit used (unweighted mean over +#' over the fit's pixels, `fireSenseUtils::yearClimateMeans()`, the same definition the fit used (the ignition covariates' means, for an escape fit too) (unweighted mean over #' the rows with the variable and with core: it needs the `coreFraction` column `fireSense_dataPrepPredict` adds). A fit without the term (older fits) gives 1, and so does a year with no #' usable row, with a warning. Stops if the covariates hold more than one year, or lack the variable or `coreFraction`. #' -#' @param fit A `fireSense_IgnitionFitted`. -#' @param covariates The raw (not standardised) covariates of the fit's pixels, one year, before `na.omit()` (`f$allRows` of `IgnitionPredictRun()`); not used by a fit without the term. +#' @param fit A `fireSense_IgnitionFitted` or `fireSense_EscapeFitted`. +#' @param covariates The raw (not standardised) covariates of the fit's pixels, one year, before `na.omit()` (`f$allRows` of `IgnitionPredictRun()`); not used (not evaluated) by a fit without the term. #' @return One number. yearClimateMultiplierOf <- function(fit, covariates) { yc <- fit$modelList$yearClimate diff --git a/tests/testthat/test-run-values.R b/tests/testthat/test-run-values.R index e048a2b..d58bd22 100644 --- a/tests/testthat/test-run-values.R +++ b/tests/testthat/test-run-values.R @@ -196,3 +196,33 @@ test_that("a year with no usable covariate gives a multiplier of 1 and a warning toyIgCovariates()[integer(0), , drop = FALSE]), "it is 1") expect_identical(m, 1) }) + +## the year climate term of the escapes (fireSense_ignitionFit's `escapeYearClimate`), with the same year mean +test_that("an escape fit's year climate term scales the expected escapes by the same z, ignitions untouched", { + dry <- twoFolds(covs = toyIgCovariates(MDC = c(100, 120, 140, 160) + 20)) # z = 1 + dry$fireSense_EscapeFitted$modelList$yearClimate <- modifyList(toyClimate, list(beta = 0.3, norm = 2)) + sim <- toyIgRun(dry) + expect_equal(probVals(sim)[, "escapeProb"], rep(1, 4) * exp(0.3) / 2) + expect_equal(probVals(sim)[, "ignitionProb"], c(0, 3, 3, 0)) + ## both terms at once: each fit's own beta, one z + both <- withYearClimate(dry, toyClimate) + simB <- toyIgRun(both) + expect_equal(probVals(simB)[, "ignitionProb"], c(0, 3, 3, 0) * exp(0.5)) + expect_equal(probVals(simB)[, "escapeProb"], rep(1, 4) * exp(0.3) / 2) + ## the hinge: the dry half is steeper + dry$fireSense_EscapeFitted$modelList$yearClimate$beta2 <- 0.4 + expect_equal(probVals(toyIgRun(dry))[, "escapeProb"], rep(1, 4) * exp(0.3 + 0.4) / 2) + ## a wet year (z = -1) does not feel it + wet <- twoFolds(covs = toyIgCovariates(MDC = c(100, 120, 140, 160) - 20)) + wet$fireSense_EscapeFitted$modelList$yearClimate <- dry$fireSense_EscapeFitted$modelList$yearClimate + expect_equal(probVals(toyIgRun(wet))[, "escapeProb"], rep(1, 4) * exp(-0.3) / 2) + ## no term (the default): escapes are untouched + expect_equal(probVals(toyIgRun(twoFolds(covs = toyIgCovariates(MDC = c(100, 120, 140, 160) + 20))))[, "escapeProb"], rep(1, 4)) +}) + +test_that("an escape fit with a term and covariates without coreFraction stops", { + noCore <- toyIgCovariates(); data.table::set(noCore, NULL, "coreFraction", NULL) + ins <- twoFolds(covs = noCore) + ins$fireSense_EscapeFitted$modelList$yearClimate <- toyClimate + expect_error(toyIgRun(ins), "no `coreFraction` column") +}) From 42046929dc6a533f252d1d9ddcc02d5540c943d7 Mon Sep 17 00:00:00 2001 From: Eliot McIntire Date: Wed, 25 Nov 2026 16:20:20 -0700 Subject: [PATCH 2/5] fireSenseUtils floor 9194 (TODO: real post-#264 version) Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01Lx3DXhXsFis2pbqBTh2PPh --- NEWS.md | 2 +- fireSense_ignitionPredict.R | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index df88296..bc479de 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,6 @@ # fireSense_ignitionPredict (development version) -* An escape fit with a year climate term (`modelList$yearClimate` of fireSense_ignitionFit's new `escapeYearClimate`) has its expected escapes multiplied by it, from the same year mean of the covariates as the ignitions' term (`yearClimateMultiplierOf()` now takes either fit). With the hinge (`beta2`, fireSense_ignitionFit's `yearClimateHinge`) the dry half is steeper. A fit without the term is unchanged. Needs fireSenseUtils (>= 0.2.3.9193). +* An escape fit with a year climate term (`modelList$yearClimate` of fireSense_ignitionFit's new `escapeYearClimate`) has its expected escapes multiplied by it, from the same year mean of the covariates as the ignitions' term (`yearClimateMultiplierOf()` now takes either fit). With the hinge (`beta2`, fireSense_ignitionFit's `yearClimateHinge`) the dry half is steeper. A fit without the term is unchanged. Needs fireSenseUtils (>= 0.2.3.9194). * A fit with a year climate term (`modelList$yearClimate` of fireSense_ignitionFit's new `ignitionYearClimate`) has its expected ignitions multiplied by `exp(beta * z)`, `z` this year's standardised mean of the climate covariate over the ELF's pixels (`fireSenseUtils::yearClimateMultiplier()`; the fit and the prediction take the same unweighted mean over the rows with the covariate and core, `fireSenseUtils::yearClimateMeans()`, in the predict taken before `na.omit()` so a pixel with an NA in another column still counts, and the multiplier averages 1 over the fit years). The covariates must carry `coreFraction` (added by fireSense_dataPrepPredict, in the same way as for the fit): without it a fit that has the term stops with a message. Escapes are untouched; fits without the term are unchanged. Needs fireSenseUtils (>= 0.2.3.9183). * The yearly ignition and escape probability map (`.plots = "png"`) is bigger. Its png is now 10 x 8 inches at 144 dpi (1440 x 1152 pixels), as fireSense_burn's; it was R's `png()` default of 480 x 480, which looked small in `SpaDES.shiny::shine()`. * The yearly map shows the escape probability beside the ignition probability (`IgnitionEscapeProbability_yr`, was `IgnitionProbability_yr`), both layers of `fireSense_IgAndEscapeProbRas`, and their product, the expected number of escaped fires starting in each pixel that year (`expectedEscapes`). diff --git a/fireSense_ignitionPredict.R b/fireSense_ignitionPredict.R index f8330d2..0821a5b 100644 --- a/fireSense_ignitionPredict.R +++ b/fireSense_ignitionPredict.R @@ -20,7 +20,7 @@ defineModule(sim, list( "data.table", "magrittr", "terra", "xgboost (>= 3.0.0)", "PredictiveEcology/SpaDES.core@development (>= 3.0.4)", "PredictiveEcology/reproducible@development", - "PredictiveEcology/fireSenseUtils@development (>= 0.2.3.9193)" # 9193: yearClimateMultiplier() reads beta2; 9184: yearClimateMeans(covariates, variable) unweighted, yearClimateMultiplier() norm; 9182: yearClimateColumn(), yearClimateMultiplier(); 9177: storedFitProblem(); 9168: foldModels(), foldMeanPrediction() + "PredictiveEcology/fireSenseUtils@development (>= 0.2.3.9194)" # TODO set to the real post-#264 version after merge (fireSenseUtils#264: yearClimateMultiplier() reads beta2); 9184: yearClimateMeans(covariates, variable) unweighted, yearClimateMultiplier() norm; 9182: yearClimateColumn(), yearClimateMultiplier(); 9177: storedFitProblem(); 9168: foldModels(), foldMeanPrediction() ), loadOrder = list(after = "fireSense_dataPrepPredict"), parameters = bindrows( From e3f3cd4e7cc6158d9aa0be82e5ee49ed8113377f Mon Sep 17 00:00:00 2001 From: Eliot McIntire Date: Wed, 25 Nov 2026 16:41:35 -0700 Subject: [PATCH 3/5] Logistic year climate term: predict test and NEWS Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01Lx3DXhXsFis2pbqBTh2PPh --- NEWS.md | 2 +- tests/testthat/test-run-values.R | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/NEWS.md b/NEWS.md index bc479de..9a3b815 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,6 @@ # fireSense_ignitionPredict (development version) -* An escape fit with a year climate term (`modelList$yearClimate` of fireSense_ignitionFit's new `escapeYearClimate`) has its expected escapes multiplied by it, from the same year mean of the covariates as the ignitions' term (`yearClimateMultiplierOf()` now takes either fit). With the hinge (`beta2`, fireSense_ignitionFit's `yearClimateHinge`) the dry half is steeper. A fit without the term is unchanged. Needs fireSenseUtils (>= 0.2.3.9194). +* An escape fit with a year climate term (`modelList$yearClimate` of fireSense_ignitionFit's new `escapeYearClimate`) has its expected escapes multiplied by it, from the same year mean of the covariates as the ignitions' term (`yearClimateMultiplierOf()` now takes either fit). A logistic term (fireSense_ignitionFit's `yearClimateShape = \"logistic\"`) is applied the same way, from the stored fit, through `fireSenseUtils::yearClimateMultiplier()`. A fit without the term is unchanged. Needs fireSenseUtils (>= 0.2.3.9194). * A fit with a year climate term (`modelList$yearClimate` of fireSense_ignitionFit's new `ignitionYearClimate`) has its expected ignitions multiplied by `exp(beta * z)`, `z` this year's standardised mean of the climate covariate over the ELF's pixels (`fireSenseUtils::yearClimateMultiplier()`; the fit and the prediction take the same unweighted mean over the rows with the covariate and core, `fireSenseUtils::yearClimateMeans()`, in the predict taken before `na.omit()` so a pixel with an NA in another column still counts, and the multiplier averages 1 over the fit years). The covariates must carry `coreFraction` (added by fireSense_dataPrepPredict, in the same way as for the fit): without it a fit that has the term stops with a message. Escapes are untouched; fits without the term are unchanged. Needs fireSenseUtils (>= 0.2.3.9183). * The yearly ignition and escape probability map (`.plots = "png"`) is bigger. Its png is now 10 x 8 inches at 144 dpi (1440 x 1152 pixels), as fireSense_burn's; it was R's `png()` default of 480 x 480, which looked small in `SpaDES.shiny::shine()`. * The yearly map shows the escape probability beside the ignition probability (`IgnitionEscapeProbability_yr`, was `IgnitionProbability_yr`), both layers of `fireSense_IgAndEscapeProbRas`, and their product, the expected number of escaped fires starting in each pixel that year (`expectedEscapes`). diff --git a/tests/testthat/test-run-values.R b/tests/testthat/test-run-values.R index d58bd22..7d993a3 100644 --- a/tests/testthat/test-run-values.R +++ b/tests/testthat/test-run-values.R @@ -209,13 +209,18 @@ test_that("an escape fit's year climate term scales the expected escapes by the simB <- toyIgRun(both) expect_equal(probVals(simB)[, "ignitionProb"], c(0, 3, 3, 0) * exp(0.5)) expect_equal(probVals(simB)[, "escapeProb"], rep(1, 4) * exp(0.3) / 2) - ## the hinge: the dry half is steeper - dry$fireSense_EscapeFitted$modelList$yearClimate$beta2 <- 0.4 - expect_equal(probVals(toyIgRun(dry))[, "escapeProb"], rep(1, 4) * exp(0.3 + 0.4) / 2) - ## a wet year (z = -1) does not feel it - wet <- twoFolds(covs = toyIgCovariates(MDC = c(100, 120, 140, 160) - 20)) - wet$fireSense_EscapeFitted$modelList$yearClimate <- dry$fireSense_EscapeFitted$modelList$yearClimate - expect_equal(probVals(toyIgRun(wet))[, "escapeProb"], rep(1, 4) * exp(-0.3) / 2) + ## a logistic escape term, from the stored fit: S-curve through z = 0, floor 1, upper level `ratio` + lgs <- list(variable = "MDC", center = 130, scale = 20, shape = "logistic", k = 2, ratio = 4, norm = 2) + dry$fireSense_EscapeFitted$modelList$yearClimate <- lgs + expect_equal(probVals(toyIgRun(dry))[, "escapeProb"], rep(1, 4) * (1 + 3 * stats::plogis(2)) / 2) + ## far beyond the fit range it saturates at the upper level over norm + vdry <- twoFolds(covs = toyIgCovariates(MDC = c(100, 120, 140, 160) + 2000)) + vdry$fireSense_EscapeFitted$modelList$yearClimate <- lgs + expect_equal(probVals(toyIgRun(vdry))[, "escapeProb"], rep(1, 4) * 4 / 2) + ## the wet side is the floor + wet <- twoFolds(covs = toyIgCovariates(MDC = c(100, 120, 140, 160) - 2000)) + wet$fireSense_EscapeFitted$modelList$yearClimate <- lgs + expect_equal(probVals(toyIgRun(wet))[, "escapeProb"], rep(1, 4) * 1 / 2) ## no term (the default): escapes are untouched expect_equal(probVals(toyIgRun(twoFolds(covs = toyIgCovariates(MDC = c(100, 120, 140, 160) + 20))))[, "escapeProb"], rep(1, 4)) }) From e760c6593f3d45f41b03b644e86c023658a51d1d Mon Sep 17 00:00:00 2001 From: Eliot McIntire Date: Wed, 25 Nov 2026 17:19:26 -0700 Subject: [PATCH 4/5] Floor comment: logistic term, not beta2 Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01Lx3DXhXsFis2pbqBTh2PPh --- NEWS.md | 2 +- fireSense_ignitionPredict.R | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index 9a3b815..e240756 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,6 @@ # fireSense_ignitionPredict (development version) -* An escape fit with a year climate term (`modelList$yearClimate` of fireSense_ignitionFit's new `escapeYearClimate`) has its expected escapes multiplied by it, from the same year mean of the covariates as the ignitions' term (`yearClimateMultiplierOf()` now takes either fit). A logistic term (fireSense_ignitionFit's `yearClimateShape = \"logistic\"`) is applied the same way, from the stored fit, through `fireSenseUtils::yearClimateMultiplier()`. A fit without the term is unchanged. Needs fireSenseUtils (>= 0.2.3.9194). +* An escape fit with a year climate term (`modelList$yearClimate` of fireSense_ignitionFit's new `escapeYearClimate`) has its expected escapes multiplied by it, from the same year mean of the covariates as the ignitions' term (`yearClimateMultiplierOf()` now takes either fit). A logistic term (fireSense_ignitionFit's `yearClimateShape = "logistic"`) is applied the same way, from the stored fit, through `fireSenseUtils::yearClimateMultiplier()`. A fit without the term is unchanged. Needs fireSenseUtils (>= 0.2.3.9194). * A fit with a year climate term (`modelList$yearClimate` of fireSense_ignitionFit's new `ignitionYearClimate`) has its expected ignitions multiplied by `exp(beta * z)`, `z` this year's standardised mean of the climate covariate over the ELF's pixels (`fireSenseUtils::yearClimateMultiplier()`; the fit and the prediction take the same unweighted mean over the rows with the covariate and core, `fireSenseUtils::yearClimateMeans()`, in the predict taken before `na.omit()` so a pixel with an NA in another column still counts, and the multiplier averages 1 over the fit years). The covariates must carry `coreFraction` (added by fireSense_dataPrepPredict, in the same way as for the fit): without it a fit that has the term stops with a message. Escapes are untouched; fits without the term are unchanged. Needs fireSenseUtils (>= 0.2.3.9183). * The yearly ignition and escape probability map (`.plots = "png"`) is bigger. Its png is now 10 x 8 inches at 144 dpi (1440 x 1152 pixels), as fireSense_burn's; it was R's `png()` default of 480 x 480, which looked small in `SpaDES.shiny::shine()`. * The yearly map shows the escape probability beside the ignition probability (`IgnitionEscapeProbability_yr`, was `IgnitionProbability_yr`), both layers of `fireSense_IgAndEscapeProbRas`, and their product, the expected number of escaped fires starting in each pixel that year (`expectedEscapes`). diff --git a/fireSense_ignitionPredict.R b/fireSense_ignitionPredict.R index 0821a5b..bae9f0c 100644 --- a/fireSense_ignitionPredict.R +++ b/fireSense_ignitionPredict.R @@ -20,7 +20,7 @@ defineModule(sim, list( "data.table", "magrittr", "terra", "xgboost (>= 3.0.0)", "PredictiveEcology/SpaDES.core@development (>= 3.0.4)", "PredictiveEcology/reproducible@development", - "PredictiveEcology/fireSenseUtils@development (>= 0.2.3.9194)" # TODO set to the real post-#264 version after merge (fireSenseUtils#264: yearClimateMultiplier() reads beta2); 9184: yearClimateMeans(covariates, variable) unweighted, yearClimateMultiplier() norm; 9182: yearClimateColumn(), yearClimateMultiplier(); 9177: storedFitProblem(); 9168: foldModels(), foldMeanPrediction() + "PredictiveEcology/fireSenseUtils@development (>= 0.2.3.9194)" # TODO set to the real post-#264 version after merge (fireSenseUtils#264: yearClimateMultiplier() reads the logistic term, logisticYearCurve()); 9184: yearClimateMeans(covariates, variable) unweighted, yearClimateMultiplier() norm; 9182: yearClimateColumn(), yearClimateMultiplier(); 9177: storedFitProblem(); 9168: foldModels(), foldMeanPrediction() ), loadOrder = list(after = "fireSense_dataPrepPredict"), parameters = bindrows( From 0561ae8c77a14791e8efbf80562a9ee564e3dffd Mon Sep 17 00:00:00 2001 From: Eliot McIntire Date: Wed, 25 Nov 2026 19:25:56 -0700 Subject: [PATCH 5/5] fireSenseUtils floor 0.2.3.9195 (the version #264 gets after merge) Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01Lx3DXhXsFis2pbqBTh2PPh --- NEWS.md | 2 +- fireSense_ignitionPredict.R | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index e240756..e9e7f9c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,6 @@ # fireSense_ignitionPredict (development version) -* An escape fit with a year climate term (`modelList$yearClimate` of fireSense_ignitionFit's new `escapeYearClimate`) has its expected escapes multiplied by it, from the same year mean of the covariates as the ignitions' term (`yearClimateMultiplierOf()` now takes either fit). A logistic term (fireSense_ignitionFit's `yearClimateShape = "logistic"`) is applied the same way, from the stored fit, through `fireSenseUtils::yearClimateMultiplier()`. A fit without the term is unchanged. Needs fireSenseUtils (>= 0.2.3.9194). +* An escape fit with a year climate term (`modelList$yearClimate` of fireSense_ignitionFit's new `escapeYearClimate`) has its expected escapes multiplied by it, from the same year mean of the covariates as the ignitions' term (`yearClimateMultiplierOf()` now takes either fit). A logistic term (fireSense_ignitionFit's `yearClimateShape = "logistic"`) is applied the same way, from the stored fit, through `fireSenseUtils::yearClimateMultiplier()`. A fit without the term is unchanged. Needs fireSenseUtils (>= 0.2.3.9195). * A fit with a year climate term (`modelList$yearClimate` of fireSense_ignitionFit's new `ignitionYearClimate`) has its expected ignitions multiplied by `exp(beta * z)`, `z` this year's standardised mean of the climate covariate over the ELF's pixels (`fireSenseUtils::yearClimateMultiplier()`; the fit and the prediction take the same unweighted mean over the rows with the covariate and core, `fireSenseUtils::yearClimateMeans()`, in the predict taken before `na.omit()` so a pixel with an NA in another column still counts, and the multiplier averages 1 over the fit years). The covariates must carry `coreFraction` (added by fireSense_dataPrepPredict, in the same way as for the fit): without it a fit that has the term stops with a message. Escapes are untouched; fits without the term are unchanged. Needs fireSenseUtils (>= 0.2.3.9183). * The yearly ignition and escape probability map (`.plots = "png"`) is bigger. Its png is now 10 x 8 inches at 144 dpi (1440 x 1152 pixels), as fireSense_burn's; it was R's `png()` default of 480 x 480, which looked small in `SpaDES.shiny::shine()`. * The yearly map shows the escape probability beside the ignition probability (`IgnitionEscapeProbability_yr`, was `IgnitionProbability_yr`), both layers of `fireSense_IgAndEscapeProbRas`, and their product, the expected number of escaped fires starting in each pixel that year (`expectedEscapes`). diff --git a/fireSense_ignitionPredict.R b/fireSense_ignitionPredict.R index bae9f0c..1c1765a 100644 --- a/fireSense_ignitionPredict.R +++ b/fireSense_ignitionPredict.R @@ -20,7 +20,7 @@ defineModule(sim, list( "data.table", "magrittr", "terra", "xgboost (>= 3.0.0)", "PredictiveEcology/SpaDES.core@development (>= 3.0.4)", "PredictiveEcology/reproducible@development", - "PredictiveEcology/fireSenseUtils@development (>= 0.2.3.9194)" # TODO set to the real post-#264 version after merge (fireSenseUtils#264: yearClimateMultiplier() reads the logistic term, logisticYearCurve()); 9184: yearClimateMeans(covariates, variable) unweighted, yearClimateMultiplier() norm; 9182: yearClimateColumn(), yearClimateMultiplier(); 9177: storedFitProblem(); 9168: foldModels(), foldMeanPrediction() + "PredictiveEcology/fireSenseUtils@development (>= 0.2.3.9195)" # 9195: fireSenseUtils#264 (yearClimateMultiplier() reads the logistic term, logisticYearCurve()); TODO change if another fireSenseUtils PR merges before #264; 9194: annualYearWeights(), standardiseYearClimate() (#263); 9184: yearClimateMeans(covariates, variable) unweighted, yearClimateMultiplier() norm; 9182: yearClimateColumn(), yearClimateMultiplier(); 9177: storedFitProblem(); 9168: foldModels(), foldMeanPrediction() ), loadOrder = list(after = "fireSense_dataPrepPredict"), parameters = bindrows(