ctd-class {oce} | R Documentation |
Class to Store CTD (or general hydrographic) Data
Description
This class stores hydrographic data such as measured with a CTD (conductivity,
temperature, depth) instrument, or with other systems that produce
similar data. Data repositories may store conductivity, temperature
and depth, as in the instrument name, but it is also common to store
salinity, temperature and pressure instead (or in addition). For this
reason, ctd
objects are required to hold salinity
,
temperature
and pressure
in their data
slot,
with other data being optional. Formulae are available for converting
between variants of these data triplets, e.g. swSCTp()
can calculate salinity
given conductivity
, temperature
and pressure
, and these are used by the main functions that
create ctd
objects. For example, if read.ctd.sbe()
is used to read a Seabird file that contains only conductivity, temperature
and pressure, then that function will automatically append a data
item to hold salinity. Since as.ctd()
does the same with
salinity, the result this is that all ctd
objects hold salinity
,
temperature
and pressure
, which are henceforth called
the three basic quantities.
Details
Different units and scales are permitted for the three basic quantities, and
most oce
functions check those units and scales before
doing calculations (e.g. of seawater density), because those calculations
demand certain units and scales. The way this is handled is that the
accessor function [[,ctd-method
] returns values in standardized
form. For example, a ctd
object might hold temperature defined on the
IPTS-68 scale, but e.g. ctd[["temperature"]]
returns a value on the ITS-90
scale. (The conversion is done with T90fromT68()
.) Similarly,
pressure may be stored in either dbars or PSI, but e.g. ctd[["pressure"]]
returns a value in dbars, after dividing by 0.689476 if the value is
stored in PSI. Luckily, there is (as of early 2016) only one salinity scale in
common use in data files, namely PSS-78.
Slots
data
As with all
oce
objects, thedata
slot forctd
objects is a list containing the main data for the object. The key items stored in this slot are:salinity
,temperature
, andpressure
, although in many instances there are quite a few additional items.metadata
As with all
oce
objects, themetadata
slot forctd
objects is a list containing information about thedata
or about the object itself. An example of the former might be the location at which actd
measurement was made, stored inlongitude
andlatitude
, and of the latter might befilename
, the name of the data source.processingLog
As with all
oce
objects, theprocessingLog
slot forctd
objects is a list with entries describing the creation and evolution of the object. The contents are updated by variousoce
functions to keep a record of processing steps. Object summaries andprocessingLogShow()
both display the log.
Modifying slot contents
Although the [[<-
operator may permit modification of the contents
of ctd objects (see [[<-,ctd-method
),
it is better to use oceSetData()
and oceSetMetadata()
,
because those functions save an entry in the processingLog
that describes the change.
Retrieving slot contents
The full contents of the data
and metadata
slots of a ctd
object may be retrieved in the standard R way using slot()
. For
example slot(o,"data")
returns the data
slot of an object named o
,
and similarly slot(o,"metadata")
returns
the metadata
slot.
The slots may also be obtained with the [[,ctd-method
operator, as e.g. o[["data"]]
and o[["metadata"]]
, respectively.
The [[,ctd-method
operator can also
be used to retrieve items from within the data
and metadata
slots.
For example, o[["temperature"]]
can be used to retrieve temperature
from an object containing that quantity. The rule is that a named
quantity is sought first within the object's metadata
slot,
with the data
slot being checked only if metadata
does not
contain the item. This [[
method can also be used to get
certain derived quantities, if the object contains sufficient
information to calculate them. For example, an object that holds
(practical) salinity, temperature and pressure, along with
longitude and latitude, has sufficient information to compute
Absolute Salinity, and so o[["SA"]]
will yield the
calculated Absolute Salinity.
It is also possible to find items more directly, using oceGetData()
and
oceGetMetadata()
, but neither of these functions can
retrieve derived items.
Reading/creating ctd
objects
A file containing CTD profile data may be read with
read.ctd()
, and a CTD object can also be created with
as.ctd()
. See read.ctd()
for references on data
formats used in CTD files. Data can also be assembled into
ctd
objects with as.ctd()
.
Statistical summaries are provided by summary,ctd-method()
, while
show()
displays an overview.
CTD objects may be plotted with plot,ctd-method()
, which does much of its
work by calling plotProfile()
or plotTS()
, both of
which can also be called by the user, to get fine control over the plots.
A CTD profile can be isolated from a larger record with ctdTrim()
,
a task made easier when plotScan()
is used to examine the results.
Towyow data can be split up into sets of profiles (ascending or descending)
with ctdFindProfiles()
. CTD data may be smoothed and/or cast onto
specified pressure levels with ctdDecimate()
.
As with all oce objects, low-level manipulation may be done with
oceSetData()
and oceSetMetadata()
. Additionally,
many of the contents of CTD objects may be altered with the
[[<-,ctd-method
scheme,
and sufficiently skilled users may even manipulate the contents directly.
Data sources
Archived CTD (and other) data may be found on servers such as
-
https://cchdo.ucsd.edu/
Author(s)
Dan Kelley
See Also
Other things related to ctd data:
CTD_BCD2014666_008_1_DN.ODF.gz
,
[[,ctd-method
,
[[<-,ctd-method
,
as.ctd()
,
cnvName2oceName()
,
ctd.cnv.gz
,
ctdDecimate()
,
ctdFindProfilesRBR()
,
ctdFindProfiles()
,
ctdRaw
,
ctdRepair()
,
ctdTrim()
,
ctd_aml.csv.gz
,
ctd
,
d200321-001.ctd.gz
,
d201211_0011.cnv.gz
,
handleFlags,ctd-method
,
initialize,ctd-method
,
initializeFlagScheme,ctd-method
,
oceNames2whpNames()
,
oceUnits2whpUnits()
,
plot,ctd-method
,
plotProfile()
,
plotScan()
,
plotTS()
,
read.ctd.aml()
,
read.ctd.itp()
,
read.ctd.odf()
,
read.ctd.odv()
,
read.ctd.saiv()
,
read.ctd.sbe()
,
read.ctd.ssda()
,
read.ctd.woce.other()
,
read.ctd.woce()
,
read.ctd()
,
setFlags,ctd-method
,
subset,ctd-method
,
summary,ctd-method
,
woceNames2oceNames()
,
woceUnit2oceUnit()
,
write.ctd()
Other classes provided by oce:
adp-class
,
adv-class
,
argo-class
,
bremen-class
,
cm-class
,
coastline-class
,
lisst-class
,
lobo-class
,
met-class
,
oce-class
,
odf-class
,
rsk-class
,
sealevel-class
,
section-class
,
topo-class
,
windrose-class
,
xbt-class
Examples
# 1. Create a ctd object with fake data.
a <- as.ctd(salinity = 35 + 1:3 / 10, temperature = 10 - 1:3 / 10, pressure = 1:3)
summary(a)
# 2. Fix a typo in a station latitude (fake! it's actually okay)
data(ctd)
ctd <- oceSetMetadata(
ctd, "latitude", ctd[["latitude"]] - 0.001,
"fix latitude typo in log book"
)