Skip to content

Commit

Permalink
Merge pull request #25 from acrenna/main
Browse files Browse the repository at this point in the history
I troubleshooted the submit_forecast function and added the submission to the ecoforecast challenge
  • Loading branch information
amcoast authored Apr 4, 2024
2 parents 0d00950 + 84db879 commit 81aed71
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 10 deletions.
33 changes: 30 additions & 3 deletions 03_ensemble_4cast.R
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,13 @@ ecoforecastR::ciEnvelope(time2,N.IP.ci[1,],N.IP.ci[3,],col=col.alpha(N.cols[2],t
ecoforecastR::ciEnvelope(time2,N.I.ci[1,],N.I.ci[3,],col=col.alpha(N.cols[1],trans))
lines(time2,N.I.ci[2,],lwd=0.5)

result_df <- data.frame(matrix(ncol = 8, nrow = 0))
col_names = c('model_id', 'datetime', 'reference_datetime', 'site_id', 'family', 'parameter', 'variable', 'prediction')
result_df <- data.frame(matrix(ncol = 10, nrow = 0))
col_names = c('project_id','duration','model_id', 'datetime', 'reference_datetime', 'site_id', 'family', 'parameter', 'variable', 'prediction')
colnames(result_df) <- col_names

for(i in 1:(30*NT)){
for(parameter in 1:10){
result_df[nrow(result_df)+1,]=c('kaiya',
result_df[nrow(result_df)+1,]=c('neon4cast','PT30','kaiya',
combine_df$datetime[nrow(combine_df)-30*NT+i],
combine_df$datetime[nrow(combine_df)-30*NT],
'HARV',
Expand All @@ -141,3 +141,30 @@ for(i in 1:(30*NT)){
sample(N.IPDE[,i], 1))
}
}

team_info <- list(team_name = "KAIYA",
team_list = list(
list(individualName = list(givenName = "Katherine",
surName = "Rein"),
organizationName = "Boston University",
electronicMailAddress = "krein21@bu.edu"),
list(individualName = list(givenName = "Yuhe",
surName = "Chang"),
organizationName = "Boston University",
electronicMailAddress = "yhchang@bu.edu"),
list(individualName = list(givenName = "Ibbu",
surName = "Quraishi"),
organizationName = "Boston University",
electronicMailAddress = "quraiibr@bu.edu"),
list(individualName = list(givenName = "Amber",
surName = "Crenna-Armstrong"),
organizationName = "Boston University",
electronicMailAddress = "acrennaa@bu.edu"),
list(individualName = list(givenName = "Alex",
surName = "Coast"),
organizationName = "Boston University",
electronicMailAddress = "amocast@bu.edu"))
)

# submission = false for now
submit_forecast(result_df,team_info,submit=FALSE)
16 changes: 9 additions & 7 deletions submit_forecast.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
library(ecoforecastR)
library(lubridate)
##' Save forecast and metadata to file, submit forecast to EFI
##' @param forecast dataframe
##' @param team_info list, see example
Expand All @@ -7,13 +9,13 @@ submit_forecast <- function(forecast,team_info,submit=FALSE){

#Forecast output file name in standards requires for Challenge.
# csv.gz means that it will be compressed
forecast_file <- paste0("aquatics","-",min(forecast$reference_datetime),"-",team_info$team_name,".csv.gz")
forecast_file <- paste0("aquatics","-",date(min(forecast$reference_datetime)),"-",team_info$team_name,".csv.gz")

## final format tweaks for submission
forecast = forecast |> mutate(model_id = team_info$team_name, family="ensemble") |>
relocate(model_id,reference_datetime) |>
relocate(parameter,.before = variable) |>
relocate(family,.before = parameter)
# forecast = forecast |> mutate(model_id = team_info$team_name, family="ensemble") |>
# relocate(model_id,reference_datetime) |>
# relocate(parameter,.before = variable) |>
# relocate(family,.before = parameter)

#Write csv to disk
write_csv(forecast, forecast_file)
Expand Down Expand Up @@ -57,10 +59,10 @@ submit_forecast <- function(forecast,team_info,submit=FALSE){
)

## this function needs to be restored
metadata_file <- neon4cast::generate_metadata(forecast_file, team_info$team_list, model_metadata)
# metadata_file <- neon4cast::generate_metadata(forecast_file, team_info$team_list, model_metadata)

if(submit){
neon4cast::submit(forecast_file = forecast_file, ask = FALSE) #metadata = metadata_file,
neon4cast::submit(forecast_file = forecast_file, metadata = model_metadata, ask = FALSE) #metadata = metadata_file,
}

}

0 comments on commit 81aed71

Please sign in to comment.