-
Notifications
You must be signed in to change notification settings - Fork 0
/
SJVI WYT classification.Rmd
39 lines (24 loc) · 1.41 KB
/
SJVI WYT classification.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
```{r}
library(readr)
library(dplyr)
path <- "C:/Users/gusta/Box/VICE Lab/RESEARCH/PROJECTS/CERC-WET/Task7_San_Joaquin_Model/pywr_models/data/common/hydrology/"
#Historical SJVI
SJVI_Livneh <- read_csv(paste(path,"historical/Livneh/SJVI.csv", sep="")) %>%
mutate(WYT = ifelse(`SJVI (maf)` >= 3.8, "Wet", ifelse(`SJVI (maf)` < 3.8 & `SJVI (maf)` > 3.1, "Above Normal", ifelse(`SJVI (maf)` <= 3.1 & `SJVI (maf)` > 2.5, "Below Normal", ifelse(`SJVI (maf)` <= 2.5 & `SJVI (maf)` > 2.1, "Dry", "Critical")))),
Scenario = "Livneh (Historical)")
SJVI_Livneh
write_csv(SJVI_Livneh, paste("C:/Users/gusta/Desktop/PhD/Classes/ES207/SJVI_Historical_Livneh_March.csv",sep=""))
#GCMs SJVI
GCMs <- c("ACCESS1-0", "CanESM2", "CCSM4", "GFDL-CM3", "HadGEM2-ES", "HadGEM2-CC", "MIROC5", "CNRM-CM5", "CMCC-CMS", "CESM1-BGC")
rcps <- c("rcp45", "rcp85")
for(GCM in GCMs){
for(rcp in rcps){
SJVI_GCMs <- read_csv(paste(path,"gcms/",GCM,"_",rcp,"/SJVI.csv", sep="")) %>%
mutate(WYT = ifelse(`SJVI (maf)` >= 3.8, "Wet", ifelse(`SJVI (maf)` < 3.8 & `SJVI (maf)` > 3.1, "Above Normal", ifelse(`SJVI (maf)` <= 3.1 & `SJVI (maf)` > 2.5, "Below Normal", ifelse(`SJVI (maf)` <= 2.5 & `SJVI (maf)` > 2.1, "Dry", "Critical")))),
Scenario = GCM,
RCP = rcp)
SJVI_GCMs
write_csv(SJVI_GCMs, paste("C:/Users/gusta/Desktop/PhD/Classes/ES207/SJVI_",GCM,"_",rcp,"_March.csv",sep=""))
}
}
```