-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path03_Validation_TaylorDiagram.r
More file actions
79 lines (70 loc) · 2.81 KB
/
03_Validation_TaylorDiagram.r
File metadata and controls
79 lines (70 loc) · 2.81 KB
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
library(ncdf4)
library(raster)
library(plotrix)
cru_ts <- raster("cru_ts4.03.1901.2018.tmp.dat_climatology.nc")
cru_pr <- raster("cru_ts4.03.1901.2018.pre.dat_climatology.nc")
cmipModels_ts <- lapply(list.files("C:/tmp/cdo_outputs/climatology/",
"_ts_", full.names = TRUE), FUN = function(x) {
f <- mask(raster(x), mask = cru_ts)
})
names(cmipModels_ts) <- paste0("X", 1:length(cmipModels_ts))
cmipModels_pr <- lapply(list.files("C:/tmp/cdo_outputs/climatology/",
"_pr_", full.names = TRUE), FUN = function(x) {
f <- mask(raster(x), mask = cru_pr)
})
names(cmipModels_pr) <- paste0("X", 1:length(cmipModels_pr))
# Greens temp
greens <- paletteer_c("pals::ocean.algae", 25)[-c(1, 21:25)]
# blue prec
blues <- paletteer_c("pals::ocean.ice", 25)[-c(1, 21:25)]
taylor.diagram(ref=rnorm(30,sd=3),
model = rnorm(30,sd=3)+rnorm(30)/2,
ref.sd = TRUE,
main = NULL,
normalize = TRUE, bg = NA, col = NA, pch = 19)
lapply(names(cmipModels_ts), FUN = function(x) {
print(x)
i <- as.integer(gsub("X", "", x))
f <- cmipModels_ts[[x]]
taylor.diagram(values(cru_ts), values(f), normalize = TRUE, add = TRUE,
col = greens[i], pch = 19, pcex = 1.5, bg = "black")
})
lapply(names(cmipModels_pr), FUN = function(x) {
print(x)
i <- as.integer(gsub("X", "", x))
f <- cmipModels_pr[[x]]
taylor.diagram(values(cru_pr), values(f), normalize = TRUE, add = TRUE,
col = blues[i], pch = 19, pcex = 1.5, bg = "black")
})
temp <- calc(stack(cmipModels_ts, quick = TRUE), mean, na.rm = TRUE)
prec <- calc(stack(cmipModels_pr, quick = TRUE), mean, na.rm = TRUE)
taylor.diagram(values(cru_ts), values(temp), normalize = TRUE, add = TRUE,
col = greens[1], pch = 17, pcex = 2, bg = "black")
taylor.diagram(values(cru_pr), values(prec), normalize = TRUE, add = TRUE,
col = blues[1], pch = 17, pcex = 2, bg = "black")
model = cmipModels_ts[1]
f <- raster(model)
f <- mask(f, cru_ts)
model <- values(f)
ref <- values(cru_ts)
taylor.diagram(ref, model, normalize = TRUE)
for (model in cmipModels_ts[-1]) {
t <- 0
print(model)
f <- raster(model)
f <- mask(f, cru_ts)
model <- values(f)
ref <- values(cru_ts)
oldpar <- taylor.diagram(ref, model, )
names(df)[3] <- "Value"
df$Model <- as.factor(model)
df$Var <- as.factor("Temperature")
temp_df <- bind_rows(temp_df, df)
rm(f)
}
f <- raster(ts_files[7], varname = "tmp")
df <- na.omit(as.data.frame(f/10, xy = TRUE))
names(df)[3] <- "Value"
df$Model <- as.factor("CRU")
df$Var <- as.factor("Temperature")
temp_df <- bind_rows(temp_df, df)