dc.argo: Download and Cache an Argo Dataset

Description Usage Arguments Details Value Caution Author(s) References See Also Examples

View source: R/argo.R

Description

Download and cache data from an argo profiling float.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
dc.argo(
  id,
  longitude,
  latitude,
  time,
  server = "ftp://usgodae.org",
  destdir = ".",
  destfile,
  force = FALSE,
  dryrun = FALSE,
  debug = getOption("dcDebug", 0)
)

Arguments

id

a character string giving the float ID to be queried. argo float. If this is provided, then longitude, latitude and time are ignored, and dc.argo() downloads a file that contains all the profiles for the named float. FIXME/dk: I think this text is garbled and out of date.

longitude

Two-element numerical vector holding the limits of longitude (degrees East) to search for Argo profiles.

latitude

Two-element numerical vector holding the latitude limits (degrees North).

time

Two-element character vector holding the time limits in YYYY-MM-DD format.

server

character value giving the base name of the server, used in the construction of URL queries. Since servers tend to change over time, this is a good argument to check, when debugging code that once worked but now fails.

destdir

character value indicating the directory in which to store downloaded files. The default value of "." means to store the downloaded file in the present working directory. Set destdir=NULL if destfile is a filename with full path information. File clutter is reduced by creating a top-level directory called data, with subdirectories for various file types; see “Examples”.

destfile

character value indicating the name of the file. If not supplied, then the file name is constructed from the other parameters of the function call, so that subsequent calls with the same parameters will yield the same result; this is useful for caching.

force

A logical value that indicates whether to force the download, even if the pathname constructed from destdir and destfile already exists.

dryrun

A logical value that indicates whether to return the constructed web query, without attempting to download the file. This can be helpful in designing responses to changing URLs.

debug

an integer specifying whether debugging information is to be printed during processing. The printing is done by a call to dcDebug(). Setting debug=0 turns off this form of debugging, while higher values yield more information. If one dc function calls another, it passes the value of debug but decreased by 1, which means that the value of debug controls not just the breadth of debugging, but also the depth.

Details

dc.argoById() downloads data for the float with a specified identifier, dc.argoSearch() downloads the most recent profile for all floats in a specified longitude, latitude, and time box, and dc.argo is a wrapper that calls either of the first two functions, depending on whether the id argument is provided.

In any case, the downloads are made from the USGODAE server (ref 1) by default (or from any other server that obeys the same directory structure). Since the servers do not provide an API for such downloads, the dc.argo* functions are forced to work by constructing URLs that are devised based on inspection of queries constructed from a GUI-style webpage (ref 2). This leads to a brittleness that is discussed in “Caution”.

Value

String indicating the full pathname to the downloaded file.

Caution

The queries used by the dc.argo functions will fail if USGODAE changes their system. For an example, USGODAE presently looks for the substring ".submit=++Go++" in the query, but if this were to be switched to ".submit=Go", a seemingly trivial change, then dc.argo would fail entirely. For this reason, the read.argo* functions may fail at any time. Users who encounter this problem should contact the author, who may be able to find a way to reverse-engineer the updated Argo system.

Author(s)

Dan Kelley

References

  1. http://.usgodae.org

  2. http://www.usgodae.org/cgi-bin/argo_select.pl

See Also

Other functions related to argo data: dc.argoById(), dc.argoIndex(), dc.argoSearch()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
library(dc)
## Not run: 
library(oce)
## 1. Get float profiles near Nova Scotia on Remembrance Day, 2017,
##    and plot the first one as a CTD.
n <- dc.argo(longitude=c(-65,-55), latitude=c(40,50),
             time=c("2017-11-11","2017-11-11"), destdir="~/data/argo")
a <- read.argo(n[1])
plotTS(as.ctd(a))

## 2. All profiles for a particular float.
N <- dc.argo(id="4902912", destdir="~/data/argo")
A <- read.argo(N)
plot(A, type="l") # trajectory

## End(Not run)

dankelley/dac documentation built on June 4, 2020, 11:45 p.m.