-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfireSense_SpreadPredict.Rmd
124 lines (94 loc) · 2.99 KB
/
fireSense_SpreadPredict.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
112
113
114
115
116
117
118
119
120
121
122
123
124
---
title: "fireSense_SpreadPredict"
author:
- "Jean Marchal (<[email protected]>)"
- "Alex M. Chubaty (<[email protected]>)"
- "Tati Micheletti (<[email protected]>)"
date: "`r format(Sys.time(), '%d %B %Y')`"
output:
html_document: default
editor_options:
chunk_output_type: console
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, results = "hold")
```
# Overview
Predicts a surface (raster) of fire spread probabilities using a model previously fit with `fireSense_SpreadFit`.
# Usage
```{r module-usage-init}
library(magrittr)
library(raster)
library(SpaDES.core)
library(SpaDES.tools)
set.seed(123)
# Define simulation parameters
times <- list(start = 1, end = 1, timeunit = "year")
modules <- list("fireSense_SpreadPredict")
paths <- list(
modulePath = ".."
)
# Create a random map of weather
nx <- ny <- 100L
weather <- raster(nrows = ny, ncols = nx, xmn = -nx/2, xmx = nx/2, ymn = -ny/2, ymx = ny/2) %>%
gaussMap(scale = 300, var = 1, speedup = 1, inMemory = TRUE)
# Create a typical output of fireSense_SpreadFit
fireSense_SpreadFitted <- list(
formula = ~ weather2 - 1,
coef = setNames(c(0.3, 3, 0.1, 1.5, 3),
c("A", "B", "D", "G", "weather"))
## A, B, D, G are parameters of the 5-parameters logistic function
)
class(fireSense_SpreadFitted) <- "fireSense_SpreadFit"
parameters <- list(
fireSense_SpreadPredict = list(
mapping = list(weather2 = "weather") # One can use mapping to map variables
# in the formula of the fitted object
# to those in data. Here weather2
# (formula) is mapped to weather (data).
)
)
# Objects to pass from the global environment to the simList environment
objects <- c(
"weather" = weather,
"fireSense_SpreadFitted" = fireSense_SpreadFitted
)
# Create the simList
sim <- simInit(
times = times,
modules = modules,
paths = paths,
params = parameters,
objects = objects
)
```
Run the model: <!-- TODO: this currently FAILS due to incorrect object class -->
```{r module-usage-run, eval = FALSE}
sim <- spades(sim)
Plot(weather, sim$fireSense_SpreadPredicted)
```
# Parameters
Provide a summary of user-visible parameters.
```{r moduleParams, echo = FALSE}
df_params <- moduleParams("fireSense_SpreadPredict", "..")
knitr::kable(df_params)
```
# Events
Events are scheduled as follows:
- Module initiation;
- Make predictions.
## Saving
There is currently nothing saved, but this may change in the future. <!-- TODO -->
# Data dependencies
## Input data
```{r moduleInputs, echo = FALSE}
df_inputs <- moduleInputs("fireSense_SpreadPredict", "..")
knitr::kable(df_inputs)
```
## Output data
```{r moduleOutputs, echo = FALSE}
df_outputs <- moduleOutputs("fireSense_SpreadPredict", "..")
knitr::kable(df_outputs)
```
# Links to other modules
Predictions made with this module can be used with the fire spread component of landscape fire models (e.g., `fireSense`). <!-- TODO -->