Skip to content

Commit b363390

Browse files
committed
CRAN Version 0.8.0
Added a global search convenience function. Fixed a bug when a coordinate variable is not lat or long and is decreasing.
1 parent abe2409 commit b363390

30 files changed

+406
-160
lines changed

.Rbuildignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,8 @@ tests/vcr_cassettes/griddap_fixes_user_inputs_2.yml
2828
^LICENSE\.md$
2929
vignettes/rerddap.Rmd
3030
vignettes/Using_rerddap.Rmd
31+
vignettes/rerddap.Rmd.org
32+
vignettes/Using_rerddap.Rmd.org
33+
man/figures
3134
revdep/
3235
^CRAN-RELEASE$

CRAN-RELEASE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
This package was submitted to CRAN on 2021-08-17.
2-
Once it is accepted, delete this file and tag the release (commit 526e71a).
1+
This package was submitted to CRAN on 2021-11-19.
2+
Once it is accepted, delete this file and tag the release (commit abe2409).

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Description: General purpose R client for 'ERDDAP' servers. Includes
55
'datasets', and fetch 'datasets', in either 'csv' or 'netCDF' format.
66
'ERDDAP' information:
77
<https://upwell.pfeg.noaa.gov/erddap/information.html>.
8-
Version: 0.7.6
8+
Version: 0.8.0
99
License: MIT + file LICENSE
1010
Authors@R: c(
1111
person("Scott", "Chamberlain", role = "aut"),
@@ -35,7 +35,7 @@ Suggests:
3535
testthat,
3636
vcr (>= 0.2.6)
3737
Enhances: taxize
38-
RoxygenNote: 7.1.1
38+
RoxygenNote: 7.1.2
3939
X-schema.org-applicationCategory: Climate
4040
X-schema.org-keywords: earth, science, climate, precipitation, temperature, storm, buoy, NOAA
4141
X-schema.org-isPartOf: https://ropensci.org

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export(ed_search)
4343
export(ed_search_adv)
4444
export(eurl)
4545
export(fipscounty)
46+
export(global_search)
4647
export(griddap)
4748
export(info)
4849
export(key_words)

NEWS.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
rerddap 0.8.0
2+
=============
3+
4+
* Added global search function
5+
* fixed bug when dataset has a decreasing coordinate that
6+
is not latitude or longitude
7+
8+
19
rerddap 0.7.6
210
=============
311

R/global_search.R

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#' @title global_search
2+
#' @description Search for ERDDAP tabledap or griddap datasets from a list
3+
#' of ERDDAP servers based on search terms.
4+
#' @param query (character) Search terms
5+
#' @param server_list (list of character) List of ERDDAP servers to search
6+
#' @param which_service character) One of tabledep or griddap.
7+
#' @return If successful a dataframe wih columns:
8+
#' \itemize{
9+
#' \item title - the dataset title
10+
#' \item dataset_id - the datasetid on that ERDDAP server
11+
#' \item url - base url of dataset ERDDAP server
12+
#' }
13+
#' if urls are valid, no match is found, will return no match found
14+
#' else returns error message
15+
#' @details Uses the 'reddap' function ed_search() to search over
16+
#' the list of servers
17+
#' @examples
18+
#' # get list of servers know by
19+
#' # https://irishmarineinstitute.github.io/awesome-erddap
20+
#' # e_servers <- servers()$url
21+
#' # select a couple to search
22+
#' # e_servers <- e_servers[c(1, 40)]
23+
#' # to meet CRAN time limits will only search 1 place
24+
#' e_servers <- "https://coastwatch.pfeg.noaa.gov/erddap/"
25+
#' test_query <- 'NOAA/NCDC Blended Monthly'
26+
#' query_results <- global_search(test_query, e_servers, "griddap")
27+
#' @seealso
28+
#' \code{\link[crul]{HttpClient}}
29+
#' @rdname global_search
30+
#' @export
31+
global_search <- function(query, server_list, which_service) {
32+
# check that input is of correct type
33+
check_arg(query, "character")
34+
check_arg(server_list, "character")
35+
check_arg(which_service, "character")
36+
which_service <- match.arg(which_service, c("tabledap","griddap"), FALSE)
37+
search_url <- list()
38+
for (iserv in seq(1, length(server_list))) {
39+
# set which server
40+
my_serv <- server_list[iserv]
41+
good_url <- TRUE
42+
# will do two tests on the server
43+
# First is if erddap is not in URL
44+
test_url <- grepl('erddap', my_serv, fixed = TRUE)
45+
if (!test_url) { # erddap not in url
46+
print(paste('server URL ', my_serv), ' does not contain "erddap"')
47+
print('will be removed from server list')
48+
good_url <- FALSE
49+
}
50+
# test if URL reachable
51+
if (good_url) {
52+
test_url <- crul::HttpClient$new(my_serv)
53+
test_url_head <- try(test_url$head(), silent = TRUE)
54+
if (suppressWarnings(class(test_url_head)[1] == 'try-error')) {
55+
print(paste(' server URL', my_serv, ' not responding'))
56+
good_url <- FALSE
57+
}
58+
}
59+
# good URL, responding, make query
60+
if (good_url){
61+
temp_list <- try(ed_search(query = query, url = my_serv,
62+
which = which_service),
63+
silent = TRUE)
64+
class_error <- suppressWarnings(class(temp_list)[1] == 'try-error')
65+
if(!class_error) {
66+
temp_list <- temp_list$info
67+
temp_names <- names(temp_list)
68+
temp_list$url <- rep(my_serv, nrow(temp_list))
69+
names(temp_list) <- c(temp_names, 'url')
70+
search_url <- rbind(search_url, temp_list)
71+
}
72+
}
73+
}
74+
if(length(search_url) == 0) {
75+
print('no search results found')
76+
return('no search results found')
77+
} else {
78+
return(search_url)
79+
}
80+
}
81+

R/grid.R

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,12 +212,13 @@ fix_dims <- function(dimargs, .info) {
212212
dimargs[[i]] <- rev(dimargs[[i]])
213213
}
214214
}
215-
215+
216216
## new
217-
if (nm %in% c('latitude', 'longitude')) {
217+
# if (nm %in% c('latitude', 'longitude')) {
218+
if (nm != 'time') {
218219
z <- unlist(strsplit(.info$alldata[[nm]]$value[1], ","))
219220
spacing <- as.numeric(unlist(strsplit(z[3], "=")[[1]])[2])
220-
if (spacing < 0) {
221+
if ((!is.na(spacing)) & (spacing < 0)) {
221222
if (!(dimargs[[i]][1] > dimargs[[i]][2])) {
222223
dimargs[[i]] <- rev(dimargs[[i]])
223224
}

cran-comments.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
## Test environments
22

33
* local macOS install, R 4.1.1
4-
* rhub ubuntu, debian, solaris
4+
* rhub ubuntu, debian, solaris, Apple Silicon (M1), macOS 11.6 Big Sur
55
* win-builder (devel and release)
66

77
## R CMD check results
88

9-
1 Note due to change in maintainer.
9+
OK from all checks
1010

1111
## Reverse dependencies
1212

1313
* No probelms with reverse dependencies.
1414

1515
---
1616

17-
New maintainer of package - Roy Mendelssohn
18-
This version fixes a bug dealing with trailing slashes in URLs
17+
This version fixes a bug dealing with coordinates that
18+
are not lat-lon and are in decreasing order. Adds a new
19+
search function.
1920

2021
Thanks!
2122
Roy Mendelssohn

man/global_search.Rd

Lines changed: 47 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)