@@ -10,8 +10,9 @@ truth_data_date <- "2023-09-01"
1010# needed to create the aux data targets
1111end_date <- Sys.Date()
1212# Generically set the generation date to the next Wednesday (or today if it's Wednesday)
13- forecast_generation_date <- seq.Date(as.Date(" 2024-11-20" ), Sys.Date(), by = 7L )
14- # forecast_generation_date <- as.Date("2025-01-08")
13+ forecast_generation_date <- Sys.Date()
14+ forecast_date <- seq.Date(as.Date(" 2024-11-20" ), Sys.Date(), by = 7L )
15+ # forecast_date <- as.Date("2025-01-08")
1516very_latent_locations <- list (list (
1617 c(" source" ),
1718 c(" flusurv" , " ILI+" )
@@ -109,14 +110,14 @@ rlang::list2(
109110 }
110111 ),
111112 tar_map(
112- values = tidyr :: expand_grid(tibble(forecast_generation_date = forecast_generation_date )),
113- names = " forecast_generation_date " ,
113+ values = tidyr :: expand_grid(tibble(forecast_date = forecast_date )),
114+ names = " forecast_date " ,
114115 tar_target(
115116 name = geo_forecasters_weights ,
116117 command = {
117- geo_forecasters_weights <- parse_prod_weights(here :: here(" flu_geo_exclusions.csv" ), forecast_generation_date )
118- if (nrow(geo_forecasters_weights %> % filter(forecast_date == forecast_generation_date )) == 0 ) {
119- cli_abort(" there are no weights for the forecast date {forecast_generation_date }" )
118+ geo_forecasters_weights <- parse_prod_weights(here :: here(" flu_geo_exclusions.csv" ), forecast_date )
119+ if (nrow(geo_forecasters_weights %> % filter(forecast_date == forecast_date )) == 0 ) {
120+ cli_abort(" there are no weights for the forecast date {forecast_date }" )
120121 }
121122 geo_forecasters_weights
122123 },
@@ -131,7 +132,7 @@ rlang::list2(
131132 tar_target(
132133 forecast_res ,
133134 command = {
134- forecast_date <- as.Date(forecast_generation_date )
135+ forecast_date <- as.Date(forecast_date )
135136 if (forecast_date < Sys.Date()) {
136137 train_data <- nhsn_archive_data %> %
137138 epix_as_of(forecast_date ) %> %
@@ -193,7 +194,7 @@ rlang::list2(
193194 ensemble_mixture_res %> %
194195 format_flusight(disease = " flu" ) %> %
195196 write_submission_file(
196- get_forecast_reference_date(as.Date(forecast_generation_date )),
197+ get_forecast_reference_date(as.Date(forecast_date )),
197198 file.path(submission_directory , " model-output/CMU-TimeSeries" )
198199 )
199200 },
@@ -211,7 +212,7 @@ rlang::list2(
211212 ungroup() %> %
212213 format_flusight(disease = " flu" ) %> %
213214 write_submission_file(
214- get_forecast_reference_date(as.Date(forecast_generation_date )),
215+ get_forecast_reference_date(as.Date(forecast_date )),
215216 submission_directory = file.path(submission_directory , " model-output/CMU-climatological-baseline" ),
216217 file_name = " CMU-climatological-baseline"
217218 )
@@ -227,7 +228,7 @@ rlang::list2(
227228 if (submission_directory != " cache" ) {
228229 validation <- validate_submission(
229230 submission_directory ,
230- file_path = sprintf(" CMU-TimeSeries/%s-CMU-TimeSeries.csv" , get_forecast_reference_date(as.Date(forecast_generation_date )))
231+ file_path = sprintf(" CMU-TimeSeries/%s-CMU-TimeSeries.csv" , get_forecast_reference_date(as.Date(forecast_date )))
231232 )
232233 } else {
233234 validation <- " not validating when there is no hub (set submission_directory)"
@@ -244,7 +245,7 @@ rlang::list2(
244245 if (submission_directory != " cache" && submit_climatological ) {
245246 validation <- validate_submission(
246247 submission_directory ,
247- file_path = sprintf(" CMU-climatological-baseline/%s-CMU-climatological-baseline.csv" , get_forecast_reference_date(as.Date(forecast_generation_date )))
248+ file_path = sprintf(" CMU-climatological-baseline/%s-CMU-climatological-baseline.csv" , get_forecast_reference_date(as.Date(forecast_date )))
248249 )
249250 } else {
250251 validation <- " not validating when there is no hub (set submission_directory)"
@@ -267,24 +268,12 @@ rlang::list2(
267268 select(geo_value , source , target_end_date = time_value , value ) %> %
268269 filter(target_end_date > truth_data_date , geo_value %nin % insufficient_data_geos ) %> %
269270 mutate(target_end_date = target_end_date + 6 )
270- forecast_date <- as.Date(forecast_generation_date )
271+ forecast_date <- as.Date(forecast_date )
271272 if (forecast_date < Sys.Date()) {
272273 truth_data <- nhsn_archive_data %> % epix_as_of(forecast_date )
273274 } else {
274275 truth_data <- nhsn_latest_data
275276 }
276- nhsn_latest_data %> %
277- pull(time_value ) %> %
278- max()
279- nhsn_archive_data %> %
280- epix_as_of(as.Date(" 2024-12-18" )) %> %
281- pull(time_value ) %> %
282- max()
283- forecast_date
284- nhsn_archive_data %> %
285- epix_as_of(forecast_date ) %> %
286- pull(time_value ) %> %
287- max()
288277 truth_data <- truth_data %> %
289278 mutate(target_end_date = time_value ) %> %
290279 filter(time_value > truth_data_date ) %> %
@@ -318,13 +307,13 @@ rlang::list2(
318307 " scripts/reports/forecast_report.Rmd" ,
319308 output_file = here :: here(
320309 " reports" ,
321- sprintf(" %s_flu_prod_on_%s.html" , as.Date(forecast_generation_date ), as.Date(Sys.Date()))
310+ sprintf(" %s_flu_prod_on_%s.html" , as.Date(forecast_date ), as.Date(Sys.Date()))
322311 ),
323312 params = list (
324313 disease = " flu" ,
325314 forecast_res = forecast_res %> % bind_rows(ensemble_mixture_res %> % mutate(forecaster = " ensemble_mix" )),
326315 ensemble_res = ensemble_res ,
327- forecast_generation_date = as.Date(forecast_generation_date ),
316+ forecast_date = as.Date(forecast_date ),
328317 truth_data = truth_data
329318 )
330319 )
0 commit comments