From 33147100af057df4b1732f533e5c91af995c47a3 Mon Sep 17 00:00:00 2001 From: Adriaan Dokter Date: Fri, 22 Dec 2023 11:58:08 -0500 Subject: [PATCH 1/4] fix #553 --- R/download_vpfiles.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/download_vpfiles.R b/R/download_vpfiles.R index 692fa2ed..7479e459 100644 --- a/R/download_vpfiles.R +++ b/R/download_vpfiles.R @@ -72,7 +72,7 @@ download_vpfiles <- function(date_min, date_max, radars, directory = ".", ) # Set base url of data repository - base_url <- "https://lw-enram.s3-eu-west-1.amazonaws.com" + base_url <- "https://aloftdata.s3-eu-west-1.amazonaws.com" # Start download and unzipping message(paste("Downloading data from", base_url)) From 6c4ea3f9c86ebdaa951fe3a6ae2f64120a0166b4 Mon Sep 17 00:00:00 2001 From: Adriaan Dokter Date: Mon, 3 Jun 2024 10:44:53 -0400 Subject: [PATCH 2/4] update bucket to aloft --- R/download_vpfiles.R | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/R/download_vpfiles.R b/R/download_vpfiles.R index 7479e459..83957c0c 100644 --- a/R/download_vpfiles.R +++ b/R/download_vpfiles.R @@ -43,9 +43,6 @@ download_vpfiles <- function(date_min, date_max, radars, directory = ".", # Stop if radar codes are not exactly 5 characters check_radar_codes(radars) - # Split 5 letter radar codes into format be_jab - ra_dars <- paste(substring(radars, 1, 2), substring(radars, 3, 5), sep = "_") - # Stop if dates are not a string assertthat::assert_that(assertthat::is.string(date_min)) assertthat::assert_that(assertthat::is.string(date_max)) @@ -67,7 +64,7 @@ download_vpfiles <- function(date_min, date_max, radars, directory = ".", year_months <- format(dates, "%Y/%m") # Expand to series of radar/yyyy/mm: be_jab/2016/10, be_wid/2016/10, ... - radar_year_months <- apply(expand.grid(ra_dars, year_months), 1, paste, + radar_year_months <- apply(expand.grid(radars, year_months), 1, paste, collapse = "/" ) @@ -84,7 +81,7 @@ download_vpfiles <- function(date_min, date_max, radars, directory = ".", file_path <- file.path(directory, file_name) # Create url of format base_url/be/jab/2016/bejab201610.zip (removing month) url <- paste( - base_url, + base_url,"baltrad/monthly", gsub( "_", "/", substring(radar_year_month, 1, nchar(radar_year_month) - 3) @@ -92,6 +89,7 @@ download_vpfiles <- function(date_min, date_max, radars, directory = ".", file_name, sep = "/" ) + print(url) # Create local unzip directory of format directory/bejab/2016/10 unzip_dir <- gsub("_", "", radar_year_month) From 54a5a1d5cae0ec348e2956638ed9187281522cc1 Mon Sep 17 00:00:00 2001 From: Adriaan Dokter Date: Mon, 3 Jun 2024 12:41:04 -0400 Subject: [PATCH 3/4] fix test --- tests/testthat/test-list_vpts_aloft.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/testthat/test-list_vpts_aloft.R b/tests/testthat/test-list_vpts_aloft.R index d322fdbd..6ae77701 100644 --- a/tests/testthat/test-list_vpts_aloft.R +++ b/tests/testthat/test-list_vpts_aloft.R @@ -108,10 +108,10 @@ test_that("list_vpts_aloft() warns if data was found for subset of radars or if expect_warning( list_vpts_aloft( date_min = "1900-01-01", - date_max = "2023-05-22", + date_max = "2010-01-01", radars = c("plpas") ), - regexp = "No data found for radar(s) between 1900-01-01 - 2023-05-22", + regexp = "No data found for radar(s) between 1900-01-01 - 2010-01-01", fixed = TRUE ) expect_warning( From 2bfb96b90a055857167b6670022467643bb16f7d Mon Sep 17 00:00:00 2001 From: Adriaan Dokter Date: Mon, 3 Jun 2024 14:34:11 -0400 Subject: [PATCH 4/4] remove url printing, rebuild documentation --- R/download_vpfiles.R | 20 +++++++++++--------- man/download_vpfiles.Rd | 4 ++-- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/R/download_vpfiles.R b/R/download_vpfiles.R index 83957c0c..4535591e 100644 --- a/R/download_vpfiles.R +++ b/R/download_vpfiles.R @@ -15,7 +15,7 @@ #' @param overwrite Logical. When `TRUE`, re-download and overwrite previously #' downloaded files of the same names. #' @return `NULL`. The function's primary effect is to download selected vertical profiles -#' files from ENRAM data repository to a specified local directory, and to provide +#' files from ENRAM data repository to a specified local directory, and to provide #' a message and a progress bar in the console indicating the download status. Message will show #' a 404 error for files that are not available. #' @export @@ -28,8 +28,8 @@ #' \donttest{ #' # Download (and overwrite) data from radars "bejab" and "bewid". #' download_vpfiles( -#' date_min = "2016-10-01", -#' date_max = "2016-10-31", +#' date_min = "2018-10-01", +#' date_max = "2018-10-31", #' radars = c("bejab", "bewid"), #' directory = tempdir(), #' overwrite = TRUE @@ -76,10 +76,12 @@ download_vpfiles <- function(date_min, date_max, radars, directory = ".", for (radar_year_month in radar_year_months) { # Create filename of format bejab201610.zip (removing _ and /) - file_name <- paste0(gsub("/", "", gsub("_", "", radar_year_month)), ".zip") - # Create filepath of format directory/bejab201610.zip + file_name <- paste0(gsub("/", "", radar_year_month), ".csv.gz") + # insert new _vpts_ label (FIXME: assumes 5 letter radar code) + file_name <- paste0(substr(file_name,1,5),"_vpts_",substr(file_name,6,nchar(file_name))) + # Create filepath of format directory/bejab_vpts_201610.csv.gz file_path <- file.path(directory, file_name) - # Create url of format base_url/be/jab/2016/bejab201610.zip (removing month) + # Create url of format base_url/be/jab/2016/bejab_vpts_201610.csv.gz (removing month) url <- paste( base_url,"baltrad/monthly", gsub( @@ -89,7 +91,7 @@ download_vpfiles <- function(date_min, date_max, radars, directory = ".", file_name, sep = "/" ) - print(url) + # Create local unzip directory of format directory/bejab/2016/10 unzip_dir <- gsub("_", "", radar_year_month) @@ -104,8 +106,8 @@ download_vpfiles <- function(date_min, date_max, radars, directory = ".", # Check http status if (req$status_code == "200") { - # Unzip file - utils::unzip(file_path, exdir = file.path(directory, unzip_dir)) + # Unzip file no longer necessary + # utils::unzip(file_path, exdir = file.path(directory, unzip_dir)) message(paste0(file_name, ": successfully downloaded")) } else { # Remove file diff --git a/man/download_vpfiles.Rd b/man/download_vpfiles.Rd index 96278d03..08084b33 100644 --- a/man/download_vpfiles.Rd +++ b/man/download_vpfiles.Rd @@ -43,8 +43,8 @@ these are stored as monthly zips per radar. \donttest{ # Download (and overwrite) data from radars "bejab" and "bewid". download_vpfiles( - date_min = "2016-10-01", - date_max = "2016-10-31", + date_min = "2018-10-01", + date_max = "2018-10-31", radars = c("bejab", "bewid"), directory = tempdir(), overwrite = TRUE