-
Notifications
You must be signed in to change notification settings - Fork 0
/
Aditya vs Gustavo2.Rmd
148 lines (113 loc) · 4.59 KB
/
Aditya vs Gustavo2.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
---
title: "Comparison"
author: "Gustavo Facincani Dourado"
date: "8/25/2020"
output: html_document
---
```{r}
library(tidyr)
library(tidyverse)
filenames <- list.files('C:/Users/gusta/Box/VICE Lab/RESEARCH/PROJECTS/CERC-WET/Task7_San_Joaquin_Model/Pywr models/bias correction/MERR/Catchment_RO_BC/CanESM2_rcp45/', pattern="*.csv", full.names=TRUE)
Aditya <- lapply(filenames, function (x){
file <- read.csv(x)
suffix = sub(".*_", "", x)
colnames(file)[2] <- paste(colnames(file)[2], suffix, sep='_')
return(file)
})
Aditya
Aditya2 <- Reduce(function(x, y) merge(x, y, by="Date"), Aditya) %>%
mutate(Total_Adi = rowSums(.[, -(1)])*70.0457, #cubic meters/second to acre-feet/day
monthyear = zoo::as.Date(zoo::as.yearmon(Date, "%Y-%m"))) %>%
aggregate(.~monthyear,
data=.,FUN=sum)
Aditya2
```
```{r}
filenames2 <- list.files('C:/Users/gusta/Desktop/PhD/CERCWET/GCMs/MERR/Catchment_RO/', pattern="*.csv", full.names=TRUE)
Gustavo <- lapply(filenames2, function (x){
file <- read.csv(x)
suffix = sub(".*_", "", x)
colnames(file)[2] <- paste(colnames(file)[2], suffix, sep='_')
return(file)
})
Gustavo
Gustavo2 <- Reduce(function(x, y) merge(x, y, by="Date"), Gustavo) %>%
mutate(Total_Gus = rowSums(.[, -1])*810.714, #mcm/day to acre-feet/day
monthyear = zoo::as.Date(zoo::as.yearmon(Date, "%Y-%m")))%>%
aggregate(.~monthyear,
data=.,FUN=sum)
Gustavo2
CanESM2 <- cbind(Gustavo2[c(1, 9)], Aditya2[9])
CanESM2
```
```{r}
library(ggplot2)
ggplot(CanESM2) +
geom_line(aes(x = monthyear, y =Total_Gus), color = "#5CDB5C") +
geom_line(aes(x = monthyear, y = Total_Adi), color = "#FF0000", alpha = 0.5)+
scale_y_log10() +
scale_x_date(limits = as.Date(c('2030-01-01','2050-12-31')),
# labels = date_format("%Y-%m"),
breaks = "5 years") +
labs(y = "Inflow (Acre-feet/month)",
x = element_blank(),
title = "Merced (CanESM2 - RCP 4.5)")
# ylim(0, 10)
```
```{r}
ggplot(livneh_mer) +
geom_line(aes(x = mer_gus.Date, y =mer_gus.total), color = "#5CDB5C") +
geom_line(aes(x = mer_gus.Date, y = mer_gust.total), color = "#FF0000", alpha = 0.5)+
scale_x_date(limits = as.Date(c('2030-01-01','2060-12-31')),
# labels = date_format("%Y-%m"),
breaks = "5 years")
# ylim(0, 10)
```
```{r}
library(ggpmisc)
my.formula <- y ~ x
ggplot(CanESM2, aes(x = Total_Adi, y =Total_Gus)) +
geom_smooth(method = "lm", se=FALSE, color="black", formula = my.formula) +
stat_poly_eq(formula = my.formula,
aes(label = paste(..eq.label.., ..rr.label.., sep = "~~~")),
parse = TRUE) +
geom_point()
```
```{r}
my.formula <- y ~ x
ggplot(livneh_mer, aes(x = mer_adi.total, y =mer_gust.total)) +
geom_smooth(method = "lm", se=FALSE, color="black", formula = my.formula) +
stat_poly_eq(formula = my.formula,
aes(label = paste(..eq.label.., ..rr.label.., sep = "~~~")),
parse = TRUE) +
geom_point()
```
```{r}
SFPUC <- readxl::read_excel("C:/Users/gusta/OneDrive/Documentos/SFPUC.xlsx", sheet = "Sheet4") %>%
mutate(`Row Labels` = as.Date(`Row Labels`, format = "%Y"))
SFPUC[SFPUC == 0] <- NA
SFPUC
```
```{r}
ggplot(SFPUC, aes(x = `Sum of El Livneh`, y =`Sum of Lake Eleanor AVERAGE_INFLOW_F11 [ft³/s]`)) +
geom_smooth(method = "lm", se=FALSE, color="black", formula = my.formula) +
stat_poly_eq(formula = my.formula,
aes(label = paste(..eq.label.., ..rr.label.., sep = "~~~")),
parse = TRUE) +
labs(x = "Eleanor - Livneh", y = "Eleanor - SFPUC", title = "Annual Flow (mcm/year)")+
geom_point()
ggplot(SFPUC, aes(x = `Sum of HH Livneh`, y =`Sum of Hetch Hetchy AVERAGE_INFLOW_F11 [ft³/s]`)) +
geom_smooth(method = "lm", se=FALSE, color="black", formula = my.formula) +
stat_poly_eq(formula = my.formula,
aes(label = paste(..eq.label.., ..rr.label.., sep = "~~~")),
parse = TRUE) +
labs(x = "Hetch Hetchy - Livneh", y = "Hetch Hetchy - SFPUC", title = "Annual Flow (mcm/year)")+
geom_point()
ggplot(SFPUC, aes(x = `Sum of Ch Livneh`, y =`Sum of Cherry Lake AVERAGE_INFLOW_F11 [ft³/s]`)) +
geom_smooth(method = "lm", se=FALSE, color="black", formula = my.formula) +
stat_poly_eq(formula = my.formula,
aes(label = paste(..eq.label.., ..rr.label.., sep = "~~~")),
parse = TRUE) +
labs(x = "Cherry - Livneh", y = "Cherry - SFPUC", title = "Annual Flow (mcm/year)")+
geom_point()
```