Skip to content

Commit

Permalink
add missing @param
Browse files Browse the repository at this point in the history
  • Loading branch information
adamhsparks committed Oct 30, 2024
1 parent eab4c08 commit af567d3
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 18 deletions.
46 changes: 28 additions & 18 deletions R/get_smips.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@
#' Defaults to \dQuote{totalbucket}.
#' @param day A single day's date to query, _e.g._, `day = "2017-12-31"`, both
#' `Character` and `Date` classes are accepted.
#'
#' @param api_key A `character` string containing your \acronym{API} key,
#' a random string provided to you by \acronym{TERN}, for the request.
#' Defaults to automatically detecting your key from your local .Renviron,
#' .Rprofile or similar. Alternatively, you may directly provide your key as
#' a string here or use functionality like that from \CRANpkg{keyring}. If
#' nothing is provided, you will be prompted on how to set up your \R session
#' so that it is auto-detected and a browswer window will open at the
#' \acronym{TERN} website for you to request a key.
#' @examples
#' r <- get_smips(day = "2024-01-01")
#'
Expand All @@ -26,19 +33,20 @@
get_smips <- function(collection = "totalbucket",
day,
api_key = get_key()) {

day <- lubridate::ymd(day)
url_date <- gsub("-", "", day)
url_year <- lubridate::year(day)

.check_collection_agreement(.collection = collection, .day = day)

approved_collections <- c("totalbucket",
"SMindex",
"bucket1",
"bucket2",
"deepD",
"runnoff")
approved_collections <- c(
"totalbucket",
"SMindex",
"bucket1",
"bucket2",
"deepD",
"runnoff"
)
collection <- rlang::arg_match(collection, approved_collections)

collection_url <- data.table::fcase(
Expand All @@ -56,14 +64,16 @@ get_smips <- function(collection = "totalbucket",
paste0("smips_runoff_mm_", url_date, ".tif")
)

r <- terra::rast(paste0("/vsicurl/https://",
paste0('apikey:', api_key),
"@data.tern.org.au/model-derived/smips/v1_0/",
collection,
"/",
url_year,
"/",
collection_url))
r <- terra::rast(paste0(
"/vsicurl/https://",
paste0("apikey:", api_key),
"@data.tern.org.au/model-derived/smips/v1_0/",
collection,
"/",
url_year,
"/",
collection_url
))
return(r)
}

Expand All @@ -73,8 +83,8 @@ get_smips <- function(collection = "totalbucket",
.url_year <- lubridate::year(.day)

if (.collection == "totalbucket" &&
.url_year < 2005 ||
.day > .last_week) {
.url_year < 2005 ||
.day > .last_week) {
cli::cli_abort("The data are not available before 2005 and past {.last_week}")
}
}
9 changes: 9 additions & 0 deletions man/get_smips.Rd

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

0 comments on commit af567d3

Please sign in to comment.