-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfireSense.Rmd
112 lines (85 loc) · 3.49 KB
/
fireSense.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
---
title: "fireSense"
author: "Jean Marchal"
date: "`r format(Sys.time(), '%B %Y')`"
output:
html_document: default
pdf_document: default
---
# Overview
A landscape fire model sensitive to environmental changes (e.g. weather and land-cover).
# Download the module
```{r download module, eval = FALSE, echo = TRUE}
library(SpaDES)
moduleName <- "fireSense"
workingDirectory <- tempdir() # Location where the module will be downloaded
downloadModule(moduleName, path = workingDirectory)
```
# Usage
## Module parameters
Name|Default|Description
----|:-------|---------------------------------------------------------------------
`mapping`|`NULL`|optional named vector or list of character strings mapping one or more inputs required by the module to objects loaded in the simList environment.
`.runInitialTime`|`start(simList)`|when to start this module? By default, the start time of the simulation.
`.runInterval`|`1`|optional. Interval between two runs of this module, expressed in units of simulation time. By default, 1 year.
`.saveInitialTime`|`NA`|optional. When to start saving output to a file.
`.saveInterval`|`NA`|optional. Interval between save events.
`.plotInitialTime`|`NA`|optional. When to start plotting.
`.plotInterval`|`NA`|optional. Interval between plot events.
|||
## Usage example
```{r module usage example, eval = FALSE}
library(SpaDES)
library(magrittr)
# Packages required by the module
library(data.table)
library(raster)
set.seed(1)
nx <- ny <- 100L
n <- nx * ny
r <- raster(nrows = ny, ncols = nx, xmn = -nx/2, xmx = nx/2, ymn = -ny/2, ymx = ny/2)
# Create a map ignition probabilities
ignitionProbRaster <- gaussMap(r, scale = 10, var = .0001, speedup = nx/5e2, inMemory = TRUE)
# Create a map of escape probabilities
escapeProbRaster <- gaussMap(r, scale = 50, var = .01, speedup = nx/5e2, inMemory = TRUE)
# Create a map of spread probabilities
spreadProbRaster <- gaussMap(r, scale = 300, var = .05, speedup = nx/5e2, inMemory = TRUE)
#outputDir <- file.path(tempdir(), "outputs")
times <- list(start = 1, end = 100, timeunit = "year")
modules <- list("fireSense")
# Pass objects found in the global environment to the simList environment
objects <- list(
ignitionProbRaster = ignitionProbRaster,
escapeProbRaster = escapeProbRaster,
spreadProbRaster = spreadProbRaster
)
paths <- list(
# cachePath = file.path(outputDir, "cache"),
modulePath = ".."
# inputPath = inputDir,
# outputPath = outputDir
)
mySim <- simInit(times = times, params = parameters, modules = modules, objects = objects, paths = paths)
spades(mySim)
```
# Events
- ignite fires
- determine which fires escape
- spread escaped fires
- save
- plot
## Plotting
- **Burn map**: Pixels burned this timestep.
- **Cumulative burn map**: Number of times each pixel burned during the simulation..
## Saving
- **burnMap**: A RasterLayer describing how which pixels burned this timestep.
- **burnMapCumul**: A RasterLayer describing how many times each pixel burned over the course of the simulation.
# Data dependencies
## Input data
- **ignitionProbRaster**: a RasterLayer or RasterStack (time series) describing spatial variations in ignition probabilities.
- **escapeProbRaster**: a RasterLayer or RasterStack (time series) describing spatial variations in escape probabilities.
- **spreadProbRaster**: a RasterLayer or RasterStack (time series) describing spatial variations in spread probabilities.
## Output data
see [Saving](#saving).
# Links to other modules
This module should be coupled with a dynamic vegetation model.