Skip to contents

dod.ctd.bats() downloads CTD data from Bermuda Atlantic Time Series (BATS) server, at http://batsftp.bios.edu/BATS/ctd/ASCII/. Note that this server does not provide an index, so users will need to visit the website to determine IDs of interest, unless they already know them. Another problem is that the data are in a nonstandard format that the oce package cannot read, so a user may wish to write code to reframe the data as shown in the ‘Examples’ section.

Usage

dod.ctd.bats(ID, info = FALSE, file = NULL, destdir = ".", age = 0, debug = 0)

Arguments

ID

an integer specifying the ID of the file of interest. This gets expanded to e.g. URL/b(ID)_ctd.txt or URL/b(ID)_ctd_QC.txt if info is FALSE, or to URL/b(ID)_info.txt otherwise.

info

a logical value. If info is FALSE, which is the default, then dod.ctd.bats() downloads the actual CTD data. Altenatively, it downloads a file holding information about sampling location, etc.

file

character value giving the name to be used for the downloaded file. If file is NULL, which is the default, then the filename on the server is used.

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. Setting age=0 (which is the default) forces a download.

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.bats() returns the full pathname of the downloaded file.

See also

Other functions that download CTD data: dod.ctd.bbmp(), dod.ctd.gtspp()

Examples

if (FALSE) {
library(dod)
# Read info file
infoFile <- dod.ctd.bats(ID=10001, info=TRUE)
info.names <- c("ID",
    "dateDeployed","dateRecovered","decimalDateDeployed","decimalDateRecovered",
    "decimalDayDeployed", "timeDeployed", "timeRecovered", "latitudeDeployed",
    "latitudeRecovered", "longitudeDeployed", "longitudeRecovered")
info <- read.delim(infoFile, sep="\t", header=FALSE, col.names=info.names)

# Read data file
dataFile <- dod.ctd.bats(ID=10001)
dataNames <- c("ID", "date","latitude", "longitude",
    "pressure","depth","temperature","conductivity", "salinity", "oxygen",
    "beamAttenuationCoefficient", "fluorescence", "PAR")
data <- read.delim(dataFile, sep="\t", header=FALSE, col.names=dataNames)

# Use oce to construct a basic CTD object (using just some of the data),
# and then to summarize and plot it.  Note that longitude in these files
# is in degrees west, so they must be negated for use in oce.
library(oce)
time <- as.POSIXct(paste(info$dateDeployed, info$timeDeployed),format="%Y%m%d %H%M")
ctd <- as.ctd(salinity=data$salinity, temperature=data$temperature,
    pressure=data$pressure, latitude=data$latitude[1],
    longitude=-data$longitude[1], time=time)
# Add some extra things that are in at least some file. Units can also be added,
# if known.
for (item in c("oxygen", "beamAttenuationCoefficient", "fluorescence", "PAR")) {
    ctd <- oceSetData(ctd, item, data[[item]])
}
summary(ctd)
plot(ctd)
}