Skip to content

Commit

Permalink
CRAN Version 1.2.2
Browse files Browse the repository at this point in the history
All examples now fail gracefully
  • Loading branch information
Roy Mendelssohn committed Feb 26, 2025
1 parent 6d712b3 commit 2945ac5
Show file tree
Hide file tree
Showing 12 changed files with 97 additions and 38 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: rerddapXtracto
Type: Package
Title: Extracts Environmental Data from 'ERDDAP™' Web Services
Version: 1.2.1
Date: 2024-7-17
Version: 1.2.2
Date: 2025-02-25
Authors@R: c(
person("Roy", "Mendelssohn", email = "[email protected]", role = c("aut","cre")),
person("Marie", "Auger-Methe", role = "ctb"),
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ export(plotTrack)
export(rxtracto)
export(rxtracto_3D)
export(rxtractogon)
export(safe_info)
export(tidy_grid)
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# rerddapXtracto 1.2.2

Added function so that all rerddap::info() calls are safe to use in examples

# rerddapXtracto 1.2.1

fixed bug in 'rxtracto()' with projected data
Expand Down
3 changes: 2 additions & 1 deletion R/rxtracto.R
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
#' ##
#' ## bathymetry example
#' ## 2-D example getting bathymetry
#' dataInfo <- rerddap::info('etopo360')
#' ## Wrap rerddap::info('etopo360') call in function that insures proper finish if it fails
#' dataInfo <- safe_info('etopo360')
#' parameter <- 'altitude'
#' # extract <- rxtracto(dataInfo, parameter, xcoord = xcoord, ycoord = ycoord)
#'
Expand Down
17 changes: 9 additions & 8 deletions R/rxtracto_3D.R
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
#' Extract environmental data in a 3-dimensional box from an 'ERDDAP' server using 'rerddap'.
#' Extract environmental data in a 3-dimensional box from an 'ERDDAP' server using 'rerddap'.
#'
#' \code{rxtracto_3D} uses the R program 'rerddap' to extract environmental data
#' from an 'ERDDAP' server in an (x,y,z, time) bounding box.
#' The same call could be made directly in rerddap,
#' but function is maintained as it is used in the polygon routine.
#' @export
#' @param dataInfo - the return from an 'rerddap:info' call to an 'ERDDAP' server
#' @param dataInfo - the return from an 'rerddap:info' call to an 'ERDDAP' server
#' @param parameter - character string containing the name of the parameter to extract
#' @param xcoord - a real array with the x-coordinates of the trajectory (if longitude in #' decimal degrees East, either 0-360 or -180 to 180)
#' @param ycoord - a real array with the y-coordinate of the trajectory (if latitude in
#' decimal degrees N; -90 to 90)
#' @param zcoord - a real array with the z-coordinate (usually altitude or depth)
#' @param tcoord - a character array with the times of the trajectory in
#' "YYYY-MM-DD" - for now restricted to be time.
#' @param xName - character string with name of the xcoord in the 'ERDDAP' dataset (default "longitude")
#' @param yName - character string with name of the ycoord in the 'ERDDAP' dataset (default "latitude")
#' @param zName - character string with name of the zcoord in the 'ERDDAP' dataset (default "altitude")
#' @param tName - character string with name of the tcoord in the 'ERDDAP' dataset (default "time")
#' @param xName - character string with name of the xcoord in the 'ERDDAP' dataset (default "longitude")
#' @param yName - character string with name of the ycoord in the 'ERDDAP' dataset (default "latitude")
#' @param zName - character string with name of the zcoord in the 'ERDDAP' dataset (default "altitude")
#' @param tName - character string with name of the tcoord in the 'ERDDAP' dataset (default "time")
#' @param verbose - logical variable (default FALSE) if the the URL request should be verbose
#' @param cache_remove - logical variable (default TRUE) whether to delete 'rerddap' cache
#' @return If successful a structure with data and dimensions:
#' \itemize{
#' \item extract$data - the data array dimensioned (lon,lat,time)
#' \item extract$varname - the name of the parameter extracted
#' \item extract$datasetname - ERDDAP dataset name
#' \item extract$datasetname - ERDDAP dataset name
#' \item extract$longitude - the longitudes on some scale as request
#' \item extract$latitude - the latitudes always going south to north
#' \item extract$time - the times of the extracts
Expand All @@ -43,7 +43,8 @@
#'
#' ## bathymetry example
#' ## 2-D example getting bathymetry
#' dataInfo <- rerddap::info('etopo360')
#' ## Wrap rerddap::info('etopo360') call in function that insures proper finish if it fails
#' dataInfo <- safe_info('etopo360')
#' parameter <- 'altitude'
#' # extract <- rxtracto_3D(dataInfo, parameter, xcoord = xcoord, ycoord = ycoord)
rxtracto_3D <- function(dataInfo, parameter = NULL, xcoord = NULL,
Expand Down
17 changes: 9 additions & 8 deletions R/rxtractogon.R
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
#' Extract environmental data in a polygon using 'ERDDAP' and 'rerddap'.
#' Extract environmental data in a polygon using 'ERDDAP' and 'rerddap'.
#'
#' \code{rxtractogon} uses the R program 'rerddap' to extract environmental data
#' from an 'ERDDAP' server in a polygon through time.
#' from an 'ERDDAP' server in a polygon through time.
#' @export
#' @param dataInfo - the return from an 'rerddap:info' call to an 'ERDDAP' server
#' @param dataInfo - the return from an 'rerddap:info' call to an 'ERDDAP' server
#' @param parameter - character string containing the name of the parameter to extract
#' @param xcoord - array giving longitudes (in decimal
#' degrees East, either 0-360 or -180 to 180) of polygon
#' @param ycoord - array giving latitudes (in decimal
#' degrees N; -90 to 90)of polygon
#' @param tcoord - 2-array of minimum and maximum times as 'YYYY-MM-DD'
#' @param zcoord - a real number with the z-coordinate(usually altitude or depth)
#' @param xName - character string with name of the xcoord in the 'ERDDAP' dataset (default "longitude")
#' @param yName - character string with name of the ycoord in the 'ERDDAP' dataset (default "latitude")
#' @param zName - character string with name of the zcoord in the 'ERDDAP' dataset (default "altitude")
#' @param tName - character string with name of the tcoord in the 'ERDDAP' dataset (default "time")
#' @param xName - character string with name of the xcoord in the 'ERDDAP' dataset (default "longitude")
#' @param yName - character string with name of the ycoord in the 'ERDDAP' dataset (default "latitude")
#' @param zName - character string with name of the zcoord in the 'ERDDAP' dataset (default "altitude")
#' @param tName - character string with name of the tcoord in the 'ERDDAP' dataset (default "time")
#' @param verbose - logical variable (default FALSE) if the the URL request should be verbose
#' @param cache_remove - logical variable (default TRUE) whether to delete 'rerddap' cache
#' @return If successful a structure with data and dimensions
Expand All @@ -41,7 +41,8 @@
#' ## MBMS bathymetry example
#' xcoord <- mbnms$Longitude
#' ycoord <- mbnms$Latitude
#' dataInfo <- rerddap::info('etopo180')
#' ## Wrap rerddap::info('etopo180') call in function that insures proper finish if it fails
#' dataInfo <- safe_info('etopo180')
#' parameter = 'altitude'
#' xName <- 'longitude'
#' yName <- 'latitude'
Expand Down
22 changes: 22 additions & 0 deletions R/utils.R
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -209,4 +209,26 @@ removeLast <- function(isotime, tcoord1) {
}


#' Wrap rerddap::info() so that it will fail gracefully
#' \code{safe_info} uses tryCatch() to deal with unavailable response
#' @export
#' @param dataset_id ERDDAP dataset_id
#' @param url base ERDDAP URL
#' @return If success, dataset information, otherwise message and end
#' @examples
#' dataInfo <- safe_info('etopo360')
#'
safe_info <- function(dataset_id, url = 'https://upwell.pfeg.noaa.gov/erddap/') {
result <- tryCatch(
{
rerddap::info(dataset_id)
},
error = function(e) {
message("The resource '", dataset_id, "' is not available at the moment. Skipping...")
return(NULL)
}
)
return(result)
}


5 changes: 3 additions & 2 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## Version 1.2.1
## Version 1.2.2

Fixes recent problem to that calls in the examples are safe

fixed bug in 'rxtracto()' with projected data


## Test environments
Expand Down
3 changes: 2 additions & 1 deletion man/rxtracto.Rd
100755 → 100644

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

17 changes: 9 additions & 8 deletions man/rxtracto_3D.Rd
100755 → 100644

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

17 changes: 9 additions & 8 deletions man/rxtractogon.Rd
100755 → 100644

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

25 changes: 25 additions & 0 deletions man/safe_info.Rd

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

0 comments on commit 2945ac5

Please sign in to comment.