-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcmip6-conus.R
96 lines (84 loc) · 2.16 KB
/
cmip6-conus.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
# install.packages("pak")
packages <-
c(
"magrittr",
"terra",
"tidyverse",
"multidplyr",
"sf"
)
pak::pkg_install(packages)
purrr::walk(packages,
library,
character.only = TRUE)
source("nexgddp_cmip6.R")
dir.create(
file.path("conus")
)
usethis::use_git_ignore("conus")
conus <-
sf::read_sf("conus_huc2.fgb")
get_cmip6(conus,
outdir = file.path("conus"),
workers = 10)
test <-
opendap.catalog::dap(URL = file.path("https://nex-gddp-cmip6.s3-us-west-2.amazonaws.com", cmip6_files$aws[[1]]),
AOI = conus)
library(tictoc)
tic()
cmip6_files %$%
paste0("https://ds.nccs.nasa.gov/thredds/dodsC/AMES/NEX/GDDP-CMIP6/",
model,"/",
scenario, "/",
run,"/",
element,"/",
dataset) %>%
magrittr::extract2(1) %>%
opendap.catalog::dap(URL = .,
varname = "hurs",
AOI = conus,
verbose = FALSE) %$%
hurs %>%
terra::writeCDF(filename = "test.nc",
overwrite = TRUE)
toc()
x <-
conus %>%
sf::st_transform(4326) %>%
st_rotate() %>%
sf::st_bbox() %>%
as.list()
tic()
cmip6_files[1,] %$%
httr::modify_url(
paste0("https://ds.nccs.nasa.gov/thredds/ncss/grid/AMES/NEX/GDDP-CMIP6/",
model,"/",
scenario, "/",
run,"/",
element,"/",
dataset),
query = list(
var = element,
north = x$ymax,
west = x$xmin,
east = x$xmax,
south = x$ymin,
disableProjSubset = "on",
horizStride = 1,
time_start = paste0(year, "-01-01"),
time_end = paste0(as.integer(year) + 1, "-01-01"),
timeStride = 1,
addLatLon = TRUE
)) %>%
get_ncss(out.path = "test_ncss.nc")
toc()
tic()
"https://nex-gddp-cmip6.s3-us-west-2.amazonaws.com/NEX-GDDP-CMIP6/ACCESS-CM2/historical/r1i1p1f1/hurs/hurs_day_ACCESS-CM2_historical_r1i1p1f1_gn_1950.nc" %>%
terra::rast() %>%
terra::crop(conus %>%
sf::st_transform(4326) %>%
st_rotate(),
snap = "out") %>%
terra::writeCDF(filename = "test.nc",
overwrite = TRUE)
toc()