Skip to content

Commit

Permalink
Add version parameter
Browse files Browse the repository at this point in the history
This commit contain several updates. Most important is adding the version parameter to keep working with new release from AgERA5
  • Loading branch information
dbrownf committed Oct 3, 2023
1 parent 756dbf5 commit 8ed7a81
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 9 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: ag5Tools
Title: Toolbox for Downloading and Extracting Copernicus AgERA5 Data
Version: 0.1
Authors@R:c(person(given = "David",
Version: 0.0.3
Authors@R: c(person(given = "David",
family = "Brown",
role = c("aut", "cre"),
email = "[email protected]",
Expand All @@ -28,7 +28,7 @@ Encoding: UTF-8
LazyData: true
Imports: terra, reticulate, fs, doSNOW, foreach
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.2
RoxygenNote: 7.2.3
Suggests:
rmarkdown,
knitr
Expand Down
8 changes: 7 additions & 1 deletion R/download.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#'@param day numeric Days of the month for the requested data.
#' Use \code{day = "all"} to download all days from requested month
#'@param time Character Only required for "2m_relative_humidity".
#'@param version Character Version 1_1 is currently the default and recommended
#'See details for available options.
#'@param path Character Target folder in an local hardrive e.g. "C:/agera5".
#' The folder should exist and the user should have write permission.
Expand Down Expand Up @@ -103,6 +104,7 @@ ag5_download <- function(variable,
month,
day,
time = NULL,
version = "1_1",
path){

if(length(month) == 1 && month == "all"){
Expand Down Expand Up @@ -137,6 +139,7 @@ ag5_download <- function(variable,
month = j,
time = time,
year = years[i],
version = version,
path = paste0(path,
years[i]))
}
Expand All @@ -149,6 +152,7 @@ ag5_download <- function(variable,
month = month,
time = time,
year = year,
version = version,
path = paste0(path,
year))

Expand All @@ -162,6 +166,7 @@ ag5_request <- function(variable,
month,
year,
time = NULL,
version = version,
path){

c <- cdsapi$Client()
Expand All @@ -173,7 +178,8 @@ ag5_request <- function(variable,
"statistic" = statistic,
"month" = month,
"day" = day,
"time" = time))
"time" = time,
"version" = version))


file_name_path <- paste(path,
Expand Down
5 changes: 3 additions & 2 deletions R/extract.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
#'@param time Only for variable Relative-Humidity-2m, see details for valid options
#'@param path \code{character} The path for the folder containing the AgERA5 files
#'@param celsius logical Only for variables "Temperature-Air-2m" and "2m_dewpoint_temperature".
#'@param ncores Number of cores to use with parallel
#'@param parallel logical Use parallel computation to speed-up data processing
#'@param ncores Number of cores to use with parallel. If NULL and parallel is ON, half the available cores will be used.
#'If \code{TRUE} the values are converted from Kelvin to Celsius. Default is \code{FALSE}
#'@param ... Other parameters
#'
Expand Down Expand Up @@ -141,7 +142,7 @@ ag5_extract.numeric <- function(coords,
to = as.Date(dates[2]),
by = "days")

data_out_period <- vector(mode = "numeric",
nc_files_list <- vector(mode = "character",
length = length(time_span))

nc_files_list <- vapply(X = time_span,
Expand Down
15 changes: 13 additions & 2 deletions man/ag5_download.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion man/ag5_extract.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8ed7a81

Please sign in to comment.