Skip to content

Commit

Permalink
fixed liz_test folder URLs, plus made appropriate chantes to run.R so…
Browse files Browse the repository at this point in the history
… it should run smoothly on Caitlin's user of the VM
  • Loading branch information
Liz.Dawson authored and Liz.Dawson committed Jul 12, 2022
1 parent 29b1b3d commit 50f8fee
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 58 deletions.
10 changes: 5 additions & 5 deletions code/functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand Down
134 changes: 90 additions & 44 deletions code/run.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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"))
Expand Down Expand Up @@ -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])
Expand All @@ -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
Expand All @@ -215,37 +280,18 @@ 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,
to = paste0(glue::glue("{protocol}://STOR@{server}/{dest}/", temp[iiii])),
userpwd = paste0(user,":", pass),
.opts=curlOptions(verbose=TRUE))
}

# # sink()
5 changes: 1 addition & 4 deletions code/run_AI.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"))
Expand Down Expand Up @@ -249,4 +247,3 @@ for (iiii in 1:length(temp)) {
# .opts=curlOptions(verbose=TRUE))
# }
#
# # sink()
7 changes: 2 additions & 5 deletions code/run_BS.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand All @@ -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"

Expand Down Expand Up @@ -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"))
Expand All @@ -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) %>%
Expand Down

0 comments on commit 50f8fee

Please sign in to comment.