From 7a0892cf42aa880cd19a28caa936bb6e3079ca1e Mon Sep 17 00:00:00 2001 From: Eliot McIntire Date: Sun, 22 Nov 2026 20:34:01 -0700 Subject: [PATCH 1/2] Ledger-row readers now come from fireSenseUtils (ledger*()) Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01Lx3DXhXsFis2pbqBTh2PPh --- NEWS.md | 2 + fireSense_spreadPredict.R | 243 ++---------------------- tests/testthat/test-climateActivation.R | 16 +- tests/testthat/test-climateCeiling.R | 12 +- tests/testthat/test-climateOutside.R | 6 +- tests/testthat/test-ledgerCovMinMax.R | 8 +- tests/testthat/test-powerLaw.R | 16 +- tests/testthat/test-smoothLinks.R | 24 +-- tests/testthat/test-spreadIntercept.R | 8 +- 9 files changed, 67 insertions(+), 268 deletions(-) diff --git a/NEWS.md b/NEWS.md index cc36f51..6c06d9d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # fireSense_spreadPredict (development version) +- The functions that read a ledger row (`ledgerLinkArgs()`, `ledgerCovCentre()`, `ledgerClimateRef()`, `ledgerPowerLawPc50()`, `ledgerSpreadClimate()`, `ledgerCovMinMax()` and their helpers) now live in `fireSenseUtils`, which also uses them (`spreadFuelEffect()`, the fuel effect on the ELF map), so a row is read in one place. They are moved unchanged; the only difference is that their errors say "spread ledger row" instead of "fireSense_spreadPredict: ledger row". Needs fireSenseUtils >= 0.2.3.9190 (PredictiveEcology/fireSenseUtils#260, version to be set after it merges). + - A ledger row of `fireSense_spreadFit`'s `spreadClimate = "activation"` predicts as that fit: fuel sets each pixel's ceiling `pc` below p50 and climate is the linear predictor (`fireSenseUtils::spreadLinkInputs(activationIntercept =)`). The row's mode is read by the new `ledgerSpreadClimate()` (column `fireSenseUtils::spreadClimateTxt`); a row without it is "ceiling" when it has `climateRef_spread` and a power-law link, else "predictor", as before. The parameter set's `activationIntercept` is not a covariate coefficient: it goes to the link, and a set and its row that disagree stop. `fireSense_SpreadPowerLaw` is then a per-pixel raster, and `fireSense_SpreadLinear` is the climate term, so `fireSense_burn` adds the year effect to it unchanged. A row that records its mode is predicted by it: "predictor" keeps climate in x even with a `climateRef_spread`, and "ceiling" or "activation" without one stops. An activation ELF is not blended with an ELF of another mode (an error, beside the one for different links; ceiling with predictor still blends), and the activation's lower-asymptote check uses the run's `lowerSpreadProb`. Other rows predict as before. Needs fireSenseUtils >= 0.2.3.9183 (PredictiveEcology/fireSenseUtils#255). - The yearly spread 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()`. diff --git a/fireSense_spreadPredict.R b/fireSense_spreadPredict.R index 9b196ef..94bd0cc 100644 --- a/fireSense_spreadPredict.R +++ b/fireSense_spreadPredict.R @@ -17,7 +17,7 @@ defineModule(sim, list( documentation = list("README.txt", "fireSense_spreadPredict.Rmd"), reqdPkgs = list("data.table", "magrittr", "Matrix", "methods", "terra", "SpaDES.core (>=3.0.4)", "stats", "ggplot2", "viridis", - "PredictiveEcology/fireSenseUtils@development (>= 0.2.3.9186)"), # 9186: splitSpreadClimate(), climateSplitRefPixels(), elfCellLabels() (fireSenseUtils#244); 9183: spreadLinkInputs(activationIntercept =), spreadClimateTxt (fireSenseUtils#255); 9181: spreadLinkInputs(), powerLawPc50 (fireSenseUtils#250); 9165: lowerAsymptote minimum (#230); 9162: smooth links, checkLinkParams() (#229); 9138: powerLawShape + "PredictiveEcology/fireSenseUtils@development (>= 0.2.3.9190)"), # 9190 (placeholder: set after the fireSenseUtils PR merges): the ledger*() row readers (fireSenseUtils#260); 9186: splitSpreadClimate(), climateSplitRefPixels(), elfCellLabels() (fireSenseUtils#244); 9183: spreadLinkInputs(activationIntercept =), spreadClimateTxt (fireSenseUtils#255); 9181: spreadLinkInputs(), powerLawPc50 (fireSenseUtils#250); 9165: lowerAsymptote minimum (#230); 9162: smooth links, checkLinkParams() (#229); 9138: powerLawShape parameters = bindrows( defineParameter(name = "lowerSpreadProb", class = "numeric", default = fireSenseUtils::spreadProbFloor, desc = paste("Lower asymptote of the 2- and 3-parameter logistic. Default", @@ -202,7 +202,7 @@ doEvent.fireSense_spreadPredict <- function(sim, eventTime, eventType, debug = F #' `paramSetForRep()`), and writes it to `sim$fireSense_SpreadPredicted`. Parameter sets are not averaged. #' #' With one fitted ELF (one row of `sim$studyAreaWithSpreadParams`) every pixel uses its parameters and -#' its `covMinMax_spread` (`ledgerCovMinMax()`; `sim$covMinMax_spread` only when the row has none). With several, each ELF's model (its parameter set, its `covMinMax_spread`, and +#' its `covMinMax_spread` (`fireSenseUtils::ledgerCovMinMax()`; `sim$covMinMax_spread` only when the row has none). With several, each ELF's model (its parameter set, its `covMinMax_spread`, and #' only the covariates it was fitted with) predicts its own pixels, from `sim$rasterToMatchLargeELF`, and #' those within `ELFblendWidth` of them; overlapping predictions are averaged with the weights of #' `ELFblendWeights()`. @@ -255,12 +255,12 @@ spreadPredictRun <- function(sim) { if (NROW(sa) == 1L) { params1 <- paramSetForRep(sa$params[[1]], rep) - lk1 <- ledgerLinkArgs(sa, 1L, floor = P(sim)$lowerSpreadProb) - pred <- do.call(spreadProbOneELF, c(list(covs, params = params1, flammableRTM = sim$flammableRTM, covMinMax = ledgerCovMinMax(sa, 1L, sim$covMinMax_spread), + lk1 <- fireSenseUtils::ledgerLinkArgs(sa, 1L, floor = P(sim)$lowerSpreadProb) + pred <- do.call(spreadProbOneELF, c(list(covs, params = params1, flammableRTM = sim$flammableRTM, covMinMax = fireSenseUtils::ledgerCovMinMax(sa, 1L, sim$covMinMax_spread), yr = time(sim), maxFireSpread = P(sim)$maxFireSpread, lowerSpreadProb = P(sim)$lowerSpreadProb, - covCentre = ledgerCovCentre(sa, 1L), climateRef = ledgerClimateRef(sa, 1L), - powerLawPc50 = ledgerPowerLawPc50(sa, 1L)), lk1)) + covCentre = fireSenseUtils::ledgerCovCentre(sa, 1L), climateRef = fireSenseUtils::ledgerClimateRef(sa, 1L), + powerLawPc50 = fireSenseUtils::ledgerPowerLawPc50(sa, 1L)), lk1)) for (nm in names(randomEffectOutputs)) sim[[nm]] <- randomEffectSDOf(params1, randomEffectOutputs[[nm]]) sim$fireSense_SpreadLink <- lk1$link ## the link's parameters: a vector, or with climate in the ceiling (`spreadClimate = "ceiling"`) one row per pixel @@ -279,14 +279,14 @@ spreadPredictRun <- function(sim) { warning("fireSense_spreadPredict: ", sum(none), " flammable pixels are more than ", P(sim)$ELFblendWidth, " m from every fitted ELF; they get no spread probability", call. = FALSE) acc <- numeric(NROW(covs)); wsum <- numeric(NROW(covs)); accSD <- matrix(0, NROW(covs), length(randomEffectOutputs), dimnames = list(NULL, names(randomEffectOutputs))) - lks <- lapply(seq_along(ids), function(i) ledgerLinkArgs(sa, i, floor = P(sim)$lowerSpreadProb)) + lks <- lapply(seq_along(ids), function(i) fireSenseUtils::ledgerLinkArgs(sa, i, floor = P(sim)$lowerSpreadProb)) links <- unique(unlist(lapply(lks, `[[`, "link"))) if (length(links) > 1L) stop("fireSense_spreadPredict: the fitted ELFs have different spread links (", paste(links, collapse = ", "), "), whose parameters cannot be blended", call. = FALSE) ## with the activation x is climate and pc a fuel potential; in the other modes x holds the fuels: a blend of an ## activation ELF with another is neither model. (A ceiling ELF blended with a predictor ELF is allowed, as before.) - modes <- unique(vapply(seq_along(ids), function(i) ledgerSpreadClimate(sa, i), character(1))) + modes <- unique(vapply(seq_along(ids), function(i) fireSenseUtils::ledgerSpreadClimate(sa, i), character(1))) if (length(modes) > 1L && "activation" %in% modes) stop("fireSense_spreadPredict: the fitted ELFs were fitted with different spreadClimate (", paste(modes, collapse = ", "), "), whose linear predictors and parameters cannot be blended", call. = FALSE) @@ -308,8 +308,8 @@ spreadPredictRun <- function(sim) { yr = time(sim), maxFireSpread = P(sim)$maxFireSpread, flammableRTM = sim$flammableRTM, lowerSpreadProb = P(sim)$lowerSpreadProb, elfPixels = if (isSplit[i]) which(elfLab %in% ids[i]), - covCentre = ledgerCovCentre(sa, i), climateRef = ledgerClimateRef(sa, i), - powerLawPc50 = ledgerPowerLawPc50(sa, i)), lks[[i]])) + covCentre = fireSenseUtils::ledgerCovCentre(sa, i), climateRef = fireSenseUtils::ledgerClimateRef(sa, i), + powerLawPc50 = fireSenseUtils::ledgerPowerLawPc50(sa, i)), lks[[i]])) rows <- these[match(p$pixelID, covs$pixelID[these])] acc[rows] <- acc[rows] + w[rows, i] * p$spreadProb accSD[rows, ] <- accSD[rows, ] + w[rows, i] * rep(vapply(randomEffectOutputs, function(txt) randomEffectSDOf(parsI, txt), numeric(1)), each = length(rows)) @@ -491,7 +491,7 @@ ELFblendWeights <- function(elfRas, template, pixelID, ids, width) { #' makes them; fuel biomass logged). It can hold more than the fit used (every ELF's covariates, or a term the #' spread formula has but the fit does not); only the covariates named in `params` are used. #' @param params one-row `data.frame`: the ELF's parameter set for this replicate (`paramSetForRep()`). -#' @param covMinMax the ELF's `covMinMax_spread` (`ledgerCovMinMax()`): the ranges the fit rescaled its +#' @param covMinMax the ELF's `covMinMax_spread` (`fireSenseUtils::ledgerCovMinMax()`): the ranges the fit rescaled its #' covariates with. Every fitted covariate must be a column of it, or it is left unscaled. #' @param elfPixels integer; the `pixelID`s of the ELF's own burnable pixels, the pixels the year's median of a split #' climate covariate (`_yr`, `_dev`; `fireSenseUtils::splitSpreadClimate()`) is taken over, as in the fit. @@ -499,33 +499,33 @@ ELFblendWeights <- function(elfRas, template, pixelID, ids, width) { #' @param flammableRTM `sim$flammableRTM`; with `elfPixels` it limits the median to the ELF's flammable pixels (`fireSenseUtils::climateSplitRefPixels()`, the fit's choice). #' @param yr,maxFireSpread,lowerSpreadProb as for `fireSenseUtils::spreadProbFromIntegerCovs()` and #' `fireSenseUtils::logisticAll()`. -#' @param covCentre the ELF's `covCentre_spread` (`ledgerCovCentre()`): the covariate means the fit subtracted +#' @param covCentre the ELF's `covCentre_spread` (`fireSenseUtils::ledgerCovCentre()`): the covariate means the fit subtracted #' from the rescaled covariates; `NULL` (a fit without an intercept, or an older ledger row) centres nothing. #' A parameter set with `fireSenseUtils::spreadInterceptTxt` has an intercept, added as a column of 1s after #' the covariates are rescaled and centred, as in the fit. A coefficient named `a:b` is an interaction: `covs` must #' have `a` and `b`, and `fireSenseUtils::spreadProbFromIntegerCovs()` multiplies them after each is #' rescaled and centred (0 where `youngAge` cleared the fuel), exactly as in the fit. -#' @param climateRef the ELF's `climateRef_spread` (`ledgerClimateRef()`): with a fit made with climate outside the +#' @param climateRef the ELF's `climateRef_spread` (`fireSenseUtils::ledgerClimateRef()`): with a fit made with climate outside the #' `maxAsymptote` ceiling (`fireSense_spreadFit`'s `spreadLink = "climateOutside"`) or moving it (`spreadClimate = #' "ceiling"`), the reference value of each climate covariate; `fireSenseUtils::spreadProbFromCovs()` and #' `spreadLinkInputs()` then apply that link, exactly as the fit did. #' `NULL` (a fit with climate under the ceiling, or an older ledger row) is the link as it always was. -#' @param powerLawGamma the ELF's `powerLawGamma_spread` (`ledgerPowerLawGamma()`): with a fit made with +#' @param powerLawGamma the ELF's `powerLawGamma_spread` (`fireSenseUtils::ledgerPowerLawGamma()`): with a fit made with #' `fireSense_spreadFit`'s `spreadLink = "powerLaw"`, its `gamma`; `fireSenseUtils::spreadProbFromCovs()` then #' applies that link (`fireSenseUtils::powerLawLink()`, with `maxAsymptote` as `p_c`), exactly as the fit did. #' `NULL` (any other link) is the link as it always was. -#' @param powerLawShape the ELF's `powerLawShape_spread` (`ledgerPowerLawShape()`): the `shape` of the link, with +#' @param powerLawShape the ELF's `powerLawShape_spread` (`fireSenseUtils::ledgerPowerLawShape()`): the `shape` of the link, with #' `powerLawGamma`; 1 (the original link) by default. -#' @param link the ELF's link when it is one of `fireSenseUtils::spreadLinearLinks` (`ledgerLinkArgs()`); `NULL` (any +#' @param link the ELF's link when it is one of `fireSenseUtils::spreadLinearLinks` (`fireSenseUtils::ledgerLinkArgs()`); `NULL` (any #' other link). By default `"powerLaw"` when `powerLawGamma` is given, the link of a row written before the #' others existed. -#' @param lowerAsymptote,richardsNu the ELF's `lowerAsymptote_spread` and `richardsNu_spread` (`ledgerLowerAsymptote()`, -#' `ledgerRichardsNu()`): with `"powerLawSmooth"` and `"richards"`, the lower asymptote, and `nu` of `"richards"`. -#' @param powerLawPc50 the ELF's `powerLawPc50_spread` (`ledgerPowerLawPc50()`): with `climateRef` and a power-law `link` +#' @param lowerAsymptote,richardsNu the ELF's `lowerAsymptote_spread` and `richardsNu_spread` (`fireSenseUtils::ledgerLowerAsymptote()`, +#' `fireSenseUtils::ledgerRichardsNu()`): with `"powerLawSmooth"` and `"richards"`, the lower asymptote, and `nu` of `"richards"`. +#' @param powerLawPc50 the ELF's `powerLawPc50_spread` (`fireSenseUtils::ledgerPowerLawPc50()`): with `climateRef` and a power-law `link` #' (a fit with `fireSense_spreadFit`'s `spreadClimate = "ceiling"`), the runaway threshold the ceiling moves toward; #' `fireSenseUtils::spreadLinkInputs()` ignores it without `climateRef`. #' @param spreadClimate `NULL` (a row that does not record it: predicted as it always was), or the row's recorded -#' `spreadClimate` (`ledgerLinkArgs()`). `"predictor"` predicts with climate in x even when the row has a `climateRef`; +#' `spreadClimate` (`fireSenseUtils::ledgerLinkArgs()`). `"predictor"` predicts with climate in x even when the row has a `climateRef`; #' `"ceiling"` and `"activation"` need one. With `"activation"` the parameter set's #' `activationIntercept` (`fireSenseUtils::activationInterceptTxt`) is not a covariate coefficient: it goes to #' `fireSenseUtils::spreadLinkInputs()`, where fuel sets each pixel's `pc` below `powerLawPc50` and climate is `x`. @@ -707,209 +707,6 @@ linkParsRas <- function(template, pixelID, pars) { r } -#' The covariate ranges of one ledger row -#' -#' A fit rescales its covariates with fixed ranges and stores them in its ledger row (`covMinMax_spread`). -#' Prediction rescales with the same values, so it never depends on `sim$covMinMax_spread`, which -#' `fireSense_spreadFit` rebuilds in every run from that run's own covariate tables (in a hindcast, from a -#' formula rebuilt for another year, which can lack a fitted term). -#' -#' @param sa `sim$studyAreaWithSpreadParams`, one row per ELF. -#' @param i integer; the row. -#' @param default what to return for a row without ranges (an older ledger row): `sim$covMinMax_spread`. -#' @return The row's `covMinMax_spread` (a `data.table`, 2 rows: min, max), else `default`. -ledgerCovMinMax <- function(sa, i, default = NULL) { - if (!"covMinMax_spread" %in% names(sa)) return(default) - cmm <- sa[["covMinMax_spread"]][[i]] - if (is.null(cmm) || !NROW(cmm)) return(default) - cmm -} - -#' The climate reference of one ledger row -#' -#' A fit made with climate outside the `maxAsymptote` ceiling (`fireSense_spreadFit`'s `spreadLink = "climateOutside"`) -#' stores the reference value of each climate covariate in the ledger row (`fireSenseUtils::spreadFitClimateRefTxt`), -#' with `spreadLink` beside it. Prediction applies the same link with the same reference -#' (`fireSenseUtils::spreadProbFromCovs()`). -#' -#' @param sa `sim$studyAreaWithSpreadParams`, one row per ELF. -#' @param i integer; the row. -#' @return A named list, or `NULL` for a row without a reference: a fit with climate under the ceiling, or a row -#' written before the link existed. Such a row predicts exactly as it always did. -ledgerClimateRef <- function(sa, i) { - col <- fireSenseUtils::spreadFitClimateRefTxt - if (!col %in% names(sa)) return(NULL) - ref <- sa[[col]][[i]] - if (is.list(ref) && length(ref)) ref else NULL -} - -#' The runaway threshold of one ledger row -#' -#' A fit made with `fireSense_spreadFit`'s `spreadClimate = "ceiling"` moves `maxAsymptote` toward the landscape's -#' runaway threshold `p50`, stored in the ledger row (`fireSenseUtils::spreadFitPowerLawPc50Txt`) as for every power-law -#' fit. Only a row with `climateRef_spread` (`ledgerClimateRef()`) uses it. -#' -#' @param sa `sim$studyAreaWithSpreadParams`, one row per ELF. -#' @param i integer; the row. -#' @return `p50`, or `NULL` for a row without the column or with `NA`. A row with `climateRef_spread` and a power-law -#' link but no finite `p50` stops, naming the row. -ledgerPowerLawPc50 <- function(sa, i) { - col <- fireSenseUtils::spreadFitPowerLawPc50Txt - p50 <- if (col %in% names(sa)) sa[[col]][[i]] - if (!is.null(ledgerClimateRef(sa, i)) && any(ledgerSpreadLink(sa, i) %in% fireSenseUtils::spreadPowerLawLinks) && - !(is.numeric(p50) && length(p50) == 1L && is.finite(p50))) - stop("fireSense_spreadPredict: ledger row ", i, " has climate in the ceiling ('", fireSenseUtils::spreadFitClimateRefTxt, - "' and spreadLink '", ledgerSpreadLink(sa, i), "') but no finite '", col, "' (", format(p50), ")", call. = FALSE) - if (is.null(p50) || is.na(p50)) NULL else p50 -} - -#' The power-law exponent of one ledger row -#' -#' A fit made with `fireSense_spreadFit`'s `spreadLink = "powerLaw"` or `"powerLawSmooth"` stores its `gamma` in the ledger row -#' (`fireSenseUtils::spreadFitPowerLawGammaTxt`), with the link in `fireSenseUtils::spreadLinkTxt`. Prediction -#' applies the same link with the same `gamma` (`fireSenseUtils::spreadProbFromCovs()`). -#' -#' @param sa `sim$studyAreaWithSpreadParams`, one row per ELF. -#' @param i integer; the row. -#' @return `gamma`, or `NULL` for a row of any other link (`"richards"` has none), such as every row written before the -#' link existed. Such a row predicts exactly as it always did. A `"powerLaw"` or `"powerLawSmooth"` row without a valid -#' `gamma` stops. -ledgerPowerLawGamma <- function(sa, i) { - link <- ledgerSpreadLink(sa, i) - if (!any(link %in% fireSenseUtils::spreadPowerLawLinks)) return(NULL) - gamma <- sa[[fireSenseUtils::spreadFitPowerLawGammaTxt]][[i]] - if (!(is.numeric(gamma) && length(gamma) == 1L && is.finite(gamma) && gamma > 0)) - stop("fireSense_spreadPredict: ledger row ", i, " has spreadLink '", link, "' but no valid '", - fireSenseUtils::spreadFitPowerLawGammaTxt, "' (", format(gamma), ")", call. = FALSE) - gamma -} - -#' The spread link of one ledger row -#' -#' @param sa `sim$studyAreaWithSpreadParams`, one row per ELF. -#' @param i integer; the row. -#' @return The row's `fireSenseUtils::spreadLinkTxt`, or `NULL` for a row without one (the default link, and every row -#' written before the column existed). -ledgerSpreadLink <- function(sa, i) { - linkCol <- fireSenseUtils::spreadLinkTxt - if (linkCol %in% names(sa)) as.character(sa[[linkCol]][[i]]) -} - -#' A number of one ledger row, for the links that record it -#' -#' The row's `lowerAsymptote_spread` and `richardsNu_spread` are checked together by -#' `fireSenseUtils::checkLinkParams()`, the check `fireSense_spreadFit` makes of its parameters; an invalid or missing -#' value stops, naming the row. -#' -#' @param sa `sim$studyAreaWithSpreadParams`, one row per ELF. -#' @param i integer; the row. -#' @param col the ledger column. -#' @param links the links that write `col`; any other row gives `NULL`. -#' @param floor the run's `lowerSpreadProb`, which an activation row's lower asymptote must equal. -#' @return The value, or `NULL` for a row of another link. -ledgerLinkNumber <- function(sa, i, col, links, floor = fireSenseUtils::spreadProbFloor) { - link <- ledgerSpreadLink(sa, i) - if (!any(link %in% links)) return(NULL) - num <- function(cn) if (cn %in% names(sa)) sa[[cn]][[i]] - tryCatch(fireSenseUtils::checkLinkParams(link, num(fireSenseUtils::spreadFitLowerAsymptoteTxt), - num(fireSenseUtils::spreadFitRichardsNuTxt), - activation = identical(ledgerSpreadClimate(sa, i), "activation"), floor = floor), - error = function(e) stop("fireSense_spreadPredict: ledger row ", i, " has spreadLink '", link, "': ", - conditionMessage(e), " (columns '", fireSenseUtils::spreadFitLowerAsymptoteTxt, "', '", - fireSenseUtils::spreadFitRichardsNuTxt, "')", call. = FALSE)) - num(col) -} - -#' The lower asymptote of one ledger row -#' -#' `fireSense_spreadFit`'s `lowerAsymptote` of a `"powerLawSmooth"` or `"richards"` fit, in -#' `fireSenseUtils::spreadFitLowerAsymptoteTxt`. -#' -#' @inheritParams ledgerLinkNumber -#' @return A number from 0 to `fireSenseUtils::spreadProbFloor`; `NULL` for a row of another link. -ledgerLowerAsymptote <- function(sa, i, floor = fireSenseUtils::spreadProbFloor) - ledgerLinkNumber(sa, i, fireSenseUtils::spreadFitLowerAsymptoteTxt, fireSenseUtils::spreadAsymptoteLinks, floor) - -#' The `nu` of one ledger row -#' -#' `fireSense_spreadFit`'s `richardsNu` of a `"richards"` fit, in `fireSenseUtils::spreadFitRichardsNuTxt`. -#' -#' @inheritParams ledgerLinkNumber -#' @return A number, 0 or more; `NULL` for a row of another link. -ledgerRichardsNu <- function(sa, i, floor = fireSenseUtils::spreadProbFloor) - ledgerLinkNumber(sa, i, fireSenseUtils::spreadFitRichardsNuTxt, "richards", floor) - -#' The link of one ledger row and its parameters, as the arguments of `spreadProbOneELF()` -#' -#' @inheritParams ledgerLinkNumber -#' @return A list of `link` (only for a link of `fireSenseUtils::spreadLinearLinks`), `powerLawGamma` (not `"richards"`), -#' `powerLawShape`, `lowerAsymptote` and `richardsNu` (the links that have them), and `spreadClimate` when the row -#' records it; the others are left out, so they take `spreadProbOneELF()`'s defaults. A row of any other link, -#' or without one, has `powerLawShape` only. -ledgerLinkArgs <- function(sa, i, floor = fireSenseUtils::spreadProbFloor) { - link <- ledgerSpreadLink(sa, i) - if (!any(link %in% fireSenseUtils::spreadLinearLinks)) link <- NULL - col <- fireSenseUtils::spreadClimateTxt - recorded <- col %in% names(sa) && !is.na(sa[[col]][[i]]) - Filter(Negate(is.null), list(link = link, powerLawGamma = ledgerPowerLawGamma(sa, i), - powerLawShape = ledgerPowerLawShape(sa, i), - lowerAsymptote = ledgerLowerAsymptote(sa, i, floor), richardsNu = ledgerRichardsNu(sa, i, floor), - spreadClimate = if (recorded) ledgerSpreadClimate(sa, i))) -} - -#' Where the fit of one ledger row put climate -#' -#' `fireSense_spreadFit` records its `spreadClimate` in the row (`fireSenseUtils::spreadClimateTxt`). A row without it -#' (written before it existed) is read as the fit made it: `"ceiling"` when it has `climateRef_spread` -#' (`ledgerClimateRef()`) and a power-law link, else `"predictor"`. -#' -#' @inheritParams ledgerLinkNumber -#' @return One of `fireSenseUtils::spreadClimateOptions`; an unknown value stops, naming the row. -ledgerSpreadClimate <- function(sa, i) { - col <- fireSenseUtils::spreadClimateTxt - mode <- if (col %in% names(sa)) as.character(sa[[col]][[i]]) - if (!length(mode) || is.na(mode)) - return(if (!is.null(ledgerClimateRef(sa, i)) && any(ledgerSpreadLink(sa, i) %in% fireSenseUtils::spreadPowerLawLinks)) - "ceiling" else "predictor") - if (!mode %in% fireSenseUtils::spreadClimateOptions) - stop("fireSense_spreadPredict: ledger row ", i, " has an unknown '", col, "' (", mode, "); one of ", - paste(fireSenseUtils::spreadClimateOptions, collapse = ", "), " expected", call. = FALSE) - mode -} - -#' The power-law curvature exponent of one ledger row -#' -#' `fireSense_spreadFit`'s `powerLawShape` is stored in the ledger row (`fireSenseUtils::spreadFitPowerLawShapeTxt`). -#' A row without the column (every row written before it existed) or with `NA` has shape 1, the original link. -#' -#' @param sa `sim$studyAreaWithSpreadParams`, one row per ELF. -#' @param i integer; the row. -#' @return `shape`, a positive number; 1 when the row has none. -ledgerPowerLawShape <- function(sa, i) { - col <- fireSenseUtils::spreadFitPowerLawShapeTxt - shape <- if (col %in% names(sa)) sa[[col]][[i]] - if (is.null(shape) || is.na(shape)) return(fireSenseUtils::spreadPowerLawShape) - if (!(is.numeric(shape) && length(shape) == 1L && is.finite(shape) && shape > 0)) - stop("fireSense_spreadPredict: ledger row ", i, " has an invalid '", col, "' (", format(shape), ")", call. = FALSE) - shape -} - -#' The covariate centres of one ledger row -#' -#' A fit with an intercept centres its covariates and stores the centres in the ledger row -#' (`fireSenseUtils::spreadFitCovCentreTxt`). Prediction subtracts the same values. -#' -#' @param sa `sim$studyAreaWithSpreadParams`, one row per ELF. -#' @param i integer; the row. -#' @return A named list, or `NULL` for a row without centres: a fit without an intercept, or a row written -#' before they were stored. Such a row predicts exactly as it always did. -ledgerCovCentre <- function(sa, i) { - col <- fireSenseUtils::spreadFitCovCentreTxt - if (!col %in% names(sa)) return(NULL) - centre <- sa[[col]][[i]] - if (is.list(centre) && length(centre)) centre else NULL -} - #' The parameter set a replicate uses #' #' Replicate `rep` uses row `((rep - 1) %% NROW(params)) + 1` of an ELF's fitted parameter sets, whole: its diff --git a/tests/testthat/test-climateActivation.R b/tests/testthat/test-climateActivation.R index a4730ac..ce912a3 100644 --- a/tests/testthat/test-climateActivation.R +++ b/tests/testthat/test-climateActivation.R @@ -70,15 +70,15 @@ test_that("fireSense_burn's reading of the outputs gives the predicted p, and th test_that("a row without the mode column predicts as it did: ceiling with climateRef and a power-law link", { ceil <- inputsCA(mode = NULL, a = NULL) sa <- ceil$studyAreaWithSpreadParams - expect_identical(ledgerSpreadClimate(sa, 1L), "ceiling") + expect_identical(fireSenseUtils::ledgerSpreadClimate(sa, 1L), "ceiling") sa[[modeColCA]] <- "ceiling" ceil2 <- ceil; ceil2$studyAreaWithSpreadParams <- sa expect_identical(predVals(toyRun(ceil)), predVals(toyRun(ceil2))) ## and a row with neither is "predictor" sa0 <- inputsPL()$studyAreaWithSpreadParams - expect_identical(ledgerSpreadClimate(sa0, 1L), "predictor") - expect_false("spreadClimate" %in% names(ledgerLinkArgs(sa0, 1L))) - expect_identical(ledgerLinkArgs(inputsCA()$studyAreaWithSpreadParams, 1L)$spreadClimate, "activation") + expect_identical(fireSenseUtils::ledgerSpreadClimate(sa0, 1L), "predictor") + expect_false("spreadClimate" %in% names(fireSenseUtils::ledgerLinkArgs(sa0, 1L))) + expect_identical(fireSenseUtils::ledgerLinkArgs(inputsCA()$studyAreaWithSpreadParams, 1L)$spreadClimate, "activation") }) test_that("an activation row and its parameters must agree, and the link must be powerLawSmooth at the floor", { @@ -89,7 +89,7 @@ test_that("an activation row and its parameters must agree, and the link must be expect_error(toyRun(bad), "lowerAsymptote = lowerSpreadProb") sa <- inputsCA()$studyAreaWithSpreadParams sa[[modeColCA]] <- "wet" - expect_error(ledgerSpreadClimate(sa, 1L), "unknown") + expect_error(fireSenseUtils::ledgerSpreadClimate(sa, 1L), "unknown") }) test_that("a recorded mode is the fit's: an explicit 'predictor' row ignores a climateRef; 'ceiling' needs one", { @@ -107,9 +107,9 @@ test_that("a recorded mode is the fit's: an explicit 'predictor' row ignores a c test_that("the activation's floor check uses the run's lowerSpreadProb", { sa <- inputsCA()$studyAreaWithSpreadParams sa[[fireSenseUtils::spreadFitLowerAsymptoteTxt]] <- 0.1 - expect_identical(ledgerLowerAsymptote(sa, 1L, floor = 0.1), 0.1) - expect_error(ledgerLowerAsymptote(sa, 1L), "lowerAsymptote = lowerSpreadProb") - expect_identical(ledgerLinkArgs(sa, 1L, floor = 0.1)$lowerAsymptote, 0.1) + expect_identical(fireSenseUtils::ledgerLowerAsymptote(sa, 1L, floor = 0.1), 0.1) + expect_error(fireSenseUtils::ledgerLowerAsymptote(sa, 1L), "lowerAsymptote = lowerSpreadProb") + expect_identical(fireSenseUtils::ledgerLinkArgs(sa, 1L, floor = 0.1)$lowerAsymptote, 0.1) }) test_that("ELFs fitted in different spreadClimate modes are not blended", { diff --git a/tests/testthat/test-climateCeiling.R b/tests/testthat/test-climateCeiling.R index 4d0100e..a17965c 100644 --- a/tests/testthat/test-climateCeiling.R +++ b/tests/testthat/test-climateCeiling.R @@ -24,13 +24,13 @@ handCC <- function(gamma = 1.9, pc0 = 0.25, floor = 0.13, p50 = 0.3, ref = 0.4) list(p = pmax(pc - (pc - floor) * exp(-sign(x) * abs(x / gamma)), 0), pc = pc, x = x) } -test_that("ledgerPowerLawPc50() reads the row's p50, NULL when absent or NA", { +test_that("fireSenseUtils::ledgerPowerLawPc50() reads the row's p50, NULL when absent or NA", { sa <- toyInputs()$studyAreaWithSpreadParams - expect_null(ledgerPowerLawPc50(sa, 1L)) + expect_null(fireSenseUtils::ledgerPowerLawPc50(sa, 1L)) sa[[pc50ColCC]] <- 0.3 - expect_identical(ledgerPowerLawPc50(sa, 1L), 0.3) + expect_identical(fireSenseUtils::ledgerPowerLawPc50(sa, 1L), 0.3) sa[[pc50ColCC]] <- NA_real_ - expect_null(ledgerPowerLawPc50(sa, 1L)) # no climateRef: not needed + expect_null(fireSenseUtils::ledgerPowerLawPc50(sa, 1L)) # no climateRef: not needed }) test_that("a row with climateRef and a power-law link predicts with climate moving the ceiling toward p50", { @@ -72,10 +72,10 @@ test_that("a climateRef row without a finite p50 stops, naming the row", { expect_error(toyRun(inputsCC(p50 = NULL)), "ledger row 1 has climate in the ceiling") expect_error(toyRun(inputsCC(p50 = NA_real_)), "ledger row 1 has climate in the ceiling") sa <- inputsCC(p50 = NA_real_)$studyAreaWithSpreadParams - expect_error(ledgerPowerLawPc50(sa, 1L), "no finite") + expect_error(fireSenseUtils::ledgerPowerLawPc50(sa, 1L), "no finite") ## a row without climateRef has no use for it: NULL, no error sa[[refColCC]] <- NULL - expect_null(ledgerPowerLawPc50(sa, 1L)) + expect_null(fireSenseUtils::ledgerPowerLawPc50(sa, 1L)) }) test_that("with several ELFs the per-pixel parameters are blended, an ELF without climateRef contributing its vector", { diff --git a/tests/testthat/test-climateOutside.R b/tests/testthat/test-climateOutside.R index ab47a35..ad4926b 100644 --- a/tests/testthat/test-climateOutside.R +++ b/tests/testthat/test-climateOutside.R @@ -53,11 +53,11 @@ test_that("a row without a reference predicts exactly as before", { withRef <- predVals(toyRun(inputsCO(ref = list(MDC = 0.5)))) expect_false(isTRUE(all.equal(withRef, base))) sa <- toyInputs()$studyAreaWithSpreadParams - expect_null(ledgerClimateRef(sa, 1L)) + expect_null(fireSenseUtils::ledgerClimateRef(sa, 1L)) sa[[refCol]] <- list(list()) - expect_null(ledgerClimateRef(sa, 1L)) + expect_null(fireSenseUtils::ledgerClimateRef(sa, 1L)) sa[[refCol]] <- list(list(MDC = 0.4)) - expect_identical(ledgerClimateRef(sa, 1L), list(MDC = 0.4)) + expect_identical(fireSenseUtils::ledgerClimateRef(sa, 1L), list(MDC = 0.4)) }) test_that("with several ELFs each row applies its own reference, blended like the probabilities", { diff --git a/tests/testthat/test-ledgerCovMinMax.R b/tests/testthat/test-ledgerCovMinMax.R index 4be4467..a5d736e 100644 --- a/tests/testthat/test-ledgerCovMinMax.R +++ b/tests/testthat/test-ledgerCovMinMax.R @@ -20,10 +20,10 @@ test_that("a row without ranges (an older ledger) falls back to sim$covMinMax_sp sa <- data.frame(polygonID = c("A", "B")) cmm <- data.table::data.table(MDC = c(0, 200)) sa$covMinMax_spread <- list(cmm, NULL) - expect_identical(ledgerCovMinMax(sa, 1L, "default"), cmm) - expect_identical(ledgerCovMinMax(sa, 2L, "default"), "default") - expect_identical(ledgerCovMinMax(data.frame(polygonID = "A"), 1L, "default"), "default") - expect_null(ledgerCovMinMax(data.frame(polygonID = "A"), 1L)) + expect_identical(fireSenseUtils::ledgerCovMinMax(sa, 1L, "default"), cmm) + expect_identical(fireSenseUtils::ledgerCovMinMax(sa, 2L, "default"), "default") + expect_identical(fireSenseUtils::ledgerCovMinMax(data.frame(polygonID = "A"), 1L, "default"), "default") + expect_null(fireSenseUtils::ledgerCovMinMax(data.frame(polygonID = "A"), 1L)) }) test_that("a fitted covariate with no range stops instead of staying unscaled", { diff --git a/tests/testthat/test-powerLaw.R b/tests/testthat/test-powerLaw.R index 9d617b6..f5a941c 100644 --- a/tests/testthat/test-powerLaw.R +++ b/tests/testthat/test-powerLaw.R @@ -28,16 +28,16 @@ test_that("a row of any other link predicts exactly as before", { expect_identical(predVals(toyRun(inputsPL(gamma = NULL, link = NULL))), base) expect_identical(predVals(toyRun(inputsPL(gamma = 4, link = "ceiling"))), base) # gamma ignored sa <- toyInputs()$studyAreaWithSpreadParams - expect_null(ledgerPowerLawGamma(sa, 1L)) + expect_null(fireSenseUtils::ledgerPowerLawGamma(sa, 1L)) sa[[linkColPL]] <- "climateOutside" - expect_null(ledgerPowerLawGamma(sa, 1L)) + expect_null(fireSenseUtils::ledgerPowerLawGamma(sa, 1L)) sa[[linkColPL]] <- "powerLaw"; sa[[gammaColPL]] <- 2.2 - expect_identical(ledgerPowerLawGamma(sa, 1L), 2.2) + expect_identical(fireSenseUtils::ledgerPowerLawGamma(sa, 1L), 2.2) ## a powerLaw row without a usable gamma stops, instead of predicting with the wrong link sa[[gammaColPL]] <- NA_real_ - expect_error(ledgerPowerLawGamma(sa, 1L), "no valid") + expect_error(fireSenseUtils::ledgerPowerLawGamma(sa, 1L), "no valid") sa[[gammaColPL]] <- NULL - expect_error(ledgerPowerLawGamma(sa, 1L), "no valid") + expect_error(fireSenseUtils::ledgerPowerLawGamma(sa, 1L), "no valid") }) test_that("with several ELFs each row applies its own link, blended like the probabilities", { @@ -136,11 +136,11 @@ test_that("a row's powerLawShape_spread bends the link; a row without it, or NA, ins$studyAreaWithSpreadParams[[shapeColPL]] <- 1 expect_identical(predVals(toyRun(ins))[cellsPL], base) sa <- toyInputs()$studyAreaWithSpreadParams - expect_identical(ledgerPowerLawShape(sa, 1L), 1) + expect_identical(fireSenseUtils::ledgerPowerLawShape(sa, 1L), 1) sa[[shapeColPL]] <- 2.5 - expect_identical(ledgerPowerLawShape(sa, 1L), 2.5) + expect_identical(fireSenseUtils::ledgerPowerLawShape(sa, 1L), 2.5) sa[[shapeColPL]] <- -1 - expect_error(ledgerPowerLawShape(sa, 1L), "invalid") + expect_error(fireSenseUtils::ledgerPowerLawShape(sa, 1L), "invalid") ## the linear predictor mapped by the link with the handed shape reproduces p ins$studyAreaWithSpreadParams[[shapeColPL]] <- 2 sim <- toyRun(ins) diff --git a/tests/testthat/test-smoothLinks.R b/tests/testthat/test-smoothLinks.R index 373464a..fc2fba5 100644 --- a/tests/testthat/test-smoothLinks.R +++ b/tests/testthat/test-smoothLinks.R @@ -57,7 +57,7 @@ test_that("a richards row predicts the Richards link with no gamma in the ledger expect_identical(sim$fireSense_SpreadPowerLaw, c(pc = 0.25, lower = 0.02, nu = 2, B = 1 / fireSenseUtils::spreadPowerLawGamma)) expect_equal(terra::values(sim$fireSense_SpreadLinear, mat = FALSE)[cellsSL], xSL(), tolerance = 1e-9) - expect_null(ledgerPowerLawGamma(ins$studyAreaWithSpreadParams, 1L)) + expect_null(fireSenseUtils::ledgerPowerLawGamma(ins$studyAreaWithSpreadParams, 1L)) ## nu = 0 is Gompertz g <- predVals(toyRun(inputsSL("richards", lower = 0.13, nu = 0))) expect_equal(g[cellsSL], 0.13 + (0.25 - 0.13) * exp(-exp(-xSL() / fireSenseUtils::spreadPowerLawGamma)), tolerance = 1e-9) @@ -75,23 +75,23 @@ test_that("with L = 0.13 a low-x pixel keeps 0.13 on both new links, and the old test_that("rows without the columns their link needs stop; the helpers read the columns", { sa <- inputsSL("richards")$studyAreaWithSpreadParams - expect_identical(ledgerLowerAsymptote(sa, 1L), 0.05) - expect_identical(ledgerRichardsNu(sa, 1L), 0.5) - expect_identical(ledgerLinkArgs(sa, 1L)$link, "richards") - expect_false("powerLawGamma" %in% names(ledgerLinkArgs(sa, 1L))) + expect_identical(fireSenseUtils::ledgerLowerAsymptote(sa, 1L), 0.05) + expect_identical(fireSenseUtils::ledgerRichardsNu(sa, 1L), 0.5) + expect_identical(fireSenseUtils::ledgerLinkArgs(sa, 1L)$link, "richards") + expect_false("powerLawGamma" %in% names(fireSenseUtils::ledgerLinkArgs(sa, 1L))) sa[[nuColSL]] <- NULL - expect_error(ledgerRichardsNu(sa, 1L), "richardsNu must be") + expect_error(fireSenseUtils::ledgerRichardsNu(sa, 1L), "richardsNu must be") sa <- inputsSL("powerLawSmooth")$studyAreaWithSpreadParams sa[[lowerColSL]] <- 0.5 - expect_error(ledgerLowerAsymptote(sa, 1L), "lowerAsymptote must be") + expect_error(fireSenseUtils::ledgerLowerAsymptote(sa, 1L), "lowerAsymptote must be") sa[[lowerColSL]] <- 0 # a lower asymptote of 0 is never accepted - expect_error(ledgerLowerAsymptote(sa, 1L), "never 0") + expect_error(fireSenseUtils::ledgerLowerAsymptote(sa, 1L), "never 0") sa[[lowerColSL]] <- NULL - expect_error(ledgerLowerAsymptote(sa, 1L), "lowerAsymptote must be") - expect_null(ledgerRichardsNu(inputsSL("powerLawSmooth")$studyAreaWithSpreadParams, 1L)) + expect_error(fireSenseUtils::ledgerLowerAsymptote(sa, 1L), "lowerAsymptote must be") + expect_null(fireSenseUtils::ledgerRichardsNu(inputsSL("powerLawSmooth")$studyAreaWithSpreadParams, 1L)) ## the other links have none - expect_null(ledgerLowerAsymptote(toyInputs()$studyAreaWithSpreadParams, 1L)) - expect_identical(ledgerLinkArgs(toyInputs()$studyAreaWithSpreadParams, 1L), list(powerLawShape = 1)) + expect_null(fireSenseUtils::ledgerLowerAsymptote(toyInputs()$studyAreaWithSpreadParams, 1L)) + expect_identical(fireSenseUtils::ledgerLinkArgs(toyInputs()$studyAreaWithSpreadParams, 1L), list(powerLawShape = 1)) }) test_that("with several ELFs of one new link the parameters blend; with different links it stops", { diff --git a/tests/testthat/test-spreadIntercept.R b/tests/testthat/test-spreadIntercept.R index bb287f3..58e5044 100644 --- a/tests/testthat/test-spreadIntercept.R +++ b/tests/testthat/test-spreadIntercept.R @@ -54,15 +54,15 @@ test_that("a row without an intercept or centres predicts exactly as before", { v <- predVals(toyRun(inputsI(intercept = FALSE, centre = FALSE))) expect_equal(v[cells], handLogistic3(xHand(0)), tolerance = 1e-7) expect_identical(v, predVals(toyRun())) - expect_null(ledgerCovCentre(toyInputs()$studyAreaWithSpreadParams, 1L)) + expect_null(fireSenseUtils::ledgerCovCentre(toyInputs()$studyAreaWithSpreadParams, 1L)) }) test_that("an old ledger row's missing centre is NULL, also beside a row that has one", { sa <- data.frame(polygonID = c("A", "B")) sa[[centreCol]] <- list(centreI, NULL) # as rbindlist(fill = TRUE) leaves an older row - expect_identical(ledgerCovCentre(sa, 1L), centreI) - expect_null(ledgerCovCentre(sa, 2L)) - expect_null(ledgerCovCentre(data.frame(polygonID = "A"), 1L)) + expect_identical(fireSenseUtils::ledgerCovCentre(sa, 1L), centreI) + expect_null(fireSenseUtils::ledgerCovCentre(sa, 2L)) + expect_null(fireSenseUtils::ledgerCovCentre(data.frame(polygonID = "A"), 1L)) }) test_that("with several ELFs each uses its own intercept and centre; an older ELF's row predicts as before", { From 9ffe9e155e35c2e3b8f4eb182ba0590e978e043c Mon Sep 17 00:00:00 2001 From: Eliot McIntire Date: Sun, 22 Nov 2026 20:58:59 -0700 Subject: [PATCH 2/2] fireSenseUtils floor 0.2.3.9191 (placeholder until fireSenseUtils#260 is merged and bumped) Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01Lx3DXhXsFis2pbqBTh2PPh --- NEWS.md | 2 +- fireSense_spreadPredict.R | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index 6c06d9d..5179058 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,6 @@ # fireSense_spreadPredict (development version) -- The functions that read a ledger row (`ledgerLinkArgs()`, `ledgerCovCentre()`, `ledgerClimateRef()`, `ledgerPowerLawPc50()`, `ledgerSpreadClimate()`, `ledgerCovMinMax()` and their helpers) now live in `fireSenseUtils`, which also uses them (`spreadFuelEffect()`, the fuel effect on the ELF map), so a row is read in one place. They are moved unchanged; the only difference is that their errors say "spread ledger row" instead of "fireSense_spreadPredict: ledger row". Needs fireSenseUtils >= 0.2.3.9190 (PredictiveEcology/fireSenseUtils#260, version to be set after it merges). +- The functions that read a ledger row (`ledgerLinkArgs()`, `ledgerCovCentre()`, `ledgerClimateRef()`, `ledgerPowerLawPc50()`, `ledgerSpreadClimate()`, `ledgerCovMinMax()` and their helpers) now live in `fireSenseUtils`, which also uses them (`spreadFuelEffect()`, the fuel effect on the ELF map), so a row is read in one place. They are moved unchanged; the only difference is that their errors say "spread ledger row" instead of "fireSense_spreadPredict: ledger row". Needs fireSenseUtils >= 0.2.3.9191 (PredictiveEcology/fireSenseUtils#260, version to be set after it merges). - A ledger row of `fireSense_spreadFit`'s `spreadClimate = "activation"` predicts as that fit: fuel sets each pixel's ceiling `pc` below p50 and climate is the linear predictor (`fireSenseUtils::spreadLinkInputs(activationIntercept =)`). The row's mode is read by the new `ledgerSpreadClimate()` (column `fireSenseUtils::spreadClimateTxt`); a row without it is "ceiling" when it has `climateRef_spread` and a power-law link, else "predictor", as before. The parameter set's `activationIntercept` is not a covariate coefficient: it goes to the link, and a set and its row that disagree stop. `fireSense_SpreadPowerLaw` is then a per-pixel raster, and `fireSense_SpreadLinear` is the climate term, so `fireSense_burn` adds the year effect to it unchanged. A row that records its mode is predicted by it: "predictor" keeps climate in x even with a `climateRef_spread`, and "ceiling" or "activation" without one stops. An activation ELF is not blended with an ELF of another mode (an error, beside the one for different links; ceiling with predictor still blends), and the activation's lower-asymptote check uses the run's `lowerSpreadProb`. Other rows predict as before. Needs fireSenseUtils >= 0.2.3.9183 (PredictiveEcology/fireSenseUtils#255). diff --git a/fireSense_spreadPredict.R b/fireSense_spreadPredict.R index 94bd0cc..495f6a4 100644 --- a/fireSense_spreadPredict.R +++ b/fireSense_spreadPredict.R @@ -17,7 +17,7 @@ defineModule(sim, list( documentation = list("README.txt", "fireSense_spreadPredict.Rmd"), reqdPkgs = list("data.table", "magrittr", "Matrix", "methods", "terra", "SpaDES.core (>=3.0.4)", "stats", "ggplot2", "viridis", - "PredictiveEcology/fireSenseUtils@development (>= 0.2.3.9190)"), # 9190 (placeholder: set after the fireSenseUtils PR merges): the ledger*() row readers (fireSenseUtils#260); 9186: splitSpreadClimate(), climateSplitRefPixels(), elfCellLabels() (fireSenseUtils#244); 9183: spreadLinkInputs(activationIntercept =), spreadClimateTxt (fireSenseUtils#255); 9181: spreadLinkInputs(), powerLawPc50 (fireSenseUtils#250); 9165: lowerAsymptote minimum (#230); 9162: smooth links, checkLinkParams() (#229); 9138: powerLawShape + "PredictiveEcology/fireSenseUtils@development (>= 0.2.3.9191)"), # 9191 (placeholder until fireSenseUtils#260 merges and is bumped): the ledger*() row readers (fireSenseUtils#260); 9186: splitSpreadClimate(), climateSplitRefPixels(), elfCellLabels() (fireSenseUtils#244); 9183: spreadLinkInputs(activationIntercept =), spreadClimateTxt (fireSenseUtils#255); 9181: spreadLinkInputs(), powerLawPc50 (fireSenseUtils#250); 9165: lowerAsymptote minimum (#230); 9162: smooth links, checkLinkParams() (#229); 9138: powerLawShape parameters = bindrows( defineParameter(name = "lowerSpreadProb", class = "numeric", default = fireSenseUtils::spreadProbFloor, desc = paste("Lower asymptote of the 2- and 3-parameter logistic. Default",