diff --git a/DESCRIPTION b/DESCRIPTION index d5ced864..9546f8d9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -9,7 +9,7 @@ Description: An R client for many NOAA data sources including the NCDC NOAA storm data via IBTrACS, and tornado data via the NOAA storm prediction center. NOAA buoy data is only on the buoy branch in the Github repository for this package (see url below). -Version: 0.3.6.9000 +Version: 0.3.7.9000 Date: 2015-05-21 License: MIT + file LICENSE Authors@R: c(person("Hart", "Edmund", role = "aut", @@ -32,15 +32,12 @@ Imports: ggplot2, scales, sp, - RCurl, rgdal, rgeos, maptools, XML, data.table, - jsonlite, - digest, - reshape2 + jsonlite Suggests: testthat, roxygen2, diff --git a/NAMESPACE b/NAMESPACE index d6b5e23c..8cde3fd5 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,12 +1,6 @@ # Generated by roxygen2 (4.1.1): do not edit by hand -S3method(as.erddap_info,character) -S3method(as.erddap_info,erddap_info) S3method(ncdc_plot,ncdc_data) -S3method(print,erddap_grid) -S3method(print,erddap_info) -S3method(print,erddap_search) -S3method(print,erddap_table) S3method(print,ghcnd) S3method(print,ghcnd_stations) S3method(print,isd) @@ -22,8 +16,6 @@ S3method(type_summ,integer) S3method(type_summ,logical) S3method(type_summ,matrix) S3method(type_summ,numeric) -export(as.erddap_info) -export(disk) export(erddap_clear_cache) export(erddap_data) export(erddap_datasets) @@ -51,7 +43,6 @@ export(is.ncdc_stations) export(isd) export(isd_stations) export(latlong2bbox) -export(memory) export(ncdc) export(ncdc_combine) export(ncdc_datacats) @@ -88,7 +79,6 @@ export(theme_ice) export(tornadoes) export(type_summ) import(XML) -import(digest) import(ggplot2) import(httr) import(maptools) @@ -101,7 +91,6 @@ importFrom(dplyr,rbind_all) importFrom(dplyr,rename) importFrom(dplyr,select) importFrom(dplyr,tbl_df) -importFrom(jsonlite,fromJSON) importFrom(lubridate,month) importFrom(lubridate,today) importFrom(lubridate,year) @@ -109,7 +98,6 @@ importFrom(lubridate,ymd) importFrom(plyr,compact) importFrom(plyr,rbind.fill) importFrom(plyr,round_any) -importFrom(reshape2,melt) importFrom(rgeos,gBuffer) importFrom(scales,date_breaks) importFrom(scales,date_format) diff --git a/R/caching.R b/R/caching.R index c5d49264..b2205ec2 100644 --- a/R/caching.R +++ b/R/caching.R @@ -1,51 +1,13 @@ #' Clear cached files -#' +#' #' @name caching #' @param path Path to location of cached files. Defaults to \code{disk()$path} #' @param force (logical) Should we force removal of files if permissions say otherwise? -#' @details BEWARE: this will clear all cached files. +#' @details BEWARE: this will clear all cached files. #' @export #' @rdname caching -erddap_clear_cache <- function(path = disk(), force = FALSE) { - files <- list.files(path$path, full.names = TRUE) - unlink(files, recursive = TRUE, force = force) -} - -#' @export -#' @rdname caching ghcnd_clear_cache <- function(path = "~/.rnoaa/ghcnd", force = FALSE) { files <- list.files(path, full.names = TRUE) unlink(files, recursive = TRUE, force = force) } - -cache_get <- function(cache, url, args=list(), path="~/") -{ - if(cache){ - key <- if(!identical(args, list())) make_key(url, args) else url - hash <- digest::digest(key) - stored_hashes <- list.files(path, full.names=TRUE, pattern=".csv") - getname <- function(x) strsplit(x, "/")[[1]][length(strsplit(x, "/")[[1]])] - stored_hashes_match <- gsub("\\.csv", "", sapply(stored_hashes, getname, USE.NAMES=FALSE)) - if(length(stored_hashes) == 0){ - NULL - } else { - tt <- stored_hashes[stored_hashes_match %in% hash] - if(identical(tt, character(0))) NULL else tt - } - } else { NULL } -} - -write_path <- function(path, url, args=list(), fmt="csv") -{ - url <- if(!identical(args, list())) make_key(url, args) else url - hash <- digest::digest(url) - file.path(path, paste0(hash, paste0(".", fmt), sep="")) -} - -make_key <- function(url, args) -{ - tmp <- httr::parse_url(url) - tmp$query <- args - httr::build_url(tmp) -} diff --git a/R/defunct.R b/R/defunct.R index abc060b9..2c037916 100644 --- a/R/defunct.R +++ b/R/defunct.R @@ -82,11 +82,58 @@ noaa_seaice <- function(...){ #' @export #' @rdname erddap_data-defunct #' @keywords internal -erddap_data <- function() -{ +erddap_data <- function(){ .Defunct(msg = "See functions erddap_grid and erddap_table for griddap and tabledap data, respectively") } +#' This function is defunct. +#' @export +#' @rdname erddap_clear_cache-defunct +#' @keywords internal +erddap_clear_cache <- function(){ + .Defunct(package = "rerddap", msg = "See package rerddap") +} + +#' This function is defunct. +#' @export +#' @rdname erddap_datasets-defunct +#' @keywords internal +erddap_datasets <- function(){ + .Defunct(new = "ed_datasets", package = "rerddap", msg = "See ed_datasets() in package rerddap") +} + +#' This function is defunct. +#' @export +#' @rdname erddap_grid-defunct +#' @keywords internal +erddap_grid <- function(){ + .Defunct(new = "griddap", package = "rerddap", msg = "See griddap() in package rerddap") +} + +#' This function is defunct. +#' @export +#' @rdname erddap_info-defunct +#' @keywords internal +erddap_info <- function(){ + .Defunct(new = "info", package = "rerddap", msg = "See info() in package rerddap") +} + +#' This function is defunct. +#' @export +#' @rdname erddap_search-defunct +#' @keywords internal +erddap_search <- function(){ + .Defunct(new = "ed_search", package = "rerddap", msg = "See ed_search() in package rerddap") +} + +#' This function is defunct. +#' @export +#' @rdname erddap_table-defunct +#' @keywords internal +erddap_table <- function(){ + .Defunct(new = "tabledap", package = "rerddap", msg = "See tabledap() in package rerddap") +} + #' Defunct functions in rnoaa #' #' \itemize{ @@ -100,8 +147,18 @@ erddap_data <- function() #' \item \code{\link{noaa_plot}}: Function name changed, prefixed with ncdc now #' \item \code{\link{noaa_combine}}: Function name changed, prefixed with ncdc now #' \item \code{\link{noaa_seaice}}: Function name changed to seaice -#' \item \code{\link{erddap_data}}: See the function \code{\link{erddap_grid}} for getting -#' griddap data and \code{\link{erddap_table}} for getting tabledap data. +#' \item \code{\link{erddap_data}}: See package rerddap +#' \item \code{\link{erddap_clear_cache}}: See package rerddap +#' \item \code{\link{erddap_datasets}}: Moved to \code{\link[rerddap]{ed_datasets}} in +#' package rerddap +#' \item \code{\link{erddap_grid}}: Moved to \code{\link[rerddap]{griddap}} in package +#' rerddap +#' \item \code{\link{erddap_info}}: Moved to \code{\link[rerddap]{info}} in package +#' rerddap +#' \item \code{\link{erddap_search}}: Moved to \code{\link[rerddap]{ed_search}} in +#' package rerddap +#' \item \code{\link{erddap_table}}: Moved to \code{\link[rerddap]{tabledap}} in +#' package rerddap #' } #' #' @name rnoaa-defunct diff --git a/R/erddap.R b/R/erddap.R deleted file mode 100644 index 2aee3525..00000000 --- a/R/erddap.R +++ /dev/null @@ -1,34 +0,0 @@ -#' ERDDAP Information -#' -#' NOAA's ERDDAP service holds many datasets of interest. It's built on top of -#' OPenDAP \url{http://www.opendap.org/}. You can search for datasets via -#' \code{\link{erddap_search}}, list datasets via \code{\link{erddap_datasets}}, -#' get information on a single dataset via \code{\link{erddap_info}}, then get -#' data you want for either tabledap type via \code{\link{erddap_table}}, or -#' for griddap type via \code{\link{erddap_grid}}. -#' -#' tabledap and griddap have different interfaces to query for data, so -#' \code{\link{erddap_table}} and \code{\link{erddap_grid}} are separated out as -#' separate functions even though some of the internals are the same. In particular, -#' with tabledap you can query on/subset all variables, whereas with gridddap, you can -#' only query on/subset the dimension varibles (e.g., latitude, longitude, altitude). -#' -#' \bold{NOTE:} With griddap data vai \code{\link{erddap_grid}} you can get a lot of -#' data quickly. Try small searches of a dataset to start to get a sense for the data, -#' then you can increase the amount of data you get. See \code{\link{erddap_grid}} -#' for more details. -#' -#' The following are the ERDDAP functions: -#' -#' \itemize{ -#' \item \code{\link{erddap_search}} -#' \item \code{\link{erddap_datasets}} -#' \item \code{\link{erddap_info}} -#' \item \code{\link{erddap_table}} -#' \item \code{\link{erddap_grid}} -#' } -#' -#' @references \url{http://upwell.pfeg.noaa.gov/erddap/index.html} -#' @author Scott Chamberlain -#' @name erddap -NULL diff --git a/R/erddap_grid.R b/R/erddap_grid.R deleted file mode 100644 index b303b4d3..00000000 --- a/R/erddap_grid.R +++ /dev/null @@ -1,264 +0,0 @@ -#' Get ERDDAP griddap data. -#' -#' @export -#' @import digest -#' @importFrom reshape2 melt -#' -#' @param x Anything coercable to an object of class erddap_info. So the output of a call to -#' \code{erddap_info}, or a datasetid, which will internally be passed through \code{erddap_info}. -#' @param ... Dimension arguments. -#' @param fields Fields to return, a character vector. -#' @param stride (integer) How many values to get. 1 = get every value, 2 = get every other value, -#' etc. Default: 1 (i.e., get every value) -#' @param fmt (character) One of csv (default) or ncdf -#' @param store One of \code{disk} (default) or \code{memory}. You can pass options to \code{disk} -#' @param callopts Pass on curl options to \code{\link[httr]{GET}} -#' -#' @details Details: -#' -#' @section Dimensions and Variables: -#' ERDDAP grid dap data has this concept of dimenions vs. variables. So, dimensions are things -#' like time, latitude, longitude, and altitude. Whereas variables are the measured variables, -#' e.g., temperature, salinity, and air. -#' -#' You can't separately adjust values for dimensions for different variables. So, here's how it's -#' gonna work: -#' -#' Pass in lower and upper limits you want for each dimension as a vector (e.g., \code{c(1,2)}), -#' or leave to defaults (i.e., don't pass anything to a dimension). Then pick which variables -#' you want returned via the \code{fields} parameter. If you don't pass in options to the -#' \code{fields} parameter, you get all variables back. -#' -#' To get the dimensions and variables, along with other metadata for a dataset, run -#' \code{erddap_info}, and each will be shown, with their min and max values, and some -#' other metadata. -#' -#' @section Where does the data go?: -#' You can choose where data is stored. Be careful though. With griddap data, you can easily get a -#' single file of hundreds of MB's or GB's in size with a single request. Using \code{disk()} -#' caches files based on the URL of the request you perform, which is the combination of all -#' parameters passed in, so if you refine a query by certain fields, etc., you will cach a -#' different file. If you choose \code{overwrite=TRUE} within the \code{disk()} function then -#' you'll force writing a new file to disk. When you use \code{memory()}, no files are cached, -#' data is stored in R's memory. -#' -#' @references \url{http://upwell.pfeg.noaa.gov/erddap/index.html} -#' @seealso \code{\link{erddap_table}} \code{\link{erddap_clear_cache}} -#' @author Scott Chamberlain -#' @examples \dontrun{ -#' # single variable dataset -#' ## You can pass in the outpu of a call to erddap_info -#' (out <- erddap_info('noaa_esrl_027d_0fb5_5d38')) -#' (res <- erddap_grid(out, -#' time = c('2012-01-01','2012-06-12'), -#' latitude = c(21, 18), -#' longitude = c(-80, -75) -#' )) -#' ## Or, pass in a dataset id -#' (res <- erddap_grid(x='noaa_esrl_027d_0fb5_5d38', -#' time = c('2012-01-01','2012-06-12'), -#' latitude = c(21, 18), -#' longitude = c(-80, -75) -#' )) -#' -#' # multi-variable dataset -#' (out <- erddap_info('noaa_gfdl_5081_7d4a_7570')) -#' (res <- erddap_grid(out, -#' time = c('2005-11-01','2006-01-01'), -#' latitude = c(20, 21), -#' longitude = c(10, 11) -#' )) -#' (res <- erddap_grid(out, time = c('2005-11-01','2006-01-01'), latitude = c(20, 21), -#' longitude = c(10, 11), fields = 'uo')) -#' (res <- erddap_grid(out, time = c('2005-11-01','2006-01-01'), latitude = c(20, 21), -#' longitude = c(10, 11), fields = 'uo', stride=c(1,2,1,2))) -#' (res <- erddap_grid(out, time = c('2005-11-01','2006-01-01'), latitude = c(20, 21), -#' longitude = c(10, 11), fields = c('uo','so'))) -#' (res <- erddap_grid(out, time = c('2005-09-01','2006-01-01'), latitude = c(20, 21), -#' longitude = c(10, 11), fields = 'none')) -#' -#' # multi-variable dataset -#' ## this one also has a 0-360 longitude system, BLARGH!!! -#' (out <- erddap_info('noaa_gfdl_3c96_7879_a9d3')) -#' (res <- erddap_grid(out, -#' time = c('2005-11-01','2006-01-01'), -#' latitude = c(20, 22), -#' longitude = c(-80, -75) -#' )) -#' (res <- erddap_grid(out, -#' time = c('2005-11-01','2006-01-01'), -#' latitude = c(20, 22), -#' longitude = c(-80, -75), -#' depth = c(5, 50) -#' )) -#' -#' # Write to memory (within R), or to disk -#' (out <- erddap_info('noaa_pfeg_e9ae_3356_22f8')) -#' ## disk, by default (to prevent bogging down system w/ large datasets) -#' ## you can also pass in path and overwrite options to disk() -#' (res <- erddap_grid(out, -#' time = c('2012-06-01','2012-06-12'), -#' latitude = c(20, 21), -#' longitude = c(-80, -75), -#' store = disk() -#' )) -#' ## the 2nd call is much faster as it's mostly just the time of reading in the table from disk -#' system.time( erddap_grid(out, -#' time = c('2012-06-01','2012-06-12'), -#' latitude = c(20, 21), -#' longitude = c(-80, -75), -#' store = disk() -#' ) ) -#' system.time( erddap_grid(out, -#' time = c('2012-06-01','2012-06-12'), -#' latitude = c(20, 21), -#' longitude = c(-80, -75), -#' store = disk() -#' ) ) -#' -#' ## memory -#' (res <- erddap_grid(out, -#' time = c('2012-06-01','2012-06-12'), -#' latitude = c(20, 21), -#' longitude = c(-80, -75), -#' store = memory() -#' )) -#' } - -erddap_grid <- function(x, ..., fields = 'all', stride = 1, - fmt = "csv", store = disk(), callopts = list()) -{ - x <- as.erddap_info(x) - dimargs <- list(...) - d <- attr(x, "datasetid") - var <- field_handler(fields, x$variables$variable_name) - dims <- dimvars(x) - if(all(var == "none")){ - args <- paste0(sapply(dims, function(y) parse_args(x, y, stride, dimargs, wname = TRUE)), collapse = ",") - } else { - pargs <- sapply(dims, function(y) parse_args(x, y, stride, dimargs)) - args <- paste0(lapply(var, function(y) paste0(y, paste0(pargs, collapse = ""))), collapse = ",") - } - resp <- erd_up_GET(url = sprintf("%sgriddap/%s.%s", eurl(), d, fmt), dset = d, args, store, fmt, callopts) - loc <- if(store$store == "disk") resp else "memory" - structure(read_upwell(resp, fmt), class=c("erddap_grid","data.frame"), datasetid=d, path=loc) -} - -#' @export -print.erddap_grid <- function(x, ..., n = 10){ - cat(sprintf(" %s", attr(x, "datasetid")), sep = "\n") - cat(sprintf(" Path: [%s]", attr(x, "path")), sep = "\n") - if(attr(x, "path") != "memory"){ - finfo <- file_info(attr(x, "path")) - cat(sprintf(" Last updated: [%s]", finfo$mtime), sep = "\n") - cat(sprintf(" File size: [%s]", finfo$size), sep = "\n") - } - cat(sprintf(" Dimensions: [%s X %s]\n", NROW(x), NCOL(x)), sep = "\n") - trunc_mat_(x, n = n) -} - -field_handler <- function(x, y){ - x <- match.arg(x, c(y, "none", "all"), TRUE) - if(length(x) == 1 && x == "all"){ - y - } else if(all(x %in% y) || x == "none") { - x - } -} - -parse_args <- function(.info, dim, s, dimargs, wname=FALSE){ - tmp <- if(dim %in% names(dimargs)){ - dimargs[[dim]] - } else { - if(dim == "time"){ - times <- c(getvar(.info, "time_coverage_start"), getvar(.info, "time_coverage_end")) - sprintf('[(%s):%s:(%s)]', times[1], s, times[2]) - } else { - actrange <- foo(.info$alldata[[dim]], "actual_range") - gsub("\\s+", "", strsplit(actrange, ",")[[1]]) - } - } - if(length(s) > 1){ - if(!length(s) == length(dimvars(.info))) stop("Your stride vector must equal length of dimension variables", call. = FALSE) - names(s) <- dimvars(.info) - if(!wname) - sprintf('[(%s):%s:(%s)]', tmp[1], s[[dim]], tmp[2]) - else - sprintf('%s[(%s):%s:(%s)]', dim, tmp[1], s[[dim]], tmp[2]) - } else { - if(!wname) - sprintf('[(%s):%s:(%s)]', tmp[1], s, tmp[2]) - else - sprintf('%s[(%s):%s:(%s)]', dim, tmp[1], s, tmp[2]) - } -} - -getvar <- function(x, y){ - x$alldata$NC_GLOBAL[ x$alldata$NC_GLOBAL$attribute_name == y, "value"] -} - -getvars <- function(x){ - vars <- names(x$alldata) - vars[ !vars %in% c("NC_GLOBAL","time", x$variables$variable_name) ] -} - -getallvars <- function(x){ - vars <- names(x$alldata) - vars[ !vars %in% "NC_GLOBAL" ] -} - -dimvars <- function(x){ - vars <- names(x$alldata) - vars[ !vars %in% c("NC_GLOBAL", x$variables$variable_name) ] -} - -erd_up_GET <- function(url, dset, args, store, fmt, ...){ - if(store$store == "disk"){ - out <- suppressWarnings(cache_get(cache = TRUE, url = url, args = args, path = store$path)) - - # fpath <- path.expand(file.path(store$path, paste0(dset, ".csv"))) - if( !is.null( out ) && !store$overwrite ){ - out - } else { - dir.create(store$path, showWarnings = FALSE, recursive = TRUE) - res <- GET(url, query=args, write_disk(write_path(store$path, url, args, fmt), store$overwrite), ...) - out <- check_response_erddap(res, fmt) - if(res$status_code != 200) unlink(res$request$writer[[1]]) - if(grepl("Error", out, ignore.case = TRUE)) NA else res$request$writer[[1]] - } - } else { - res <- GET(url, query=args, ...) - out <- check_response_erddap(res, fmt) - if(grepl("Error", out, ignore.case = TRUE)) NA else res - } -} - -file_info <- function(x){ - tmp <- file.info(x) - row.names(tmp) <- NULL - tmp2 <- tmp[,c('mtime','size')] - tmp2$size <- if(tmp2$size < 10000) paste0(round(tmp2$size/1000L, 2), " KB") else paste0(round(tmp2$size/1000000L, 2), " MB") - tmp2 -} - -# file = "~/.rnoaa/erddap/e93051f9010dbbd568fca953a71acae7.nc" -get_ncdf <- function(file){ - nc <- open.ncdf(file) - lat <- get.var.ncdf(nc, "latitude") - long <- get.var.ncdf(nc, "longitude") - time <- get.var.ncdf(nc, "time") - vars <- names(nc$var) - outvars <- list() - for(i in seq_along(vars)){ - outvars[[ vars[i] ]] <- melt(get.var.ncdf(nc, vars[i]))[,"value"] - } - df <- do.call("cbind.data.frame", outvars) - rows <- length(outvars[[1]]) - meta <- data.frame(time=rep(time, each=rows/length(time)), - lat=rep(lat, each=rows/length(lat)), - long=rep(long, each=rows/length(long)), - stringsAsFactors = FALSE) - alldf <- cbind(meta, df) - close.ncdf(nc) - alldf -} diff --git a/R/erddap_info.R b/R/erddap_info.R deleted file mode 100644 index 593f52ad..00000000 --- a/R/erddap_info.R +++ /dev/null @@ -1,136 +0,0 @@ -#' Get information on an ERDDAP dataset. -#' -#' @export -#' @importFrom jsonlite fromJSON -#' -#' @param datasetid Dataset id -#' @param ... Further args passed on to \code{\link[httr]{GET}} (must be a named parameter) -#' @param x A datasetid or the output of \code{erddap_info} -#' @return Prints a summary of the data on return, but you can index to various information. -#' -#' The data is a list of length two with: -#' \itemize{ -#' \item variables - Data.frame of variables and their types -#' \item alldata - List of data variables and their full attributes -#' } -#' Where \code{alldata} element has many data.frame's, one for each variable, with metadata -#' for that variable. E.g., for griddap dataset \code{noaa_pfeg_696e_ec99_6fa6}, \code{alldata} -#' has: -#' \itemize{ -#' \item NC_GLOBAL -#' \item time -#' \item latitude -#' \item longitude -#' \item sss -#' } -#' @references \url{http://upwell.pfeg.noaa.gov/erddap/index.html} -#' @author Scott Chamberlain -#' @examples \dontrun{ -#' # grid dap datasets -#' erddap_info('noaa_pfeg_696e_ec99_6fa6') -#' erddap_info('noaa_ngdc_34bf_a95c_7e28') -#' -#' (out <- erddap_search(query='temperature')) -#' erddap_info(out$info$dataset_id[5]) -#' erddap_info(out$info$dataset_id[15]) -#' erddap_info(out$info$dataset_id[25]) -#' erddap_info(out$info$dataset_id[33]) -#' erddap_info(out$info$dataset_id[65]) -#' erddap_info(out$info$dataset_id[150]) -#' erddap_info(out$info$dataset_id[400]) -#' erddap_info(out$info$dataset_id[678]) -#' -#' out <- erddap_info(datasetid='noaa_ngdc_34bf_a95c_7e28') -#' ## See brief overview of the variables and range of possible values, if given -#' out$variables -#' ## all information on longitude -#' out$alldata$longitude -#' ## all information on Climatological_Temperature -#' out$alldata$Climatological_Temperature -#' -#' # table dap datasets -#' (out <- erddap_search(query='temperature', which = "table")) -#' erddap_info(out$info$dataset_id[1]) -#' erddap_info(out$info$dataset_id[2]) -#' erddap_info(out$info$dataset_id[3]) -#' erddap_info(out$info$dataset_id[4]) -#' erddap_info(out$info$dataset_id[54]) -#' -#' erddap_info(datasetid='erdCalCOFIfshsiz') -#' out <- erddap_info(datasetid='erdCinpKfmBT') -#' ## See brief overview of the variables and range of possible values, if given -#' out$variables -#' ## all information on longitude -#' out$alldata$longitude -#' ## all information on Haliotis_corrugata_Mean_Density -#' out$alldata$Haliotis_corrugata_Mean_Density -#' } - -erddap_info <- function(datasetid, ...){ - json <- erddap_GET(url = sprintf(paste0(eurl(), 'info/%s/index.json'), datasetid), list(), ...) - colnames <- vapply(tolower(json$table$columnNames), function(z) gsub("\\s", "_", z), "", USE.NAMES = FALSE) - dfs <- lapply(json$table$rows, function(x){ - tmp <- data.frame(x, stringsAsFactors = FALSE) - names(tmp) <- colnames - tmp - }) - lists <- lapply(json$table$rows, setNames, nm=colnames) - names(lists) <- vapply(lists, function(b) b$variable_name, "", USE.NAMES = FALSE) - outout <- list() - for(i in seq_along(lists)){ - outout[[names(lists[i])]] <- unname(lists[ names(lists) %in% names(lists)[i] ]) - } - - df <- data.frame(rbindlist(dfs)) - vars <- df[ df$row_type == 'variable', names(df) %in% c('variable_name','data_type')] - actual <- vapply(split(df, df$variable_name), function(z){ - tmp <- z[ z$attribute_name %in% 'actual_range' , "value"] - if(length(tmp)==0) "" else tmp - }, "") - actualdf <- data.frame(variable_name=names(actual), actual_range=unname(actual)) - vars <- merge(vars, actualdf, by="variable_name") - oo <- lapply(outout, function(x) data.frame(rbindlist(x))) - structure(list(variables=vars, alldata=oo), - class="erddap_info", - datasetid=datasetid, - type=table_or_grid(datasetid)) -} - -#' @export -print.erddap_info <- function(x, ...){ - global <- x$alldata$NC_GLOBAL - tt <- global[ global$attribute_name %in% c('time_coverage_end','time_coverage_start'), "value", ] - dims <- x$alldata[dimvars(x)] - vars <- x$alldata[x$variables$variable_name] - cat(sprintf(" %s", attr(x, "datasetid")), "\n") - if(attr(x, "type") == "griddap") cat(" Dimensions (range): ", "\n") - for(i in seq_along(dims)){ - if(names(dims[i]) == "time"){ - cat(sprintf(" time: (%s, %s)", tt[2], tt[1]), "\n") - } else { - cat(sprintf(" %s: (%s)", names(dims[i]), foo(dims[[i]], "actual_range")), "\n") - } - } - cat(" Variables: ", "\n") - for(i in seq_along(vars)){ - cat(sprintf(" %s:", names(vars[i])), "\n") - ar <- foo(vars[[i]], "actual_range") - if(!length(ar) == 0) cat(" Range:", foo(vars[[i]], "actual_range"), "\n") - un <- foo(vars[[i]], "units") - if(!length(un) == 0) cat(" Units:", foo(vars[[i]], "units"), "\n") - } -} - -foo <- function(x, y){ - x[ x$attribute_name == y, "value"] -} - -#' @export -#' @rdname erddap_info -as.erddap_info <- function(x) UseMethod("as.erddap_info") - -#' @export -as.erddap_info.erddap_info <- function(x) x - -#' @export -as.erddap_info.character <- function(x) erddap_info(x) diff --git a/R/erddap_search.R b/R/erddap_search.R deleted file mode 100644 index 2777893c..00000000 --- a/R/erddap_search.R +++ /dev/null @@ -1,77 +0,0 @@ -#' Search for ERDDAP tabledep or griddap datasets. -#' -#' @export -#' -#' @param query (character) Search terms -#' @param page (integer) Page number -#' @param page_size (integer) Results per page -#' @param which (character) One of tabledep or griddap. -#' @param ... Further args passed on to \code{\link[httr]{GET}} (must be a named parameter) -#' @references \url{http://upwell.pfeg.noaa.gov/erddap/index.html} -#' @author Scott Chamberlain -#' @examples \dontrun{ -#' (out <- erddap_search(query='temperature')) -#' out$alldata[[1]] -#' (out <- erddap_search(query='size')) -#' out$info -#' -#' # List datasets -#' head( erddap_datasets('table') ) -#' head( erddap_datasets('grid') ) -#' } - -erddap_search <- function(query, page=NULL, page_size=NULL, which='griddap', ...){ - which <- match.arg(which, c("tabledap","griddap"), FALSE) - args <- noaa_compact(list(searchFor=query, page=page, itemsPerPage=page_size)) - json <- erddap_GET(paste0(eurl(), 'search/index.json'), args, ...) - colnames <- vapply(tolower(json$table$columnNames), function(z) gsub("\\s", "_", z), "", USE.NAMES = FALSE) - dfs <- lapply(json$table$rows, function(x){ - names(x) <- colnames - x <- x[c('title','dataset_id')] - data.frame(x, stringsAsFactors = FALSE) - }) - df <- data.frame(rbindlist(dfs)) - lists <- lapply(json$table$rows, setNames, nm=colnames) - df$gd <- vapply(lists, function(x) if(x$griddap == "") "tabledap" else "griddap", character(1)) - df <- df[ df$gd == which, -3 ] - res <- list(info=df, alldata=lists) - structure(res, class="erddap_search") -} - -#' @export -print.erddap_search <- function(x, ...){ - cat(sprintf("%s results, showing first 20", nrow(x$info)), "\n") - print(head(x$info, n = 20)) -} - -erddap_GET <- function(url, args, ...){ - tt <- GET(url, query=args, ...) - stop_for_status(tt) - stopifnot(tt$headers$`content-type` == 'application/json;charset=UTF-8') - out <- content(tt, as = "text") - jsonlite::fromJSON(out, FALSE) -} - -table_or_grid <- function(datasetid){ - table_url <- paste0(eurl(), 'tabledap/index.json') - tab <- toghelper(table_url) - if(datasetid %in% tab) "tabledap" else "griddap" -} - -toghelper <- function(url){ - out <- erddap_GET(url, list(page=1, itemsPerPage=10000L)) - nms <- out$table$columnNames - lists <- lapply(out$table$rows, setNames, nm=nms) - vapply(lists, "[[", "", "Dataset ID") -} - -#' @export -#' @rdname erddap_search -erddap_datasets <- function(which = 'tabledap'){ - which <- match.arg(which, c("tabledap","griddap"), FALSE) - url <- sprintf('%s%s/index.json', eurl(), which) - out <- erddap_GET(url, list(page=1, itemsPerPage=10000L)) - nms <- out$table$columnNames - lists <- lapply(out$table$rows, setNames, nm=nms) - data.frame(rbindlist(lapply(lists, data.frame)), stringsAsFactors = FALSE) -} diff --git a/R/erddap_table.R b/R/erddap_table.R deleted file mode 100644 index 3cfef1e5..00000000 --- a/R/erddap_table.R +++ /dev/null @@ -1,230 +0,0 @@ -#' Get ERDDAP tabledap data. -#' -#' @export -#' -#' @param x Anything coercable to an object of class erddap_info. So the output of a call to -#' \code{erddap_info}, or a datasetid, which will internally be passed through \code{erddap_info}. -#' @param ... Any number of key-value pairs in quotes as query constraints. See Details & examples -#' @param fields Columns to return, as a character vector -#' @param distinct If TRUE ERDDAP will sort all of the rows in the results table (starting with the -#' first requested variable, then using the second requested variable if the first variable has a -#' tie, ...), then remove all non-unique rows of data. In many situations, ERDDAP can return -#' distinct values quickly and efficiently. But in some cases, ERDDAP must look through all rows -#' of the source dataset. -#' @param orderby If used, ERDDAP will sort all of the rows in the results table (starting with the -#' first variable, then using the second variable if the first variable has a tie, ...). Normally, -#' the rows of data in the response table are in the order they arrived from the data source. -#' orderBy allows you to request that the results table be sorted in a specific way. For example, -#' use \code{orderby=c("stationID,time")} to get the results sorted by stationID, then time. The -#' orderby variables MUST be included in the list of requested variables in the fields parameter. -#' @param orderbymax Give a vector of one or more fields, that must be included in the fields -#' parameter as well. Gives back data given constraints. ERDDAP will sort all of the rows in the -#' results table (starting with the first variable, then using the second variable if the first -#' variable has a tie, ...) and then just keeps the rows where the value of the last sort variable -#' is highest (for each combination of other values). -#' @param orderbymin Same as \code{orderbymax} parameter, except returns minimum value. -#' @param orderbyminmax Same as \code{orderbymax} parameter, except returns two rows for every -#' combination of the n-1 variables: one row with the minimum value, and one row with the maximum -#' value. -#' @param units One of 'udunits' (units will be described via the UDUNITS standard (e.g.,degrees_C)) -#' or 'ucum' (units will be described via the UCUM standard (e.g., Cel)). -#' @param store One of \code{disk} (default) or \code{memory}. You can pass options to \code{disk}. -#' See Details. -#' @param callopts Further args passed on to \code{\link[httr]{GET}} -#' -#' @details Details: -#' -#' @section Variables: -#' For key-value pair query constraints, the valid operators are =, != (not equals), =~ (a regular -#' expression test), <, <=, >, and >= . For regular expressions you need to add a regular -#' expression. For others, nothing more is needed. Construct the entry like -#' \code{'time>=2001-07-07'} with the parameter on the left, value on the right, and the operator -#' in the middle, all within a set of quotes. Since ERDDAP accepts values other than \code{=}, we -#' can't simply do \code{time = '2001-07-07'} as we normally would. -#' -#' @section Server-side functionality: -#' Some tasks are done server side. You don't have to worry about what -#' that means. They are provided via parameters in this function. See \code{distinct}, -#' \code{orderby}, \code{orderbymax}, \code{orderbymin}, \code{orderbyminmax}, and \code{units}. -#' -#' @section Where does the data go?: -#' You can choose where data is stored. Be careful though. With griddap data, you can easily get a -#' single file of hundreds of MB's or GB's in size with a single request. Using \code{disk()} -#' caches files based on the URL of the request you perform, which is the combination of all -#' parameters passed in, so if you refine a query by certain fields, etc., you will cach a -#' different file. If you choose \code{overwrite=TRUE} within the \code{disk()} function then -#' you'll force writing a new file to disk. When you use \code{memory()}, no files are cached, -#' data is stored in R's memory. -#' -#' @references \url{http://upwell.pfeg.noaa.gov/erddap/index.html} -#' @seealso \code{\link{erddap_grid}} \code{\link{erddap_clear_cache}} -#' @author Scott Chamberlain -#' @examples \dontrun{ -#' # Just passing the datasetid without fields gives all columns back -#' erddap_table('erdCalCOFIfshsiz') -#' -#' # Pass time constraints -#' erddap_table('erdCalCOFIfshsiz', 'time>=2001-07-07', 'time<=2001-07-08') -#' -#' # Pass in fields (i.e., columns to retrieve) & time constraints -#' erddap_table('erdCalCOFIfshsiz','time>=2001-07-07','time<=2001-07-10', -#' fields=c('longitude','latitude','fish_size','itis_tsn')) -#' erddap_table('erdCinpKfmBT', fields=c('latitude','longitude', -#' 'Aplysia_californica_Mean_Density','Muricea_californica_Mean_Density'), -#' 'time>=2007-06-24','time<=2007-07-01') -#' -#' # Get info on a datasetid, then get data given information learned -#' erddap_info('erdCalCOFIlrvsiz')$variables -#' erddap_table('erdCalCOFIlrvsiz', fields=c('latitude','longitude','larvae_size', -#' 'itis_tsn'), 'time>=2011-10-25', 'time<=2011-10-31') -#' -#' # An example workflow -#' ## Search for data -#' (out <- erddap_search(query='fish', which = 'table')) -#' ## Using a datasetid, search for information on a datasetid -#' id <- out$info$dataset_id[7] -#' erddap_info(id)$variables -#' ## Get data from the dataset -#' erddap_table(id, fields = c('fish','landings','year')) -#' -#' # Time constraint -#' ## Limit by time with date only -#' (info <- erddap_info('erdCalCOFIfshsiz')) -#' erddap_table(info, fields = c('latitude','longitude','scientific_name'), -#' 'time>=2001-07-14') -#' -#' # Use distinct parameter -#' erddap_table('erdCalCOFIfshsiz',fields=c('longitude','latitude','fish_size','itis_tsn'), -#' 'time>=2001-07-07','time<=2001-07-10', distinct=TRUE) -#' -#' # Use units parameter -#' ## In this example, values are the same, but sometimes they can be different given the units -#' ## value passed -#' erddap_table('erdCinpKfmT', 'time>=2007-09-19', 'time<=2007-09-21', -#' fields=c('longitude','latitude','time','temperature'), units='udunits') -#' erddap_table('erdCinpKfmT', 'time>=2007-09-19', 'time<=2007-09-21', -#' fields=c('longitude','latitude','time','temperature'), units='ucum') -#' -#' # Use orderby parameter -#' erddap_table('erdCinpKfmT', fields=c('longitude','latitude','time','temperature'), -#' 'time>=2007-09-19', 'time<=2007-09-21', orderby='temperature') -#' # Use orderbymax parameter -#' erddap_table('erdCinpKfmT', fields=c('longitude','latitude','time','temperature'), -#' 'time>=2007-09-19', 'time<=2007-09-21', orderbymax='temperature') -#' # Use orderbymin parameter -#' erddap_table('erdCinpKfmT', fields=c('longitude','latitude','time','temperature'), -#' 'time>=2007-09-19', 'time<=2007-09-21', orderbymin='temperature') -#' # Use orderbyminmax parameter -#' erddap_table('erdCinpKfmT', fields=c('longitude','latitude','time','temperature'), -#' 'time>=2007-09-19', 'time<=2007-09-21', orderbyminmax='temperature') -#' # Use orderbymin parameter with multiple values -#' erddap_table('erdCinpKfmT', fields=c('longitude','latitude','time','depth','temperature'), -#' 'time>=2007-06-10', 'time<=2007-09-21', orderbymax=c('depth','temperature')) -#' -#' # Spatial delimitation -#' erddap_table('erdCalCOFIfshsiz', fields = c('latitude','longitude','scientific_name'), -#' 'latitude>=34.8', 'latitude<=35', 'longitude>=-125', 'longitude<=-124') -#' -#' # Integrate with taxize -#' out <- erddap_table('erdCalCOFIfshsiz', -#' fields = c('latitude','longitude','scientific_name','itis_tsn')) -#' tsns <- unique(out$itis_tsn[1:100]) -#' library("taxize") -#' classif <- classification(tsns, db = "itis") -#' head(rbind(classif)); tail(rbind(classif)) -#' -#' # Write to memory (within R), or to disk -#' (out <- erddap_info('erdCalCOFIfshsiz')) -#' ## disk, by default (to prevent bogging down system w/ large datasets) -#' ## you can also pass in path and overwrite options to disk() -#' erddap_table('erdCalCOFIfshsiz', store = disk()) -#' ## the 2nd call is much faster as it's mostly just the time of reading in the table from disk -#' system.time( erddap_table('erdCalCOFIfshsiz', store = disk()) ) -#' system.time( erddap_table('erdCalCOFIfshsiz', store = disk()) ) -#' ## memory -#' erddap_table(x='erdCalCOFIfshsiz', store = memory()) -#' } - -erddap_table <- function(x, ..., fields=NULL, distinct=FALSE, orderby=NULL, - orderbymax=NULL, orderbymin=NULL, orderbyminmax=NULL, units=NULL, - store = disk(), callopts=list()) -{ - x <- as.erddap_info(x) - fields <- paste(fields, collapse = ",") - url <- sprintf(paste0(eurl(), "tabledap/%s.csv?%s"), attr(x, "datasetid"), fields) - args <- list(...) - distinct <- if(distinct) 'distinct()' else NULL - units <- if(!is.null(units)) makevar(toupper(units), 'units("%s")') else units - orderby <- makevar(orderby, 'orderBy("%s")') - orderbymax <- makevar(orderbymax, 'orderByMax("%s")') - orderbymin <- makevar(orderbymin, 'orderByMin("%s")') - orderbyminmax <- makevar(orderbyminmax, 'orderByMinMax("%s")') - moreargs <- noaa_compact(list(distinct, orderby, orderbymax, orderbymin, orderbyminmax, units)) - args <- c(args, moreargs) - args <- lapply(args, function(x) RCurl::curlEscape(x)) - args <- paste0(args, collapse = "&") - if(!nchar(args[[1]]) == 0){ - url <- paste0(url, '&', args) - } - resp <- erd_tab_GET(url, dset=attr(x, "datasetid"), store, callopts) - loc <- if(store$store == "disk") resp else "memory" - structure(read_table(resp), class=c("erddap_table","data.frame"), datasetid=attr(x, "datasetid"), path=loc) -} - -#' @export -print.erddap_table <- function(x, ..., n = 10){ - cat(sprintf(" %s", attr(x, "datasetid")), sep = "\n") - cat(sprintf(" Path: [%s]", attr(x, "path")), sep = "\n") - if(attr(x, "path") != "memory"){ - finfo <- file_info(attr(x, "path")) - cat(sprintf(" Last updated: [%s]", finfo$mtime), sep = "\n") - cat(sprintf(" File size: [%s]", finfo$size), sep = "\n") - } - cat(sprintf(" Dimensions: [%s X %s]\n", NROW(x), NCOL(x)), sep = "\n") - trunc_mat_(x, n = n) -} - -erd_tab_GET <- function(url, dset, store, ...){ - if(store$store == "disk"){ - out <- suppressWarnings(cache_get(cache = TRUE, url = url, path = store$path)) - - if( !is.null( out ) && !store$overwrite ){ out } else { - dir.create(store$path, showWarnings = FALSE, recursive = TRUE) - res <- GET(url, write_disk(write_path(store$path, url), store$overwrite), ...) - out <- check_response_erddap(res) - if(res$status_code != 200) unlink(res$request$writer[[1]]) - if(grepl("Error", out, ignore.case = TRUE)) NA else res$request$writer[[1]] - } - } else { - res <- GET(url, ...) - out <- check_response_erddap(res) - if(grepl("Error", out, ignore.case = TRUE)) NA else res - } -} - -# erd_tab_GET <- function(url, dset, store, ...){ -# if(store$store == "disk"){ -# fpath <- path.expand(file.path(store$path, paste0(dset, ".csv"))) -# if( file.exists( fpath ) && !store$overwrite ){ fpath } else { -# dir.create(store$path, showWarnings = FALSE, recursive = TRUE) -# res <- GET(url, write_disk(writepath(store$path, dset), store$overwrite), ...) -# out <- check_response_erddap(res) -# if(grepl("Error", out, ignore.case = TRUE)) NA else res$request$writer[[1]] -# } -# } else { -# res <- GET(url, ...) -# out <- check_response_erddap(res) -# if(grepl("Error", out, ignore.case = TRUE)) NA else res -# } -# } - -makevar <- function(x, y){ - if(!is.null(x)){ - x <- paste0(x, collapse = ",") - sprintf(y, x) - } else { - NULL - } -} - -eurl <- function() "http://upwell.pfeg.noaa.gov/erddap/" diff --git a/R/erddap_utils.R b/R/erddap_utils.R deleted file mode 100644 index 7f22f63b..00000000 --- a/R/erddap_utils.R +++ /dev/null @@ -1,12 +0,0 @@ -#' Options for saving ERDDAP datasets. -#' -#' @export -#' @param path Path to store files in. Default: ~/.rnoaa/upwell -#' @param overwrite (logical) Overwrite an existing file of the same name? Default: TRUE -disk <- function(path = "~/.rnoaa/erddap", overwrite = FALSE){ - list(store="disk", path = path, overwrite = overwrite) -} - -#' @export -#' @rdname disk -memory <- function() list(store="memory") diff --git a/R/rnoaa-package.r b/R/rnoaa-package.r index 076e0353..b8c2864b 100644 --- a/R/rnoaa-package.r +++ b/R/rnoaa-package.r @@ -11,7 +11,6 @@ #' #' \itemize{ #' \item \code{buoy_*} - NOAA Buoy data, only on buoy branch in Github repo -#' \item \code{erddap_*} - NOAA ERDDAP vignette #' \item \code{ncdc_*} - NOAA National Climatic Data Center (NCDC) vignette (examples) #' \item \code{seaice} - Sea ice vignette #' \item \code{swdi} - Severe Weather Data Inventory (SWDI) vignette diff --git a/R/zzz.r b/R/zzz.r index 1ffa73a2..fe9232a7 100644 --- a/R/zzz.r +++ b/R/zzz.r @@ -11,7 +11,7 @@ is.ncdc_data <- function(x) inherits(x, "ncdc_data") #' @rdname is.ncdc_data #' @export -#' @keywords internal +#' @keywords internal is.ncdc_datasets <- function(x) inherits(x, "ncdc_datasets") #' @rdname is.ncdc_data @@ -128,32 +128,6 @@ check_response <- function(x){ } } -#' Check response from NOAA, including status codes, server error messages, mime-type, etc. -#' @keywords internal -check_response_erddap <- function(x, fmt){ - if(!x$status_code == 200){ - html <- content(x) - values <- xpathApply(html, "//u", xmlValue) - error <- grep("Error|Resource", values, ignore.case = TRUE, value = TRUE) - if(length(error) > 1) error <- error[1] - #check specifically for no matching results error - if(grepl("no matching results", error)) error <- 'Error: Your query produced no matching results.' - - if(!is.null(error)){ - if(grepl('Error|Resource not found', error, ignore.case = TRUE)){ - stop(sprintf("(%s) - %s", x$status_code, error), call. = FALSE) - } else { stop(sprintf("Error: (%s)", x$status_code), call. = FALSE) } - } else { stop_for_status(x) } - } else { - if(fmt == "csv"){ - stopifnot(x$headers$`content-type`=='text/csv;charset=UTF-8') - } else { - stopifnot(x$headers$`content-type`=='application/x-download') - } - return( x ) - } -} - #' Check response from NOAA SWDI service, including status codes, server error messages, #' mime-type, etc. #' @keywords internal @@ -195,28 +169,12 @@ read_csv <- function(x){ tmp } -read_upwell <- function(x, fmt){ - if(fmt == "csv"){ - if(is(x, "response")) { - x <- content(x, "text") - tmp <- read.csv(text = x, header = FALSE, sep = ",", stringsAsFactors=FALSE, skip = 2) - nmz <- names(read.csv(text = x, header = TRUE, sep = ",", stringsAsFactors=FALSE, nrows=1)) - } else { - tmp <- read.csv(x, header = FALSE, sep = ",", stringsAsFactors=FALSE, skip = 2) - nmz <- names(read.csv(x, header = TRUE, sep = ",", stringsAsFactors=FALSE, nrows=1)) - } - setNames(tmp, tolower(nmz)) - } else { - get_ncdf(x) - } -} - read_table <- function(x){ if(is(x, "response")) { txt <- gsub('\n$', '', content(x, "text")) read.csv(text = txt, sep = ",", stringsAsFactors=FALSE, blank.lines.skip=FALSE)[-1, , drop=FALSE] - } else { + } else { read.delim(x, sep=",", stringsAsFactors=FALSE, blank.lines.skip=FALSE)[-1, , drop=FALSE] } diff --git a/man/caching.Rd b/man/caching.Rd index 7e55da5c..acd7d488 100644 --- a/man/caching.Rd +++ b/man/caching.Rd @@ -2,12 +2,9 @@ % Please edit documentation in R/caching.R \name{caching} \alias{caching} -\alias{erddap_clear_cache} \alias{ghcnd_clear_cache} \title{Clear cached files} \usage{ -erddap_clear_cache(path = disk(), force = FALSE) - ghcnd_clear_cache(path = "~/.rnoaa/ghcnd", force = FALSE) } \arguments{ diff --git a/man/check_response_erddap.Rd b/man/check_response_erddap.Rd deleted file mode 100644 index 23d1bc76..00000000 --- a/man/check_response_erddap.Rd +++ /dev/null @@ -1,13 +0,0 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand -% Please edit documentation in R/zzz.r -\name{check_response_erddap} -\alias{check_response_erddap} -\title{Check response from NOAA, including status codes, server error messages, mime-type, etc.} -\usage{ -check_response_erddap(x, fmt) -} -\description{ -Check response from NOAA, including status codes, server error messages, mime-type, etc. -} -\keyword{internal} - diff --git a/man/disk.Rd b/man/disk.Rd deleted file mode 100644 index 76f27136..00000000 --- a/man/disk.Rd +++ /dev/null @@ -1,20 +0,0 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand -% Please edit documentation in R/erddap_utils.R -\name{disk} -\alias{disk} -\alias{memory} -\title{Options for saving ERDDAP datasets.} -\usage{ -disk(path = "~/.rnoaa/erddap", overwrite = FALSE) - -memory() -} -\arguments{ -\item{path}{Path to store files in. Default: ~/.rnoaa/upwell} - -\item{overwrite}{(logical) Overwrite an existing file of the same name? Default: TRUE} -} -\description{ -Options for saving ERDDAP datasets. -} - diff --git a/man/erddap.Rd b/man/erddap.Rd deleted file mode 100644 index d2a6634b..00000000 --- a/man/erddap.Rd +++ /dev/null @@ -1,42 +0,0 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand -% Please edit documentation in R/erddap.R -\name{erddap} -\alias{erddap} -\title{ERDDAP Information} -\description{ -NOAA's ERDDAP service holds many datasets of interest. It's built on top of -OPenDAP \url{http://www.opendap.org/}. You can search for datasets via -\code{\link{erddap_search}}, list datasets via \code{\link{erddap_datasets}}, -get information on a single dataset via \code{\link{erddap_info}}, then get -data you want for either tabledap type via \code{\link{erddap_table}}, or -for griddap type via \code{\link{erddap_grid}}. -} -\details{ -tabledap and griddap have different interfaces to query for data, so -\code{\link{erddap_table}} and \code{\link{erddap_grid}} are separated out as -separate functions even though some of the internals are the same. In particular, -with tabledap you can query on/subset all variables, whereas with gridddap, you can -only query on/subset the dimension varibles (e.g., latitude, longitude, altitude). - -\bold{NOTE:} With griddap data vai \code{\link{erddap_grid}} you can get a lot of -data quickly. Try small searches of a dataset to start to get a sense for the data, -then you can increase the amount of data you get. See \code{\link{erddap_grid}} -for more details. - -The following are the ERDDAP functions: - -\itemize{ - \item \code{\link{erddap_search}} - \item \code{\link{erddap_datasets}} - \item \code{\link{erddap_info}} - \item \code{\link{erddap_table}} - \item \code{\link{erddap_grid}} -} -} -\author{ -Scott Chamberlain -} -\references{ -\url{http://upwell.pfeg.noaa.gov/erddap/index.html} -} - diff --git a/man/erddap_clear_cache-defunct.Rd b/man/erddap_clear_cache-defunct.Rd new file mode 100644 index 00000000..44e3a660 --- /dev/null +++ b/man/erddap_clear_cache-defunct.Rd @@ -0,0 +1,13 @@ +% Generated by roxygen2 (4.1.1): do not edit by hand +% Please edit documentation in R/defunct.R +\name{erddap_clear_cache} +\alias{erddap_clear_cache} +\title{This function is defunct.} +\usage{ +erddap_clear_cache() +} +\description{ +This function is defunct. +} +\keyword{internal} + diff --git a/man/erddap_datasets-defunct.Rd b/man/erddap_datasets-defunct.Rd new file mode 100644 index 00000000..4f660eee --- /dev/null +++ b/man/erddap_datasets-defunct.Rd @@ -0,0 +1,13 @@ +% Generated by roxygen2 (4.1.1): do not edit by hand +% Please edit documentation in R/defunct.R +\name{erddap_datasets} +\alias{erddap_datasets} +\title{This function is defunct.} +\usage{ +erddap_datasets() +} +\description{ +This function is defunct. +} +\keyword{internal} + diff --git a/man/erddap_grid-defunct.Rd b/man/erddap_grid-defunct.Rd new file mode 100644 index 00000000..f1f4af99 --- /dev/null +++ b/man/erddap_grid-defunct.Rd @@ -0,0 +1,13 @@ +% Generated by roxygen2 (4.1.1): do not edit by hand +% Please edit documentation in R/defunct.R +\name{erddap_grid} +\alias{erddap_grid} +\title{This function is defunct.} +\usage{ +erddap_grid() +} +\description{ +This function is defunct. +} +\keyword{internal} + diff --git a/man/erddap_grid.Rd b/man/erddap_grid.Rd deleted file mode 100644 index c93ca832..00000000 --- a/man/erddap_grid.Rd +++ /dev/null @@ -1,152 +0,0 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand -% Please edit documentation in R/erddap_grid.R -\name{erddap_grid} -\alias{erddap_grid} -\title{Get ERDDAP griddap data.} -\usage{ -erddap_grid(x, ..., fields = "all", stride = 1, fmt = "csv", - store = disk(), callopts = list()) -} -\arguments{ -\item{x}{Anything coercable to an object of class erddap_info. So the output of a call to -\code{erddap_info}, or a datasetid, which will internally be passed through \code{erddap_info}.} - -\item{...}{Dimension arguments.} - -\item{fields}{Fields to return, a character vector.} - -\item{stride}{(integer) How many values to get. 1 = get every value, 2 = get every other value, -etc. Default: 1 (i.e., get every value)} - -\item{fmt}{(character) One of csv (default) or ncdf} - -\item{store}{One of \code{disk} (default) or \code{memory}. You can pass options to \code{disk}} - -\item{callopts}{Pass on curl options to \code{\link[httr]{GET}}} -} -\description{ -Get ERDDAP griddap data. -} -\details{ -Details: -} -\section{Dimensions and Variables}{ - -ERDDAP grid dap data has this concept of dimenions vs. variables. So, dimensions are things -like time, latitude, longitude, and altitude. Whereas variables are the measured variables, -e.g., temperature, salinity, and air. - -You can't separately adjust values for dimensions for different variables. So, here's how it's -gonna work: - -Pass in lower and upper limits you want for each dimension as a vector (e.g., \code{c(1,2)}), -or leave to defaults (i.e., don't pass anything to a dimension). Then pick which variables -you want returned via the \code{fields} parameter. If you don't pass in options to the -\code{fields} parameter, you get all variables back. - -To get the dimensions and variables, along with other metadata for a dataset, run -\code{erddap_info}, and each will be shown, with their min and max values, and some -other metadata. -} - -\section{Where does the data go?}{ - -You can choose where data is stored. Be careful though. With griddap data, you can easily get a -single file of hundreds of MB's or GB's in size with a single request. Using \code{disk()} -caches files based on the URL of the request you perform, which is the combination of all -parameters passed in, so if you refine a query by certain fields, etc., you will cach a -different file. If you choose \code{overwrite=TRUE} within the \code{disk()} function then -you'll force writing a new file to disk. When you use \code{memory()}, no files are cached, -data is stored in R's memory. -} -\examples{ -\dontrun{ -# single variable dataset -## You can pass in the outpu of a call to erddap_info -(out <- erddap_info('noaa_esrl_027d_0fb5_5d38')) -(res <- erddap_grid(out, - time = c('2012-01-01','2012-06-12'), - latitude = c(21, 18), - longitude = c(-80, -75) -)) -## Or, pass in a dataset id -(res <- erddap_grid(x='noaa_esrl_027d_0fb5_5d38', - time = c('2012-01-01','2012-06-12'), - latitude = c(21, 18), - longitude = c(-80, -75) -)) - -# multi-variable dataset -(out <- erddap_info('noaa_gfdl_5081_7d4a_7570')) -(res <- erddap_grid(out, - time = c('2005-11-01','2006-01-01'), - latitude = c(20, 21), - longitude = c(10, 11) -)) -(res <- erddap_grid(out, time = c('2005-11-01','2006-01-01'), latitude = c(20, 21), - longitude = c(10, 11), fields = 'uo')) -(res <- erddap_grid(out, time = c('2005-11-01','2006-01-01'), latitude = c(20, 21), - longitude = c(10, 11), fields = 'uo', stride=c(1,2,1,2))) -(res <- erddap_grid(out, time = c('2005-11-01','2006-01-01'), latitude = c(20, 21), - longitude = c(10, 11), fields = c('uo','so'))) -(res <- erddap_grid(out, time = c('2005-09-01','2006-01-01'), latitude = c(20, 21), - longitude = c(10, 11), fields = 'none')) - -# multi-variable dataset -## this one also has a 0-360 longitude system, BLARGH!!! -(out <- erddap_info('noaa_gfdl_3c96_7879_a9d3')) -(res <- erddap_grid(out, - time = c('2005-11-01','2006-01-01'), - latitude = c(20, 22), - longitude = c(-80, -75) -)) -(res <- erddap_grid(out, - time = c('2005-11-01','2006-01-01'), - latitude = c(20, 22), - longitude = c(-80, -75), - depth = c(5, 50) -)) - -# Write to memory (within R), or to disk -(out <- erddap_info('noaa_pfeg_e9ae_3356_22f8')) -## disk, by default (to prevent bogging down system w/ large datasets) -## you can also pass in path and overwrite options to disk() -(res <- erddap_grid(out, - time = c('2012-06-01','2012-06-12'), - latitude = c(20, 21), - longitude = c(-80, -75), - store = disk() -)) -## the 2nd call is much faster as it's mostly just the time of reading in the table from disk -system.time( erddap_grid(out, - time = c('2012-06-01','2012-06-12'), - latitude = c(20, 21), - longitude = c(-80, -75), - store = disk() -) ) -system.time( erddap_grid(out, - time = c('2012-06-01','2012-06-12'), - latitude = c(20, 21), - longitude = c(-80, -75), - store = disk() -) ) - -## memory -(res <- erddap_grid(out, - time = c('2012-06-01','2012-06-12'), - latitude = c(20, 21), - longitude = c(-80, -75), - store = memory() -)) -} -} -\author{ -Scott Chamberlain -} -\references{ -\url{http://upwell.pfeg.noaa.gov/erddap/index.html} -} -\seealso{ -\code{\link{erddap_table}} \code{\link{erddap_clear_cache}} -} - diff --git a/man/erddap_info-defunct.Rd b/man/erddap_info-defunct.Rd new file mode 100644 index 00000000..964a98a4 --- /dev/null +++ b/man/erddap_info-defunct.Rd @@ -0,0 +1,13 @@ +% Generated by roxygen2 (4.1.1): do not edit by hand +% Please edit documentation in R/defunct.R +\name{erddap_info} +\alias{erddap_info} +\title{This function is defunct.} +\usage{ +erddap_info() +} +\description{ +This function is defunct. +} +\keyword{internal} + diff --git a/man/erddap_info.Rd b/man/erddap_info.Rd deleted file mode 100644 index d3bf572b..00000000 --- a/man/erddap_info.Rd +++ /dev/null @@ -1,89 +0,0 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand -% Please edit documentation in R/erddap_info.R -\name{erddap_info} -\alias{as.erddap_info} -\alias{erddap_info} -\title{Get information on an ERDDAP dataset.} -\usage{ -erddap_info(datasetid, ...) - -as.erddap_info(x) -} -\arguments{ -\item{datasetid}{Dataset id} - -\item{...}{Further args passed on to \code{\link[httr]{GET}} (must be a named parameter)} - -\item{x}{A datasetid or the output of \code{erddap_info}} -} -\value{ -Prints a summary of the data on return, but you can index to various information. - -The data is a list of length two with: -\itemize{ - \item variables - Data.frame of variables and their types - \item alldata - List of data variables and their full attributes -} -Where \code{alldata} element has many data.frame's, one for each variable, with metadata -for that variable. E.g., for griddap dataset \code{noaa_pfeg_696e_ec99_6fa6}, \code{alldata} -has: -\itemize{ - \item NC_GLOBAL - \item time - \item latitude - \item longitude - \item sss -} -} -\description{ -Get information on an ERDDAP dataset. -} -\examples{ -\dontrun{ -# grid dap datasets -erddap_info('noaa_pfeg_696e_ec99_6fa6') -erddap_info('noaa_ngdc_34bf_a95c_7e28') - -(out <- erddap_search(query='temperature')) -erddap_info(out$info$dataset_id[5]) -erddap_info(out$info$dataset_id[15]) -erddap_info(out$info$dataset_id[25]) -erddap_info(out$info$dataset_id[33]) -erddap_info(out$info$dataset_id[65]) -erddap_info(out$info$dataset_id[150]) -erddap_info(out$info$dataset_id[400]) -erddap_info(out$info$dataset_id[678]) - -out <- erddap_info(datasetid='noaa_ngdc_34bf_a95c_7e28') -## See brief overview of the variables and range of possible values, if given -out$variables -## all information on longitude -out$alldata$longitude -## all information on Climatological_Temperature -out$alldata$Climatological_Temperature - -# table dap datasets -(out <- erddap_search(query='temperature', which = "table")) -erddap_info(out$info$dataset_id[1]) -erddap_info(out$info$dataset_id[2]) -erddap_info(out$info$dataset_id[3]) -erddap_info(out$info$dataset_id[4]) -erddap_info(out$info$dataset_id[54]) - -erddap_info(datasetid='erdCalCOFIfshsiz') -out <- erddap_info(datasetid='erdCinpKfmBT') -## See brief overview of the variables and range of possible values, if given -out$variables -## all information on longitude -out$alldata$longitude -## all information on Haliotis_corrugata_Mean_Density -out$alldata$Haliotis_corrugata_Mean_Density -} -} -\author{ -Scott Chamberlain -} -\references{ -\url{http://upwell.pfeg.noaa.gov/erddap/index.html} -} - diff --git a/man/erddap_search-defunct.Rd b/man/erddap_search-defunct.Rd new file mode 100644 index 00000000..2984872d --- /dev/null +++ b/man/erddap_search-defunct.Rd @@ -0,0 +1,13 @@ +% Generated by roxygen2 (4.1.1): do not edit by hand +% Please edit documentation in R/defunct.R +\name{erddap_search} +\alias{erddap_search} +\title{This function is defunct.} +\usage{ +erddap_search() +} +\description{ +This function is defunct. +} +\keyword{internal} + diff --git a/man/erddap_search.Rd b/man/erddap_search.Rd deleted file mode 100644 index 48462273..00000000 --- a/man/erddap_search.Rd +++ /dev/null @@ -1,45 +0,0 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand -% Please edit documentation in R/erddap_search.R -\name{erddap_search} -\alias{erddap_datasets} -\alias{erddap_search} -\title{Search for ERDDAP tabledep or griddap datasets.} -\usage{ -erddap_search(query, page = NULL, page_size = NULL, which = "griddap", - ...) - -erddap_datasets(which = "tabledap") -} -\arguments{ -\item{query}{(character) Search terms} - -\item{page}{(integer) Page number} - -\item{page_size}{(integer) Results per page} - -\item{which}{(character) One of tabledep or griddap.} - -\item{...}{Further args passed on to \code{\link[httr]{GET}} (must be a named parameter)} -} -\description{ -Search for ERDDAP tabledep or griddap datasets. -} -\examples{ -\dontrun{ -(out <- erddap_search(query='temperature')) -out$alldata[[1]] -(out <- erddap_search(query='size')) -out$info - -# List datasets -head( erddap_datasets('table') ) -head( erddap_datasets('grid') ) -} -} -\author{ -Scott Chamberlain -} -\references{ -\url{http://upwell.pfeg.noaa.gov/erddap/index.html} -} - diff --git a/man/erddap_table-defunct.Rd b/man/erddap_table-defunct.Rd new file mode 100644 index 00000000..de5a8627 --- /dev/null +++ b/man/erddap_table-defunct.Rd @@ -0,0 +1,13 @@ +% Generated by roxygen2 (4.1.1): do not edit by hand +% Please edit documentation in R/defunct.R +\name{erddap_table} +\alias{erddap_table} +\title{This function is defunct.} +\usage{ +erddap_table() +} +\description{ +This function is defunct. +} +\keyword{internal} + diff --git a/man/erddap_table.Rd b/man/erddap_table.Rd deleted file mode 100644 index bce7832f..00000000 --- a/man/erddap_table.Rd +++ /dev/null @@ -1,181 +0,0 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand -% Please edit documentation in R/erddap_table.R -\name{erddap_table} -\alias{erddap_table} -\title{Get ERDDAP tabledap data.} -\usage{ -erddap_table(x, ..., fields = NULL, distinct = FALSE, orderby = NULL, - orderbymax = NULL, orderbymin = NULL, orderbyminmax = NULL, - units = NULL, store = disk(), callopts = list()) -} -\arguments{ -\item{x}{Anything coercable to an object of class erddap_info. So the output of a call to -\code{erddap_info}, or a datasetid, which will internally be passed through \code{erddap_info}.} - -\item{...}{Any number of key-value pairs in quotes as query constraints. See Details & examples} - -\item{fields}{Columns to return, as a character vector} - -\item{distinct}{If TRUE ERDDAP will sort all of the rows in the results table (starting with the -first requested variable, then using the second requested variable if the first variable has a -tie, ...), then remove all non-unique rows of data. In many situations, ERDDAP can return -distinct values quickly and efficiently. But in some cases, ERDDAP must look through all rows -of the source dataset.} - -\item{orderby}{If used, ERDDAP will sort all of the rows in the results table (starting with the -first variable, then using the second variable if the first variable has a tie, ...). Normally, -the rows of data in the response table are in the order they arrived from the data source. -orderBy allows you to request that the results table be sorted in a specific way. For example, -use \code{orderby=c("stationID,time")} to get the results sorted by stationID, then time. The -orderby variables MUST be included in the list of requested variables in the fields parameter.} - -\item{orderbymax}{Give a vector of one or more fields, that must be included in the fields -parameter as well. Gives back data given constraints. ERDDAP will sort all of the rows in the -results table (starting with the first variable, then using the second variable if the first -variable has a tie, ...) and then just keeps the rows where the value of the last sort variable -is highest (for each combination of other values).} - -\item{orderbymin}{Same as \code{orderbymax} parameter, except returns minimum value.} - -\item{orderbyminmax}{Same as \code{orderbymax} parameter, except returns two rows for every -combination of the n-1 variables: one row with the minimum value, and one row with the maximum -value.} - -\item{units}{One of 'udunits' (units will be described via the UDUNITS standard (e.g.,degrees_C)) -or 'ucum' (units will be described via the UCUM standard (e.g., Cel)).} - -\item{store}{One of \code{disk} (default) or \code{memory}. You can pass options to \code{disk}. -See Details.} - -\item{callopts}{Further args passed on to \code{\link[httr]{GET}}} -} -\description{ -Get ERDDAP tabledap data. -} -\details{ -Details: -} -\section{Variables}{ - -For key-value pair query constraints, the valid operators are =, != (not equals), =~ (a regular -expression test), <, <=, >, and >= . For regular expressions you need to add a regular -expression. For others, nothing more is needed. Construct the entry like -\code{'time>=2001-07-07'} with the parameter on the left, value on the right, and the operator -in the middle, all within a set of quotes. Since ERDDAP accepts values other than \code{=}, we -can't simply do \code{time = '2001-07-07'} as we normally would. -} - -\section{Server-side functionality}{ - -Some tasks are done server side. You don't have to worry about what -that means. They are provided via parameters in this function. See \code{distinct}, -\code{orderby}, \code{orderbymax}, \code{orderbymin}, \code{orderbyminmax}, and \code{units}. -} - -\section{Where does the data go?}{ - -You can choose where data is stored. Be careful though. With griddap data, you can easily get a -single file of hundreds of MB's or GB's in size with a single request. Using \code{disk()} -caches files based on the URL of the request you perform, which is the combination of all -parameters passed in, so if you refine a query by certain fields, etc., you will cach a -different file. If you choose \code{overwrite=TRUE} within the \code{disk()} function then -you'll force writing a new file to disk. When you use \code{memory()}, no files are cached, -data is stored in R's memory. -} -\examples{ -\dontrun{ -# Just passing the datasetid without fields gives all columns back -erddap_table('erdCalCOFIfshsiz') - -# Pass time constraints -erddap_table('erdCalCOFIfshsiz', 'time>=2001-07-07', 'time<=2001-07-08') - -# Pass in fields (i.e., columns to retrieve) & time constraints -erddap_table('erdCalCOFIfshsiz','time>=2001-07-07','time<=2001-07-10', - fields=c('longitude','latitude','fish_size','itis_tsn')) -erddap_table('erdCinpKfmBT', fields=c('latitude','longitude', - 'Aplysia_californica_Mean_Density','Muricea_californica_Mean_Density'), - 'time>=2007-06-24','time<=2007-07-01') - -# Get info on a datasetid, then get data given information learned -erddap_info('erdCalCOFIlrvsiz')$variables -erddap_table('erdCalCOFIlrvsiz', fields=c('latitude','longitude','larvae_size', - 'itis_tsn'), 'time>=2011-10-25', 'time<=2011-10-31') - -# An example workflow -## Search for data -(out <- erddap_search(query='fish', which = 'table')) -## Using a datasetid, search for information on a datasetid -id <- out$info$dataset_id[7] -erddap_info(id)$variables -## Get data from the dataset -erddap_table(id, fields = c('fish','landings','year')) - -# Time constraint -## Limit by time with date only -(info <- erddap_info('erdCalCOFIfshsiz')) -erddap_table(info, fields = c('latitude','longitude','scientific_name'), - 'time>=2001-07-14') - -# Use distinct parameter -erddap_table('erdCalCOFIfshsiz',fields=c('longitude','latitude','fish_size','itis_tsn'), - 'time>=2001-07-07','time<=2001-07-10', distinct=TRUE) - -# Use units parameter -## In this example, values are the same, but sometimes they can be different given the units -## value passed -erddap_table('erdCinpKfmT', 'time>=2007-09-19', 'time<=2007-09-21', - fields=c('longitude','latitude','time','temperature'), units='udunits') -erddap_table('erdCinpKfmT', 'time>=2007-09-19', 'time<=2007-09-21', - fields=c('longitude','latitude','time','temperature'), units='ucum') - -# Use orderby parameter -erddap_table('erdCinpKfmT', fields=c('longitude','latitude','time','temperature'), - 'time>=2007-09-19', 'time<=2007-09-21', orderby='temperature') -# Use orderbymax parameter -erddap_table('erdCinpKfmT', fields=c('longitude','latitude','time','temperature'), - 'time>=2007-09-19', 'time<=2007-09-21', orderbymax='temperature') -# Use orderbymin parameter -erddap_table('erdCinpKfmT', fields=c('longitude','latitude','time','temperature'), - 'time>=2007-09-19', 'time<=2007-09-21', orderbymin='temperature') -# Use orderbyminmax parameter -erddap_table('erdCinpKfmT', fields=c('longitude','latitude','time','temperature'), - 'time>=2007-09-19', 'time<=2007-09-21', orderbyminmax='temperature') -# Use orderbymin parameter with multiple values -erddap_table('erdCinpKfmT', fields=c('longitude','latitude','time','depth','temperature'), - 'time>=2007-06-10', 'time<=2007-09-21', orderbymax=c('depth','temperature')) - -# Spatial delimitation -erddap_table('erdCalCOFIfshsiz', fields = c('latitude','longitude','scientific_name'), - 'latitude>=34.8', 'latitude<=35', 'longitude>=-125', 'longitude<=-124') - -# Integrate with taxize -out <- erddap_table('erdCalCOFIfshsiz', - fields = c('latitude','longitude','scientific_name','itis_tsn')) -tsns <- unique(out$itis_tsn[1:100]) -library("taxize") -classif <- classification(tsns, db = "itis") -head(rbind(classif)); tail(rbind(classif)) - -# Write to memory (within R), or to disk -(out <- erddap_info('erdCalCOFIfshsiz')) -## disk, by default (to prevent bogging down system w/ large datasets) -## you can also pass in path and overwrite options to disk() -erddap_table('erdCalCOFIfshsiz', store = disk()) -## the 2nd call is much faster as it's mostly just the time of reading in the table from disk -system.time( erddap_table('erdCalCOFIfshsiz', store = disk()) ) -system.time( erddap_table('erdCalCOFIfshsiz', store = disk()) ) -## memory -erddap_table(x='erdCalCOFIfshsiz', store = memory()) -} -} -\author{ -Scott Chamberlain -} -\references{ -\url{http://upwell.pfeg.noaa.gov/erddap/index.html} -} -\seealso{ -\code{\link{erddap_grid}} \code{\link{erddap_clear_cache}} -} - diff --git a/man/rnoaa-defunct.Rd b/man/rnoaa-defunct.Rd index 92f37ca0..708a5d18 100644 --- a/man/rnoaa-defunct.Rd +++ b/man/rnoaa-defunct.Rd @@ -15,8 +15,18 @@ \item \code{\link{noaa_plot}}: Function name changed, prefixed with ncdc now \item \code{\link{noaa_combine}}: Function name changed, prefixed with ncdc now \item \code{\link{noaa_seaice}}: Function name changed to seaice - \item \code{\link{erddap_data}}: See the function \code{\link{erddap_grid}} for getting - griddap data and \code{\link{erddap_table}} for getting tabledap data. + \item \code{\link{erddap_data}}: See package rerddap + \item \code{\link{erddap_clear_cache}}: See package rerddap + \item \code{\link{erddap_datasets}}: Moved to \code{\link[rerddap]{ed_datasets}} in + package rerddap + \item \code{\link{erddap_grid}}: Moved to \code{\link[rerddap]{griddap}} in package + rerddap + \item \code{\link{erddap_info}}: Moved to \code{\link[rerddap]{info}} in package + rerddap + \item \code{\link{erddap_search}}: Moved to \code{\link[rerddap]{ed_search}} in + package rerddap + \item \code{\link{erddap_table}}: Moved to \code{\link[rerddap]{tabledap}} in + package rerddap } } diff --git a/man/rnoaa-package.Rd b/man/rnoaa-package.Rd index 8e466f57..f656c16f 100644 --- a/man/rnoaa-package.Rd +++ b/man/rnoaa-package.Rd @@ -20,7 +20,6 @@ are: \itemize{ \item \code{buoy_*} - NOAA Buoy data, only on buoy branch in Github repo - \item \code{erddap_*} - NOAA ERDDAP vignette \item \code{ncdc_*} - NOAA National Climatic Data Center (NCDC) vignette (examples) \item \code{seaice} - Sea ice vignette \item \code{swdi} - Severe Weather Data Inventory (SWDI) vignette