Newer
Older
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
---
title: "check_opt_data"
author: "CB"
date: "7/28/2020"
output: html_document
---
# RCP0 whole Finland - version 7
### (rslt_RCP0_FIN_V7.csv)
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
### Running on cPouta or WIN local
on_cPouta <- TRUE
### Set path to input files
if(on_cPouta == TRUE) {
# for pouta
datapath <- "/media/volume/outp_rcp0/"
path <- "/home/ubuntu/workspace/MultiForest2/"
# path <- paste0(getwd(),"/")
} else {
# for Windows
datapath <- "C:/MyTemp/r_SIMO_output/output/MF_FIN/RCP0_test/"
}
### load libraries
library(dplyr)
library(tidyr)
library(ggplot2)
library(data.table)
library(gridExtra)
library(egg)
library(kableExtra)
```
```{r , echo=FALSE}
poutaxy <- read.csv(paste0(datapath, "rslt_RCP0_FIN_V7_XY.csv"), sep = ";", header = TRUE, stringsAsFactors = FALSE)
pouta0 <- read.csv(paste0(datapath, "rslt_RCP0_FIN_V7.csv"), sep = ";", header = TRUE, stringsAsFactors = FALSE)
# poutaxy <- read.csv(paste0(datapath, "rslt_test_XY.csv"), sep = ";", header = TRUE, stringsAsFactors = FALSE)
# pouta0 <- read.csv(paste0(datapath, "rslt_test.csv"), sep = ";", header = TRUE, stringsAsFactors = FALSE)
pouta <- pouta0 %>%
dplyr::left_join(poutaxy[,c("id", "year", "regime", "standid", "CARBON_STORAGE")], by = c("id", "year", "regime"))
```
## How many stands?
```{r, echo=TRUE}
length(unique(pouta$id))
```
## Simulated regimes
```{r, echo=TRUE}
unique(pouta$regime)
```
# Check for outliers of certain indicators
Based on summary, the following are looked at due to high max-min values: </br>
- V </br>
- i_Vm3 </br>
- CARBON SINK </br>
## Indicator: V
```{r , echo=TRUE}
boxplot(pouta$V, main="Indicator: V")
V_out <- pouta %>% dplyr::filter(V > 1500) %>% # Standing volume above xx m3/ha
dplyr::mutate(error = "V")
# how many stands effected
length(unique(V_out$standid))
# ---------------
# which stands
# ---------------
unique(V_out$standid)
# which region
unique(V_out$region)
# which regime
unique(V_out$regime)
```
## Indicator: i_Vm3
```{r , echo=TRUE}
boxplot(pouta$i_Vm3, main="Indicator: i_Vm3")
i_Vm3_out <- pouta %>% filter(i_Vm3 > 50) %>% # annual volume increment above xx m3/ha
mutate(error = "i_Vm3")
# how many stands effected
length(unique(i_Vm3_out$id))
# ---------------
# which stands
# ---------------
unique(i_Vm3_out$standid)
# which region
unique(i_Vm3_out$region)
# which regime
unique(i_Vm3_out$regime)
```
### What are the high values
```{r , echo=TRUE}
i_Vm3_high <- pouta %>%
select(c("id", "standid", "year", "regime", "i_Vm3", "V","Harvested_V")) %>%
filter(id %in% unique(i_Vm3_out$id)) %>%
filter(i_Vm3 > 50 )
# first 20 rows
i_Vm3_high[1:20,] %>%
knitr::kable(caption = "FIRST 20 ROWS ONLY !!") %>%
kable_styling()
```
```{r , echo=TRUE}
## Indicator: CARBON SINK
```{r , echo=TRUE}
plot_carbon <- pouta %>%
filter(CARBON_SINK > -5000000)
boxplot(plot_carbon$CARBON_SINK, main="CARBON_SINK without the huge outlier")
carbon_sink_out <- pouta %>% filter(CARBON_SINK < -1000000 | CARBON_SINK > 1000000) %>% # source/sink of more than 1000 t CO2/ha
mutate(error = "CARBON_SINK")
# how many stands
length(unique(carbon_sink_out$id))
# ---------------
# which stands
# ---------------
unique(carbon_sink_out$standid)
# which regime
unique(carbon_sink_out$regime)
# which region
unique(carbon_sink_out$region)
```
### What are the high values
```{r , echo=TRUE}
carbononly <- pouta %>%
select(c("id", "standid", "year", "regime", "V", "Harvested_V" ,"CARBON_STORAGE", "CARBON_SINK")) %>%
filter(id %in% unique(carbon_sink_out$id))
carbononly %>%
filter(CARBON_SINK < -1000000 | CARBON_SINK > 1000000) %>%
knitr::kable(caption = "ALL ROWS !!") %>%
kable_styling()
```
### Plot some example stands
```{r , echo=TRUE}
carbonplot <- carbononly %>%
filter(regime %in% c("SA","initial_state") & id %in% 99037593 |
regime %in% c("BAU_30","initial_state") & id %in% 99034584 |
regime %in% c("CCF_2", "CCF_1", "CCF_3", "initial_state") & id %in% 99032541) %>%
mutate(deltaCarbonstorage = round(CARBON_SINK / 3.67, digits = 2))
# for scenarios BAU_30 and SA
p1 = ggplot(carbonplot[carbonplot$regime %in% c("BAU_30", "SA"),], aes(year, V)) +
geom_line() +
facet_grid(.~regime) +
theme(axis.text.x = element_text(angle = 90))
p2 = ggplot(carbonplot[carbonplot$regime %in% c("BAU_30", "SA"),], aes(year, CARBON_STORAGE)) +
geom_line() +
facet_grid(.~regime) +
theme(axis.text.x = element_text(angle = 90)) +
scale_y_continuous(labels = function(x) format(x, scientific = FALSE))
p3 = ggplot(carbonplot[carbonplot$regime %in% c("BAU_30", "SA"),], aes(year, deltaCarbonstorage)) +
geom_line() +
facet_grid(.~regime) +
theme(axis.text.x = element_text(angle = 90)) +
scale_y_continuous(labels = function(x) format(x, scientific = FALSE))
ggarrange(p1, p2, p3,
top = "BAU_30 99034584 standid: 9932854 - SA 99037593 standid: 10628286")
```
!!! HIGH Carbon sinks due to extremly high simulated Volumes !!!
```{r , echo=TRUE}
# for scenarios CC_2, _1 and _3
p4 = ggplot(carbonplot[carbonplot$regime %in% c("CCF_2", "CCF_1", "CCF_3"),], aes(year, V)) +
geom_line() +
facet_grid(.~regime) +
theme(axis.text.x = element_text(angle = 90))
p5 = ggplot(carbonplot[carbonplot$regime %in% c("CCF_2", "CCF_1", "CCF_3"),], aes(year, CARBON_STORAGE)) +
geom_line() +
facet_grid(.~regime) +
theme(axis.text.x = element_text(angle = 90)) +
scale_y_continuous(labels = function(x) format(x, scientific = FALSE))
p6 = ggplot(carbonplot[carbonplot$regime %in% c("CCF_2", "CCF_1", "CCF_3"),], aes(year, deltaCarbonstorage)) +
geom_line() +
facet_grid(.~regime) +
theme(axis.text.x = element_text(angle = 90)) +
scale_y_continuous(labels = function(x) format(x, scientific = FALSE))
ggarrange(p4, p5, p6,
top = "99032541 - standid 23271031")
```