From 4edc6321d789d647d1defeef5c0f413c51c557e7 Mon Sep 17 00:00:00 2001 From: "Adam H. Sparks" Date: Tue, 5 Dec 2023 22:24:51 +0800 Subject: [PATCH] Match args (#78) --- DESCRIPTION | 10 +- NEWS.md | 24 +- R/get_power.R | 246 +++++++++----------- R/internal_functions.R | 17 +- R/query_parameters.R | 2 +- R/sysdata.rda | Bin 2731 -> 2737 bytes README.md | 120 ++++++---- codemeta.json | 43 +++- cran-comments.md | 12 +- data-raw/README.md | 45 ++-- inst/WORDLIST | 6 +- man/get_power.Rd | 36 ++- man/nasapower-package.Rd | 2 +- revdep/README.md | 51 ++-- revdep/cran.md | 2 +- tests/fixtures/adjusted_air_pressure.json | 2 +- tests/fixtures/adjusted_wind_elevation.json | 2 +- tests/fixtures/climatology_ag_point.json | 2 +- tests/fixtures/daily_ag_point.json | 2 +- tests/fixtures/daily_sb_point_LST.json | 2 +- tests/fixtures/daily_sb_point_UTC.json | 2 +- tests/fixtures/temporal_api-warning.json | 1 - tests/testthat.R | 8 + tests/testthat/test-get_power.R | 74 +----- tests/testthat/test-internal_functions.R | 16 +- tests/testthat/test-query_parameters.R | 4 +- 26 files changed, 359 insertions(+), 372 deletions(-) delete mode 100644 tests/fixtures/temporal_api-warning.json diff --git a/DESCRIPTION b/DESCRIPTION index 2c58d184..2d3eb2c7 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: nasapower Type: Package Title: NASA POWER API Client -Version: 4.0.12 +Version: 4.1.0 Authors@R: c(person(given = "Adam H.", family = "Sparks", @@ -62,7 +62,7 @@ URL: https://docs.ropensci.org/nasapower/ BugReports: https://github.com/ropensci/nasapower/issues Description: An API client for NASA POWER global meteorology, surface solar energy and climatology data API. POWER (Prediction Of Worldwide Energy - Resource) data are freely available for download with varying spatial + Resources) data are freely available for download with varying spatial resolutions dependent on the original data and with several temporal resolutions depending on the POWER parameter and community. This work is funded through the NASA Earth Science Directorate Applied Science Program. @@ -72,10 +72,12 @@ Depends: R (>= 3.5.0) License: MIT + file LICENSE Imports: + cli, crul, lubridate, jsonlite, readr, + rlang, tibble (>= 3.0.2) RoxygenNote: 7.2.3 Encoding: UTF-8 @@ -87,7 +89,7 @@ Suggests: purrr, rmarkdown, spelling, - testthat, + testthat (>= 3.0.0), vcr (>= 0.6.0) VignetteBuilder: knitr X-schema.org-applicationCategory: Tools @@ -96,3 +98,5 @@ X-schema.org-keywords: NASA, meteorological-data, weather, global, weather, data-access, climate-data X-schema.org-isPartOf: https://ropensci.org Roxygen: list(markdown = TRUE) +Config/testthat/edition: 3 +Config/testthat/parallel: true diff --git a/NEWS.md b/NEWS.md index cb6f9b82..9e643f65 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,22 @@ -# nasapower (development version) +# nasapower 4.1.0 + +## Bug fixes + +* Fix formula in documentation that didn't display properly in HTML. + +* Fix non-functional link in documentation. + +* Fix code coverage badging. + +## Minor changes + +* Use {cli} and {rlang} for clear messages for end users. + +* Use argument matching for function arguments where practical. + +* The `temporal_api` argument of `get_power()` now defaults to "daily", previously it had no default value. + +* The `temporal_average` argument for `get_power()` has now been removed after being deprecated and issuing a message to users to use `temporal_api` instead since release 4.0.0. # nasapower 4.0.11 @@ -16,9 +34,9 @@ * Reorder README to stress that this is not the data source and should not be cited as such. -* Tidy up minor bits-n-pieces in documentation to make it nicer, *e.g.* grammar corrections, using `\dQuote{}` rather than """ in ROxygen. +* Tidy up minor bits-n-pieces in documentation to make it nicer, *e.g.*, grammar corrections, using `\dQuote{}` rather than """ in ROxygen. -* Uses `sprintf` rather than `paste` where possible. +* Uses `sprintf()` rather than `paste()` where possible. * Update {vcr} configuration and infrastructure to use .json cassettes. diff --git a/R/get_power.R b/R/get_power.R index cd3bf6be..eec70795 100644 --- a/R/get_power.R +++ b/R/get_power.R @@ -1,4 +1,5 @@ + #' Get NASA POWER Data From the POWER API #' #' @description Get \acronym{POWER} global meteorology and surface solar energy @@ -17,12 +18,15 @@ #' for \dQuote{daily}, \dQuote{monthly} and \dQuote{climatology} #' `temporal_api`s. If the `temporal_api` is specified as \dQuote{hourly} #' only 15 `pars` can be specified in a single query. See `temporal_api` for -#' more. +#' more. These values are checked internally for validity before sending the +#' query to the \acronym{POWER} \acronym{API}. #' @param temporal_api Temporal \acronym{API} end-point for data being queried, #' supported values are \dQuote{hourly}, \dQuote{daily}, \dQuote{monthly} or -#' \dQuote{climatology}. See argument details for more. +#' \dQuote{climatology}. Defaults to \dQuote{daily}. See argument details +#' for more. #' @param lonlat A numeric vector of geographic coordinates for a cell or region -#' entered as x, y coordinates. See argument details for more. +#' entered as x, y (longitude, latitude) coordinates. See argument details +#' for more. #' @param dates A character vector of start and end dates in that order,\cr #' _e.g._, `dates = c("1983-01-01", "2017-12-31")`. #' Not used when\cr `temporal_api` is set to \dQuote{climatology}. @@ -41,9 +45,6 @@ #' . #' @param wind_surface A user-supplied wind surface for which the corrected #' wind-speed is to be supplied. See `wind-surface` section for more detail. -#' @param temporal_average Deprecated. This argument has been superseded by -#' `temporal_api` to align with the new \acronym{POWER} \acronym{API} -#' terminology. #' @param time_standard \acronym{POWER} provides two different time standards: #' * Universal Time Coordinated (\acronym{UTC}): is the standard time measure #' that used by the world. @@ -130,15 +131,15 @@ #' \item{airportgrass}{Airport: flat rough grass} #' } #' -#' @section Rate limiting: The POWER API endpoints limit queries to prevent -#' server overloads due to repetitive and rapid requests. If you find that -#' the \acronym{API} is throttling your queries, I suggest that you -#' investigate the use of `limit_rate()` from \CRANpkg{ratelimitr} to create -#' self-limiting functions that will respect the rate limits that the -#' \acronym{API} has in place. It is considered best practice to check the -#' [POWER website](https://power.larc.nasa.gov/docs/services/api/#rate-limiting) -#' for the latest rate limits as they differ between temporal \acronym{API}s -#' and may change over time as the project matures. +#' @section Rate limiting: The \acronym{POWER} \acronym{API} endpoints limit +#' queries to prevent server overloads due to repetitive and rapid requests. +#' If you find that the \acronym{API} is throttling your queries, I suggest +#' that you investigate the use of `limit_rate()` from \CRANpkg{ratelimitr} to +#' create self-limiting functions that will respect the rate limits that the +#' \acronym{API} has in place. It is considered best practice to check the +#' [POWER website](https://power.larc.nasa.gov/docs/services/api/) for the +#' latest rate limits as they differ between temporal \acronym{API}s and may +#' change over time as the project matures. #' #' @note The associated metadata shown in the decorative header are not saved #' if the data are exported to a file format other than a native \R data @@ -191,99 +192,96 @@ #' @author Adam H. Sparks \email{adamhsparks@@gmail.com} #' #' @export -get_power <- function(community, +get_power <- function(community = c("ag", "re", "sb"), pars, - temporal_api = NULL, + temporal_api = c("daily", + "monthly", + "hourly", + "climatology"), lonlat, dates = NULL, site_elevation = NULL, wind_elevation = NULL, wind_surface = NULL, - temporal_average = NULL, - time_standard = "LST") { - if (is.null(temporal_api) & !is.null(temporal_average)) { - warning( - call. = FALSE, - "`temporal_average has been deprecated for `temporal_api`.\n", - "Your query has been modified to use the new terminology for ", - "`get_power`. Please update your scripts to use the new argument." + time_standard = c("LST", "UTC")) { + community <- tolower(community) + temporal_api <- tolower(temporal_api) + time_standard <- toupper(time_standard) + + community <- rlang::arg_match(community) + temporal_api <- rlang::arg_match(temporal_api) + time_standard <- rlang::arg_match(time_standard) + + if (!is.null(wind_surface)) { + wind_surface <- tolower(wind_surface) + wind_surface <- rlang::arg_match( + wind_surface, + c( + "vegtype_1", + "vegtype_2", + "vegtype_3", + "vegtype_4", + "vegtype_5", + "vegtype_6", + "vegtype_7", + "vegtype_8", + "vegtype_9", + "vegtype_10", + "vegtype_11", + "vegtype_12", + "vegtype_20", + "seaice", + "openwater", + "airportice", + "airportgrass" + ) ) - temporal_api <- temporal_average - } - if (is.null(temporal_api)) { - stop(call. = FALSE, - "You must provide a `temporal_api` value.") - } - if (is.character(temporal_api)) { - temporal_api <- tolower(temporal_api) - if (temporal_api == "climatology") { - dates <- NULL - } - } - if (temporal_api %notin% c("hourly", "daily", "monthly", "climatology")) { - stop(call. = FALSE, - "You have entered an invalid value for `temporal_api`.\n") - } - if (is.character(community)) { - community <- tolower(community) } - if (community %notin% c("ag", "sb", "re")) { - stop(call. = FALSE, - "You have provided an invalid `community` value.\n") - } - if (is.character(pars)) { - pars <- toupper(pars) + + if (temporal_api == "climatology") { + dates <- NULL } + if (any(lonlat == "global")) { # remove this if POWER enables global queries for climatology again - stop( - call. = FALSE, - "The POWER team have not enabled `global` data queries with this ", - "version of the 'API'." + cli::cli_abort( + "The POWER team have not enabled `global` data queries with this version of the 'API'." ) } if (!is.null(site_elevation) && !is.numeric(site_elevation)) { - stop(call. = FALSE, + cli::cli_abort( "You have entered an invalid value for `site_elevation`.\n") } if (length(lonlat) > 2 && !is.null(site_elevation)) { - message( - "You have provided `site_elevation` for a region request.\n", - "The `site_elevation` value will be ignored.\n" + cli::cli_inform( + "You have provided `site_elevation`, {.var {site_elevation}} for a region request. The `site_elevation` value will be ignored.\n" ) site_elevation <- NULL } if (length(lonlat) > 2 && !is.null(wind_elevation)) { - message( - "You have provided `wind_elevation` for a region request.\n", - "The `wind_elevation` value will be ignored.\n" + cli::cli_inform( + "You have provided `wind_elevation`, {.var {wind_elevation}}, for a region request. The `wind_elevation` value will be ignored.\n" ) wind_elevation <- NULL } if (is.character(wind_surface) && is.null(wind_elevation)) { - stop( - call. = FALSE, - "If you provide a correct wind surface alias, `wind_surface`, please ", - "include a surface elevation, `wind_elevation`, with the request.\n" + cli::cli_abort( + "If you provide a correct wind surface alias, `wind_surface`, please include a surface elevation, `wind_elevation`, with the request.\n" ) } if (!is.null(wind_elevation)) { if (wind_elevation < 10 || wind_elevation > 300) { - stop( - call. = FALSE, - "`wind_elevation` values in metres are required to be between", - " 10m and 300m.\n" + cli::cli_abort( + "`wind_elevation` values in metres are required to be between 10m and 300m.\n" ) } } if (is.character(lonlat)) { lonlat <- tolower(lonlat) if (lonlat != "global") { - stop( - call. = FALSE, - "You have entered an invalid value for `lonlat`. Valid values are ", - "`global` with `climatology` or a string of lon and lat values.\n" + cli::cli_abort( + "You have entered an invalid value for `lonlat`. Valid values are `global` with `climatology` or a string of lon and lat values.\n" ) } } @@ -293,7 +291,7 @@ get_power <- function(community, community, temporal_api) lonlat_identifier <- .check_lonlat(lonlat, - pars) + pars) dates <- .check_dates(dates, lonlat, temporal_api) @@ -310,10 +308,9 @@ get_power <- function(community, time_standard ) - power_url <- paste0( - "https://power.larc.nasa.gov/api/temporal/", + power_url <- sprintf( + "https://power.larc.nasa.gov/api/temporal/%s/%s", temporal_api, - "/", lonlat_identifier$identifier ) @@ -329,15 +326,15 @@ get_power <- function(community, meta <- power_data[c(grep("-BEGIN HEADER-", power_data):grep("-END HEADER-", - power_data))] + power_data))] # strip BEGIN/END HEADER lines meta <- meta[-c(1, max(length(meta)))] # replace missing values with NA in metadata header for (i in c("-999", "-99", "-99.00")) { meta <- gsub(pattern = i, - replacement = "NA", - x = meta) + replacement = "NA", + x = meta) } # create tibble object @@ -369,8 +366,8 @@ get_power <- function(community, # add new class power_data <- tibble::new_tibble(power_data, - class = "POWER.Info", - nrow = nrow(power_data)) + class = "POWER.Info", + nrow = nrow(power_data)) # add attributes for printing df attr(power_data, "POWER.Info") <- meta[1] @@ -400,15 +397,13 @@ get_power <- function(community, #' @noRd .check_dates <- function(dates, lonlat, temporal_api) { if (is.null(dates) & temporal_api != "climatology") { - stop(call. = FALSE, - "You have not entered dates for the query.\n") + cli::cli_abort( + "You have not entered dates for the query.") } if (temporal_api == "monthly") { if (length(unique(dates)) < 2) { - stop( - call. = FALSE, - "For `temporal_api = monthly`, at least two (2) years ", - "are required to be provided.\n" + cli::cli_abort( + "For `temporal_api = monthly`, at least two (2) years are required to be provided." ) } if (any(nchar(dates) > 4)) { @@ -427,8 +422,8 @@ get_power <- function(community, dates <- c(dates, dates) } if (length(dates) > 2) { - stop(call. = FALSE, - "You have supplied more than two dates for start and end.\n") + cli::cli_abort( + "You have supplied more than two dates for start and end.") } # put dates in list to use lapply @@ -436,7 +431,7 @@ get_power <- function(community, # check dates as entered by user date_format <- function(x) { - tryCatch( + rlang::try_fetch( # try to parse the date format using lubridate x <- lubridate::parse_date_time(x, c( @@ -449,10 +444,9 @@ get_power <- function(community, "bdy" )), warning = function(c) { - stop(call. = FALSE, - "", - x, - " is not a valid entry for date. Enter as YYYY-MM-DD.\n") + cli::cli_abort( + call = rlang::caller_env(n = 3), + "{.var {x}} is not a valid entry for a date value. Enter as 'YYYY-MM-DD' (ISO8601 format) or check that it is a valid date.") } ) as.Date(x) @@ -471,15 +465,15 @@ get_power <- function(community, # check date to be sure it's not before POWER data start if (temporal_api != "hourly" && dates[[1]] < "1981-01-01") { - stop(call. = FALSE, + cli::cli_abort( "1981-01-01 is the earliest available data from POWER.\n") } else if (temporal_api == "hourly" & dates[[1]] < "2001-01-01") - stop(call. = FALSE, + cli::cli_abort( "2001-01-01 is the earliest available hourly data from POWER.\n") # check end date to be sure it's not _after_ if (dates[[2]] > Sys.Date()) { - stop(call. = FALSE, + cli::cli_abort( "The weather data cannot possibly extend beyond this day.\n") } @@ -507,24 +501,18 @@ get_power <- function(community, if (lonlat == "global") { identifier <- "global" } else if (is.character(lonlat)) { - stop(call. = FALSE, + cli::cli_abort( "You have entered an invalid request for `lonlat`.\n") } } else if (is.numeric(lonlat) & length(lonlat) == 2) { if (lonlat[1] < -180 | lonlat[1] > 180) { - stop( - call. = FALSE, - "Please check your longitude, `", - paste0(lonlat[1]), - "`, to be sure it is valid.\n" + cli::cli_abort( + "Please check your longitude, {.var {lonlat[1]}}, to be sure it is valid." ) } if (lonlat[2] < -90 | lonlat[2] > 90) { - stop( - call. = FALSE, - "Please check your latitude, `", - paste0(lonlat[2]), - "`, value to be sure it is valid.\n" + cli::cli_abort( + "Please check your latitude, {.var {lonlat[2]}}, value to be sure it is valid." ) } identifier <- "point" @@ -532,42 +520,29 @@ get_power <- function(community, latitude <- lonlat[2] } else if (length(lonlat) == 4 & is.numeric(lonlat)) { if ((lonlat[[3]] - lonlat[[1]]) * (lonlat[[4]] - lonlat[[2]]) * 4 > 100) { - stop( - call. = FALSE, - "Please provide correct bounding box values. The bounding box\n", - "can only enclose a max of 10 x 10 region of 0.5 degree values\n", - "or a 5 x 5 region of 1 degree values, (i.e., 100 points total).\n" + cli::cli_abort( + "Please provide correct bounding box values. The bounding box can only enclose a max of 10 x 10 region of 0.5 degree values or a 5 x 5 region of 1 degree values, (i.e., 100 points total)." ) } else if (any(lonlat[1] < -180 | lonlat[3] < -180 | lonlat[1] > 180 | lonlat[3] > 180)) { - stop( - call. = FALSE, - "Please check your longitude, `", - lonlat[1], - "`, `", - lonlat[3], - "`, values to be sure they are valid.\n" + cli::cli_abort( + "Please check your longitude values, {.var {lonlat[1]}} and {.var {lonlat[3]}}, to be sure they are valid.\n" ) } else if (any(lonlat[2] < -90 | lonlat[4] < -90 | lonlat[2] > 90 | lonlat[4] > 90)) { - stop( - call. = FALSE, - "Please check your latitude, `", - lonlat[2], - "`, `", - lonlat[4], - "`, values to be sure they are valid.\n" + cli::cli_abort( + "Please check your latitude values, {.var {lonlat[2]}} and {.var {lonlat[4]}}, to be sure they are valid.\n" ) } else if (lonlat[2] > lonlat[4]) { - stop(call. = FALSE, - "The first `lat` value must be the minimum value.\n") + cli::cli_abort( + "The first `lat` value must be the minimum value.") } else if (lonlat[1] > lonlat[3]) { - stop(call. = FALSE, - "The first `lon` value must be the minimum value.\n") + cli::cli_abort( + "The first `lon` value must be the minimum value.") } identifier <- "regional" bbox <- c( @@ -577,7 +552,7 @@ get_power <- function(community, "ymax" = lonlat[4] ) } else { - stop(call. = FALSE, + cli::cli_abort( "You have entered an invalid request for `lonlat`.\n") } @@ -696,15 +671,12 @@ get_power <- function(community, # Extract month as integer power_response <- tibble::add_column(power_response, - MM = as.integer( - substr( - power_response$YYYYMMDD, 6, 7)), + MM = as.integer(substr(power_response$YYYYMMDD, 6, 7)), .after = "YEAR") # Extract day as integer return(tibble::add_column(power_response, - DD = as.integer( - substr( + DD = as.integer(substr( power_response$YYYYMMDD, 9, 10 )), .after = "MM")) diff --git a/R/internal_functions.R b/R/internal_functions.R index 03bf2e9d..631a06af 100644 --- a/R/internal_functions.R +++ b/R/internal_functions.R @@ -28,7 +28,7 @@ .check_pars <- function(pars, community, temporal_api) { # make sure that there are no duplicates in the query - pars <- unique(pars) + pars <- unique(toupper(pars)) p <- unlist(parameters[paste(toupper(temporal_api), toupper(community), @@ -37,8 +37,7 @@ # check pars to make sure that they are valid for both the par and # temporal_api if (any(pars %notin% p)) { - stop( - call. = FALSE, + cli::cli_abort( "", paste(pars[which(pars %notin% p)], collapse = ", "), " is/are not valid in 'pars'.\n", @@ -47,14 +46,12 @@ } if (length(pars) > 15 && temporal_api == "hourly") { - stop( - call. = FALSE, + cli::cli_abort( "A maximum of 15 parameters can currently be requested ", "in one submission for hourly data.\n" ) } else if (length(pars) > 20) { - stop( - call. = FALSE, + cli::cli_abort( "A maximum of 20 parameters can currently be requested ", "in one submission.\n" ) @@ -73,6 +70,8 @@ #' @param .url A character string of the URL to be used for the \acronym{API} #' query #' @keywords internal +#' @return A response from the POWER server containing either an error message +#' or the data requested. #' @noRd #' .send_query <- function(.query_list, @@ -91,8 +90,8 @@ if (response$status_code > 201) { mssg <- jsonlite::fromJSON(response$parse("UTF-8"))$message x <- response$status_http() - stop(sprintf("HTTP (%s) - %s\n %s", x$status_code, x$explanation, mssg), - call. = FALSE) + cli::cli_abort( + sprintf("HTTP (%s) - %s\n %s", x$status_code, x$explanation, mssg)) } # parse response return(response) diff --git a/R/query_parameters.R b/R/query_parameters.R index d84ed01a..b164c02f 100644 --- a/R/query_parameters.R +++ b/R/query_parameters.R @@ -69,7 +69,7 @@ query_parameters <- function(community = NULL, )) } else { if (is.null(community) || is.null(temporal_api)) { - stop(call. = FALSE, + cli::cli_abort( "`commmunity` and `temporal_api` strings must be supplied.") } diff --git a/R/sysdata.rda b/R/sysdata.rda index 1aa3f9fb6c16759f975e964979de7dd3aee74a83..562336553398ace4f8e974ad3536b547c55c305c 100644 GIT binary patch literal 2737 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 Nmc*kcnj5Om{2xMeI7k2h literal 2731 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 Ll?SwXne6*F=5In{ diff --git a/README.md b/README.md index 78cda67c..e77e2b14 100644 --- a/README.md +++ b/README.md @@ -1,40 +1,56 @@ ---- -output: github_document ---- # {nasapower}: NASA POWER API Client logo -[![tic](https://github.com/ropensci/nasapower/workflows/tic/badge.svg?branch=main)](https://github.com/ropensci/nasapower/actions) -[![codecov](https://codecov.io/gh/ropensci/nasapower/branch/main/graph/badge.svg?token=Kq9aea0TQN)](https://app.codecov.io/gh/ropensci/nasapower) -[![DOI](https://zenodo.org/badge/109224461.svg)](https://zenodo.org/badge/latestdoi/109224461) -[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active) -[![peer-review](https://badges.ropensci.org/155_status.svg)](https://github.com/ropensci/software-review/issues/155) +[![tic](https://github.com/ropensci/nasapower/workflows/tic/badge.svg?branch=main)](https://github.com/ropensci/nasapower/actions) +[![codecov](https://codecov.io/gh/ropensci/nasapower/branch/main/graph/badge.svg?token=Kq9aea0TQN)](https://app.codecov.io/gh/ropensci/nasapower) +[![DOI](https://zenodo.org/badge/109224461.svg)](https://zenodo.org/badge/latestdoi/109224461) +[![Project Status: Active – The project has reached a stable, usable +state and is being actively +developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active) +[![peer-review](https://badges.ropensci.org/155_status.svg)](https://github.com/ropensci/software-review/issues/155) [![DOI](http://joss.theoj.org/papers/10.21105/joss.01035/status.svg)](https://doi.org/10.21105/joss.01035) -[![CRAN status](https://www.r-pkg.org/badges/version/nasapower)](https://CRAN.R-project.org/package=nasapower) +[![CRAN +status](https://www.r-pkg.org/badges/version/nasapower)](https://CRAN.R-project.org/package=nasapower) ## POWER data vs {nasapower} Please note that {nasapower} is **NOT** the source of NASA POWER data. It is only an API client that allows easy access to the data. -{nasapower} does not redistribute the data or provide it in any way, *we encourage users to follow the requests of the POWER Project Team and properly acknowledge them for the data rather than citing this package* (unless you have actually used it in your work). - - >*When POWER data products are used in a publication, we request the following acknowledgement be included: - "These data were obtained from the NASA Langley Research Center POWER Project funded through the NASA Earth - Science Directorate Applied Science Program."* - -The previous statement that properly cites the POWER data is different than the citation for {nasapower}. -To cite this R package, {nasapower}, please use the output from `citation(package = "nasapower")` and cite both the package manual, which includes the version you used and the paper which refers to the peer-review of the software package as the functionality of the package has changed and will likely change to match the API in the future as necessary. +{nasapower} does not redistribute the data or provide it in any way, *we +encourage users to follow the requests of the POWER Project Team and +properly acknowledge them for the data rather than citing this package* +(unless you have actually used it in your work). + +> *When POWER data products are used in a publication, we request the +> following acknowledgement be included: “These data were obtained from +> the NASA Langley Research Center POWER Project funded through the NASA +> Earth Science Directorate Applied Science Program.”* + +The previous statement that properly cites the POWER data is different +than the citation for {nasapower}. To cite this R package, {nasapower}, +please use the output from `citation(package = "nasapower")` and cite +both the package manual, which includes the version you used and the +paper which refers to the peer-review of the software package as the +functionality of the package has changed and will likely change to match +the API in the future as necessary. ## About {nasapower} -{nasapower} aims to make it quick and easy to automate *downloading* of the [NASA-POWER](https://power.larc.nasa.gov) global meteorology, surface solar energy and climatology data in your R session as a tidy data frame `tibble` object for analysis and use in modelling or other purposes. -POWER (Prediction Of Worldwide Energy Resource) data are freely available for download with varying spatial resolutions dependent on the original data and with several temporal resolutions depending on the POWER parameter and community. +{nasapower} aims to make it quick and easy to automate *downloading* of +the [NASA-POWER](https://power.larc.nasa.gov) global meteorology, +surface solar energy and climatology data in your R session as a tidy +data frame `tibble` object for analysis and use in modelling or other +purposes. POWER (Prediction Of Worldwide Energy Resource) data are +freely available for download with varying spatial resolutions dependent +on the original data and with several temporal resolutions depending on +the POWER parameter and community. -**Note that the data are not static and may be replaced with improved data.** -Please see for detailed information in this regard. +**Note that the data are not static and may be replaced with improved +data.** Please see for +detailed information in this regard. ### Quick start @@ -44,8 +60,7 @@ Please see for detailed information The stable version is available through CRAN. - -```r +``` r install.packages("nasapower") ``` @@ -53,8 +68,7 @@ install.packages("nasapower") A development version is available through GitHub. - -```r +``` r if (!require("remotes")) { install.packages("remotes") } @@ -64,10 +78,11 @@ remotes::install_github("ropensci/nasapower") ### Example -Fetch daily “ag” community temperature, relative humidity and precipitation for January 1, 1985 for Kingsthorpe, Queensland, Australia. +Fetch daily “ag” community temperature, relative humidity and +precipitation for January 1, 1985 for Kingsthorpe, Queensland, +Australia. - -```r +``` r library("nasapower") daily_ag <- get_power(community = "ag", lonlat = c(151.81, -27.48), @@ -78,36 +93,39 @@ daily_ag <- get_power(community = "ag", daily_ag ``` -``` -## NASA/POWER CERES/MERRA2 Native Resolution Daily Data -## Dates (month/day/year): 01/01/1985 through 01/01/1985 -## Location: Latitude -27.48 Longitude 151.81 -## Elevation from MERRA-2: Average for 0.5 x 0.625 degree lat/lon region = 442.77 meters -## The value for missing source data that cannot be computed or is outside of the sources availability range: NA -## Parameter(s): -## -## Parameters: -## RH2M MERRA-2 Relative Humidity at 2 Meters (%) ; -## T2M MERRA-2 Temperature at 2 Meters (C) ; -## PRECTOTCORR MERRA-2 Precipitation Corrected (mm/day) -## -## # A tibble: 1 × 10 -## LON LAT YEAR MM DD DOY YYYYMMDD RH2M T2M PRECTOTCORR -## -## 1 152. -27.5 1985 1 1 1 1985-01-01 54.7 24.9 0.9 -``` + ## NASA/POWER CERES/MERRA2 Native Resolution Daily Data + ## Dates (month/day/year): 01/01/1985 through 01/01/1985 + ## Location: Latitude -27.48 Longitude 151.81 + ## Elevation from MERRA-2: Average for 0.5 x 0.625 degree lat/lon region = 442.77 meters + ## The value for missing source data that cannot be computed or is outside of the sources availability range: NA + ## Parameter(s): + ## + ## Parameters: + ## RH2M MERRA-2 Relative Humidity at 2 Meters (%) ; + ## T2M MERRA-2 Temperature at 2 Meters (C) ; + ## PRECTOTCORR MERRA-2 Precipitation Corrected (mm/day) + ## + ## # A tibble: 1 × 10 + ## LON LAT YEAR MM DD DOY YYYYMMDD RH2M T2M PRECTOTCORR + ## + ## 1 152. -27.5 1985 1 1 1 1985-01-01 54.7 24.9 0.9 ## Documentation -More documentation is available in the vignette in your R session, `vignette("nasapower")` or available online, . +More documentation is available in the vignette in your R session, +`vignette("nasapower")` or available online, +. ## Meta -- Please [report any issues or bugs](https://github.com/ropensci/nasapower/issues). -Please note that the {nasapower} project is released with a [Contributor Code of Conduct](https://github.com/ropensci/nasapower/blob/main/CODE_OF_CONDUCT.md). -By participating in the {nasapower} project you agree to abide by its terms. +- Please [report any issues or + bugs](https://github.com/ropensci/nasapower/issues). Please note that + the {nasapower} project is released with a [Contributor Code of + Conduct](https://github.com/ropensci/nasapower/blob/main/CODE_OF_CONDUCT.md). + By participating in the {nasapower} project you agree to abide by its + terms. -- License: MIT +- License: MIT ## References diff --git a/codemeta.json b/codemeta.json index 4036fe6b..fc2e8934 100644 --- a/codemeta.json +++ b/codemeta.json @@ -2,18 +2,18 @@ "@context": "https://doi.org/10.5063/schema/codemeta-2.0", "@type": "SoftwareSourceCode", "identifier": "nasapower", - "description": "An API client for NASA POWER global meteorology, surface solar energy and climatology data API. POWER (Prediction Of Worldwide Energy Resource) data are freely available for download with varying spatial resolutions dependent on the original data and with several temporal resolutions depending on the POWER parameter and community. This work is funded through the NASA Earth Science Directorate Applied Science Program. For more on the data themselves, the methodologies used in creating, a web- based data viewer and web access, please see .", + "description": "An API client for NASA POWER global meteorology, surface solar energy and climatology data API. POWER (Prediction Of Worldwide Energy Resources) data are freely available for download with varying spatial resolutions dependent on the original data and with several temporal resolutions depending on the POWER parameter and community. This work is funded through the NASA Earth Science Directorate Applied Science Program. For more on the data themselves, the methodologies used in creating, a web- based data viewer and web access, please see .", "name": "nasapower: NASA POWER API Client", "codeRepository": "https://github.com/ropensci/nasapower", "issueTracker": "https://github.com/ropensci/nasapower/issues", "license": "https://spdx.org/licenses/MIT", - "version": "4.0.11", + "version": "4.1.0", "programmingLanguage": { "@type": "ComputerLanguage", "name": "R", "url": "https://r-project.org" }, - "runtimePlatform": "R version 4.3.1 (2023-06-16)", + "runtimePlatform": "R version 4.3.2 (2023-10-31)", "provider": { "@id": "https://cran.r-project.org", "@type": "Organization", @@ -119,6 +119,7 @@ "@type": "SoftwareApplication", "identifier": "testthat", "name": "testthat", + "version": ">= 3.0.0", "provider": { "@id": "https://cran.r-project.org", "@type": "Organization", @@ -149,6 +150,18 @@ "version": ">= 3.5.0" }, "2": { + "@type": "SoftwareApplication", + "identifier": "cli", + "name": "cli", + "provider": { + "@id": "https://cran.r-project.org", + "@type": "Organization", + "name": "Comprehensive R Archive Network (CRAN)", + "url": "https://cran.r-project.org" + }, + "sameAs": "https://CRAN.R-project.org/package=cli" + }, + "3": { "@type": "SoftwareApplication", "identifier": "crul", "name": "crul", @@ -160,7 +173,7 @@ }, "sameAs": "https://CRAN.R-project.org/package=crul" }, - "3": { + "4": { "@type": "SoftwareApplication", "identifier": "lubridate", "name": "lubridate", @@ -172,7 +185,7 @@ }, "sameAs": "https://CRAN.R-project.org/package=lubridate" }, - "4": { + "5": { "@type": "SoftwareApplication", "identifier": "jsonlite", "name": "jsonlite", @@ -184,7 +197,7 @@ }, "sameAs": "https://CRAN.R-project.org/package=jsonlite" }, - "5": { + "6": { "@type": "SoftwareApplication", "identifier": "readr", "name": "readr", @@ -196,7 +209,19 @@ }, "sameAs": "https://CRAN.R-project.org/package=readr" }, - "6": { + "7": { + "@type": "SoftwareApplication", + "identifier": "rlang", + "name": "rlang", + "provider": { + "@id": "https://cran.r-project.org", + "@type": "Organization", + "name": "Comprehensive R Archive Network (CRAN)", + "url": "https://cran.r-project.org" + }, + "sameAs": "https://CRAN.R-project.org/package=rlang" + }, + "8": { "@type": "SoftwareApplication", "identifier": "tibble", "name": "tibble", @@ -214,7 +239,7 @@ "applicationCategory": "Tools", "isPartOf": "https://ropensci.org", "keywords": ["NASA", "meteorological-data", "weather", "global", "weather-data", "meteorology", "NASA-POWER", "agroclimatology", "earth-science", "data-access", "climate-data", "r", "nasa-power", "nasa", "agroclimatology-data", "weather-variables", "rstats", "r-package"], - "fileSize": "376.958KB", + "fileSize": "374.385KB", "citation": [ { "@type": "SoftwareSourceCode", @@ -228,7 +253,7 @@ "name": "{nasapower}: NASA-POWER Data from R", "identifier": "10.5281/zenodo.1040727", "url": "https://CRAN.R-project.org/package=nasapower", - "description": "R package version 4.0.11", + "description": "R package version 4.1.0", "@id": "https://doi.org/10.5281/zenodo.1040727", "sameAs": "https://doi.org/10.5281/zenodo.1040727" }, diff --git a/cran-comments.md b/cran-comments.md index 3edfc9ae..a51917e3 100755 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,15 +1,19 @@ -# nasapower 4.0.11 +# nasapower 4.1.0 ## R CMD check results +### Checked under + +* Windows - R Under development (unstable) (2023-12-02 r85657 ucrt) +* MacOS - R version 4.3.2 (2023-10-31) -- "Eye Holes" aarch64-apple-darwin20 (64-bit) + 0 errors | 0 warnings | 1 note -* This is a new patch release. +* This is a new minor release. ## revdepcheck results -We checked 2 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package. +We checked 4 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package. We saw 0 new problems We failed to check 0 packages - diff --git a/data-raw/README.md b/data-raw/README.md index 3e23461b..8853ec71 100644 --- a/data-raw/README.md +++ b/data-raw/README.md @@ -1,7 +1,7 @@ Fetch NASA-POWER Parameters and Include Them as an Internal List ================ Adam H. Sparks -2023-07-09 +2023-12-05 # Create parameters nested list for internal checks before sending queries to POWER server @@ -120,51 +120,52 @@ sessioninfo::session_info() ## ─ Session info ─────────────────────────────────────────────────────────────── ## setting value - ## version R version 4.3.1 (2023-06-16) - ## os macOS Ventura 13.4.1 + ## version R version 4.3.2 (2023-10-31) + ## os macOS Sonoma 14.1.2 ## system aarch64, darwin20 ## ui X11 ## language (EN) ## collate en_US.UTF-8 ## ctype en_US.UTF-8 ## tz Australia/Perth - ## date 2023-07-09 - ## pandoc 3.1.4 @ /opt/homebrew/bin/ (via rmarkdown) + ## date 2023-12-05 + ## pandoc 3.1.9 @ /opt/homebrew/bin/ (via rmarkdown) ## ## ─ Packages ─────────────────────────────────────────────────────────────────── ## package * version date (UTC) lib source - ## askpass 1.1 2019-01-13 [1] CRAN (R 4.3.0) + ## askpass 1.2.0 2023-09-03 [1] CRAN (R 4.3.0) ## cli 3.6.1 2023-03-23 [1] CRAN (R 4.3.0) + ## colorout 1.2-2 2023-09-24 [1] local ## crayon 1.5.2 2022-09-29 [1] CRAN (R 4.3.0) - ## credentials 1.3.2 2021-11-29 [1] CRAN (R 4.3.0) + ## credentials 2.0.1 2023-09-06 [1] CRAN (R 4.3.0) ## desc 1.4.2 2022-09-08 [1] CRAN (R 4.3.0) ## digest 0.6.33 2023-07-07 [1] CRAN (R 4.3.0) - ## evaluate 0.21 2023-05-05 [1] CRAN (R 4.3.0) - ## fansi 1.0.4 2023-01-22 [1] CRAN (R 4.3.0) + ## evaluate 0.23 2023-11-01 [1] CRAN (R 4.3.1) + ## fansi 1.0.5 2023-10-08 [1] CRAN (R 4.3.1) ## fastmap 1.1.1 2023-02-24 [1] CRAN (R 4.3.0) - ## fs 1.6.2 2023-04-25 [1] CRAN (R 4.3.0) + ## fs 1.6.3 2023-07-20 [1] CRAN (R 4.3.0) ## glue 1.6.2 2022-02-24 [1] CRAN (R 4.3.0) - ## htmltools 0.5.5 2023-03-23 [1] CRAN (R 4.3.0) + ## htmltools 0.5.7 2023-11-03 [1] CRAN (R 4.3.1) ## jsonlite * 1.8.7 2023-06-29 [1] CRAN (R 4.3.0) - ## knitr 1.43 2023-05-25 [1] CRAN (R 4.3.0) - ## lifecycle 1.0.3 2022-10-07 [1] CRAN (R 4.3.0) + ## knitr 1.45 2023-10-30 [1] CRAN (R 4.3.1) + ## lifecycle 1.0.4 2023-11-07 [1] CRAN (R 4.3.1) ## magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.3.0) - ## openssl 2.0.6 2023-03-09 [1] CRAN (R 4.3.0) + ## openssl 2.1.1 2023-09-25 [1] CRAN (R 4.3.1) ## pillar 1.9.0 2023-03-22 [1] CRAN (R 4.3.0) ## pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.3.0) - ## purrr * 1.0.1 2023-01-10 [1] CRAN (R 4.3.0) + ## purrr * 1.0.2 2023-08-10 [1] CRAN (R 4.3.0) ## R6 2.5.1 2021-08-19 [1] CRAN (R 4.3.0) - ## rlang 1.1.1 2023-04-28 [1] CRAN (R 4.3.0) - ## rmarkdown 2.23 2023-07-01 [1] CRAN (R 4.3.0) - ## rprojroot 2.0.3 2022-04-02 [1] CRAN (R 4.3.0) - ## rstudioapi 0.14 2022-08-22 [1] CRAN (R 4.3.0) + ## rlang 1.1.2 2023-11-04 [1] CRAN (R 4.3.1) + ## rmarkdown 2.25 2023-09-18 [1] CRAN (R 4.3.1) + ## rprojroot 2.0.4 2023-11-05 [1] CRAN (R 4.3.1) + ## rstudioapi 0.15.0 2023-07-07 [1] CRAN (R 4.3.0) ## sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.3.0) ## sys 3.4.2 2023-05-23 [1] CRAN (R 4.3.0) ## tibble 3.2.1 2023-03-20 [1] CRAN (R 4.3.0) ## usethis 2.2.2 2023-07-06 [1] CRAN (R 4.3.0) - ## utf8 1.2.3 2023-01-31 [1] CRAN (R 4.3.0) - ## vctrs 0.6.3 2023-06-14 [1] CRAN (R 4.3.0) - ## xfun 0.39 2023-04-20 [1] CRAN (R 4.3.0) + ## utf8 1.2.4 2023-10-22 [1] CRAN (R 4.3.1) + ## vctrs 0.6.5 2023-12-01 [1] CRAN (R 4.3.1) + ## xfun 0.41 2023-11-01 [1] CRAN (R 4.3.1) ## yaml 2.3.7 2023-01-23 [1] CRAN (R 4.3.0) ## ## [1] /Users/adamsparks/Library/R/arm64/4.3/library diff --git a/inst/WORDLIST b/inst/WORDLIST index 1f7bad7d..56958bd2 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -23,9 +23,10 @@ WS YYYY acknowledgement ag -api apsimx +badging broadleaf +cli climatologies codecov crul @@ -39,12 +40,10 @@ httr icasa interannual json -larc lon metFile metres modelling -nasa needleleaf pre rOpenSci @@ -52,6 +51,7 @@ radn ratelimitr rda rds +rlang ropensci sb terra diff --git a/man/get_power.Rd b/man/get_power.Rd index 879c0ac7..1844f5c1 100644 --- a/man/get_power.Rd +++ b/man/get_power.Rd @@ -5,16 +5,15 @@ \title{Get NASA POWER Data From the POWER API} \usage{ get_power( - community, + community = c("ag", "re", "sb"), pars, - temporal_api = NULL, + temporal_api = c("daily", "monthly", "hourly", "climatology"), lonlat, dates = NULL, site_elevation = NULL, wind_elevation = NULL, wind_surface = NULL, - temporal_average = NULL, - time_standard = "LST" + time_standard = c("LST", "UTC") ) } \arguments{ @@ -27,14 +26,17 @@ coordinates, a maximum of twenty (20) \code{pars} can be specified at one time, for \dQuote{daily}, \dQuote{monthly} and \dQuote{climatology} \code{temporal_api}s. If the \code{temporal_api} is specified as \dQuote{hourly} only 15 \code{pars} can be specified in a single query. See \code{temporal_api} for -more.} +more. These values are checked internally for validity before sending the +query to the \acronym{POWER} \acronym{API}.} \item{temporal_api}{Temporal \acronym{API} end-point for data being queried, supported values are \dQuote{hourly}, \dQuote{daily}, \dQuote{monthly} or -\dQuote{climatology}. See argument details for more.} +\dQuote{climatology}. Defaults to \dQuote{daily}. See argument details +for more.} \item{lonlat}{A numeric vector of geographic coordinates for a cell or region -entered as x, y coordinates. See argument details for more.} +entered as x, y (longitude, latitude) coordinates. See argument details +for more.} \item{dates}{A character vector of start and end dates in that order,\cr \emph{e.g.}, \code{dates = c("1983-01-01", "2017-12-31")}. @@ -58,10 +60,6 @@ request, see \item{wind_surface}{A user-supplied wind surface for which the corrected wind-speed is to be supplied. See \code{wind-surface} section for more detail.} -\item{temporal_average}{Deprecated. This argument has been superseded by -\code{temporal_api} to align with the new \acronym{POWER} \acronym{API} -terminology.} - \item{time_standard}{\acronym{POWER} provides two different time standards: \itemize{ \item Universal Time Coordinated (\acronym{UTC}): is the standard time measure @@ -181,15 +179,15 @@ Valid surface types are described here. } \section{Rate limiting}{ - The POWER API endpoints limit queries to prevent -server overloads due to repetitive and rapid requests. If you find that -the \acronym{API} is throttling your queries, I suggest that you -investigate the use of \code{limit_rate()} from \CRANpkg{ratelimitr} to create -self-limiting functions that will respect the rate limits that the + The \acronym{POWER} \acronym{API} endpoints limit +queries to prevent server overloads due to repetitive and rapid requests. +If you find that the \acronym{API} is throttling your queries, I suggest +that you investigate the use of \code{limit_rate()} from \CRANpkg{ratelimitr} to +create self-limiting functions that will respect the rate limits that the \acronym{API} has in place. It is considered best practice to check the -\href{https://power.larc.nasa.gov/docs/services/api/#rate-limiting}{POWER website} -for the latest rate limits as they differ between temporal \acronym{API}s -and may change over time as the project matures. +\href{https://power.larc.nasa.gov/docs/services/api/}{POWER website} for the +latest rate limits as they differ between temporal \acronym{API}s and may +change over time as the project matures. } \examples{ diff --git a/man/nasapower-package.Rd b/man/nasapower-package.Rd index 04f573a3..a8009246 100644 --- a/man/nasapower-package.Rd +++ b/man/nasapower-package.Rd @@ -8,7 +8,7 @@ \description{ \if{html}{\figure{logo.png}{options: style='float: right' alt='logo' width='120'}} -An API client for NASA POWER global meteorology, surface solar energy and climatology data API. POWER (Prediction Of Worldwide Energy Resource) data are freely available for download with varying spatial resolutions dependent on the original data and with several temporal resolutions depending on the POWER parameter and community. This work is funded through the NASA Earth Science Directorate Applied Science Program. For more on the data themselves, the methodologies used in creating, a web- based data viewer and web access, please see \url{https://power.larc.nasa.gov/}. +An API client for NASA POWER global meteorology, surface solar energy and climatology data API. POWER (Prediction Of Worldwide Energy Resources) data are freely available for download with varying spatial resolutions dependent on the original data and with several temporal resolutions depending on the POWER parameter and community. This work is funded through the NASA Earth Science Directorate Applied Science Program. For more on the data themselves, the methodologies used in creating, a web- based data viewer and web access, please see \url{https://power.larc.nasa.gov/}. } \seealso{ Useful links: diff --git a/revdep/README.md b/revdep/README.md index 58a7a98d..fcb15809 100644 --- a/revdep/README.md +++ b/revdep/README.md @@ -1,59 +1,60 @@ # Platform -|field |value | -|:--------|:-----------------------------------| -|version |R version 4.3.1 (2023-06-16) | -|os |macOS Ventura 13.5.1 | -|system |aarch64, darwin20 | -|ui |X11 | -|language |(EN) | -|collate |en_US.UTF-8 | -|ctype |en_US.UTF-8 | -|tz |Australia/Perth | -|date |2023-08-19 | -|pandoc |3.1.6.1 @ /opt/homebrew/bin//pandoc | +|field |value | +|:--------|:------------------------------------------| +|version |R version 4.3.2 (2023-10-31) | +|os |macOS Sonoma 14.1.2 | +|system |aarch64, darwin20 | +|ui |RStudio | +|language |(EN) | +|collate |en_US.UTF-8 | +|ctype |en_US.UTF-8 | +|tz |Australia/Perth | +|date |2023-12-05 | +|rstudio |2023.09.1+494 Desert Sunflower (desktop) | +|pandoc |3.1.9 @ /opt/homebrew/bin/ (via rmarkdown) | # Dependencies |package |old |new |Δ | |:-----------|:------|:------|:--| -|nasapower |4.0.10 |4.0.11 |* | +|nasapower |4.0.12 |4.1.0 |* | |bit |4.0.5 |4.0.5 | | |bit64 |4.0.5 |4.0.5 | | |cli |3.6.1 |3.6.1 | | |clipr |0.8.0 |0.8.0 | | -|cpp11 |0.4.6 |0.4.6 | | +|cpp11 |0.4.7 |0.4.7 | | |crayon |1.5.2 |1.5.2 | | |crul |1.4.0 |1.4.0 | | -|curl |5.0.2 |5.0.2 | | -|fansi |1.0.4 |1.0.4 | | +|curl |5.1.0 |5.1.0 | | +|fansi |1.0.5 |1.0.5 | | |generics |0.1.3 |0.1.3 | | |glue |1.6.2 |1.6.2 | | |hms |1.1.3 |1.1.3 | | |httpcode |0.3.0 |0.3.0 | | -|jsonlite |1.8.7 |1.8.7 | | -|lifecycle |1.0.3 |1.0.3 | | -|lubridate |1.9.2 |1.9.2 | | +|jsonlite |1.8.8 |1.8.8 | | +|lifecycle |1.0.4 |1.0.4 | | +|lubridate |1.9.3 |1.9.3 | | |magrittr |2.0.3 |2.0.3 | | |mime |0.12 |0.12 | | |pillar |1.9.0 |1.9.0 | | |pkgconfig |2.0.3 |2.0.3 | | -|prettyunits |1.1.1 |1.1.1 | | +|prettyunits |1.2.0 |1.2.0 | | |progress |1.2.2 |1.2.2 | | |R6 |2.5.1 |2.5.1 | | |Rcpp |1.0.11 |1.0.11 | | |readr |2.1.4 |2.1.4 | | -|rlang |1.1.1 |1.1.1 | | +|rlang |1.1.2 |1.1.2 | | |tibble |3.2.1 |3.2.1 | | |tidyselect |1.2.0 |1.2.0 | | |timechange |0.2.0 |0.2.0 | | |triebeard |0.4.1 |0.4.1 | | |tzdb |0.4.0 |0.4.0 | | |urltools |1.7.3 |1.7.3 | | -|utf8 |1.2.3 |1.2.3 | | -|vctrs |0.6.3 |0.6.3 | | -|vroom |1.6.3 |1.6.3 | | -|withr |2.5.0 |2.5.0 | | +|utf8 |1.2.4 |1.2.4 | | +|vctrs |0.6.5 |0.6.5 | | +|vroom |1.6.4 |1.6.4 | | +|withr |2.5.2 |2.5.2 | | # Revdeps diff --git a/revdep/cran.md b/revdep/cran.md index d07935b8..ab1853ce 100644 --- a/revdep/cran.md +++ b/revdep/cran.md @@ -1,6 +1,6 @@ ## revdepcheck results -We checked 2 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package. +We checked 4 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package. * We saw 0 new problems * We failed to check 0 packages diff --git a/tests/fixtures/adjusted_air_pressure.json b/tests/fixtures/adjusted_air_pressure.json index 58b6cc53..8b81341a 100644 --- a/tests/fixtures/adjusted_air_pressure.json +++ b/tests/fixtures/adjusted_air_pressure.json @@ -1 +1 @@ -{"http_interactions":[{"request":{"method":"get","uri":"https://power.larc.nasa.gov/api/temporal/daily/point?parameters=T2M%2CT2M_MIN%2CT2M_MAX%2CRH2M%2CWS10M%2CPS&community=ag&start=19830101&end=19830101&site-elevation=0&longitude=-179.5&latitude=-89.5&format=csv&time-standard=UTC&user=nasapower4012","body":{"encoding":"","string":""},"headers":{"User-Agent":"libcurl/8.1.2 r-curl/5.0.2 crul/1.4.0","Accept-Encoding":"gzip, deflate","Accept":"application/json, text/xml, application/xml, */*"}},"response":{"status":{"status_code":"200","message":"OK","explanation":"Request fulfilled, document follows"},"headers":{"content-disposition":"attachment; filename=POWER_Point_Daily_19830101_19830101_089d50S_0179d50W_UTC.csv","content-language":"en-US","content-length":"912","content-type":"text/csv","date":"Sun, 20 Aug 2023 03:52:09 GMT","status":"HTTP/2 200 ","via":"1.1 8b783853f686a4f741f19858147f3e7e.cloudfront.net (CloudFront), 1.1 f38bd9207113f94192bb63d23f26aa12.cloudfront.net (CloudFront)","x-amz-apigw-id":"J8McTFhcvHcF7gA=","x-amz-cf-id":"FKHe0_yD12NQUyHH3jrdYdTEq6bgtGT1KpjBXIAUTRoFrE9tcILE2Q==","x-amz-cf-pop":["PER50-C1","PER50-C1"],"x-amzn-remapped-content-length":"912","x-amzn-requestid":"cf8a06b9-b722-46ea-8752-36298adc94f8","x-amzn-trace-id":"Root=1-64e18de8-2ce60bd80d98e26341ec41d4","x-app-version":"v2.4.4","x-archive-time":"1.565","x-cache":"Miss from cloudfront","x-data-sources":"merra2,power","x-objects-time":"0.009","x-process-time":"0.2","x-service-time":"1.775"},"body":{"encoding":"","file":false,"string":"-BEGIN HEADER-\r\nNASA/POWER CERES/MERRA2 Native Resolution Daily Data \r\nDates (month/day/year): 01/01/1983 through 01/01/1983 \r\nLocation: Latitude -89.5 Longitude -179.5 \r\nElevation from MERRA-2: Average for 0.5 x 0.625 degree lat/lon region = 2885.03 meters\r\nThe value for missing source data that cannot be computed or is outside of the sources availability range: -999 \r\nParameter(s): \r\nT2M MERRA-2 Temperature at 2 Meters (C) \r\nT2M_MIN MERRA-2 Temperature at 2 Meters Minimum (C) \r\nT2M_MAX MERRA-2 Temperature at 2 Meters Maximum (C) \r\nRH2M MERRA-2 Relative Humidity at 2 Meters (%) \r\nWS10M MERRA-2 Wind Speed at 10 Meters (m/s) \r\nPS MERRA-2 Surface Pressure (kPa) \r\nPSC MERRA-2 Corrected Atmospheric Pressure (Adjusted For Site Elevation) (kPa) \r\n-END HEADER-\r\nYEAR,DOY,T2M,T2M_MIN,T2M_MAX,RH2M,WS10M,PS,PSC\n1983,1,-24.36,-25.37,-22.7,92.44,1.93,69.23,101.38\n"}},"recorded_at":"2023-08-20 03:52:09 GMT","recorded_with":"vcr/1.2.2, webmockr/0.9.0"}]} +{"http_interactions":[{"request":{"method":"get","uri":"https://power.larc.nasa.gov/api/temporal/daily/point?parameters=T2M%2CT2M_MIN%2CT2M_MAX%2CRH2M%2CWS10M%2CPS&community=ag&start=19830101&end=19830101&site-elevation=0&longitude=-179.5&latitude=-89.5&format=csv&time-standard=UTC&user=nasapower410","body":{"encoding":"","string":""},"headers":{"User-Agent":"libcurl/8.1.2 r-curl/5.1.0 crul/1.4.0","Accept-Encoding":"gzip, deflate","Accept":"application/json, text/xml, application/xml, */*"}},"response":{"status":{"status_code":"200","message":"OK","explanation":"Request fulfilled, document follows"},"headers":{"content-disposition":"attachment; filename=POWER_Point_Daily_19830101_19830101_089d50S_0179d50W_UTC.csv","content-language":"en-US","content-length":"912","content-type":"text/csv","date":"Tue, 05 Dec 2023 12:00:46 GMT","status":"HTTP/2 200 ","via":"1.1 b26d50f4268747fbb55ffbc1b1778adc.cloudfront.net (CloudFront), 1.1 8f55f9526b9325921fbddb26c450c97a.cloudfront.net (CloudFront)","x-amz-apigw-id":"Pd-VGHAVvHcEVOQ=","x-amz-cf-id":"z-ijJRJphayyLuZOLg4SUyx_9BHIxOaStLhWKA-tcyR4LSUXIAIOqw==","x-amz-cf-pop":["MEL52-P1","MEL52-P1"],"x-amzn-remapped-content-length":"912","x-amzn-requestid":"7805534d-ea9e-4f76-81c7-1eea9db9ab1b","x-amzn-trace-id":"Root=1-656f10ed-19ec47b54e1bcb7437b95536","x-app-name":"daily","x-app-version":"v2.5.1","x-archive-time":"1.379","x-cache":"Miss from cloudfront","x-data-sources":"merra2,power","x-objects-time":"0.012","x-process-time":"0.2","x-service-time":"1.592"},"body":{"encoding":"","file":false,"string":"-BEGIN HEADER-\r\nNASA/POWER CERES/MERRA2 Native Resolution Daily Data \r\nDates (month/day/year): 01/01/1983 through 01/01/1983 \r\nLocation: Latitude -89.5 Longitude -179.5 \r\nElevation from MERRA-2: Average for 0.5 x 0.625 degree lat/lon region = 2885.03 meters\r\nThe value for missing source data that cannot be computed or is outside of the sources availability range: -999 \r\nParameter(s): \r\nT2M MERRA-2 Temperature at 2 Meters (C) \r\nT2M_MIN MERRA-2 Temperature at 2 Meters Minimum (C) \r\nT2M_MAX MERRA-2 Temperature at 2 Meters Maximum (C) \r\nRH2M MERRA-2 Relative Humidity at 2 Meters (%) \r\nWS10M MERRA-2 Wind Speed at 10 Meters (m/s) \r\nPS MERRA-2 Surface Pressure (kPa) \r\nPSC MERRA-2 Corrected Atmospheric Pressure (Adjusted For Site Elevation) (kPa) \r\n-END HEADER-\r\nYEAR,DOY,T2M,T2M_MIN,T2M_MAX,RH2M,WS10M,PS,PSC\n1983,1,-24.36,-25.37,-22.7,92.44,1.93,69.23,101.38\n"}},"recorded_at":"2023-12-05 12:00:47 GMT","recorded_with":"vcr/1.2.2, webmockr/0.9.0"}]} diff --git a/tests/fixtures/adjusted_wind_elevation.json b/tests/fixtures/adjusted_wind_elevation.json index 3ecc9336..24d249c9 100644 --- a/tests/fixtures/adjusted_wind_elevation.json +++ b/tests/fixtures/adjusted_wind_elevation.json @@ -1 +1 @@ -{"http_interactions":[{"request":{"method":"get","uri":"https://power.larc.nasa.gov/api/temporal/daily/point?parameters=T2M%2CT2M_MIN%2CT2M_MAX%2CRH2M%2CWS10M%2CPS&community=ag&start=19830101&end=19830101&wind-elevation=300&wind-surface=vegtype_1&longitude=-179.5&latitude=-89.5&format=csv&time-standard=UTC&user=nasapower4012","body":{"encoding":"","string":""},"headers":{"User-Agent":"libcurl/8.1.2 r-curl/5.0.2 crul/1.4.0","Accept-Encoding":"gzip, deflate","Accept":"application/json, text/xml, application/xml, */*"}},"response":{"status":{"status_code":"200","message":"OK","explanation":"Request fulfilled, document follows"},"headers":{"content-disposition":"attachment; filename=POWER_Point_Daily_19830101_19830101_089d50S_0179d50W_UTC.csv","content-language":"en-US","content-length":"1024","content-type":"text/csv","date":"Sun, 20 Aug 2023 03:52:12 GMT","status":"HTTP/2 200 ","vary":"Accept-Encoding","via":"1.1 d65f0ada2f9649266b32f91b10382a3e.cloudfront.net (CloudFront), 1.1 f38bd9207113f94192bb63d23f26aa12.cloudfront.net (CloudFront)","x-amz-apigw-id":"J8McsHu2PHcFgZQ=","x-amz-cf-id":"XjY7WRhKau2zlEALn0W-K8NT12bhVL-4iweDUIV4a3nsGCuqeUssMA==","x-amz-cf-pop":["PER50-C1","PER50-C1"],"x-amzn-remapped-content-length":"1024","x-amzn-requestid":"b68a5cce-6021-4e71-a246-fbc20e52e17c","x-amzn-trace-id":"Root=1-64e18dea-1fec1b170cb741a80881c7f6","x-app-version":"v2.4.4","x-archive-time":"1.732","x-cache":"Miss from cloudfront","x-data-sources":"merra2,power","x-objects-time":"0.017","x-process-time":"0.19","x-service-time":"1.94"},"body":{"encoding":"","file":false,"string":"-BEGIN HEADER-\r\nNASA/POWER CERES/MERRA2 Native Resolution Daily Data \r\nDates (month/day/year): 01/01/1983 through 01/01/1983 \r\nLocation: Latitude -89.5 Longitude -179.5 \r\nElevation from MERRA-2: Average for 0.5 x 0.625 degree lat/lon region = 2885.03 meters\r\nThe value for missing source data that cannot be computed or is outside of the sources availability range: -999 \r\nParameter(s): \r\nT2M MERRA-2 Temperature at 2 Meters (C) \r\nT2M_MIN MERRA-2 Temperature at 2 Meters Minimum (C) \r\nT2M_MAX MERRA-2 Temperature at 2 Meters Maximum (C) \r\nRH2M MERRA-2 Relative Humidity at 2 Meters (%) \r\nWS10M MERRA-2 Wind Speed at 10 Meters (m/s) \r\nPS MERRA-2 Surface Pressure (kPa) \r\nWSC MERRA-2 Corrected Wind Speed (Adjusted For Elevation) (m/s) \r\nMessage(s): \r\nCorrected Wind Speed has a custom surface implemented: 35-m broadleaf-evergreen trees (70% coverage) (vegtype_1) \r\n-END HEADER-\r\nYEAR,DOY,T2M,T2M_MIN,T2M_MAX,RH2M,WS10M,PS,WSC\n1983,1,-24.36,-25.37,-22.7,92.44,1.93,69.23,6.49\n"}},"recorded_at":"2023-08-20 03:52:12 GMT","recorded_with":"vcr/1.2.2, webmockr/0.9.0"}]} +{"http_interactions":[{"request":{"method":"get","uri":"https://power.larc.nasa.gov/api/temporal/daily/point?parameters=T2M%2CT2M_MIN%2CT2M_MAX%2CRH2M%2CWS10M%2CPS&community=ag&start=19830101&end=19830101&wind-elevation=300&wind-surface=vegtype_1&longitude=-179.5&latitude=-89.5&format=csv&time-standard=UTC&user=nasapower410","body":{"encoding":"","string":""},"headers":{"User-Agent":"libcurl/8.1.2 r-curl/5.1.0 crul/1.4.0","Accept-Encoding":"gzip, deflate","Accept":"application/json, text/xml, application/xml, */*"}},"response":{"status":{"status_code":"200","message":"OK","explanation":"Request fulfilled, document follows"},"headers":{"content-disposition":"attachment; filename=POWER_Point_Daily_19830101_19830101_089d50S_0179d50W_UTC.csv","content-language":"en-US","content-length":"1024","content-type":"text/csv","date":"Tue, 05 Dec 2023 12:00:49 GMT","status":"HTTP/2 200 ","vary":"Accept-Encoding","via":"1.1 c039aab48f1d7b49b82fa30def82ba1a.cloudfront.net (CloudFront), 1.1 8f55f9526b9325921fbddb26c450c97a.cloudfront.net (CloudFront)","x-amz-apigw-id":"Pd-VeFIXvHcEhKQ=","x-amz-cf-id":"a-n89yr-L7ll8vUDdsqRhkGx92o4UOv-SEhatiyRWrEFn0PJWOPQ8A==","x-amz-cf-pop":["MEL52-P1","MEL52-P1"],"x-amzn-remapped-content-length":"1024","x-amzn-requestid":"293fd75b-9544-4962-9be3-c999cc0c125a","x-amzn-trace-id":"Root=1-656f10ef-7d08e96e53aebc1c2ddfb814","x-app-name":"daily","x-app-version":"v2.5.1","x-archive-time":"1.753","x-cache":"Miss from cloudfront","x-data-sources":"merra2,power","x-objects-time":"0.024","x-process-time":"0.16","x-service-time":"1.938"},"body":{"encoding":"","file":false,"string":"-BEGIN HEADER-\r\nNASA/POWER CERES/MERRA2 Native Resolution Daily Data \r\nDates (month/day/year): 01/01/1983 through 01/01/1983 \r\nLocation: Latitude -89.5 Longitude -179.5 \r\nElevation from MERRA-2: Average for 0.5 x 0.625 degree lat/lon region = 2885.03 meters\r\nThe value for missing source data that cannot be computed or is outside of the sources availability range: -999 \r\nParameter(s): \r\nT2M MERRA-2 Temperature at 2 Meters (C) \r\nT2M_MIN MERRA-2 Temperature at 2 Meters Minimum (C) \r\nT2M_MAX MERRA-2 Temperature at 2 Meters Maximum (C) \r\nRH2M MERRA-2 Relative Humidity at 2 Meters (%) \r\nWS10M MERRA-2 Wind Speed at 10 Meters (m/s) \r\nPS MERRA-2 Surface Pressure (kPa) \r\nWSC MERRA-2 Corrected Wind Speed (Adjusted For Elevation) (m/s) \r\nMessage(s): \r\nCorrected Wind Speed has a custom surface implemented: 35-m broadleaf-evergreen trees (70% coverage) (vegtype_1) \r\n-END HEADER-\r\nYEAR,DOY,T2M,T2M_MIN,T2M_MAX,RH2M,WS10M,PS,WSC\n1983,1,-24.36,-25.37,-22.7,92.44,1.93,69.23,6.49\n"}},"recorded_at":"2023-12-05 12:00:49 GMT","recorded_with":"vcr/1.2.2, webmockr/0.9.0"}]} diff --git a/tests/fixtures/climatology_ag_point.json b/tests/fixtures/climatology_ag_point.json index 4eb40564..b624de38 100644 --- a/tests/fixtures/climatology_ag_point.json +++ b/tests/fixtures/climatology_ag_point.json @@ -1 +1 @@ -{"http_interactions":[{"request":{"method":"get","uri":"https://power.larc.nasa.gov/api/temporal/climatology/point?parameters=T2M&community=ag&longitude=-179.5&latitude=-89.5&format=csv&time-standard=LST&user=nasapower4012","body":{"encoding":"","string":""},"headers":{"User-Agent":"libcurl/8.1.2 r-curl/5.0.2 crul/1.4.0","Accept-Encoding":"gzip, deflate","Accept":"application/json, text/xml, application/xml, */*"}},"response":{"status":{"status_code":"200","message":"OK","explanation":"Request fulfilled, document follows"},"headers":{"content-disposition":"attachment; filename=POWER_Point_Climatology_Climatology_2001_2020_089d50S_0179d50W_UTC.csv","content-language":"en-US","content-length":"663","content-type":"text/csv","date":"Sun, 20 Aug 2023 03:52:25 GMT","status":"HTTP/2 200 ","via":"1.1 73c1be06ae71c031888969ad46c601b2.cloudfront.net (CloudFront), 1.1 f38bd9207113f94192bb63d23f26aa12.cloudfront.net (CloudFront)","x-amz-apigw-id":"J8MeFFy2vHcF-Cg=","x-amz-cf-id":"SIojJRfOx2CPyVMRcUl9KzdLS4Gasy6PbDfu7o_RGBAVIr1bo4iB3w==","x-amz-cf-pop":["PER50-C1","PER50-C1"],"x-amzn-remapped-content-length":"663","x-amzn-requestid":"105785a2-ed07-403f-ae31-18c7b889eb0f","x-amzn-trace-id":"Root=1-64e18df3-0263bc1330783baf2bb6ff35","x-app-version":"v2.4.5","x-archive-time":"5.546","x-cache":"Miss from cloudfront","x-data-sources":"merra2","x-objects-time":"0.034","x-process-time":"0.81","x-service-time":"6.391"},"body":{"encoding":"","file":false,"string":"-BEGIN HEADER-\r\nNASA/POWER CERES/MERRA2 Native Resolution Climatology Climatologies \r\n20-year Meteorological and Solar Monthly & Annual Climatologies (January 2001 - December 2020) \r\nLocation: Latitude -89.5 Longitude -179.5 \r\nElevation from MERRA-2: Average for 0.5 x 0.625 degree lat/lon region = 2885.03 meters\r\nThe value for missing source data that cannot be computed or is outside of the sources availability range: -999 \r\nParameter(s): \r\nT2M MERRA-2 Temperature at 2 Meters (C) \r\n-END HEADER-\r\nPARAMETER,JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC,ANN\nT2M,-29.16,-40.68,-52.56,-57.06,-57.9,-59.46,-62.02,-61.4,-60.25,-52.29,-38.76,-28.66,-50.04\n"}},"recorded_at":"2023-08-20 03:52:25 GMT","recorded_with":"vcr/1.2.2, webmockr/0.9.0"}]} +{"http_interactions":[{"request":{"method":"get","uri":"https://power.larc.nasa.gov/api/temporal/climatology/point?parameters=T2M&community=ag&longitude=-179.5&latitude=-89.5&format=csv&time-standard=LST&user=nasapower410","body":{"encoding":"","string":""},"headers":{"User-Agent":"libcurl/8.1.2 r-curl/5.1.0 crul/1.4.0","Accept-Encoding":"gzip, deflate","Accept":"application/json, text/xml, application/xml, */*"}},"response":{"status":{"status_code":"200","message":"OK","explanation":"Request fulfilled, document follows"},"headers":{"content-disposition":"attachment; filename=POWER_Point_Climatology_Climatology_2001_2020_089d50S_0179d50W_UTC.csv","content-language":"en-US","content-length":"663","content-type":"text/csv","date":"Tue, 05 Dec 2023 12:01:00 GMT","status":"HTTP/2 200 ","via":"1.1 705200fb622a45f111dbfe8a0df07cfa.cloudfront.net (CloudFront), 1.1 8f55f9526b9325921fbddb26c450c97a.cloudfront.net (CloudFront)","x-amz-apigw-id":"Pd-W1HNKPHcErZQ=","x-amz-cf-id":"NMGntHnWXridwsM0VH3K5YLFoOk5hPj723tFCgoz2FlQBfcJzj7nFg==","x-amz-cf-pop":["MEL52-P1","MEL52-P1"],"x-amzn-remapped-content-length":"663","x-amzn-requestid":"0f1fa1c4-89b3-41df-94bb-b1ee31b38697","x-amzn-trace-id":"Root=1-656f10f8-01e68c1170a50adc2e540987","x-app-name":"climatology","x-app-version":"v2.5.2","x-archive-time":"3.587","x-cache":"Miss from cloudfront","x-data-sources":"merra2","x-objects-time":"0.017","x-process-time":"0.2","x-service-time":"3.805"},"body":{"encoding":"","file":false,"string":"-BEGIN HEADER-\r\nNASA/POWER CERES/MERRA2 Native Resolution Climatology Climatologies \r\n20-year Meteorological and Solar Monthly & Annual Climatologies (January 2001 - December 2020) \r\nLocation: Latitude -89.5 Longitude -179.5 \r\nElevation from MERRA-2: Average for 0.5 x 0.625 degree lat/lon region = 2885.03 meters\r\nThe value for missing source data that cannot be computed or is outside of the sources availability range: -999 \r\nParameter(s): \r\nT2M MERRA-2 Temperature at 2 Meters (C) \r\n-END HEADER-\r\nPARAMETER,JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC,ANN\nT2M,-29.16,-40.68,-52.56,-57.06,-57.9,-59.46,-62.02,-61.4,-60.25,-52.29,-38.76,-28.66,-50.04\n"}},"recorded_at":"2023-12-05 12:01:01 GMT","recorded_with":"vcr/1.2.2, webmockr/0.9.0"}]} diff --git a/tests/fixtures/daily_ag_point.json b/tests/fixtures/daily_ag_point.json index 071cf6b3..c9f078a4 100644 --- a/tests/fixtures/daily_ag_point.json +++ b/tests/fixtures/daily_ag_point.json @@ -1 +1 @@ -{"http_interactions":[{"request":{"method":"get","uri":"https://power.larc.nasa.gov/api/temporal/daily/point?parameters=T2M%2CT2M_MIN%2CT2M_MAX%2CRH2M%2CWS10M%2CPS&community=ag&start=19830101&end=19830101&longitude=-179.5&latitude=-89.5&format=csv&time-standard=UTC&user=nasapower4012","body":{"encoding":"","string":""},"headers":{"User-Agent":"libcurl/8.1.2 r-curl/5.0.2 crul/1.4.0","Accept-Encoding":"gzip, deflate","Accept":"application/json, text/xml, application/xml, */*"}},"response":{"status":{"status_code":"200","message":"OK","explanation":"Request fulfilled, document follows"},"headers":{"content-disposition":"attachment; filename=POWER_Point_Daily_19830101_19830101_089d50S_0179d50W_UTC.csv","content-language":"en-US","content-length":"812","content-type":"text/csv","date":"Sun, 20 Aug 2023 03:52:07 GMT","status":"HTTP/2 200 ","via":"1.1 8b783853f686a4f741f19858147f3e7e.cloudfront.net (CloudFront), 1.1 f38bd9207113f94192bb63d23f26aa12.cloudfront.net (CloudFront)","x-amz-apigw-id":"J8Mb9E91vHcFnDg=","x-amz-cf-id":"lbynHLpZvR5s-WtA1oKejC127ElAxGgoTGFnBmhPEMrm9P87LQ8u5w==","x-amz-cf-pop":["PER50-C1","PER50-C1"],"x-amzn-remapped-content-length":"812","x-amzn-requestid":"c8146d21-b179-4d53-adaa-1fed38ec4797","x-amzn-trace-id":"Root=1-64e18de5-27a06d337b53e40c06c062da","x-app-version":"v2.4.4","x-archive-time":"1.586","x-cache":"Miss from cloudfront","x-data-sources":"merra2,power","x-objects-time":"0.005","x-process-time":"0.18","x-service-time":"1.773"},"body":{"encoding":"","file":false,"string":"-BEGIN HEADER-\r\nNASA/POWER CERES/MERRA2 Native Resolution Daily Data \r\nDates (month/day/year): 01/01/1983 through 01/01/1983 \r\nLocation: Latitude -89.5 Longitude -179.5 \r\nElevation from MERRA-2: Average for 0.5 x 0.625 degree lat/lon region = 2885.03 meters\r\nThe value for missing source data that cannot be computed or is outside of the sources availability range: -999 \r\nParameter(s): \r\nT2M MERRA-2 Temperature at 2 Meters (C) \r\nT2M_MIN MERRA-2 Temperature at 2 Meters Minimum (C) \r\nT2M_MAX MERRA-2 Temperature at 2 Meters Maximum (C) \r\nRH2M MERRA-2 Relative Humidity at 2 Meters (%) \r\nWS10M MERRA-2 Wind Speed at 10 Meters (m/s) \r\nPS MERRA-2 Surface Pressure (kPa) \r\n-END HEADER-\r\nYEAR,DOY,T2M,T2M_MIN,T2M_MAX,RH2M,WS10M,PS\n1983,1,-24.36,-25.37,-22.7,92.44,1.93,69.23\n"}},"recorded_at":"2023-08-20 03:52:07 GMT","recorded_with":"vcr/1.2.2, webmockr/0.9.0"}]} +{"http_interactions":[{"request":{"method":"get","uri":"https://power.larc.nasa.gov/api/temporal/daily/point?parameters=T2M%2CT2M_MIN%2CT2M_MAX%2CRH2M%2CWS10M%2CPS&community=ag&start=19830101&end=19830101&longitude=-179.5&latitude=-89.5&format=csv&time-standard=UTC&user=nasapower410","body":{"encoding":"","string":""},"headers":{"User-Agent":"libcurl/8.1.2 r-curl/5.1.0 crul/1.4.0","Accept-Encoding":"gzip, deflate","Accept":"application/json, text/xml, application/xml, */*"}},"response":{"status":{"status_code":"200","message":"OK","explanation":"Request fulfilled, document follows"},"headers":{"content-disposition":"attachment; filename=POWER_Point_Daily_19830101_19830101_089d50S_0179d50W_UTC.csv","content-language":"en-US","content-length":"812","content-type":"text/csv","date":"Tue, 05 Dec 2023 12:00:44 GMT","status":"HTTP/2 200 ","via":"1.1 6bec7f912b2b0f8f2808e647a5c2a972.cloudfront.net (CloudFront), 1.1 8f55f9526b9325921fbddb26c450c97a.cloudfront.net (CloudFront)","x-amz-apigw-id":"Pd-UuGySvHcENAQ=","x-amz-cf-id":"qGWLdALdRd_aRKwwWKe-OLQfgph1iJGhTBBF0Na6F35wN-r7piXHYg==","x-amz-cf-pop":["MEL52-P1","MEL52-P1"],"x-amzn-remapped-content-length":"812","x-amzn-requestid":"ff6172f0-b502-4520-8dc4-5ac802bc0261","x-amzn-trace-id":"Root=1-656f10ea-34d4dc53140681325c0fabdc","x-app-name":"daily","x-app-version":"v2.5.1","x-archive-time":"1.429","x-cache":"Miss from cloudfront","x-data-sources":"power,merra2","x-objects-time":"0.006","x-process-time":"0.14","x-service-time":"1.576"},"body":{"encoding":"","file":false,"string":"-BEGIN HEADER-\r\nNASA/POWER CERES/MERRA2 Native Resolution Daily Data \r\nDates (month/day/year): 01/01/1983 through 01/01/1983 \r\nLocation: Latitude -89.5 Longitude -179.5 \r\nElevation from MERRA-2: Average for 0.5 x 0.625 degree lat/lon region = 2885.03 meters\r\nThe value for missing source data that cannot be computed or is outside of the sources availability range: -999 \r\nParameter(s): \r\nT2M MERRA-2 Temperature at 2 Meters (C) \r\nT2M_MIN MERRA-2 Temperature at 2 Meters Minimum (C) \r\nT2M_MAX MERRA-2 Temperature at 2 Meters Maximum (C) \r\nRH2M MERRA-2 Relative Humidity at 2 Meters (%) \r\nWS10M MERRA-2 Wind Speed at 10 Meters (m/s) \r\nPS MERRA-2 Surface Pressure (kPa) \r\n-END HEADER-\r\nYEAR,DOY,T2M,T2M_MIN,T2M_MAX,RH2M,WS10M,PS\n1983,1,-24.36,-25.37,-22.7,92.44,1.93,69.23\n"}},"recorded_at":"2023-12-05 12:00:44 GMT","recorded_with":"vcr/1.2.2, webmockr/0.9.0"}]} diff --git a/tests/fixtures/daily_sb_point_LST.json b/tests/fixtures/daily_sb_point_LST.json index 8e53d297..fdd863dc 100644 --- a/tests/fixtures/daily_sb_point_LST.json +++ b/tests/fixtures/daily_sb_point_LST.json @@ -1 +1 @@ -{"http_interactions":[{"request":{"method":"get","uri":"https://power.larc.nasa.gov/api/temporal/daily/point?parameters=T2M%2CT2M_MIN%2CT2M_MAX%2CRH2M%2CWS10M&community=sb&start=19830101&end=19830101&longitude=-179.5&latitude=-89.5&format=csv&time-standard=LST&user=nasapower4012","body":{"encoding":"","string":""},"headers":{"User-Agent":"libcurl/8.1.2 r-curl/5.0.2 crul/1.4.0","Accept-Encoding":"gzip, deflate","Accept":"application/json, text/xml, application/xml, */*"}},"response":{"status":{"status_code":"200","message":"OK","explanation":"Request fulfilled, document follows"},"headers":{"content-disposition":"attachment; filename=POWER_Point_Daily_19830101_19830101_089d50S_0179d50W_LST.csv","content-language":"en-US","content-length":"763","content-type":"text/csv","date":"Sun, 20 Aug 2023 03:52:17 GMT","status":"HTTP/2 200 ","via":"1.1 2d59845825b74fd3ae094215b11f2c10.cloudfront.net (CloudFront), 1.1 f38bd9207113f94192bb63d23f26aa12.cloudfront.net (CloudFront)","x-amz-apigw-id":"J8MddHJKPHcFrnw=","x-amz-cf-id":"q-9O7471so_8CVTBsbsNH-88a7Tc1eDvbL176tESvFN7dKVG6wDZgA==","x-amz-cf-pop":["PER50-C1","PER50-C1"],"x-amzn-remapped-content-length":"763","x-amzn-requestid":"d3701824-d338-4da7-9587-0ace3f7e9a43","x-amzn-trace-id":"Root=1-64e18def-5cd73974596227d75a87ace4","x-app-version":"v2.4.4","x-archive-time":"1.495","x-cache":"Miss from cloudfront","x-data-sources":"power,merra2","x-objects-time":"0.018","x-process-time":"0.18","x-service-time":"1.694"},"body":{"encoding":"","file":false,"string":"-BEGIN HEADER-\r\nNASA/POWER CERES/MERRA2 Native Resolution Daily Data \r\nDates (month/day/year): 01/01/1983 through 01/01/1983 \r\nLocation: Latitude -89.5 Longitude -179.5 \r\nElevation from MERRA-2: Average for 0.5 x 0.625 degree lat/lon region = 2885.03 meters\r\nThe value for missing source data that cannot be computed or is outside of the sources availability range: -999 \r\nParameter(s): \r\nT2M MERRA-2 Temperature at 2 Meters (C) \r\nT2M_MIN MERRA-2 Temperature at 2 Meters Minimum (C) \r\nT2M_MAX MERRA-2 Temperature at 2 Meters Maximum (C) \r\nRH2M MERRA-2 Relative Humidity at 2 Meters (%) \r\nWS10M MERRA-2 Wind Speed at 10 Meters (m/s) \r\n-END HEADER-\r\nYEAR,MO,DY,T2M,T2M_MIN,T2M_MAX,RH2M,WS10M\n1983,1,1,-25.24,-25.67,-24.88,94.25,2.32\n"}},"recorded_at":"2023-08-20 03:52:17 GMT","recorded_with":"vcr/1.2.2, webmockr/0.9.0"}]} +{"http_interactions":[{"request":{"method":"get","uri":"https://power.larc.nasa.gov/api/temporal/daily/point?parameters=T2M%2CT2M_MIN%2CT2M_MAX%2CRH2M%2CWS10M&community=sb&start=19830101&end=19830101&longitude=-179.5&latitude=-89.5&format=csv&time-standard=LST&user=nasapower410","body":{"encoding":"","string":""},"headers":{"User-Agent":"libcurl/8.1.2 r-curl/5.1.0 crul/1.4.0","Accept-Encoding":"gzip, deflate","Accept":"application/json, text/xml, application/xml, */*"}},"response":{"status":{"status_code":"200","message":"OK","explanation":"Request fulfilled, document follows"},"headers":{"content-disposition":"attachment; filename=POWER_Point_Daily_19830101_19830101_089d50S_0179d50W_LST.csv","content-language":"en-US","content-length":"763","content-type":"text/csv","date":"Tue, 05 Dec 2023 12:00:53 GMT","status":"HTTP/2 200 ","via":"1.1 75737370d7e6451b1bd1c4dcf8c70dbe.cloudfront.net (CloudFront), 1.1 8f55f9526b9325921fbddb26c450c97a.cloudfront.net (CloudFront)","x-amz-apigw-id":"Pd-WIG8LvHcEfHQ=","x-amz-cf-id":"0a_6Lv1beWTFpEXBl4ZjpeMhVnW5IkYAYzl4q9D3r5E2cU6CbL1TyQ==","x-amz-cf-pop":["MEL52-P1","MEL52-P1"],"x-amzn-remapped-content-length":"763","x-amzn-requestid":"0c0b8bed-6f24-44f8-b7d3-e8b608c1f5c3","x-amzn-trace-id":"Root=1-656f10f3-7a9e1f027fc9b1d96b86d878","x-app-name":"daily","x-app-version":"v2.5.1","x-archive-time":"1.272","x-cache":"Miss from cloudfront","x-data-sources":"power,merra2","x-objects-time":"0.012","x-process-time":"0.15","x-service-time":"1.435"},"body":{"encoding":"","file":false,"string":"-BEGIN HEADER-\r\nNASA/POWER CERES/MERRA2 Native Resolution Daily Data \r\nDates (month/day/year): 01/01/1983 through 01/01/1983 \r\nLocation: Latitude -89.5 Longitude -179.5 \r\nElevation from MERRA-2: Average for 0.5 x 0.625 degree lat/lon region = 2885.03 meters\r\nThe value for missing source data that cannot be computed or is outside of the sources availability range: -999 \r\nParameter(s): \r\nT2M MERRA-2 Temperature at 2 Meters (C) \r\nT2M_MIN MERRA-2 Temperature at 2 Meters Minimum (C) \r\nT2M_MAX MERRA-2 Temperature at 2 Meters Maximum (C) \r\nRH2M MERRA-2 Relative Humidity at 2 Meters (%) \r\nWS10M MERRA-2 Wind Speed at 10 Meters (m/s) \r\n-END HEADER-\r\nYEAR,MO,DY,T2M,T2M_MIN,T2M_MAX,RH2M,WS10M\n1983,1,1,-25.24,-25.67,-24.88,94.25,2.32\n"}},"recorded_at":"2023-12-05 12:00:53 GMT","recorded_with":"vcr/1.2.2, webmockr/0.9.0"}]} diff --git a/tests/fixtures/daily_sb_point_UTC.json b/tests/fixtures/daily_sb_point_UTC.json index eb678fd0..5ec2725a 100644 --- a/tests/fixtures/daily_sb_point_UTC.json +++ b/tests/fixtures/daily_sb_point_UTC.json @@ -1 +1 @@ -{"http_interactions":[{"request":{"method":"get","uri":"https://power.larc.nasa.gov/api/temporal/daily/point?parameters=T2M%2CT2M_MIN%2CT2M_MAX%2CRH2M%2CWS10M&community=sb&start=19830101&end=19830101&longitude=-179.5&latitude=-89.5&format=csv&time-standard=UTC&user=nasapower4012","body":{"encoding":"","string":""},"headers":{"User-Agent":"libcurl/8.1.2 r-curl/5.0.2 crul/1.4.0","Accept-Encoding":"gzip, deflate","Accept":"application/json, text/xml, application/xml, */*"}},"response":{"status":{"status_code":"200","message":"OK","explanation":"Request fulfilled, document follows"},"headers":{"content-disposition":"attachment; filename=POWER_Point_Daily_19830101_19830101_089d50S_0179d50W_UTC.csv","content-language":"en-US","content-length":"762","content-type":"text/csv","date":"Sun, 20 Aug 2023 03:52:14 GMT","status":"HTTP/2 200 ","via":"1.1 6e19875b14d906dfd0ef8e65e8726f1c.cloudfront.net (CloudFront), 1.1 f38bd9207113f94192bb63d23f26aa12.cloudfront.net (CloudFront)","x-amz-apigw-id":"J8MdGHUjPHcFcew=","x-amz-cf-id":"iQhMcu5QKI3sOmPi5P7ogeEiLGA1eCkCcIXwqdUHutgxUxqMTqzSYA==","x-amz-cf-pop":["PER50-C1","PER50-C1"],"x-amzn-remapped-content-length":"762","x-amzn-requestid":"56e6a0bb-1331-4866-a8df-f5d799c86655","x-amzn-trace-id":"Root=1-64e18ded-783f378c4c75b97743abf6dc","x-app-version":"v2.4.4","x-archive-time":"1.472","x-cache":"Miss from cloudfront","x-data-sources":"merra2,power","x-objects-time":"0.021","x-process-time":"0.16","x-service-time":"1.655"},"body":{"encoding":"","file":false,"string":"-BEGIN HEADER-\r\nNASA/POWER CERES/MERRA2 Native Resolution Daily Data \r\nDates (month/day/year): 01/01/1983 through 01/01/1983 \r\nLocation: Latitude -89.5 Longitude -179.5 \r\nElevation from MERRA-2: Average for 0.5 x 0.625 degree lat/lon region = 2885.03 meters\r\nThe value for missing source data that cannot be computed or is outside of the sources availability range: -999 \r\nParameter(s): \r\nT2M MERRA-2 Temperature at 2 Meters (C) \r\nT2M_MIN MERRA-2 Temperature at 2 Meters Minimum (C) \r\nT2M_MAX MERRA-2 Temperature at 2 Meters Maximum (C) \r\nRH2M MERRA-2 Relative Humidity at 2 Meters (%) \r\nWS10M MERRA-2 Wind Speed at 10 Meters (m/s) \r\n-END HEADER-\r\nYEAR,MO,DY,T2M,T2M_MIN,T2M_MAX,RH2M,WS10M\n1983,1,1,-24.36,-25.37,-22.7,92.44,1.93\n"}},"recorded_at":"2023-08-20 03:52:14 GMT","recorded_with":"vcr/1.2.2, webmockr/0.9.0"}]} +{"http_interactions":[{"request":{"method":"get","uri":"https://power.larc.nasa.gov/api/temporal/daily/point?parameters=T2M%2CT2M_MIN%2CT2M_MAX%2CRH2M%2CWS10M&community=sb&start=19830101&end=19830101&longitude=-179.5&latitude=-89.5&format=csv&time-standard=UTC&user=nasapower410","body":{"encoding":"","string":""},"headers":{"User-Agent":"libcurl/8.1.2 r-curl/5.1.0 crul/1.4.0","Accept-Encoding":"gzip, deflate","Accept":"application/json, text/xml, application/xml, */*"}},"response":{"status":{"status_code":"200","message":"OK","explanation":"Request fulfilled, document follows"},"headers":{"content-disposition":"attachment; filename=POWER_Point_Daily_19830101_19830101_089d50S_0179d50W_UTC.csv","content-language":"en-US","content-length":"762","content-type":"text/csv","date":"Tue, 05 Dec 2023 12:00:51 GMT","status":"HTTP/2 200 ","via":"1.1 f5ada3a2e963ec386faa5c3dd2e81c6a.cloudfront.net (CloudFront), 1.1 8f55f9526b9325921fbddb26c450c97a.cloudfront.net (CloudFront)","x-amz-apigw-id":"Pd-V3HRuPHcEsUQ=","x-amz-cf-id":"dcnj9RFxrTAtBZn10q_KJ1uffkx6qF4OfXBMaXOXZtZ5CFUCbSTSHg==","x-amz-cf-pop":["MEL52-P1","MEL52-P1"],"x-amzn-remapped-content-length":"762","x-amzn-requestid":"a6dfbb30-10d7-475f-a9d7-f6c49f5191bc","x-amzn-trace-id":"Root=1-656f10f2-55a120ca6aec971929827faf","x-app-name":"daily","x-app-version":"v2.5.1","x-archive-time":"1.137","x-cache":"Miss from cloudfront","x-data-sources":"merra2,power","x-objects-time":"0.007","x-process-time":"0.17","x-service-time":"1.315"},"body":{"encoding":"","file":false,"string":"-BEGIN HEADER-\r\nNASA/POWER CERES/MERRA2 Native Resolution Daily Data \r\nDates (month/day/year): 01/01/1983 through 01/01/1983 \r\nLocation: Latitude -89.5 Longitude -179.5 \r\nElevation from MERRA-2: Average for 0.5 x 0.625 degree lat/lon region = 2885.03 meters\r\nThe value for missing source data that cannot be computed or is outside of the sources availability range: -999 \r\nParameter(s): \r\nT2M MERRA-2 Temperature at 2 Meters (C) \r\nT2M_MIN MERRA-2 Temperature at 2 Meters Minimum (C) \r\nT2M_MAX MERRA-2 Temperature at 2 Meters Maximum (C) \r\nRH2M MERRA-2 Relative Humidity at 2 Meters (%) \r\nWS10M MERRA-2 Wind Speed at 10 Meters (m/s) \r\n-END HEADER-\r\nYEAR,MO,DY,T2M,T2M_MIN,T2M_MAX,RH2M,WS10M\n1983,1,1,-24.36,-25.37,-22.7,92.44,1.93\n"}},"recorded_at":"2023-12-05 12:00:51 GMT","recorded_with":"vcr/1.2.2, webmockr/0.9.0"}]} diff --git a/tests/fixtures/temporal_api-warning.json b/tests/fixtures/temporal_api-warning.json deleted file mode 100644 index 86c7403b..00000000 --- a/tests/fixtures/temporal_api-warning.json +++ /dev/null @@ -1 +0,0 @@ -{"http_interactions":[{"request":{"method":"get","uri":"https://power.larc.nasa.gov/api/temporal/daily/point?parameters=T2M&community=ag&start=19830101&end=19830101&longitude=-179.5&latitude=-89.5&format=csv&time-standard=LST&user=nasapower4012","body":{"encoding":"","string":""},"headers":{"User-Agent":"libcurl/8.1.2 r-curl/5.0.2 crul/1.4.0","Accept-Encoding":"gzip, deflate","Accept":"application/json, text/xml, application/xml, */*"}},"response":{"status":{"status_code":"200","message":"OK","explanation":"Request fulfilled, document follows"},"headers":{"content-disposition":"attachment; filename=POWER_Point_Daily_19830101_19830101_089d50S_0179d50W_LST.csv","content-language":"en-US","content-length":"479","content-type":"text/csv","date":"Sun, 20 Aug 2023 03:52:40 GMT","status":"HTTP/2 200 ","via":"1.1 cbb086b8f97c75d3b789dd691b0ed148.cloudfront.net (CloudFront), 1.1 f38bd9207113f94192bb63d23f26aa12.cloudfront.net (CloudFront)","x-amz-apigw-id":"J8MhQFfMPHcFvzg=","x-amz-cf-id":"U52HvGLcfqqBIBkoeoDHU3tPXYd1W4h9XyoT4_9qjJ7qFM-woHJYrw==","x-amz-cf-pop":["PER50-C1","PER50-C1"],"x-amzn-remapped-content-length":"479","x-amzn-requestid":"f011b706-42f7-4c85-8f8c-6194ab3704d0","x-amzn-trace-id":"Root=1-64e18e07-761164ef03d8bea514d41c79","x-app-version":"v2.4.4","x-archive-time":"0.96","x-cache":"Miss from cloudfront","x-data-sources":"merra2","x-objects-time":"0.008","x-process-time":"0.12","x-service-time":"1.09"},"body":{"encoding":"","file":false,"string":"-BEGIN HEADER-\r\nNASA/POWER CERES/MERRA2 Native Resolution Daily Data \r\nDates (month/day/year): 01/01/1983 through 01/01/1983 \r\nLocation: Latitude -89.5 Longitude -179.5 \r\nElevation from MERRA-2: Average for 0.5 x 0.625 degree lat/lon region = 2885.03 meters\r\nThe value for missing source data that cannot be computed or is outside of the sources availability range: -999 \r\nParameter(s): \r\nT2M MERRA-2 Temperature at 2 Meters (C) \r\n-END HEADER-\r\nYEAR,DOY,T2M\n1983,1,-25.24\n"}},"recorded_at":"2023-08-20 03:52:40 GMT","recorded_with":"vcr/1.2.2, webmockr/0.9.0"}]} diff --git a/tests/testthat.R b/tests/testthat.R index f980dfb5..2a58c7ca 100644 --- a/tests/testthat.R +++ b/tests/testthat.R @@ -1,3 +1,11 @@ +# This file is part of the standard setup for testthat. +# It is recommended that you do not modify it. +# +# Where should you do additional test configuration? +# Learn more about the roles of various files in: +# * https://r-pkgs.org/testing-design.html#sec-tests-files-overview +# * https://testthat.r-lib.org/articles/special-files.html + library(testthat) library(nasapower) diff --git a/tests/testthat/test-get_power.R b/tests/testthat/test-get_power.R index cc0a1311..19ca2447 100644 --- a/tests/testthat/test-get_power.R +++ b/tests/testthat/test-get_power.R @@ -18,7 +18,7 @@ test_that("get_power() returns daily point ag data", { ) }) - expect_is(power_query, "data.frame") + expect_s3_class(power_query, "data.frame") expect_equal(power_query$LAT, -89.5, tolerance = 1e-3) expect_equal(power_query$LON, -179.5, tolerance = 1e-3) expect_equal(power_query$YEAR, 1983) @@ -73,7 +73,7 @@ test_that("get_power() returns daily point ag data with adjusted atmospheric ) }) - expect_is(power_query, "data.frame") + expect_s3_class(power_query, "data.frame") expect_equal(power_query$LAT, -89.5, tolerance = 1e-3) expect_equal(power_query$LON, -179.5, tolerance = 1e-3) expect_equal(power_query$YEAR, 1983) @@ -131,7 +131,7 @@ test_that("get_power() returns daily point ag data with adjusted wind ) }) - expect_is(power_query, "data.frame") + expect_s3_class(power_query, "data.frame") expect_equal(power_query$LAT, -89.5, tolerance = 1e-3) expect_equal(power_query$LON, -179.5, tolerance = 1e-3) expect_equal(power_query$YEAR, 1983) @@ -185,7 +185,7 @@ test_that("get_power() returns daily point SB data", { ) }) - expect_is(power_query, "data.frame") + expect_s3_class(power_query, "data.frame") expect_equal(power_query$LAT, -89.5, tolerance = 1e-3) expect_equal(power_query$LON, -179.5, tolerance = 1e-3) expect_equal(power_query$YEAR, 1983) @@ -217,7 +217,7 @@ test_that("get_power() returns daily point SB data for LST", { ) }) - expect_is(power_query, "data.frame") + expect_s3_class(power_query, "data.frame") expect_equal(power_query$LAT, -89.5, tolerance = 1e-3) expect_equal(power_query$LON, -179.5, tolerance = 1e-3) expect_equal(power_query$YEAR, 1983) @@ -312,22 +312,6 @@ test_that("get_power() returns point ag data for climatology", { ) }) - -# test user input check response messages ----- -test_that("get_power() stops if `temporal_api` not valid", { - skip_if_offline() - expect_error( - get_power( - community = "ag", - lonlat = c(-179.5, -89.5), - pars = "T2M", - dates = "1983-01-01", - temporal_api = 1 - ), - regexp = "You have entered an invalid value for `temporal_api`.\n" - ) -}) - test_that("get_power() stops if hourly data are requested < 2001-01-01", { skip_if_offline() expect_error( @@ -342,20 +326,6 @@ test_that("get_power() stops if hourly data are requested < 2001-01-01", { ) }) -test_that("get_power() stops if an invalid community supplied", { - skip_if_offline() - expect_error( - get_power( - community = "rOpenSci", - lonlat = "global", - pars = "T2M", - dates = "1983-01-01", - temporal_api = "daily" - ), - regexp = "You have provided an invalid `community` value.\n" - ) -}) - test_that("get_power() stops if site elevation is supplied not for point", { Sys.sleep(10) skip_if_offline() @@ -368,7 +338,7 @@ test_that("get_power() stops if site elevation is supplied not for point", { temporal_api = "daily", site_elevation = 35 ), - regexp = "You have provided `site_elevation` for a region*." + regexp = "You have provided `site_elevation`, `35` for a region request.*" ) }) @@ -429,7 +399,7 @@ test_that("get_power() ignores wind_elevation for regional requests", { temporal_api = "daily", wind_elevation = 15 ), - regexp = "You have provided `wind_elevation` for a region request.*" + regexp = "You have provided `wind_elevation`, `15`, for a region request.*" ) }) @@ -479,36 +449,6 @@ test_that("get_power() stops if temporal_api is hourly and pars > 15", { ) }) - -test_that("get_power() gives warning if `temporal_average` is used", { - skip_if_offline() - vcr::use_cassette("temporal_api-warning", { - expect_warning( - get_power( - community = "ag", - lonlat = c(-179.5, -89.5), - pars = "T2M", - dates = "1983-01-01", - temporal_average = "daily" - ), - regexp = "`temporal_average has been deprecated for `temporal_api`*" - ) - }) -}) - -test_that("get_power() stops if there is no temporal_api()", { - skip_if_offline() - expect_error( - get_power( - community = "ag", - lonlat = c(-179.5, -89.5), - pars = "T2M", - dates = "1983-01-01" - ), - regexp = "You must provide a `temporal_api` value." - ) -}) - test_that("get_power() stops if global lonlat is set", { skip_if_offline() expect_error( diff --git a/tests/testthat/test-internal_functions.R b/tests/testthat/test-internal_functions.R index 42445316..611f5fb2 100644 --- a/tests/testthat/test-internal_functions.R +++ b/tests/testthat/test-internal_functions.R @@ -86,7 +86,7 @@ test_that("Invalid `dates` are handled", { lonlat <- c(-179.5, -89.5) site_elevation <- NULL expect_error(.check_dates(dates, lonlat, temporal_api), - regexp = "*1983-02-31 is not a valid entry for date.*") + regexp = "`1983-02-31` is not a valid entry for a date value.*") }) test_that("Dates are returned as a vector of characters", { @@ -95,7 +95,7 @@ test_that("Dates are returned as a vector of characters", { lonlat <- c(-179.5, -89.5) site_elevation <- NULL dates <- .check_dates(dates, lonlat, temporal_api) - expect_is(dates, "character") + expect_type(dates, "character") }) test_that( @@ -212,42 +212,42 @@ test_that(".check_lonlat() checks order of the latitude values", { temporal_api <- "daily" expect_error(.check_lonlat(lonlat = c(-179.5, 89.5, 179.5, -89.5), pars), - regexp = "The first `lat` value must be the minimum value.\n") + regexp = "The first `lat` value must be the minimum value.") }) test_that(".check_lonlat() checks order of the longitude values", { temporal_api <- "daily" expect_error(.check_lonlat(lonlat = c(179.5, -89.5, -179.5, 89.5), pars), - regexp = "The first `lon` value must be the minimum value.\n") + regexp = "The first `lon` value must be the minimum value.") }) test_that(".check_lonlat() checks validity of bbox latmin values", { temporal_api <- "daily" expect_error(.check_lonlat(lonlat = c(-179.5, 91, -179.5, 90), pars), - regexp = "Please check your latitude, `91`, `90`*") + regexp = "Please check your latitude values*") }) test_that(".check_lonlat() checks validity of bbox latmax values", { temporal_api <- "daily" expect_error(.check_lonlat(lonlat = c(-179.5, 90, -179.5, 93), pars), - regexp = "Please check your latitude, `90`, `93`,*") + regexp = "Please check your latitude values*") }) test_that(".check_lonlat() checks validity of bbox lonmin values", { temporal_api <- "daily" expect_error(.check_lonlat(lonlat = c(-181.5, 89.5, -179.5, 89.5), pars), - regexp = "Please check your longitude, `-181.5`, `-179.5`*") + regexp = "Please check your longitude*") }) test_that(".check_lonlat() checks validity of bbox lonmax values", { temporal_api <- "daily" expect_error(.check_lonlat(lonlat = c(-179.5, 89.5, 181, 89.5), pars), - regexp = "Please check your longitude, `-179.5`, `181`,*") + regexp = "Please check your longitude*") }) test_that( diff --git a/tests/testthat/test-query_parameters.R b/tests/testthat/test-query_parameters.R index 6cc14c1e..44186474 100644 --- a/tests/testthat/test-query_parameters.R +++ b/tests/testthat/test-query_parameters.R @@ -5,7 +5,7 @@ test_that("query_parameters() returns proper list of info", { par = c("T2M"), temporal_api = "Daily") - expect_is(par_query, "list") + expect_type(par_query, "list") expect_length(par_query, 1) expect_named(par_query, "T2M") }) @@ -13,7 +13,7 @@ test_that("query_parameters() returns proper list of info", { test_that("query_parameters() returns list of parameter information", { skip_on_cran() par_query <- query_parameters(par = "T2M") - expect_is(par_query, "list") + expect_type(par_query, "list") expect_length(par_query, 1) expect_named(par_query, "T2M") })