Skip to content

Commit

Permalink
updating docs
Browse files Browse the repository at this point in the history
  • Loading branch information
khufkens committed Aug 27, 2024
1 parent 42d1ddd commit 52ec55b
Show file tree
Hide file tree
Showing 17 changed files with 103 additions and 107 deletions.
37 changes: 18 additions & 19 deletions R/wf_archetype.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,25 @@
#'
#' @examples
#' \dontrun{
#' # format an archetype function
#' ERAI <- wf_archetype(
#' request = list(stream = "oper",
#' levtype = "sfc",
#' param = "165.128/166.128/167.128",
#' dataset = "interim",
#' step = "0",
#' grid = "0.75/0.75",
#' time = "00/06/12/18",
#' date = "2014-07-01/to/2014-07-31",
#' type = "an",
#' class = "ei",
#' area = "73.5/-27/33/45",
#' format = "netcdf",
#' target = "tmp.nc"),
#' dynamic_fields = c("date", "time")
#' )
#'
#' # print output of the function with below parameters
#' str(ERA_interim("20100101", 3, 200))
#' ERA <- wf_archetype(
#' request = list(
#' dataset_short_name = "reanalysis-era5-pressure-levels",
#' product_type = "reanalysis",
#' variable = "geopotential",
#' year = "2024",
#' month = "03",
#' day = "01",
#' time = "13:00",
#' pressure_level = "1000",
#' data_format = "grib",
#' target = "download.grib"
#' ),
#' dynamic_fields = c("year", "day", "target")
#' )

#' # print output of the function with below (new) parameters
#' str(ERA(2021, 3, "new_download.grip"))
#'
#' }
wf_archetype <- function(request, dynamic_fields) {
Expand Down
11 changes: 5 additions & 6 deletions R/wf_check_request.R
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
#' check ECMWF / CDS data requests
#'
#' Check the validity of a data request, and login credentials.
#' Check the validity of a data request by comparing the main dataset
#' to the list provided by \code{\link[ecmwfr]{wf_datasets}}
#'
#' @param user user (email address) used to sign up for the ECMWF data service,
#' used to retrieve the token set by \code{\link[ecmwfr]{wf_set_key}}
#' @param request nested list with query parameters following the layout
#' as specified on the ECMWF API page
#' @return a data frame with the determined service and url service endpoint
#' @seealso \code{\link[ecmwfr]{wf_set_key}}
#' \code{\link[ecmwfr]{wf_transfer}},\code{\link[ecmwfr]{wf_request}}
#' \code{\link[ecmwfr]{wf_transfer}},\code{\link[ecmwfr]{wf_request}},
#' \code{\link[ecmwfr]{wf_transfer}}
#' @export
#' @author Koen Hufkens
#' @importFrom memoise memoise

wf_check_request <- memoise::memoise(function(
request,
user
request
){

# Stop if not a list
Expand Down
2 changes: 1 addition & 1 deletion R/wf_dataset_info.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#' @examples
#' \dontrun{
#' # Return information
#' info <- wf_product_info("reanalysis-era5-single-levels")
#' info <- wf_dataset_info("reanalysis-era5-single-levels")
#' names(info)
#' }
#' @seealso \code{\link[ecmwfr]{wf_datasets}}.
Expand Down
2 changes: 1 addition & 1 deletion R/wf_datasets.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#'
#' \dontrun{
#' # get a list of ECMWF Data Store datasets
#' wf_datasets(service = "cems")
#' wf_datasets()
#'}

wf_datasets <- memoise::memoise(function(
Expand Down
4 changes: 4 additions & 0 deletions R/wf_delete.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
#' @examples
#'
#' \dontrun{
#'
#' # demo query using a valid request (not shown)
#' file <- wf_request(request = request)
#'
#' # delete request
#' job_url <- file$get_url()
#' wf_delete(url = job_url)
Expand Down
2 changes: 1 addition & 1 deletion R/wf_get_key.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#' in the keychain
#' @seealso \code{\link[ecmwfr]{wf_set_key}}
#' @export
#' @author Koen Kufkens
#' @author Koen Hufkens
#' @examples
#'
#' \dontrun{
Expand Down
32 changes: 16 additions & 16 deletions R/wf_request.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,31 @@
#'
#' \dontrun{
#' # set key
#' wf_set_key(user = "[email protected]", key = "123")
#' wf_set_key(key = "123")
#'
#' request <- list(stream = "oper",
#' levtype = "sfc",
#' param = "167.128",
#' dataset = "interim",
#' step = "0",
#' grid = "0.75/0.75",
#' time = "00",
#' date = "2014-07-01/to/2014-07-02",
#' type = "an",
#' class = "ei",
#' area = "50/10/51/11",
#' format = "netcdf",
#' target = "tmp.nc")
#' request <- list(
#' dataset_short_name = "reanalysis-era5-pressure-levels",
#' product_type = "reanalysis",
#' variable = "geopotential",
#' year = "2024",
#' month = "03",
#' day = "01",
#' time = "13:00",
#' pressure_level = "1000",
#' data_format = "grib",
#' target = "download.grib"
#' )
#'
#' # demo query
#' wf_request(request = request, user = "[email protected]")
#' wf_request(request = request)
#'
#' # Run as an RStudio Job. When finished, will create a
#' # variable named "test" in your environment with the path to
#' # the downloaded file.
#' wf_request(request = request, user = "[email protected]", job_name = "test")
#' wf_request(request = request, job_name = "test")
#'}


wf_request <- function(
request,
user = "ecmwfr",
Expand Down
3 changes: 0 additions & 3 deletions R/wf_transfer.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
#' @examples
#'
#' \dontrun{
#' # set key
#' wf_set_key(key = "123")
#'
#' # request data and grab url and try a transfer
#' # (request not provided)
#' r <- wf_request(request, transfer = FALSE)
Expand Down
26 changes: 13 additions & 13 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -169,19 +169,19 @@ make_script <- function(call, name) {
return(script)
}

# Downlaods only the header information
retrieve_header <- function(url, headers) {
h <- curl::new_handle()
curl::handle_setheaders(h, .list = headers)
con <- curl::curl(url, handle = h)

open(con, "rf")
head <- curl::handle_data(h)
close(con)

head$headers <- curl::parse_headers_list(head$headers)
return(head)
}
# Downloads only the header information
# retrieve_header <- function(url, headers) {
# h <- curl::new_handle()
# curl::handle_setheaders(h, .list = headers)
# con <- curl::curl(url, handle = h)
#
# open(con, "rf")
# head <- curl::handle_data(h)
# close(con)
#
# head$headers <- curl::parse_headers_list(head$headers)
# return(head)
# }

# Encapsulates errors are warnings logic.
# warn_or_error <- function(..., error = FALSE) {
Expand Down
36 changes: 17 additions & 19 deletions man/wf_archetype.Rd

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

11 changes: 5 additions & 6 deletions man/wf_check_request.Rd

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

2 changes: 1 addition & 1 deletion man/wf_dataset_info.Rd

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

2 changes: 1 addition & 1 deletion man/wf_datasets.Rd

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

4 changes: 4 additions & 0 deletions man/wf_delete.Rd

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

2 changes: 1 addition & 1 deletion man/wf_get_key.Rd

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

31 changes: 15 additions & 16 deletions man/wf_request.Rd

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

3 changes: 0 additions & 3 deletions man/wf_transfer.Rd

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

0 comments on commit 52ec55b

Please sign in to comment.