dod.ctd.bbmp can retrieve both index files and data files from the Bedford Basin Mooring Project (BBMP). Since the naming convention of the data files may alter from year to year, it is important to start by downloading an index first, to ascertain the name of a file of interest; see ‘Examples’.
Usage
dod.ctd.bbmp(
year,
ID = NULL,
index = FALSE,
file = NULL,
destdir = ".",
age = 0,
quiet = FALSE,
debug = 0
)
Arguments
- year
a numeric or character value specifying the year of interest. If this is not provided, it defaults to the current year.
- ID
a character value specifying the file of interest that is copied from the index.
- index
a boolean value. If this is TRUE, then dod.ctd.bbmp downloads an index file that provides the names of files containing CTD data along with the sampling dates. The value of
ID
is ignored in this case. By contrast, ifindex
is FALSE, then dod.ctd.bbmp downloads the CTD file with the specifiedID
. See ‘Examples’.- file
character value giving the name to be used for the downloaded file. If this is NULL (which is the default) then the filename is as on the remote data server.
- destdir
a character value indicating the directory in which to store downloaded files.
- age
a numerical value indicating a time interval, in days. If the file to be downloaded from the server already exists locally, and was created less than
age
days in the past, it will not be downloaded again. Settingage=0
forces a download, so that existing files will always be updated. By contrast, settingage
to a negative number prevents the updating of files that already exist locally, regardless of their age.- quiet
a logical value, passed to
curl::curl_download()
, which does the downloading. If this is TRUE (the default), then the work is done quietly. Until version version 0.1.12, this parameter was calledsilent
, but it was renamed to match the corresponding argument incurl::curl_download()
, which may be more familiar to users.- debug
an integer value indicating the level of debugging. If this exceeds 0, then some debugging messages will be printed. This value is passed down to related functions, but with 1 subtracted for each pass.
Value
dod.ctd.bbmp returns a character value naming the file that was retrieved. This may be either an index file or a data file; see the ‘Examples’ section for an example of a typical workflow.
See also
Other functions that download files:
dod.amsr()
,
dod.buoy()
,
dod.coastline()
,
dod.ctd()
,
dod.ctd.bats()
,
dod.ctd.gtspp()
,
dod.ctd.itp()
,
dod.met()
,
dod.tideGauge()
,
dod.topo()
Examples
# Download and study this year's first BBMP CTD file
if (interactive()) { # sidestep a pkgdown::build_site() error
# NOTE: data file is removed at end, to pass CRAN checks
library(dod)
destdir <- tempdir()
indexFile <- dod.ctd("BBMP", index = TRUE, destdir = destdir)
index <- read.csv(indexFile, header = FALSE, col.names = c("file", "time"), skip = 3)
# Download the first file in the index
ctdFile <- dod.ctd("BBMP", ID = index$file[1], destdir = destdir)
# Use oce to read, summarize and plot the data.
library(oce)
ctd <- read.oce(ctdFile)
summary(ctd)
plot(ctd)
unlink(destdir, recursive = TRUE)
}