-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodobs_zroot_ecosystem.Rmd
680 lines (584 loc) · 31 KB
/
modobs_zroot_ecosystem.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
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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
---
title: "Modelled vs. observed ecosystem-scale zroot"
author: "Beni Stocker"
date: "4/30/2019"
output:
html_document:
toc: true
toc_depth: 3
toc_float: true
---
```{r setup, include=FALSE}
library(rbeni)
library(dplyr)
library(ggplot2)
library(tidyr)
library(readr)
library(raster)
library(rasterVis)
library(stringr)
library(forcats)
library(sf)
```
# Comparison of global z$_\text{root}$ estimate with RPGE data
The global z$_\text{root}$ estimate can be compared with the ecosystem-level RPGE data.
The figure below shows the distribution of modelled values (bars, where 'Balland' and 'SaxtonRawls' refers to the WHC estimate based on pedotransfer functions from Balland et al., 2008, and Saxton & Rawls, 2006, respectively.). The blue line represents the distribution of depth estimates for the extrapolated 95% quantile of root mass (`D95_extrapolated`) in the RPGE data.
Read data and exclude what's not used in Schenk & Jackson 2002.
```{r echo = FALSE}
# Load data
# note: re-downloaded data is the same as the one shersingh gave me
#df_obs2 <- read_csv("/alphadata01/bstocker/data/RPGE_shersing/data/root_profiles_D50D95.csv")
df_obs <- read_csv("/alphadata01/bstocker/data/rootingdepth/root_profiles_schenkjackson02/data/root_profiles_D50D95.csv") %>%
dplyr::filter(Wetland == "N" & Anthropogenic == "N" & Schenk_Jackson_2002 == "YES")
```
Do some data explorations, trying to reproduce analyses in Schenk & Jackson (2002)...
## Rooting depth by vegetation type
Problem: Could not identify the classes from Fig. 4 in Schenk & Jackson with the classes given in the dataset. Available vegetation classes are:
```{r}
df_obs$Vegetation %>% unique() %>% print()
```
Trying to identify similar classes as in Schenk & Jackson by hand:
```{r}
df_obs <- df_obs %>%
mutate( veg2 = Vegetation ) %>%
mutate( veg2 = ifelse(str_detect(Vegetation, "boreal") & str_detect(Vegetation, "forest"), "boreal_forest", veg2) ) %>%
mutate( veg2 = ifelse(str_detect(Vegetation, "tem") & str_detect(Vegetation, "forest"), "temperate_forest", veg2) ) %>%
mutate( veg2 = ifelse( str_detect(Vegetation, "EBL forest / trop"), "tropical_evergreen_forest", veg2) ) %>%
mutate( veg2 = ifelse( str_detect(Vegetation, "DBL forest / trop"), "tropical_deciduous_forest", veg2) ) %>%
mutate( veg2 = ifelse( str_detect(Vegetation, "Savanna") & abs(Latitude) <= 30.0, "tropical_savanna", veg2) ) %>%
mutate( veg2 = ifelse( str_detect(Vegetation, "Savanna") & abs(Latitude) > 30.0, "temp_savanna", veg2) ) %>%
# mutate( veg2 = ifelse( Vegetation == "alpine herbaceous", "alpine_herbaceous", veg2)) %>%
# mutate( veg2 = ifelse( Vegetation == "Grassland", "grassland", veg2)) %>%
# mutate( veg2 = ifelse( Vegetation == "Grassland", "grassland", veg2)) %>%
mutate( veg2 = as.factor(veg2) )
```
Plot histograms of depth of 95% quantile in my similar classes, trying to reproduce something similar to Fig. 4 in Schenk & Jackson, 2002.
```{r}
df_obs %>%
dplyr::filter( veg2 %in% c("Tundra", "boreal_forest", "temperate_forest", "alpine herbaceous", "Pasture", "Grassland", "temp_savanna", "Closed shrubland", "open shrubland", "Wooded grassland", "tropical_savanna", "tropical_deciduous_forest", "tropical_evergreen_forest") ) %>%
mutate( veg2 = fct_relevel(veg2, c("Tundra", "boreal_forest", "temperate_forest", "alpine herbaceous", "Pasture", "Grassland", "temp_savanna", "Closed shrubland", "open shrubland", "Wooded grassland", "tropical_savanna", "tropical_deciduous_forest", "tropical_evergreen_forest")) ) %>%
ggplot() +
geom_boxplot(aes(x = veg2, y = -D95_extrapolated * 100)) +
ylim(-300,0) +
theme(axis.text.x = element_text(angle=90, hjust=1))
```
**Needed:**
- correct classification to reproduce Fig. 4, or...
- sites classified into some standard vegetation types for which we have global maps (e.g., IGBP). UMD cover is provided. This here is the only classification key I discovered in the internet:
![](fig/umd_key.png)
-> Can this be translated 1:1 into IGBP?
What are viable targets? Given that it's difficult to compare values predicted at sites one by one, can we at least get the distribution of predicted values right, not only globally by across different classes where we expect differences in rooting depth across classes?
- Climate zones (e.g., Koeppen-Geiger)
- Vegetation classes (tropical evergreen, tropical forests with dry season, savannah, mediterranean forests, mediterranean shrublands, ... )
### My results by vegetation class.
Using UMD classification in the Schenk & Jackson data, and translating it into IGBP:
```{r}
df_obs <- df_obs %>%
mutate( igbp = NA ) %>%
mutate( igbp = ifelse(UMD_cover==1, "ENF", igbp) ) %>%
mutate( igbp = ifelse(UMD_cover==2, "EBF", igbp) ) %>%
mutate( igbp = ifelse(UMD_cover==4, "DBF", igbp) ) %>%
mutate( igbp = ifelse(UMD_cover==5, "MF", igbp) ) %>%
mutate( igbp = ifelse(UMD_cover==6, "SAV", igbp) ) %>%
mutate( igbp = ifelse(UMD_cover==7, "WSA", igbp) ) %>%
mutate( igbp = ifelse(UMD_cover==8, "CSH", igbp) ) %>%
mutate( igbp = ifelse(UMD_cover==9, "OSH", igbp) ) %>%
mutate( igbp = ifelse(UMD_cover==10,"GRA", igbp) ) %>%
mutate( igbp = as.factor(igbp) )
```
Plot observations by IGBP class:
```{r}
df_obs %>%
mutate( igbp = fct_relevel(igbp, c("ENF", "EBF", "DBF", "MF", "SAV", "WSA", "CSH", "OSH", "GRA")) ) %>%
ggplot() +
geom_boxplot(aes(x = igbp, y = -D95_extrapolated * 100)) +
ylim(-300,0) +
theme(axis.text.x = element_text(angle=90, hjust=1))
```
Problem: No clear variations across IGBP classes.
## Rooting depth vs. latitude.
```{r}
df_obs %>%
mutate(tropical = ifelse(abs(Latitude)<30, TRUE, FALSE )) %>%
mutate(D95_extrapolated_neg_log = -log(100*D95_extrapolated)) %>%
dplyr::filter(abs(Latitude) <= 90) %>%
ggplot() +
geom_point(aes(x = abs(Latitude), y = D95_extrapolated_neg_log, color = tropical)) +
geom_smooth(aes(x = abs(Latitude), y = D95_extrapolated_neg_log, color = tropical), se = FALSE, method = lm)
```
**Issue:**
- Apparently, "Tropical" vs. "Extra-tropical" in Schenk & Jackson is not solely based on latitude.
Rooting depth vs. PET
```{r}
df_obs %>%
dplyr::filter(PET>0) %>%
ggplot() +
geom_point(aes(x = PET, y = D95_extrapolated * -100)) +
ylim(-500, 0)
```
### My results vs. latitude
Dividing simulated rooting depth by 10!
```{r}
load("./data/df_20y_bl_v3.Rdata") # loading df_20y_bl_v3
df_20y_bl_v3 %>%
mutate(tropical = ifelse(abs(lat)<30, TRUE, FALSE )) %>%
ggplot(aes(x = abs(lat), y = -log(zroot/10), color = tropical)) +
geom_point(alpha = 0.1) +
geom_smooth(se = FALSE, method = lm) +
ylim(-7, -2)
```
## Rooting depth by climate zone
Complement Schenk & Jackson data with Koeppen-Geiger climate classification.
```{r echo = FALSE}
kgclimate_lores <- raster("/alphadata01/bstocker/data/koeppengeiger/Beck_KG_V1/Beck_KG_V1_present_0p5.tif")
kgclimate_hires <- raster("/alphadata01/bstocker/data/koeppengeiger/Beck_KG_V1/Beck_KG_V1_present_0p0083.tif")
# plot(kgclimate_lores)
## complement Schenk & Jackson data with koeppen-geiger climate zone from hi-res file by Beck et al.
df_obs2 <- extract(kgclimate_hires, SpatialPoints(dplyr::select(df_obs, Longitude, Latitude)), sp = TRUE) %>%
as_tibble() %>%
mutate( kgclimate = NA ) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p0083==1, "Af", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p0083==2, "Am", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p0083==3, "Aw", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p0083==4, "BWh", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p0083==5, "BWk", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p0083==6, "BSh", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p0083==7, "BSk", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p0083==8, "Csa", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p0083==9, "Csb", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p0083==10, "Csc", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p0083==11, "Cwa", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p0083==12, "Cwb", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p0083==13, "Cwc", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p0083==14, "Cfa", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p0083==15, "Cfb", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p0083==16, "Cfc", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p0083==17, "Dsa", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p0083==18, "Dsb", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p0083==19, "Dsc", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p0083==20, "Dsd", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p0083==21, "Dwa", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p0083==22, "Dwb", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p0083==23, "Dwc", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p0083==24, "Dwd", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p0083==25, "Dfa", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p0083==26, "Dfb", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p0083==27, "Dfc", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p0083==28, "Dfd", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p0083==29, "ET", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p0083==30, "EF", kgclimate )) %>%
bind_cols(df_obs, .)
df_obs2 <- df_obs2 %>%
mutate( mykgclimate = kgclimate ) %>%
mutate( mykgclimate = ifelse( kgclimate == "Af", "Af", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "Am", "Am", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "Aw", "Aw", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "BWh", "BW", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "BWk", "BW", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "BSh", "BS", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "BSk", "BS", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "Csa", "Cs", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "Csb", "Cs", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "Csc", "Cs", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "Cwa", "Cw", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "Cwb", "Cw", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "Cwc", "Cw", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "Cfa", "Cf", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "Cfb", "Cf", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "Cfc", "Cf", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "Dsa", "Ds", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "Dsb", "Ds", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "Dsc", "Ds", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "Dsd", "Ds", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "Dwa", "Dw", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "Dwb", "Dw", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "Dwc", "Dw", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "Dwd", "Dw", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "Dfa", "Df", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "Dfb", "Df", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "Dfc", "Df", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "Dfd", "Df", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "ET", "ET", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "EF", "EF", mykgclimate ))
## complement model output with climate zone classification
df_20y_bl_v3 <- extract(kgclimate_lores, SpatialPoints(dplyr::select(df_20y_bl_v3, lon, lat)), sp = TRUE) %>%
as_tibble() %>%
mutate( kgclimate = NA ) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p5==1, "Af", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p5==2, "Am", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p5==3, "Aw", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p5==4, "BWh", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p5==5, "BWk", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p5==6, "BSh", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p5==7, "BSk", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p5==8, "Csa", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p5==9, "Csb", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p5==10, "Csc", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p5==11, "Cwa", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p5==12, "Cwb", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p5==13, "Cwc", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p5==14, "Cfa", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p5==15, "Cfb", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p5==16, "Cfc", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p5==17, "Dsa", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p5==18, "Dsb", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p5==19, "Dsc", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p5==20, "Dsd", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p5==21, "Dwa", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p5==22, "Dwb", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p5==23, "Dwc", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p5==24, "Dwd", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p5==25, "Dfa", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p5==26, "Dfb", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p5==27, "Dfc", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p5==28, "Dfd", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p5==29, "ET", kgclimate )) %>%
mutate( kgclimate = ifelse( Beck_KG_V1_present_0p5==30, "EF", kgclimate )) %>%
right_join(df_20y_bl_v3, by = c("lon", "lat")) %>%
mutate( mykgclimate = kgclimate ) %>%
mutate( mykgclimate = ifelse( kgclimate == "Af", "Af", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "Am", "Am", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "Aw", "Aw", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "BWh", "BW", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "BWk", "BW", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "BSh", "BS", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "BSk", "BS", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "Csa", "Cs", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "Csb", "Cs", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "Csc", "Cs", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "Cwa", "Cw", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "Cwb", "Cw", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "Cwc", "Cw", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "Cfa", "Cf", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "Cfb", "Cf", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "Cfc", "Cf", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "Dsa", "Ds", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "Dsb", "Ds", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "Dsc", "Ds", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "Dsd", "Ds", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "Dwa", "Dw", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "Dwb", "Dw", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "Dwc", "Dw", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "Dwd", "Dw", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "Dfa", "Df", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "Dfb", "Df", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "Dfc", "Df", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "Dfd", "Df", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "ET", "ET", mykgclimate )) %>%
mutate( mykgclimate = ifelse( kgclimate == "EF", "EF", mykgclimate ))
table_kgclimate <- matrix(
c(
c(1,'Af','Tropical, rainforest'),
c(2,'Am','Tropical, monsoon'),
c(3,'Aw','Tropical, savannah'),
c(4,'BWh','Arid, desert, hot'),
c(5,'BWk','Arid, desert, cold'),
c(6,'BSh','Arid, steppe, hot'),
c(7,'BSk','Arid, steppe, cold'),
c(8,'Csa','Temperate, dry summer, hot summer'),
c(9,'Csb','Temperate, dry summer, warm summer'),
c(10,'Csc','Temperate, dry summer, cold summer'),
c(11,'Cwa','Temperate, dry winter, hot summer'),
c(12,'Cwb','Temperate, dry winter, warm summer'),
c(13,'Cwc','Temperate, dry winter, cold summer'),
c(14,'Cfa','Temperate, no dry season, hot summer'),
c(15,'Cfb','Temperate, no dry season, warm summer'),
c(16,'Cfc','Temperate, no dry season, cold summer'),
c(17,'Dsa','Cold, dry summer, hot summer'),
c(18,'Dsb','Cold, dry summer, warm summer'),
c(19,'Dsc','Cold, dry summer, cold summer'),
c(20,'Dsd','Cold, dry summer, very cold winter'),
c(21,'Dwa','Cold, dry winter, hot summer'),
c(22,'Dwb','Cold, dry winter, warm summer'),
c(23,'Dwc','Cold, dry winter, cold summer'),
c(24,'Dwd','Cold, dry winter, very cold winter'),
c(25,'Dfa','Cold, no dry season, hot summer'),
c(26,'Dfb','Cold, no dry season, warm summer'),
c(27,'Dfc','Cold, no dry season, cold summer'),
c(28,'Dfd','Cold, no dry season, very cold winter'),
c(29,'ET','Polar, tundra'),
c(30,'EF','Polar, frost')
), nrow = 30, byrow = TRUE
) %>%
as_tibble() %>%
setNames(c("code_in_file", "kg_code", "description"))
table_kgclimate %>% knitr::kable()
```
Plot data by climate zone.
```{r}
df_obs2 %>%
ggplot() +
geom_boxplot(aes(x = mykgclimate, y = -D95_extrapolated * 100)) +
ylim(-300,0)
# df_20y_bl_v3 %>%
# ggplot() +
# geom_boxplot(aes(x = kgclimate, y = -zroot)) +
# ylim(-300,0)
df_obs2 %>%
dplyr::select(zroot = D95_extrapolated, mykgclimate) %>%
mutate(zroot = zroot * 100) %>%
mutate(source = "obs") %>%
bind_rows(
dplyr::select(df_20y_bl_v3, zroot, mykgclimate) %>%
mutate( source = "mod") %>%
mutate( zroot = zroot / 10 )) %>%
ggplot() +
geom_boxplot(aes(x = mykgclimate, y = -zroot, fill = source)) +
ylim(-300,0)
theme(axis.text.x = element_text(angle=90, hjust=1))
#ggsave("fig/boxplot_zroot_kgclimate.pdf", width = 12, height = 8)
```
## Rooting depth by biome
### NCRS biome map
```{r eval=FALSE}
# PROBLEM WITH THIS: NOT GEOREFERENCED, JUST A BITMAP
# data downloaded from https://www.nrcs.usda.gov/wps/portal/nrcs/detail/soils/use/worldsoils/?cid=nrcs142p2_054002
rasta <- raster("/alphadata01/bstocker/data/biomes/NCRS/global_biomes_geotiff/biomes.tif")
plot(rasta)
rasterVis::levelplot(rasta, margin = F, pretty=TRUE) #, at=cutpts, cuts=11, par.settings = mapTheme, main="test variable -- as raster layer")
crs(rasta) <- "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"
writeRaster(rasta, "data/biomes_ncrs.nc", overwrite=TRUE, format="CDF", varname="biome", varunit="category", longname="NCRS biome", xname="lon", yname="lat")
nc <- read_nc_onefile(filn = "data/biomes_ncrs.nc")
plot_map2(nc)
```
### Olson et al. 2001 biome map
```{r}
library(rgdal)
# read in the polygons
shape <- readOGR("/alphadata01/bstocker/data/biomes/olson2001_teow/wwf_terr_ecos.shp")
# create empty raster
rasta <- raster(nrows=360, ncols=720, xmx=180, ymn=-90, ymx=90, crs=CRS("+init=EPSG:4326"))
# convert polygons to 1x1 raster
rasta_biome <- rasterize(shape, rasta, background=NA, field="BIOME")
#plot(rasta_biome)
# remove no data values
rasta_biome[rasta_biome %in% c(98, 99)] <- NA
# convert raster to factor
rasta_biome <- as.factor(rasta_biome)
# save to file
saveRDS(rasta_biome, "./data/teow_raster.rds")
#plot(rasta_biome$layer) # , col.regions=c("red","orange","darkgreen","grey45")
sf_shape <- sf::st_as_sf(shape)
st_crs(sf_shape) <- "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"
# Extract data at points given by df_obs
points_df_obs <- SpatialPoints(dplyr::select(df_obs, x = Longitude, y = Latitude)) %>%
sf::st_as_sf()
st_crs(points_df_obs) <- "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"
points_df_obs_st <- sf::st_intersection(points_df_obs, sf_shape)
df_obs <- points_df_obs_st %>%
as_tibble() %>%
mutate( x = purrr::map_dbl(geometry, 1),
y = purrr::map_dbl(geometry, 2)) %>%
dplyr::select(Longitude = x, Latitude = y, biome = BIOME) %>%
dplyr::mutate( biome = as.factor(biome) ) %>%
right_join( df_obs, by = c("Longitude", "Latitude"))
## Extract data at points given by global model output (gridcells)
df_20y_bl_v3 <- extract(rasta_biome, SpatialPoints(dplyr::select(df_20y_bl_v3, lon, lat)), sp = TRUE) %>%
as_tibble() %>%
right_join(df_20y_bl_v3, by = c("lon", "lat")) %>%
rename(biome = layer) %>%
mutate( biome = as.factor(biome) )
biome_key <- tibble(
biome = as.factor(1:14),
biome_chr = c("Tropical and Subtropical Moist Broadleaf Forests", "Tropical and Subtropicatl Dry Broadleaf Forests", "Tropical and Subtropical Coniferous Forests",
"Temperate Broadleaf and Mixed Forests", "Temperate Coniferous Forests", "Boreal Forest/Taiga", "Tropical and Subtropical Grasslands, Savannas, and Shrublands",
"Temperate Grasslands, Savannas, and Shrublands", "Flooded Grasslands and Savannas", "Montane Grasslands and Shrublands", "Tundra", "Mediterranean Forests, Woodlands, and Scrub",
"Deserts and xeric shrublands", "Mangroves")
)
df_obs <- df_obs %>%
left_join(biome_key, by = "biome")
df_20y_bl_v3 <- df_20y_bl_v3 %>%
left_join(biome_key, by = "biome")
```
Plot data by biomes.
```{r}
df_obs %>%
ggplot() +
geom_boxplot(aes(x = biome_chr, y = -D95_extrapolated * 100)) +
ylim(-300,0) +
theme(axis.text.x = element_text(angle=90, hjust=1))
df_20y_bl_v3 %>%
ggplot() +
geom_boxplot(aes(x = biome, y = -zroot)) +
ylim(-300,0)
df_obs %>%
dplyr::select(zroot = D95_extrapolated, biome_chr) %>%
mutate(zroot = zroot * 100) %>%
mutate(source = "obs") %>%
bind_rows(
dplyr::select(df_20y_bl_v3, zroot, biome_chr) %>%
mutate( source = "mod") %>%
mutate( zroot = zroot / 20 )) %>%
ggplot() +
geom_boxplot(aes(x = biome_chr, y = -zroot, fill = source)) +
ylim(-300,0) +
theme(axis.text.x = element_text(angle=90, hjust=1))
ggsave("fig/boxplot_zroot_biomes.pdf", width = 12, height = 12)
```
## Distribution of values
```{r}
# Look at distribution of global values and values in dataset.
# load("./data/df_20y_sr_v2.Rdata")
# load("./data/df_20y_bl_v2.Rdata")
load("./data/df_20y_sr_v3.Rdata")
load("./data/df_20y_bl_v3.Rdata")
df_tmp <- df_20y_sr_v3 %>%
dplyr::select(lon, lat, zroot_sr = zroot) %>%
left_join(dplyr::select(df_20y_bl_v3, lon, lat, zroot_bl = zroot), by=c("lon", "lat")) %>%
tidyr::gather(method, zroot, c(zroot_bl, zroot_sr))
ggplot() +
geom_histogram(
data = df_tmp,
aes(x = zroot/1000, y = ..count../sum(..count..), fill = method),
color = "black", alpha = 0.3, binwidth = 0.1,
position="identity") +
xlim(0,10) + ylim(0, 0.045) +
geom_density(
data = df_obs,
aes(x = D95_extrapolated, y=..density..*0.03/0.7), color = "dodgerblue1", size = 1, show.legend = FALSE
) +
geom_hline(yintercept = 0, color = "black") +
scale_fill_manual(name = "", values = c("black", "red"), labels = c("Balland", "SaxtonRawls"))
```
This suggests:
- A good general agreement of the magnitude and the distribution, especially at intermediate values (between about 0.5 m and 2.3 m),
- The frequency of very shallow rooting (below about 0.5 m) is overestimated by the model, and the frequency of rather deep rooting (values around 2.5 m and above) tends to be underestimated. This may be related to the scale mismatch. The model uses gridcell-average fAPAR to estimate the water demand per unit area, with must be lower than the water demand per unit area of vegetetated land only. This discrepancy is highest in areas with low fAPAR, including arid regions with large dry season water deficits.
## Site-by-site evaluation
A site-by-site comparison of modelled vs. observed rooting depth (scatterplot), where modelled is extracted from the global simulation, is done below.
```{r echo = FALSE, eval=FALSE}
# Extract values from the global halfdegree map, complementing the observational data frame.
df_obs <- df_obs %>%
rowwise() %>%
mutate(
zroot_40y_bl = extract_point_nc(lon = Longitude, lat = Latitude, filnam = "data/zroot_mct_40y_bl_v3.nc", varnam = "zroot"),
zroot_40y_sr = extract_point_nc(lon = Longitude, lat = Latitude, filnam = "data/zroot_mct_40y_sr_v3.nc", varnam = "zroot"),
zroot_20y_bl = extract_point_nc(lon = Longitude, lat = Latitude, filnam = "data/zroot_mct_20y_bl_v3.nc", varnam = "zroot"),
zroot_20y_sr = extract_point_nc(lon = Longitude, lat = Latitude, filnam = "data/zroot_mct_20y_sr_v3.nc", varnam = "zroot")
)
## Compare observed and modelled in a scatterplot.
## Balland, 40 y
out <- df_obs %>% analyse_modobs2(mod = "zroot_40y_bl", obs = "D95_extrapolated")
out$gg + labs(title = "Balland, 40y, comparing to 95% quantile", x = "Modelled rooting depth (m)", y = "Observed rooting depth (m)")
## Saxton & Rawls, 40 y
out <- df_obs %>% analyse_modobs2(mod = "zroot_40y_sr", obs = "D95_extrapolated")
out$gg + labs(title = "Saxton & Rawls, 40y", x = "Modelled rooting depth (m)", y = "Observed rooting depth (m)")
```
This suggests:
- A poor model performance.
- An likely challenge of scale mismatch.
## Rooting depth map
The values of the points in the RPGE data are overlaid onto the rooting depth map from the model. The question is: Are there broad patterns that we could focus on?
```{r echo = FALSE}
# Compare modelled and observed on the map.
# nc <- read_nc_onefile("data/zroot_mct_40y_bl.nc")
# plot_map( nc, lev = c(0,5,10), color = c( "wheat", "tomato2", "tomato4", "darkorchid4" ), minval = 0, maxval = 10 )
rasta <- brick("data/zroot_mct_40y_bl_v3.nc")
nbin <- 10
df_sp <- as(rasta, "SpatialPixelsDataFrame")
df <- as.data.frame(df_sp)
names(df) <- c("layer", "x", "y")
# maxval <- quantile(df$layer, 0.99) %>% ceiling()
maxval <- 15
gg <- plot_map2(
rasta,
nbin = nbin,
legend_title = expression(paste("z"[root], " (m)")),
maxval = maxval
) +
labs(title = expression(paste("z"[root])))
df_obs <- df_obs %>%
mutate(D95_extrapolated_lim = min(D95_extrapolated, 5.0))
gg +
geom_point(
data = df_obs,
aes(Longitude, Latitude, fill = D95_extrapolated * 10),
color='black', shape=21, size=2, stroke=0.1,
show.legend = FALSE
) +
scale_color_gradientn(
colors = c( "wheat", "tomato2", "tomato4", "orchid4" ),
na.value = 'grey90',
breaks = seq(0, maxval, length.out = (nbin+1)), limits = c(0,maxval), oob=scales::squish )
#ggsave("fig/zroot_mct_40y_bl_v3.pdf", width = 10, height = 7)
```
Let's discuss what we can get from this ...
## Addressing the scale mismatch
We may argue that we cannot expect a global model that does not account for local topography to accurately simulate rooting depth measured at the site scale. Can we instead require the model to capture known patterns in the rooting depth across some class of vegetation type, climate, biome, ... ? The challenge is to identify such patterns where *a priori* expect rooting depth variations.
Let's discuss this further ...
Distribution of values within Ahlstroem land classes.
```{r eval=FALSE}
df_anders <- nc_to_df(
"/alphadata01/bstocker/data/landclass_ahlstroem/semiarid_shrub_savannah.nc",
varnam = "semidry shrub & savannah") %>%
mutate( myvar = ifelse(is.nan(myvar), NA, myvar)) %>%
mutate( myvar = ifelse(!is.na(myvar), TRUE, FALSE)) %>%
rename( semiarid_shrub_savannah = myvar ) %>%
left_join(
nc_to_df(
"/alphadata01/bstocker/data/landclass_ahlstroem/forest_extratropical.nc",
varnam = "extra-tropical forest"),
by = c("lon", "lat")
) %>%
mutate( myvar = ifelse(is.nan(myvar), NA, myvar)) %>%
mutate( myvar = ifelse(!is.na(myvar), TRUE, FALSE)) %>%
rename( forest_extratropical = myvar ) %>%
left_join(
nc_to_df(
"/alphadata01/bstocker/data/landclass_ahlstroem/forest_tropical.nc",
varnam = "tropical forest"),
by = c("lon", "lat")
) %>%
mutate( myvar = ifelse(is.nan(myvar), NA, myvar)) %>%
mutate( myvar = ifelse(!is.na(myvar), TRUE, FALSE)) %>%
rename( forest_tropical = myvar ) %>%
left_join(
nc_to_df(
"/alphadata01/bstocker/data/landclass_ahlstroem/grassland_crops.nc",
varnam = "grasslands & crops"),
by = c("lon", "lat")
) %>%
mutate( myvar = ifelse(is.nan(myvar), NA, myvar)) %>%
mutate( myvar = ifelse(!is.na(myvar), TRUE, FALSE)) %>%
rename( grassland_crops = myvar ) %>%
left_join(
nc_to_df(
"/alphadata01/bstocker/data/landclass_ahlstroem/sparse_veg.nc",
varnam = "sparsely veg"),
by = c("lon", "lat")
) %>%
mutate( myvar = ifelse(is.nan(myvar), NA, myvar)) %>%
mutate( myvar = ifelse(!is.na(myvar), TRUE, FALSE)) %>%
rename( sparse_veg = myvar ) %>%
left_join(
nc_to_df(
"/alphadata01/bstocker/data/landclass_ahlstroem/tundra_cool_shrub.nc",
varnam = "tundra & cool shrub"),
by = c("lon", "lat")
) %>%
mutate( myvar = ifelse(is.nan(myvar), NA, myvar)) %>%
mutate( myvar = ifelse(!is.na(myvar), TRUE, FALSE)) %>%
rename( tundra_cool_shrub = myvar ) %>%
tidyr::gather(
landclass,
value,
c(semiarid_shrub_savannah, forest_extratropical, forest_tropical, grassland_crops, sparse_veg, tundra_cool_shrub)) %>%
dplyr::filter(value) %>%
dplyr::select(-value)
save(df_anders, file = "data/df_anders.Rdata")
df_tmp <- df_tmp %>%
left_join(df_anders, by=c("lon", "lat"))
ggplot() +
geom_histogram(
data = dplyr::filter(df_tmp, landclass == "semiarid_shrub_savannah"),
aes(x = zroot/1000, y = ..count../sum(..count..), fill = method),
color = "black", alpha = 0.3, binwidth = 0.1,
position="identity") +
xlim(0,10) + ylim(0, 0.08) +
ggplot() +
geom_density(
data = df_obs,
aes(x = D95_extrapolated, y=..density..), color = "dodgerblue1", size = 1, show.legend = FALSE
) +
geom_hline(yintercept = 0, color = "black") +
scale_fill_manual(name = "", values = c("black", "red"), labels = c("Balland", "SaxtonRawls"))
```