forked from dzaugis/forecast_app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOISST_extract.R
126 lines (54 loc) · 3.73 KB
/
OISST_extract.R
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
##### OISST gulf of maine extent
OISSTgrd <- raster::stack("/Users/mdzaugis/Box/RES Data/OISST/ThroughFeb2020.grd")
gom_extent <- raster::extent(c(-71.33, -66.75, 41.75, 45))
gom_oisst <-raster::extract(OISSTgrd, gom_extent, fun= mean, na.rm = TRUE)
dates <- seq.Date(as.Date("1981-09-01"), as.Date("2020-02-29"), "day")
gom_oisst_df <- data.frame(gom_oisst)
times <- data.frame("times" = seq(0,14069, by = 1))
gom_oisst_df <- gom_oisst_df %>% cbind(times) %>% mutate(Date = as.Date(times, origin = "1981-09-01"))
gom_oisst_df <- gom_oisst_df %>% mutate(Date = as.Date(times, origin = "1981-09-01")) %>% dplyr::select(-times)
write_csv(gom_oisst_df, "Data/gom_oisst.csv")
cmip5mean <- raster::stack("/Users/mdzaugis/Box/RES Data/CMIP5_SST/RCP85_mu.grd")
gom_85mean <-raster::extract(cmip5mean, gom_extent, fun= mean, na.rm = TRUE)
Date <- seq.Date(as.Date("1982-01-01"), as.Date("2300-12-10"), "month")
gom_85mean_df <- data.frame("Mean" = gom_85mean)
gom_85mean_df <- gom_85mean_df %>% cbind(Date) %>% filter(Date<"2100-01-01")
cmip55 <- raster::stack("/Users/mdzaugis/Box/RES Data/CMIP5_SST/RCP85_5th.grd")
gom_855 <-raster::extract(cmip55, gom_extent, fun= mean, na.rm = TRUE)
Date <- seq.Date(as.Date("1982-01-01"), as.Date("2300-12-10"), "month")
gom_855_df <- data.frame("low" = gom_855)
gom_855_df <- gom_855_df %>% cbind(Date) %>% filter(Date<"2100-01-01")
cmip595 <- raster::stack("/Users/mdzaugis/Box/RES Data/CMIP5_SST/RCP85_95th.grd")
gom_8595 <-raster::extract(cmip595, gom_extent, fun= mean, na.rm = TRUE)
Date <- seq.Date(as.Date("1982-01-01"), as.Date("2300-12-10"), "month")
gom_8595_df <- data.frame("high" = gom_8595)
gom_8595_df <- gom_8595_df %>% cbind(Date) %>% filter(Date<"2100-01-01")
cmipsst <- gom_85mean_df %>% left_join(gom_855_df, by = "Date") %>% left_join(., gom_8595_df, by = "Date")
write_csv(cmipsst, "Data/CMIPSSTProjections.csv")
############### SNE extent
OISSTgrd <- raster::stack("/Users/mdzaugis/Box/RES Data/OISST/ThroughFeb2020.grd")
sne_extent <- raster::extent(c(-74.5, -70.75, 39.75, 41.66))
sne_oisst <-raster::extract(OISSTgrd, sne_extent, fun= mean, na.rm = TRUE)
dates <- seq.Date(as.Date("1981-09-01"), as.Date("2020-02-29"), "day")
sne_oisst_df <- data.frame(sne_oisst)
times <- data.frame("times" = seq(0,14069, by = 1))
sne_oisst_df <- sne_oisst_df %>% cbind(times) %>% mutate(Date = as.Date(times, origin = "1981-09-01"))
sne_oisst_df <- sne_oisst_df %>% mutate(Date = as.Date(times, origin = "1981-09-01")) %>% dplyr::select(-times)
write_csv(sne_oisst_df, "Data/sne_oisst.csv")
cmip5mean <- raster::stack("/Users/mdzaugis/Box/RES Data/CMIP5_SST/RCP85_mu.grd")
sne_85mean <-raster::extract(cmip5mean, sne_extent, fun= mean, na.rm = TRUE)
Date <- seq.Date(as.Date("1982-01-01"), as.Date("2300-12-10"), "month")
sne_85mean_df <- data.frame("Mean" = sne_85mean)
sne_85mean_df <- sne_85mean_df %>% cbind(Date) %>% filter(Date<"2100-01-01")
cmip55 <- raster::stack("/Users/mdzaugis/Box/RES Data/CMIP5_SST/RCP85_5th.grd")
sne_855 <-raster::extract(cmip55, sne_extent, fun= mean, na.rm = TRUE)
Date <- seq.Date(as.Date("1982-01-01"), as.Date("2300-12-10"), "month")
sne_855_df <- data.frame("low" = sne_855)
sne_855_df <- sne_855_df %>% cbind(Date) %>% filter(Date<"2100-01-01")
cmip595 <- raster::stack("/Users/mdzaugis/Box/RES Data/CMIP5_SST/RCP85_95th.grd")
sne_8595 <-raster::extract(cmip595, sne_extent, fun= mean, na.rm = TRUE)
Date <- seq.Date(as.Date("1982-01-01"), as.Date("2300-12-10"), "month")
sne_8595_df <- data.frame("high" = sne_8595)
sne_8595_df <- sne_8595_df %>% cbind(Date) %>% filter(Date<"2100-01-01")
cmipsst_sne <- sne_85mean_df %>% left_join(sne_855_df, by = "Date") %>% left_join(., sne_8595_df, by = "Date")
write_csv(cmipsst_sne, "Data/CMIPSSTProjections_sne.csv")