Title: | Tools and Utilities for Working With the SCFM Wildfire Simulation Model |
---|---|
Description: | The original fire model is described by Cumming et al. (1998), and more accessibly in Armstrong and Cumming (2003). It has recently been implemented as a collection of 'SpaDES' modules by Cumming, McIntire, Eddy, and Chubaty, available from <https://github.com/PredictiveEcology/scfm>. |
Authors: | Steve Cumming [aut], Alex M Chubaty [aut, cre] , Eliot J B McIntire [aut] , Ian M S Eddy [aut] , His Majesty the King in Right of Canada, as represented by the Minister of Natural Resources Canada [cph] |
Maintainer: | Alex M Chubaty <[email protected]> |
License: | GPL (>= 3) |
Version: | 2.0.3 |
Built: | 2024-11-17 05:43:18 UTC |
Source: | https://github.com/PredictiveEcology/scfmutils |
scfmutil
packageThe original fire model is described by Cumming et al. (1998), and more accessibly in Armstrong and Cumming (2003). It has recently been implemented as a collection of 'SpaDES' modules by Cumming, McIntire, Eddy, and Chubaty, available from https://github.com/PredictiveEcology/scfm.
Maintainer: Alex M Chubaty [email protected] (ORCID)
Authors:
Steve Cumming [email protected]
Eliot J B McIntire [email protected] (ORCID)
Ian M S Eddy [email protected] (ORCID)
Other contributors:
His Majesty the King in Right of Canada, as represented by the Minister of Natural Resources Canada [copyright holder]
Useful links:
Report bugs at https://github.com/PredictiveEcology/scfmutils/issues
scfmRegime
: calcZonalRegimePars
scfmRegime
: calcZonalRegimePars
calcZonalRegimePars( polygonID, firePolys, firePoints, epochLength, maxSizeFactor, fireSizeColumnName, targetBurnRate = NULL, targetMaxFireSize = NULL )
calcZonalRegimePars( polygonID, firePolys, firePoints, epochLength, maxSizeFactor, fireSizeColumnName, targetBurnRate = NULL, targetMaxFireSize = NULL )
polygonID |
TODO |
firePolys |
TODO |
firePoints |
TODO |
epochLength |
TODO |
maxSizeFactor |
TODO |
fireSizeColumnName |
TODO |
targetBurnRate |
TODO |
targetMaxFireSize |
TODO |
list containing the following elements and their values:
ignitionRate
(ignition rate),
pEscape
(escape probability),
xBar
(mean fire size),
lxBar
(mean log-fire-size),
xMax
(maximum observed fire size),
emfs_ha
(estimated maximum fire size in ha),
empiricalBurnRate
(empircal burn rate)
scfmDriver
: calibrateFireRegimePolys
Calibrate fire regime polygons ... (TODO)
calibrateFireRegimePolys( polygonType, targetN, fireRegimePolys, buffDist, pJmp, pMin, pMax, flammableMap = NULL, plotPath = NULL, outputPath = NULL, optimizer = "bfgs" )
calibrateFireRegimePolys( polygonType, targetN, fireRegimePolys, buffDist, pJmp, pMin, pMax, flammableMap = NULL, plotPath = NULL, outputPath = NULL, optimizer = "bfgs" )
polygonType |
the names of polygons, i.e. |
targetN |
the number of fires to simulate during calibration |
fireRegimePolys |
|
buffDist |
buffer distance for cells available to be burned outside of each regime polygon |
pJmp |
numeric. default spread probability for degenerate polygons |
pMin |
numeric. minimum spread probability |
pMax |
numeric. maximum allowable spread probability |
flammableMap |
a packed |
plotPath |
character. file name specifying an output directory to use for producing plots of the scam fit for each polygon. |
outputPath |
character. path to output directory. |
optimizer |
character. the numerical optimization method to use with scam fitting;
see |
data.table
with columns:
PolyID
: polygon ID;
pSpread
: spread probability;
p0
: TODO;
naiveP0
: TODO;
pIgnition
: ignition probability;
maxBurnCells
: maximum number of burned cells.
fireRegimePolys
Check for various issues with fireRegimePolys
checkForIssues( fireRegimePolys, studyArea, rasterToMatch, flammableMap, sliverThresh, cacheTag )
checkForIssues( fireRegimePolys, studyArea, rasterToMatch, flammableMap, sliverThresh, cacheTag )
fireRegimePolys |
|
studyArea |
|
rasterToMatch |
|
flammableMap |
|
sliverThresh |
minimum sliver size |
cacheTag |
character specifying additional user tags for caching |
a cleaned up fireRegimePolys
object
data.table
to compare scfm predictions with historical observationsCreate data.table
to compare scfm predictions with historical observations
comparePredictions_summaryDT( fireRegimePoints = NULL, burnSummary = NULL, fireRegimePolys = NULL, times = NULL ) comparePredictions_meanFireSize(dt) comparePredictions_fireReturnInterval(dt, times) comparePredictions_annualIgnitions(dt) comparePredictions_annualEscapes(dt) comparePredictions_fireDistribution( fireRegimePoints = NULL, burnSummary = NULL, size )
comparePredictions_summaryDT( fireRegimePoints = NULL, burnSummary = NULL, fireRegimePolys = NULL, times = NULL ) comparePredictions_meanFireSize(dt) comparePredictions_fireReturnInterval(dt, times) comparePredictions_annualIgnitions(dt) comparePredictions_annualEscapes(dt) comparePredictions_fireDistribution( fireRegimePoints = NULL, burnSummary = NULL, size )
fireRegimePoints |
|
burnSummary |
|
fireRegimePolys |
|
times |
list of simulation start and end times (i.e., output from |
dt |
scfm summary |
size |
minimum fire size (ha) |
comparePredictions_summaryDT
returns a data.table
object;
other functions return ggplot
objects.
Ian Eddy
## Not run: ## assumes user has run scfm to produce the simList `mySimOut` dt <- comparePredictions_summaryDT(fireRegimePoints = mySimOut$fireRegimePoints, burnSummary = mySimOut$burnSummary, fireRegimePolys = mySimOut$fireRegimePolys, times = times(mySimOut)) gg_mfs <- comparePredictions_meanFireSize(dt) gg_fri <- comparePredictions_fireReturnInterval(dt) gg_ign <- comparePredictions_annualIgnitions(dt) gg_frp <- plot_fireRegimePolys(mySimOut$fireRegimePolys) gridExtra::grid.arrange(fps, gg_mfs, gg_fri, gg_ign, nrow = 2, ncol = 2) ## End(Not run)
## Not run: ## assumes user has run scfm to produce the simList `mySimOut` dt <- comparePredictions_summaryDT(fireRegimePoints = mySimOut$fireRegimePoints, burnSummary = mySimOut$burnSummary, fireRegimePolys = mySimOut$fireRegimePolys, times = times(mySimOut)) gg_mfs <- comparePredictions_meanFireSize(dt) gg_fri <- comparePredictions_fireReturnInterval(dt) gg_ign <- comparePredictions_annualIgnitions(dt) gg_frp <- plot_fireRegimePolys(mySimOut$fireRegimePolys) gridExtra::grid.arrange(fps, gg_mfs, gg_fri, gg_ign, nrow = 2, ncol = 2) ## End(Not run)
The threshold is applied to the area of the multipolygon object, not each individual polygon. Non-sliver polygons keep their original attributes. Intended to be used when it is important to retain the original extent of an area while removing sliver polygons.
deSliver(x, threshold)
deSliver(x, threshold)
x |
an |
threshold |
the minimum area below which a polygon is considered a sliver |
an object of class sf
with sliver polygons merged to their nearest valid neighbour.
scfmDriver
: executeDesign
DESCRIPTION NEEDED
executeDesign(L, dT, maxCells)
executeDesign(L, dT, maxCells)
L |
TODO |
dT |
TODO |
maxCells |
TODO |
TODO
prepInputsFireRegimePolys
Create fire regime polygons for scfmRegime
.
fireRegimePolyTypes() prepInputsFireRegimePolys( url = NULL, destinationPath = tempdir(), studyArea = NULL, rasterToMatch = NULL, type = "ECOREGION" )
fireRegimePolyTypes() prepInputsFireRegimePolys( url = NULL, destinationPath = tempdir(), studyArea = NULL, rasterToMatch = NULL, type = "ECOREGION" )
url |
character. URL from which to download and prepare fire regime polygons. Defaults are provided for Canadian ecodistrict, ecoregion, ecoprovince, and ecozone, as well as national Fire Regime Types and Fire Regime Units from Erni et al. (2020) doi:10.1139/cjfr-2019-0191. |
destinationPath |
character. Path to directory where data will be downloaded. |
studyArea |
|
rasterToMatch |
|
type |
character. The polygon type to use:
Must be one of "ECODISTRICT", "ECOREGION" (default), "ECOPROVINCE", "ECOZONE",
"FRT", or "FRU".
If |
library(terra) library(SpaDES.tools) ## random study area in central Alberta studyAreaAB <- vect(cbind(-115, 55), crs = "epsg:4326") |> project(paste("+proj=lcc +lat_1=49 +lat_2=77 +lat_0=0 +lon_0=-95", "+x_0=0 +y_0=0 +units=m +no_defs +ellps=GRS80 +towgs84=0,0,0")) |> randomStudyArea(seed = 60, size = 1e10) studyAreaBC <- vect(cbind(-122.14, 52.14), crs = "epsg:4326") |> project(paste("+proj=lcc +lat_1=49 +lat_2=77 +lat_0=0 +lon_0=-95", "+x_0=0 +y_0=0 +units=m +no_defs +ellps=GRS80 +towgs84=0,0,0")) |> randomStudyArea(seed = 60, size = 1e10) frpEcoregion <- prepInputsFireRegimePolys(studyArea = studyAreaAB, type = "ECOREGION") plot(frpEcoregion) frpBECNDT <- prepInputsFireRegimePolys(studyArea = studyAreaBC, type = "BECNDT") plot(frpBECNDT) frpFRT <- prepInputsFireRegimePolys(studyArea = studyAreaAB, type = "FRT") plot(frpFRT) frpFRU <- prepInputsFireRegimePolys(studyArea = studyAreaAB, type = "FRU") plot(frpFRU)
library(terra) library(SpaDES.tools) ## random study area in central Alberta studyAreaAB <- vect(cbind(-115, 55), crs = "epsg:4326") |> project(paste("+proj=lcc +lat_1=49 +lat_2=77 +lat_0=0 +lon_0=-95", "+x_0=0 +y_0=0 +units=m +no_defs +ellps=GRS80 +towgs84=0,0,0")) |> randomStudyArea(seed = 60, size = 1e10) studyAreaBC <- vect(cbind(-122.14, 52.14), crs = "epsg:4326") |> project(paste("+proj=lcc +lat_1=49 +lat_2=77 +lat_0=0 +lon_0=-95", "+x_0=0 +y_0=0 +units=m +no_defs +ellps=GRS80 +towgs84=0,0,0")) |> randomStudyArea(seed = 60, size = 1e10) frpEcoregion <- prepInputsFireRegimePolys(studyArea = studyAreaAB, type = "ECOREGION") plot(frpEcoregion) frpBECNDT <- prepInputsFireRegimePolys(studyArea = studyAreaBC, type = "BECNDT") plot(frpBECNDT) frpFRT <- prepInputsFireRegimePolys(studyArea = studyAreaAB, type = "FRT") plot(frpFRT) frpFRU <- prepInputsFireRegimePolys(studyArea = studyAreaAB, type = "FRU") plot(frpFRU)
scfmLandCoverInit
: genFireMapAttr
scfmLandCoverInit
: genFireMapAttr
genFireMapAttr(flammableMap, fireRegimePolys, neighbours)
genFireMapAttr(flammableMap, fireRegimePolys, neighbours)
flammableMap |
|
fireRegimePolys |
|
neighbours |
integer of value |
TODO
scfmDriver
: genSimLand
Buffers polygon, generates index raster
genSimLand(coreLand, buffDist, flammableMap = NULL)
genSimLand(coreLand, buffDist, flammableMap = NULL)
coreLand |
TODO |
buffDist |
distance to buffer |
flammableMap |
|
list containing fireRegimePoly
, landscapeIndex
, flammableMap
objects.
Get fire points data from the Canadian National Fire Database
getFirePoints_NFDB_scfm( url = NULL, studyArea = NULL, rasterToMatch = NULL, redownloadIn = 2, NFDB_pointPath = NULL )
getFirePoints_NFDB_scfm( url = NULL, studyArea = NULL, rasterToMatch = NULL, redownloadIn = 2, NFDB_pointPath = NULL )
url |
URL from which to download the fire points data. Default |
studyArea |
|
rasterToMatch |
|
redownloadIn |
time in years that we tolerate the data to be "old", and require redownload. I.e. 0.5 would mean "redownload data older than 6 months". Default 2. |
NFDB_pointPath |
file path to save the download data. Must be provided. |
scfmDriver
: escape probability1 - (1-p0)**N = pEscape 1 - pEscape = (1-p0)**N (1 - pEscape)**1/N = 1 - p0 p0 = 1 - (1 - pEscape)**1/N ```
hatP0(pEscape, n = 8) escapeProbDelta(p0, w, hatPE)
hatP0(pEscape, n = 8) escapeProbDelta(p0, w, hatPE)
pEscape |
TODO |
n |
TODO |
p0 |
TODO |
w |
TODO |
hatPE |
TODO |
TODO
scfmDriver
: makeAndExecuteDesign
This is a wrapper around makeDesign
and executeDesign
.
makeAndExecuteDesign(...)
makeAndExecuteDesign(...)
... |
objects to pass through to |
output of executeDesign
(TODO)
scfmDriver
: makeDesign
scfmDriver
: makeDesign
makeDesign(indices, targetN, pEscape = 0.1, pmin, pmax, q = 1)
makeDesign(indices, targetN, pEscape = 0.1, pmin, pmax, q = 1)
indices |
TODO |
targetN |
TODO |
pEscape |
TODO |
pmin |
TODO |
pmax |
TODO |
q |
TODO |
data.frame
with columns igLoc
, p0
, and p
.
This version of makeDesign
is the simplest possible.
Plot age map
plot_ageMap(x, title, maxAge)
plot_ageMap(x, title, maxAge)
x |
|
title |
character, the plot title |
maxAge |
the maximum age to plot |
ggplot
object
Plot burn maps
plot_burnMap(x, title)
plot_burnMap(x, title)
x |
|
title |
character, the plot title |
ggplot
object
Plot fire regime polygons
plot_fireRegimePolys(fireRegimePolys)
plot_fireRegimePolys(fireRegimePolys)
fireRegimePolys |
|
a ggplot
object
Plot fire regime raster
plot_fireRegimeRas(x, title)
plot_fireRegimeRas(x, title)
x |
|
title |
character, the plot title |
ggplot
object
Plot flammable map
plot_flammableMap(x, title)
plot_flammableMap(x, title)
x |
|
title |
character, the plot title |
ggplot
object
: pdf is
pTE(x, theta, T) dTE(x, theta, T) qTE(p, theta, T) rTE(n, theta, T) qqTE( x, theta = stop("missing theta"), T = stop("missing T"), plot.it = TRUE, xlab = deparse(substitute(x)), ylab = deparse(substitute(y)), ... ) ETE(theta, T, a = 0) ETEx(theta, T, a = 0, shift = 200) ExpBar(Z) HannonDayiha(Z, Tspec = 0)
pTE(x, theta, T) dTE(x, theta, T) qTE(p, theta, T) rTE(n, theta, T) qqTE( x, theta = stop("missing theta"), T = stop("missing T"), plot.it = TRUE, xlab = deparse(substitute(x)), ylab = deparse(substitute(y)), ... ) ETE(theta, T, a = 0) ETEx(theta, T, a = 0, shift = 200) ExpBar(Z) HannonDayiha(Z, Tspec = 0)
x |
TODO |
theta |
TODO |
T |
TODO |
p |
TODO |
n |
TODO |
plot.it |
logical indicating whether to plot the resulting figure |
xlab , ylab
|
label text for x- and y-axes |
... |
additional arguments passed to |
a |
TODO |
shift |
TODO |
Z |
TODO |
Tspec |
TODO |
where T
is the truncation point or upper bound and is the shape parameter
in this application,
x
are fire sizes >= shift
, which is a lower bound
and z = log(x / shift)
are the scaled log transformed sizes which seem to
fit a truncated exponential distribution fairly well.
Originally written by Steve in 1999 in support of Cumming CJFR 2001. Has been in use by BEACONs and was acquired from Pierre Vernier in May 17 2014.
pTE()
is the distribution function;
dTE()
is the density function;
qTE()
is the quantile function;
rTE()
is the random generation function.
In fire size applications exp(rTE(n, theta, T)) * shift
will generate n
random fire sizes;
qqTE()
produces a quantile-quantile plot of vector x
against a TE(theta, T)
;
ETE()
is TODO;
ETEx()
is TODO;
ExpBar()
is TODO;
HannonDayiha()
implements the estimator of Hannon and Dayiha (1999),
ported from 1999 C language implementation by SGC June 2004.
Patrick M. Hannona & Ram C. Dahiyaa (1999) Estimation of parameters for the truncated exponential distribution. Communications in Statistics - Theory and Methods 28(11): 2591-2612. doi:10.1080/03610929908832440.
Ratio partition
ratioPartition(targetBurnRate, empiricalBurnRate, pEscape, xBar, rate) ratioPartition2(targetBurnRate, empiricalBurnRate, pEscape, xBar, rate)
ratioPartition(targetBurnRate, empiricalBurnRate, pEscape, xBar, rate) ratioPartition2(targetBurnRate, empiricalBurnRate, pEscape, xBar, rate)
targetBurnRate |
target burn rate |
empiricalBurnRate |
burn rate estimated by the model |
pEscape |
escape probability |
xBar |
mean fire size |
rate |
ignition rate |
a list containing the following elements:
rate
(ignition rate),
pEscape
(escape probability),
xBar
(mean fire size).
unirootFunction
unirootFunction
unirootFunction(x, cM, xBar)
unirootFunction(x, cM, xBar)
x |
TODO |
cM |
TODO |
xBar |
TODO |
TODO