Skip to content

Commit

Permalink
forecast_model_reruns tested
Browse files Browse the repository at this point in the history
  • Loading branch information
robbinscalebj committed Oct 27, 2023
1 parent bea10e4 commit 22518f5
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions Generate_forecasts/tg_randfor/forecast_model_reruns.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Script ain't meant to automate.
# only for aquatics forecasts
#

#### Step 0: load packages
library(here)
Expand Down Expand Up @@ -79,19 +79,19 @@ model_metadata = list(
# set dates to rerun forecasts
#2022-12-31 is last training date
forecast_dates <- seq(as_date("2023-01-01"), today(), by = "1 day")
forecast_dates_test <- forecast_dates[1:4]


#register parallel and set loop
cl <- makeCluster(4)
registerDoParallel(cl)
foreach(i = 1:length(forecast_dates_test),
foreach(i = 1:length(forecast_dates),
.packages = c("tidyverse", "tidymodels", "here", "bundle")) %dopar% {

here::i_am("Forecast_submissions/Generate_forecasts/tg_randfor/forecast_model_reruns.R") # must declare inside foreach ex
source(here("Forecast_submissions/download_target.R"))

#### Step 2: Get NOAA driver data
forecast_date <- forecast_dates_test[i]
forecast_date <- forecast_dates[i]
noaa_date <- forecast_date - lubridate::days(1) #Need to use yesterday's NOAA forecast because today's is not available yet

#We're going to get data for all sites relevant to this model, so as to not have to re-load data for the same sites
Expand Down Expand Up @@ -228,13 +228,13 @@ for (theme in model_themes) {


#Write csv to disk
#write_csv(forecast, forecast_file) # TESTING uncomment this
write_csv(forecast, paste0("C:/Users/caleb/Desktop/test_forecasts/",
paste0(theme,"-",file_date,"-",model_id,".csv"))) #TESTING - Delete this
write_csv(forecast, forecast_file)
#write_csv(forecast, paste0("C:/Users/caleb/Desktop/test_forecasts/",
# paste0(theme,"-",file_date,"-",model_id,".csv"))) #TESTING - Delete this


# Step 5: Submit forecast!
#neon4cast::submit(forecast_file = forecast_file, metadata = NULL, ask = FALSE) TESTING
neon4cast::submit(forecast_file = forecast_file, metadata = NULL, ask = FALSE)
}
}
}#close foreach

0 comments on commit 22518f5

Please sign in to comment.