Skip to content

Commit

Permalink
[skip-ci] minor cleanup/formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
achubaty committed Sep 18, 2023
1 parent dce836b commit 82aa2a8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
16 changes: 9 additions & 7 deletions R/comparePredictions.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ comparePredictions_summaryDT <- function(scfmDriverPars = NULL,
## This is a long way of saying 'sum of fires / (flammable landscape * fire epoch)'.
## hist_mfs will be NaN if there were no fires larger than one pixel

#median fire size is not used by scfm but is worth recording
#regimes where mean is much greater than median will be hard to recreate
## median fire size is not used by scfm but is worth recording
## regimes where mean is much greater than median will be hard to recreate
escaped <- fireRegimePoints[fireRegimePoints$SIZE_HA > landscapeAttr$cellSize,]
medianFireSize <- median(escaped$SIZE_HA) #should be no need for na.rm

Expand Down Expand Up @@ -111,8 +111,8 @@ comparePredictions_summaryDT <- function(scfmDriverPars = NULL,
"achievedIgnitions" = achievedIgnitions,
"targetEscapes" = targetEscapes,
"achievedEscapes" = achievedEscapes,
"pEscape" = regime$pEscape, #escape prob (no. fires > cellSize / no. fires)
"p0" = driver$p0, #p0 and pEscape may indicate something incorrect
"pEscape" = regime$pEscape, ## escape prob (no. fires > cellSize / no. fires)
"p0" = driver$p0, ## p0 and pEscape may indicate something incorrect
"pSpread" = pSpread, ## spread probability estimated from the SCAM model
"pIgnition" = pIg) ## ignition probability of a single pixel
return(pred)
Expand All @@ -133,7 +133,8 @@ comparePredictions_meanFireSize <- function(dt) {

ggplot(dt, aes(x = histMeanSize, y = modMeanSize)) +
geom_point(aes(histMeanSize, modMeanSize)) +
labs(x = "historical mean fire size", y = "modeled mean fire size") +
xlab("historical mean fire size") +
ylab("modeled mean fire size") +
theme_bw() +
scale_y_continuous(limits = c(0, NA)) +
scale_x_continuous(limits = c(0, NA)) +
Expand Down Expand Up @@ -214,14 +215,15 @@ comparePredictions_annualEscapes <- function(dt) {

#' @export
#' @rdname comparePredictions
comparePredictions_fireDistribution <- function(dt){
comparePredictions_fireDistribution <- function(dt) {
if (any(is.null(dt))) {
stop("all arguments must be provided and cannot be NULL.")
}

ggplot(dt, aes(x = histMedianSize, y = histMeanSize)) +
geom_point() +
labs(y = "estimated mean fire size (ha)", x = "estimated median fire size (ha)") +
xlab("estimated median fire size (ha)") +
ylab("estimated mean fire size (ha)") +
theme_bw() +
geom_abline(slope = 1) +
scale_y_continuous(limits = c(0, NA)) +
Expand Down
7 changes: 3 additions & 4 deletions R/utils_scfmRegime.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ calcZonalRegimePars <- function(polygonID, firePolys,
targetBurnRate = NULL,
targetMaxFireSize = NULL) {

idx <- firePolys$PolyID == polygonID
tmpA <- firePoints[firePoints$PolyID == as.numeric(polygonID),]
tmpA <- firePoints[firePoints$PolyID == as.numeric(polygonID), ]
landAttr <- landscapeAttr[[polygonID]]
cellSize = landAttr[["cellSize"]]
nFires <- dim(tmpA)[1]
Expand Down Expand Up @@ -134,8 +133,8 @@ calcZonalRegimePars <- function(polygonID, firePolys,

## max fire size is returned twice - I think this is a backwards compatibility decision
return(list(
ignitionRate = rate, #per ha per yr
pEscape = pEscape,
ignitionRate = rate, ## per ha per yr
pEscape = pEscape, ## escape probability
xBar = xBar, ## mean fire size
lxBar = lxBar, ## mean log(fire size)
xMax = xMax, ## maximum observed size
Expand Down

0 comments on commit 82aa2a8

Please sign in to comment.