From 50f8fee0b5184e21b6b167410d661702e965f6a7 Mon Sep 17 00:00:00 2001 From: "Liz.Dawson" Date: Tue, 12 Jul 2022 15:20:59 -0700 Subject: [PATCH] fixed liz_test folder URLs, plus made appropriate chantes to run.R so it should run smoothly on Caitlin's user of the VM --- code/functions.R | 10 ++-- code/run.R | 134 +++++++++++++++++++++++++++++++---------------- code/run_AI.R | 5 +- code/run_BS.R | 7 +-- 4 files changed, 98 insertions(+), 58 deletions(-) diff --git a/code/functions.R b/code/functions.R index e67e40a..de2e7c5 100644 --- a/code/functions.R +++ b/code/functions.R @@ -328,11 +328,11 @@ make_varplot_wrapper <- function(maxyr, # path = dir_googledrive_upload, # overwrite = FALSE) - dir_googledrive_upload0 <- googledrive::drive_ls(path = googledrive::as_id(dir_googledrive_upload)) %>% - dplyr::filter(name == "anom") %>% - dplyr::select("id") %>% - unlist() %>% - googledrive::as_id() + # dir_googledrive_upload0 <- googledrive::drive_ls(path = googledrive::as_id(dir_googledrive_upload)) %>% + # dplyr::filter(name == "anom") %>% + # dplyr::select("id") %>% + # unlist() %>% + # googledrive::as_id() if (plot_mean) { diff --git a/code/run.R b/code/run.R index 95c1ee2..7832f97 100644 --- a/code/run.R +++ b/code/run.R @@ -15,7 +15,7 @@ var <- "bt" googledrive_dl <- TRUE dir_googledrive_log <- "https://docs.google.com/spreadsheets/d/16CJA6hKOcN1a3QNpSu3d2nTGmrmBeCdmmBCcQlLVqrE/edit#gid=315914502" -dir_googledrive_upload_bs = "https://drive.google.com/drive/folders/1vWza36Dog0SpZLcTN22wD-iCEn6ooGCM" +#dir_googledrive_upload_bs = "https://drive.google.com/drive/folders/1vWza36Dog0SpZLcTN22wD-iCEn6ooGCM" dir_googledrive_upload_ai = "https://drive.google.com/drive/folders/1SeNOAh5-muQ2BDgOHWZWwYIoLl68DHWX" #dir_googledrive_upload_test = "https://drive.google.com/drive/folders/1rsR0aFfFzrspTBFU48Bb26EJvdhIZSpl" @@ -63,11 +63,10 @@ googledrive::drive_auth() ## the tasks scheduler, which has no concept of a project root folder. #dir_wd <-"C:/Users/liz.dawson/Work/R/GAPSurveyTemperatureMap/" #dir_wd <- "G:/EBSother/GAPsurveyTemperatureMap/" -dir_wd <- paste0(getwd(), "/") +#dir_wd <- paste0(getwd(), "/") +#dir_wd <-"C:/Users/liz.dawson/Work/R/GAPSurveyTemperatureMap/" dir_wd <- "C:/Users/caitlin.akselrud/Work/survey-live-temperature-map/" -# sink(file=paste0(dir_wd, "/output/", Sys.Date(), "_log.txt")) # save console output - source(file = paste0(dir_wd,"code/functions.R")) # source(file = paste0(dir_wd, "code/data_dl.R")) # you don't unnecessarily run this each time source(file = paste0(dir_wd, "code/data.R")) @@ -152,9 +151,9 @@ make_varplot_wrapper(maxyr = maxyr, # Daily plot ## send all current files to the FTP ------------------------------------------- # vars here defined in ftp.R -dir_out <- paste0(getwd(),"/output/",maxyr,"_",SRVY,"/") +dir_out <- paste0(dir_wd,"/output/",maxyr,"_",SRVY,"/") temp <- list.files(path = dir_out, pattern = "current_daily", full.names = FALSE) -dest <- dev_bs +dest <- dev_ai for (iiii in 1:length(temp)) { print(temp[iiii]) @@ -167,39 +166,105 @@ for (iiii in 1:length(temp)) { .opts=curlOptions(verbose=TRUE)) } - # NBS + EBS Maps -------------------------------------------------------------- +maxyr <- 2022 +data_source <- "gd" # google drive +dates0 <- "latest" # "all" # latest # "all", #"2021-06-05",# Sys.Date(), # as.character(seq(as.Date("2022-07-30"), as.Date("2022-08-14"), by="days")) +shapef <- FALSE #set to TRUE to run make_grid_wrapper to run shapefiles for EBS and AI +var <- "bt" + +googledrive_dl <- TRUE +dir_googledrive_log <- "https://docs.google.com/spreadsheets/d/16CJA6hKOcN1a3QNpSu3d2nTGmrmBeCdmmBCcQlLVqrE/edit#gid=315914502" +dir_googledrive_upload_bs = "https://drive.google.com/drive/folders/1vWza36Dog0SpZLcTN22wD-iCEn6ooGCM" +#dir_googledrive_upload_ai = "https://drive.google.com/drive/folders/1SeNOAh5-muQ2BDgOHWZWwYIoLl68DHWX" +#dir_googledrive_upload_test = "https://drive.google.com/drive/folders/1rsR0aFfFzrspTBFU48Bb26EJvdhIZSpl" + +# The surveys this script will be covering +dat_survreg <- data.frame(reg_shapefile = "EBS_SHELF", + region_long = "Eastern Bering Sea", + SRVY = "EBS", + region = "BS", + vessel_id = c(94, 162), # CHANGE + vessel_shape = c("V", "A"), # CHANGE + reg_dates = "May 25 - Aug 03 2022") # CHANGE +dat_survreg <- dplyr::bind_rows(dat_survreg, + data.frame(reg_shapefile = "NBS_SHELF", + region_long = "Northern Bering Sea", + SRVY = "NBS", + region = "BS", + vessel_id = c(94, 162), # CHANGE + vessel_shape = c("V", "A"), # CHANGE + reg_dates = "Aug 03 - Aug 28 2022")) # CHANGE +dat_survreg <- dplyr::bind_rows(dat_survreg, + data.frame(reg_shapefile = "AI", + region_long = "Aleutian Islands", + SRVY = "AI", + region = "AI", + vessel_id = c(148, 176), # CHANGE + vessel_shape = c("OEX", "AP"), # CHANGE + reg_dates = "Jun 07 - Aug 17 2022")) # CHANGE +# dat_survreg <- dplyr::bind_rows(dat_survreg, +# data.frame(reg_shapefile = "GOA", +# region_long = "Gulf of Alaska", +# SRVY = "GOA", +# region = "GOA", +# vessel_id = c(148, 176), # CHANGE +# vessel_shape = c("OEX", "SS"), # CHANGE +# reg_dates = "May 25 - Aug 04")) # CHANGE + +# SIGN INTO GOOGLE DRIVE-------------------------------------------------------- +## This sign in needs to be here for the Task Scheduler to run, please do not comment out. +googledrive::drive_deauth() +googledrive::drive_auth() +1 + +# SOURCE SUPPORT SCRIPTS ------------------------------------------------------- +## Actually we cant use the here package, here - it actually causes issues with +## the tasks scheduler, which has no concept of a project root folder. +#dir_wd <-"C:/Users/liz.dawson/Work/R/GAPSurveyTemperatureMap/" +#dir_wd <- "G:/EBSother/GAPsurveyTemperatureMap/" +#dir_wd <- paste0(getwd(), "/") +#dir_wd <-"C:/Users/liz.dawson/Work/R/GAPSurveyTemperatureMap/" +dir_wd <- "C:/Users/caitlin.akselrud/Work/survey-live-temperature-map/" + +source(file = paste0(dir_wd,"code/functions.R")) +# source(file = paste0(dir_wd, "code/data_dl.R")) # you don't unnecessarily run this each time +source(file = paste0(dir_wd, "code/data.R")) +if (googledrive_dl == TRUE) { + source(file = paste0(dir_wd, "code/ftp.R")) # removed in gitignore - ask for premission +} + SRVY <- "BS" region_akgfmaps = "bs.all" plot_subtitle <- "NOAA Fisheries Bering Sea Bottom Trawl Survey" dir_googledrive_upload <- (dir_googledrive_upload_bs) survey_area <- akgfmaps::get_base_layers(select.region = region_akgfmaps, set.crs = "auto") show_planned_stations <- TRUE -plot_anom <- TRUE -survey_area$survey.grid <- survey_area$survey.grid %>% +plot_anom <- FALSE +survey_area$survey.grid <- survey_area$survey.grid %>% sf::st_transform(x = ., survey_area$crs$input) %>% dplyr::rename(station = STATIONID) %>% - sp::merge(x = ., + sp::merge(x = ., y = haul %>% - dplyr::rename(station = stationid) %>% - dplyr::select(station, stratum) %>% - dplyr::distinct(), - all.x = TRUE) %>% + dplyr::rename(station = stationid) %>% + dplyr::select(station, stratum) %>% + dplyr::distinct(), + all.x = TRUE) %>% dplyr::mutate(region = "Bering Sea") survey_area$place.labels$y[survey_area$place.labels$lab == "200 m"] <- -60032.7 if(shapef == TRUE) { -make_grid_wrapper(maxyr = maxyr, # Blank grid plot - SRVY = SRVY, - haul = haul, - dat_survreg = dat_survreg, - dir_googledrive_upload = dir_googledrive_upload, - survey_area = survey_area, - data_source = data_source, - plot_subtitle = plot_subtitle, - dir_wd = dir_wd) + make_grid_wrapper(maxyr = maxyr, # Blank grid plot + SRVY = SRVY, + haul = haul, + dat_survreg = dat_survreg, + dir_googledrive_upload = dir_googledrive_upload, + survey_area = survey_area, + data_source = data_source, + plot_subtitle = plot_subtitle, + dir_wd = dir_wd) } make_varplot_wrapper(maxyr = maxyr, # Daily plot @@ -215,31 +280,14 @@ make_varplot_wrapper(maxyr = maxyr, # Daily plot data_source = data_source, plot_anom = plot_anom, dir_wd = dir_wd) -# make_varplot_wrapper(maxyr = maxyr, # Anom and mean plot -# SRVY = SRVY, -# haul = haul, -# dat_survreg = dat_survreg, -# var = var, -# dir_googledrive_upload = dir_googledrive_upload, -# dates0 = "latest", -# survey_area = survey_area, -# plot_subtitle = plot_subtitle, -# show_planned_stations = show_planned_stations, -# data_source = data_source, -# plot_daily = FALSE, -# plot_anom = FALSE, # anom plot here doesnt make sense to print until the end -# plot_mean = TRUE, -# dir_wd = dir_wd) -## send all current files to the FTP ------------------------------------------- -# vars here defined in ftp.R -dir_out <- paste0(getwd(),"/output/",maxyr,"_",SRVY,"/") +dir_out <- paste0(dir_wd,"/output/",maxyr,"_",SRVY,"/") temp <- list.files(path = dir_out, pattern = "current_daily", full.names = FALSE) dest <- dev_bs for (iiii in 1:length(temp)) { print(temp[iiii]) - + RCurl::ftpUpload( what = paste0(dir_out, "/", temp[iiii]), asText = FALSE, @@ -247,5 +295,3 @@ for (iiii in 1:length(temp)) { userpwd = paste0(user,":", pass), .opts=curlOptions(verbose=TRUE)) } - -# # sink() diff --git a/code/run_AI.R b/code/run_AI.R index 1cb630a..891474c 100644 --- a/code/run_AI.R +++ b/code/run_AI.R @@ -16,7 +16,7 @@ var <- "bt" googledrive_dl <- TRUE dir_googledrive_log <- "https://docs.google.com/spreadsheets/d/16CJA6hKOcN1a3QNpSu3d2nTGmrmBeCdmmBCcQlLVqrE/edit#gid=315914502" #dir_googledrive_upload_bs = "https://drive.google.com/drive/u/2/folders/1wvLejYW73nd0v_lOejmAdoCBbD2kUsbf" #NULL #"https://drive.google.com/drive/folders/1vWza36Dog0SpZLcTN22wD-iCEn6ooGCM" -dir_googledrive_upload_ai = "https://drive.google.com/drive/u/2/folders/17rHN6GTkw5ywMXJ6VfyOkKXr7FY7o7B3" #NULL #"https://drive.google.com/drive/folders/1SeNOAh5-muQ2BDgOHWZWwYIoLl68DHWX" +dir_googledrive_upload_ai = "https://drive.google.com/drive/u/0/folders/17rHN6GTkw5ywMXJ6VfyOkKXr7FY7o7B3" #NULL #"https://drive.google.com/drive/folders/1SeNOAh5-muQ2BDgOHWZWwYIoLl68DHWX" #dir_googledrive_upload_test = "https://drive.google.com/drive/folders/1rsR0aFfFzrspTBFU48Bb26EJvdhIZSpl" # The surveys this script will be covering @@ -67,8 +67,6 @@ googledrive::drive_auth() dir_wd <-"C:/Users/liz.dawson/Work/R/GAPSurveyTemperatureMap/" #dir_wd <- "C:/Users/caitlin.akselrud/Work/survey-live-temperature-map/" -# sink(file=paste0(dir_wd, "/output/", Sys.Date(), "_log.txt")) # save console output - source(file = paste0(dir_wd,"code/functions.R")) # source(file = paste0(dir_wd, "code/data_dl.R")) # you don't unnecessarily run this each time source(file = paste0(dir_wd, "code/data.R")) @@ -249,4 +247,3 @@ for (iiii in 1:length(temp)) { # .opts=curlOptions(verbose=TRUE)) # } # -# # sink() diff --git a/code/run_BS.R b/code/run_BS.R index 5ced8ae..2d49aa2 100644 --- a/code/run_BS.R +++ b/code/run_BS.R @@ -6,7 +6,6 @@ #' --------------------------- # Knowns ----------------------------------------------------------------------- -#sink(file="C:/Users/liz.dawson/Desktop/job1.log",split=TRUE,type="output") maxyr <- 2022 data_source <- "gd" # google drive dates0 <- "latest" # "all" # latest # "all", #"2021-06-05",# Sys.Date(), # as.character(seq(as.Date("2022-07-30"), as.Date("2022-08-14"), by="days")) @@ -15,7 +14,7 @@ var <- "bt" googledrive_dl <- TRUE dir_googledrive_log <- "https://docs.google.com/spreadsheets/d/16CJA6hKOcN1a3QNpSu3d2nTGmrmBeCdmmBCcQlLVqrE/edit#gid=315914502" -dir_googledrive_upload_bs = "https://drive.google.com/drive/u/2/folders/1wvLejYW73nd0v_lOejmAdoCBbD2kUsbf" #NULL #"https://drive.google.com/drive/folders/1vWza36Dog0SpZLcTN22wD-iCEn6ooGCM" +dir_googledrive_upload_bs = "https://drive.google.com/drive/u/0/folders/1wvLejYW73nd0v_lOejmAdoCBbD2kUsbf" #NULL #"https://drive.google.com/drive/folders/1vWza36Dog0SpZLcTN22wD-iCEn6ooGCM" #dir_googledrive_upload_ai = "https://drive.google.com/drive/u/2/folders/17rHN6GTkw5ywMXJ6VfyOkKXr7FY7o7B3" #NULL #"https://drive.google.com/drive/folders/1SeNOAh5-muQ2BDgOHWZWwYIoLl68DHWX" #dir_googledrive_upload_test = "https://drive.google.com/drive/folders/1rsR0aFfFzrspTBFU48Bb26EJvdhIZSpl" @@ -67,8 +66,6 @@ googledrive::drive_auth() dir_wd <-"C:/Users/liz.dawson/Work/R/GAPSurveyTemperatureMap/" #dir_wd <- "C:/Users/caitlin.akselrud/Work/survey-live-temperature-map/" -# sink(file=paste0(dir_wd, "/output/", Sys.Date(), "_log.txt")) # save console output - source(file = paste0(dir_wd,"code/functions.R")) # source(file = paste0(dir_wd, "code/data_dl.R")) # you don't unnecessarily run this each time source(file = paste0(dir_wd, "code/data.R")) @@ -82,7 +79,7 @@ plot_subtitle <- "NOAA Fisheries Bering Sea Bottom Trawl Survey" dir_googledrive_upload <- (dir_googledrive_upload_bs) survey_area <- akgfmaps::get_base_layers(select.region = region_akgfmaps, set.crs = "auto") show_planned_stations <- TRUE -plot_anom <- TRUE +plot_anom <- FALSE survey_area$survey.grid <- survey_area$survey.grid %>% sf::st_transform(x = ., survey_area$crs$input) %>% dplyr::rename(station = STATIONID) %>%