ctd
.read.ctd(file, type=NULL, columns=NULL, station=NULL,
monitor=FALSE, debug=getOption("oceDebug"), processingLog, ...)
read.ctd.sbe(file, columns=NULL, station=NULL, missing.value,
monitor=FALSE, debug=getOption("oceDebug"), processingLog, ...)
read.ctd.woce(file, columns=NULL, station=NULL, missing.value=-999,
monitor=FALSE, debug=getOption("oceDebug"), processingLog, ...)
read.ctd.woce.other(file, columns=NULL, station=NULL, missing.value=-999,
monitor=FALSE, debug=getOption("oceDebug"), processingLog, ...)
read.ctd.odf(file, columns=NULL, station=NULL, missing.value=-999,
monitor=FALSE, debug=getOption("oceDebug"), processingLog, ...)
read.ctd.itp(file, columns=NULL, station=NULL, missing.value=-999,
monitor=FALSE, debug=getOption("oceDebug"), processingLog, ...)
read.ctd.sbe()
and read.ctd.woce()
, this may be
a wildcard (e.g. "*.cnv"
or "*.csv"
) in which case the
retuNULL
, then the first line is studied, in order to
determine the file type. If type="SBE19"
, then a Seabird
19 (or similar) CTD format is assumed. If type="WOCE"
then a
WOCE-exchangeNULL
, then read.ctd
tries to infer column
names from the header. For SBE files only, the column
argument
can control the column selection. It is a list that names data types and
the columns conNA
upon reading.TRUE
to provide an indication
of progress. This is useful if filename
is a wildcard.class
"ctd"
, which is a
list with elements detailed below.
The most important elements are the station name and position, along
with the profile data that are contained in the data frame named data
.
(Other elements in the list may be deleted in future versions of the
package, if they prove to be of little use in practice, or if they prove
to have been idiosyncratic features of the particular files used in
early development of oce
.)data$pressure
,
data$salinity
, data$temperature
, and
data$sigmatheta
. ($\sigma_\theta$ is calculated
using swSigmaTheta
.)oce
format.read.ctd.sbe
handles water depths
in any of the following forms, but ostensibly similar forms may not work.
read.ctd
sets it
to the maximum recorded pressure, and issues a warning to that effect. Similar issues come up for essentially everything stored in CTD headers,
and so if odd values are found (e.g. a station in the wrong hemisphere),
there is a good chance that the format is not being handled correctly.
Given the expense of collecting data, users are well-advised to check
inferred values against the values in the data files, for at least on
profile within a given cruise. Modifying the read.ctd
code is not
particularly difficult, and users are encouraged to examine the source code
(in R/ctd.R
) to see whether modification can help. Some experience
with regular expressions and string manipulation may be needed; see
regexpr
and sub
.
Three sample files are provided with the package, in
system.file("extdata", "ctd.cnv", package="oce")
system.file("extdata", "d200321-001.ctd", package="oce")
system.file("extdata", "CTD_BCD2010666_01_01_DN.ODF", package="oce")
In many cases, CTD instruments are set up to report dates in English. This
can cause a problem for users running in different locales, since e.g month
names differ. Therefore, if you know your datafile is written in
American-English notation, you might want to do
Sys.setlocale("LC_TIME", "en_US")
before you try to read the data.
read.ctd
, which analyzes some of the file
contents, and then calls one of the following, any of which can be called
directly.
read.ctd.sbe()
reads files files created by Seabird CTD
instruments. These are recognized by a first line with first ten
characters ``* Sea-Bird
.''read.ctd.woce()
reads files stored in the exchange format
used by the World Ocean Circulation Experiment (WOCE) (first 4
characters of the first line being ``CTD,
''), and also in a
rarer format with the first 3 characters being ``CTD
'' followed by
a blank or the end of the line).read.ctd.woce.other()
reads the format called ``CTD''
in the section of the archive websites named ``Other formats.'' These
data are stored in filenames ending.WCT
, and they do not have
a great deal of metadata (e.g. longitude), so the user is forced to infer
such things from a separate file. Support for this data type is limited,
e.g. requiring a header of a certain length and data columns in a certain order.
Improvements are unlikely to be added to the function, since
this data type seems to offer no advantages
over the type handled byread.ctd.woce()
.read.ctd.odf()
reads files stored in Ocean Data Format,
used in some Canadian hydrographic databases. Different file types provide different meta-information. For example, the
WOCE exchange format binds together the institute name and the initials of
the chief scientist into a single string that read.ctd
cannot parse,
so both object@metadata$institute
and
object@metadata$scientist
are left blank for WOCE files.
The WOCE-exchange format is described at
The ODF format, used by the Canadian Department of Fisheries and Oceans, is
described at
read.ctd.odf
. However, it was only a
starting point, for examination of data files revealed many variants in the
names of the data columns. If anything odd happens with ODF files (e.g. if
they cannot be plotted), the first thing to do is to reread the files with
debug=1
, to see if column names were converted properly.
Ice-tethered profile (ITF) data are available at
ctd-class
explains the structure
of ctd
objects, and also outlines the other functions dealing with
them.library(oce)
## Labrador Sea data, file 0001919.tar.gz from website
## http://www.nodc.noaa.gov/cgi-bin/OAS/prd/accession/download
d <- read.ctd.woce("*.csv")
data(coastlineWorld)
plot(coastlineWorld, clat=55, clon=-50, span=5000)
longitude <- sapply(d, function(stn) stn[['longitude']])
latitude <- sapply(d, function(stn) stn[['latitude']])
points(longitude, latitude, col='red')
Run the code above in your browser using DataLab