generated from hubverse-org/hubTemplate
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
47 changed files
with
125 additions
and
21 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
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 |
---|---|---|
@@ -1,12 +1,16 @@ | ||
{ | ||
"schema_version": "https://raw.githubusercontent.com/Infectious-Disease-Modeling-Hubs/schemas/main/v2.0.0/admin-schema.json", | ||
"name": "Simple Forecast Hub", | ||
"maintainer": "Consortium of Infectious Disease Modeling Hubs", | ||
"schema_version": "https://raw.githubusercontent.com/kjsato/schemas/br-v3.0.0/v3.0.0/admin-schema.json", | ||
"name": "US RSV Forecast Hub", | ||
"maintainer": "Johns Hopkins University, Infectious Disease Dynamics Group", | ||
"contact": { | ||
"name": "K. Sato", | ||
"email": "[email protected]" | ||
}, | ||
"repository_url": "https://github.com/Infectious-Disease-Modeling-Hubs/hubTemplate", | ||
"repository": { | ||
"host": "github", | ||
"owner": "kjsato", | ||
"name": "rsv-forecast-hub" | ||
}, | ||
"file_format": ["csv", "parquet"], | ||
"timezone": "US/Eastern" | ||
} |
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
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+19.1 KB
model-output/CEPH-Rtrend_rsv/2023-11-19-CEPH-Rtrend_rsv-RETRO.parquet
Binary file not shown.
Binary file added
BIN
+19.1 KB
model-output/CEPH-Rtrend_rsv/2023-12-03-CEPH-Rtrend_rsv-RETRO.parquet
Binary file not shown.
Binary file added
BIN
+19.1 KB
model-output/CEPH-Rtrend_rsv/2023-12-10-CEPH-Rtrend_rsv-RETRO.parquet
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+18.9 KB
model-output/CEPH-Rtrend_rsv/2023-12-24-CEPH-Rtrend_rsv-RETRO.parquet
Binary file not shown.
Binary file added
BIN
+18.7 KB
model-output/CEPH-Rtrend_rsv/2023-12-31-CEPH-Rtrend_rsv-RETRO.parquet
Binary file not shown.
Binary file added
BIN
+18.7 KB
model-output/CEPH-Rtrend_rsv/2024-01-07-CEPH-Rtrend_rsv-RETRO.parquet
Binary file not shown.
Binary file added
BIN
+18.7 KB
model-output/CEPH-Rtrend_rsv/2024-01-14-CEPH-Rtrend_rsv-RETRO.parquet
Binary file not shown.
Binary file added
BIN
+18.4 KB
model-output/CEPH-Rtrend_rsv/2024-01-21-CEPH-Rtrend_rsv-RETRO.parquet
Binary file not shown.
Binary file added
BIN
+17.3 KB
model-output/CEPH-Rtrend_rsv/2024-01-28-CEPH-Rtrend_rsv-RETRO.parquet
Binary file not shown.
Binary file added
BIN
+17.4 KB
model-output/CEPH-Rtrend_rsv/2024-02-04-CEPH-Rtrend_rsv-RETRO.parquet
Binary file not shown.
Binary file added
BIN
+16.5 KB
model-output/CEPH-Rtrend_rsv/2024-02-11-CEPH-Rtrend_rsv-RETRO.parquet
Binary file not shown.
Binary file added
BIN
+16.7 KB
model-output/CEPH-Rtrend_rsv/2024-02-18-CEPH-Rtrend_rsv-RETRO.parquet
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+4.98 KB
model-output/UGA_flucast-INFLAenza/2024-05-05-UGA_flucast-INFLAenza.parquet
Binary file not shown.
Binary file added
BIN
+4.98 KB
model-output/UGA_flucast-INFLAenza/2024-05-12-UGA_flucast-INFLAenza.parquet
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,74 @@ | ||
## retro_ensemble.R customized for rsv-forecast-hub | ||
|
||
# Get the file_path from the command line arguments | ||
args <- commandArgs(trailingOnly = TRUE) | ||
retro_file_path <- args[1] | ||
|
||
local_path <- paste0(dirname(here::here())) | ||
dir_path <- file.path(local_path, "rsv-forecast-hub/") | ||
data_path <- file.path(local_path, "rsv-forecast-hub/") | ||
print(local_path) | ||
#dir_path <- local_path | ||
#data_path <- local_path | ||
print(dir_path) | ||
|
||
library(hubUtils) | ||
library(hubData) | ||
library(hubEnsembles) | ||
library(dplyr) | ||
library(purrr) | ||
library(jsonlite) | ||
|
||
hub_path <- dir_path | ||
print(hub_path) | ||
hub_con <- connect_hub(hub_path) | ||
|
||
loc_data <- readr::read_csv(file.path(dir_path, "auxiliary-data/location_census/locations.csv")) | ||
|
||
output_path <- file.path(dir_path, "model-output") | ||
|
||
# Extract date from file name | ||
curr_origin_date <- as.Date(gsub("^(\\d{4}-\\d{2}-\\d{2}).*", "\\1", basename(retro_file_path))) | ||
|
||
# Get all RETRO files (maybe needed consideration for the case of a combo without RETRO files) | ||
file_paths <- list.files(output_path, pattern = "-RETRO\\.parquet$|-RETRO\\.csv$", full.names = TRUE, recursive = TRUE) | ||
file_paths <- file_paths[grepl(curr_origin_date, file_paths)] | ||
print(file_paths) | ||
|
||
# read the files, and concatenate all the data frames with adding the team name in "model_id" column | ||
projection_data_all <- file_paths %>% | ||
map_df(~{ | ||
# func selection according to the input file format | ||
read_fun <- ifelse(grepl("\\.parquet$", .x), arrow::read_parquet, readr::read_csv) | ||
|
||
# read data | ||
data <- read_fun(.x, stringsAsFactors = FALSE) | ||
|
||
# check if 'origin_date' column exists | ||
if (!"origin_date" %in% names(data)) { | ||
print(paste("File", .x, "does not contain 'origin_date' column")) | ||
} | ||
|
||
# append the team name in "model_id" | ||
data$model_id <- basename(dirname(.x)) | ||
|
||
# return data | ||
data | ||
}) | ||
head(projection_data_all) | ||
|
||
# Prepare data | ||
projection_data_all <- dplyr::mutate(projection_data_all, | ||
target_date = as.Date(origin_date) + (horizon * 7) - 1) | ||
projection_data_all <- as_model_out_tbl(projection_data_all) | ||
|
||
round <- projection_data_all %>% | ||
dplyr::filter(origin_date == as.Date(curr_origin_date)) %>% | ||
dplyr::collect() | ||
|
||
# Generate ensemble | ||
round_ens <- hubEnsembles::simple_ensemble(round) | ||
|
||
# Save ensemble | ||
dir.create(file.path(dir_path, "model-output", "hub-ensemble"), showWarnings = FALSE, recursive = TRUE) | ||
arrow::write_parquet(round_ens, file.path(dir_path, "model-output", "hub-ensemble", paste0(curr_origin_date, "-hub-ensemble-RETRO.parquet"))) |