-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from noaa-afsc/revisions
Revisions in Response to Peer Review
- Loading branch information
Showing
108 changed files
with
10,398 additions
and
2,635 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FROM rocker/geospatial | ||
|
||
RUN R -e "install.packages('renv', repos = c(CRAN = 'https://cloud.r-project.org'))" | ||
|
||
WORKDIR /project | ||
COPY renv.lock renv.lock | ||
|
||
RUN mkdir -p renv | ||
COPY .Rprofile .Rprofile | ||
COPY renv/activate.R renv/activate.R | ||
COPY renv/settings.json renv/settings.json | ||
|
||
RUN R -e "renv::restore()" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "${localWorkspaceFolderBasename}", | ||
"image": "ghcr.io/rocker-org/devcontainer/geospatial:4", | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
add_ssrd <- function(d) { | ||
years <- 2005:2021 | ||
|
||
raster_merge <- vector(mode = "list", length = length(years)) | ||
|
||
for (i in 1:length(years)) { | ||
left_file <- here::here('data_raw','era5_ssrd',paste0('era5_ssrd_',years[i],'_left.nc')) | ||
right_file <- here::here('data_raw','era5_ssrd',paste0('era5_ssrd_',years[i],'_right.nc')) | ||
r1 <- terra::rast(left_file) | ||
r2 <- terra::rast(right_file) | ||
raster_merge[[i]] <- terra::merge(r1,r2) | ||
} | ||
|
||
ssrd_dataset <- terra::rast(raster_merge) | ||
|
||
pts_vec <- project(terra::vect(d), 'EPSG:4326') | ||
|
||
# list to store for-loop results | ||
pts_ssrd_list <- vector(mode = "list", length = length(years)) | ||
|
||
for (i in 1:length(years)) { | ||
r <- subset(ssrd_dataset, lubridate::year(time(ssrd_dataset)) == years[i]) | ||
v <- subset(pts_vec, lubridate::year(pts_vec$haulout_dt) == years[i]) | ||
tm <- match(v$haulout_dt,time(r)) | ||
pts_ssrd_list[[i]] <- terra::extract(r,v,layer=tm, bind=TRUE) | ||
} | ||
|
||
ssrd_data <- do.call(rbind,pts_ssrd_list) %>% | ||
sf::st_as_sf() %>% | ||
dplyr::rename(era5_ssrd = value) %>% | ||
dplyr::mutate(era5_ssrd_watts = era5_ssrd/3600) %>% | ||
dplyr::select(-layer) | ||
|
||
return(ssrd_data) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
create_deploy_details <- function(deploy_details_file) { | ||
deploy_tbl <- readr::read_csv(deploy_details_file) | ||
|
||
tryCatch({ | ||
con <- dbConnect(RPostgres::Postgres(), | ||
dbname = 'pep', | ||
host = Sys.getenv('PEP_PG_IP'), | ||
user = keyringr::get_kc_account("pgpep_londonj"), | ||
password = keyringr::decrypt_kc_pw("pgpep_londonj")) | ||
}, | ||
error = function(cond) { | ||
print("Unable to connect to Database.") | ||
}) | ||
on.exit(dbDisconnect(con)) | ||
|
||
deploy_db <- tbl(con, in_schema("telem","tbl_tag_deployments")) %>% | ||
dplyr::select(speno, deploy_lat, deploy_long, capture_lat, capture_long) %>% | ||
dplyr::mutate(deploy_lat = if_else(is.na(deploy_lat), capture_lat, deploy_lat), | ||
deploy_long = if_else(is.na(deploy_long), capture_long, deploy_long)) %>% | ||
collect() | ||
|
||
dbDisconnect(con) | ||
|
||
deploy_tbl <- deploy_tbl %>% | ||
# dplyr::select(speno, species, location, region, latitude, longitude) %>% | ||
left_join(deploy_db, by = "speno") %>% | ||
mutate(latitude = coalesce(latitude,deploy_lat), | ||
longitude = coalesce(longitude, deploy_long)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.