-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Point to the new PortalPredictions, portal-forecasts
Portal-forecasts is a revised version of portalPredictions Portal-forecasts contains forecasts as zipped files
- Loading branch information
1 parent
a35a772
commit 67c04e7
Showing
109 changed files
with
317 additions
and
10,750 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,4 @@ testing_dir/* | |
/Meta/ | ||
inst/app/models.knit.md | ||
*.DS_Store* | ||
.Rproj.user |
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,6 +1,6 @@ | ||
Package: portalcasting | ||
Title: Model and Forecast Portal Rodent Dynamics | ||
Version: 0.60.1 | ||
Version: 0.60.2 | ||
Authors@R: c( | ||
person(c("Juniper", "L."), "Simonis", | ||
email = "[email protected]", role = c("aut", "cre"), | ||
|
@@ -21,7 +21,7 @@ Authors@R: c( | |
comment = c(ORCID = "0000-0001-6728-7745")), | ||
person(c("S. K.", "Morgan"), "Ernest", role = c("aut"), | ||
comment = c(ORCID = "0000-0002-6026-8530"))) | ||
Description: Create a directory, populate it with data, build models, forecast rodent populations, and visualize the results. The user can spin-up a local lightweight sandbox or full-scale production environment from the same code underlying the continuously deployed Portal Predictions Project continuous integration system <https://github.com/weecology/portalpredictions> and website <https://portal.naturecast.org>. | ||
Description: Create a directory, populate it with data, build models, forecast rodent populations, and visualize the results. The user can spin-up a local lightweight sandbox or full-scale production environment from the same code underlying the continuously deployed Portal Predictions Project continuous integration system <https://github.com/weecology/portal-forecasts> and website <https://portal.naturecast.org>. | ||
URL: https://weecology.github.io/portalcasting/, https://github.com/weecology/portalcasting | ||
BugReports: https://github.com/weecology/portalcasting/issues | ||
Depends: | ||
|
@@ -48,7 +48,9 @@ Imports: | |
shiny, | ||
stats, | ||
viridis, | ||
yaml | ||
yaml, | ||
utils, | ||
zipR | ||
Suggests: | ||
pkgdown, | ||
testthat | ||
|
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
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,91 @@ | ||
#' unZip and zip forecasts by forecast date | ||
#' | ||
#' @param type either zip or unzip | ||
#' @param forecast_path location of forecast directory | ||
#' @param date forecaset date to use while zipping | ||
#' | ||
#' @export | ||
#' | ||
zip_unzip <- | ||
function(type = NULL, | ||
forecast_path = "forecasts/", | ||
date = NULL) { | ||
print("Preparing forecasts files") | ||
proj_path <- forecast_path | ||
forecasts_metadata = paste0(proj_path, "/forecasts_metadata.csv") | ||
|
||
proj_path <- normalizePath(proj_path, mustWork = FALSE) | ||
forecasts_metadata <- | ||
normalizePath(forecasts_metadata, mustWork = FALSE) | ||
|
||
metadata <- read.csv(forecasts_metadata) | ||
unique_dates <- unique(metadata$forecast_date) | ||
unique_dates = sort(unique_dates) | ||
|
||
if (type == "zip") { | ||
csv_file <- "_forecast_table.csv" | ||
yaml_file <- "_metadata.yaml" | ||
json_file <- "_model_forecast.json" | ||
if (!is.null(date)) { | ||
unique_dates = c(date) | ||
print(paste0("Zipping forecasts files for ", date)) | ||
} | ||
for (forecast_day in unique_dates) { | ||
id_date_files <- c() | ||
zipfile <- | ||
paste0(proj_path, "/forecast_id_", forecast_day, ".zip") | ||
# Get all the values of that particular day in a data frame | ||
newdata <- | ||
subset(metadata, | ||
forecast_date == forecast_day, | ||
select = c(forecast_id, forecast_date)) | ||
# for each forecast_id get 3 files | ||
All_ids <- newdata$forecast_id | ||
for (id in All_ids) { | ||
csv_file_path = paste0(proj_path, "forecast_id_", id, csv_file) | ||
yaml_file_path = paste0(proj_path, "forecast_id_", id, yaml_file) | ||
json_file_path = paste0(proj_path, "forecast_id_", id, json_file) | ||
id_date_files <- | ||
c(id_date_files, | ||
csv_file_path, | ||
yaml_file_path, | ||
json_file_path) | ||
} | ||
zipfile <- normalizePath(zipfile, mustWork = FALSE) | ||
# First remove old zip file if exists | ||
unlink(zipfile) | ||
# zip all id_date_files | ||
zipr(zipfile, id_date_files, compression_level = 9) | ||
unlink(id_date_files) | ||
} | ||
|
||
# Zip forecasts_evaluations.csv | ||
id_date_files <- | ||
c(paste0(proj_path, "/forecasts_evaluations.csv")) | ||
id_date_files <- normalizePath(id_date_files, mustWork = FALSE) | ||
|
||
zipfile <- paste0(proj_path, "/forecasts_evaluations.zip") | ||
zipfile <- normalizePath(zipfile, mustWork = FALSE) | ||
|
||
zipr(zipfile, id_date_files, compression_level = 9) | ||
} | ||
|
||
if (type == "unzip") { | ||
print("Unzipping forecasts files") | ||
# unzip files basing on unique_dates | ||
for (forecast_day in unique_dates) { | ||
zipfile <- paste0(proj_path, "/forecast_id_", forecast_day, ".zip") | ||
zipfile <- normalizePath(zipfile, mustWork = FALSE) | ||
if (file.exists(zipfile)) { | ||
unzip(zipfile, exdir = proj_path) | ||
unlink(zipfile) | ||
} | ||
} | ||
|
||
# Unzip forecasts_evaluations.csv | ||
eval_zip <- paste0(proj_path, "/forecasts_evaluations.zip") | ||
eval_zip <- normalizePath(eval_zip, mustWork = FALSE) | ||
utils::unzip(eval_zip, exdir = proj_path) | ||
unlink(eval_zip) | ||
} | ||
} |
Oops, something went wrong.