Learn R Programming

oce (version 0.1-76)

read.ctd: Read a CTD data file

Description

Read a CTD data file, producing an object of type ctd.

Usage

read.ctd(file, type=NULL, debug=FALSE,
 	columns=NULL, station=NULL, check.human.headers=FALSE, log.action)

Arguments

file
a connection or a character string giving the name of the file to load.
type
if NULL, 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-exchange file is
debug
a flag that can be set to TRUE to turn on debugging.
columns
if NULL, then read.ctd tries to infer column names from the header. If a list, then it will be taken to be the list of columns. The list must include "pressure", "temperature" and either
station
optional character string containing an identifying name (or number) for the station. (This can be useful if the routine cannot determine the name automatically, or if another name is preferred.)
check.human.headers
produces warnings for missing human-written header items.
log.action
if provided, the action item to be stored in the log. (Typically only provided for internal calls; the default that it provides is better for normal calls by a user.)

Value

  • An object of 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.)
  • dataa data table containing the profile data. The column names are discovered from the header, and may differ from file to file. For example, some CTD instruments may have a fluorometer connected, others may not. The order of the columns may vary from case to case, and so it is important to refer to them by name. The following vectors are normally present: data$pressure, data$salinity, data$temperature, and data$sigma.theta. ($\sigma_\theta$ is calculated using sw.sigma.theta.)
  • metadataa list containing the following items [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
  • processing.loga processing log, in the standard oce format.

Details

Oceanographers use CTD (conductivity-temperature-depth) instruments to measure key properties of the ocean, such as water temperature, salinity, etc. This function reads CTD datasets that have been stored in common formats, and could be extended to accommodate other formats if needed.

read.ctd does a reasonable job of inferring meta-information from file headers, but it still has limitations. For example, in the first file tested during development, the sampling rate was written as * sample rate = 1 scan every 0.5 seconds, while in the second test file it was written * Real-Time Sample Interval = 0.125 seconds. Similarly, read.ctd can be challenged in parsing latitudes and longitudes in the wide variety of ways that humans choose. Still, such limitations are not really pressing in practice, since the ctd object is made available for manipulation. If read.ctd cannot scan 33 and a third as a latitude, just examine the header (stored as a list in object$metadata$header), and do something like object$metadata$latitude <- 33 + 1/3.

It should be noted that 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$institute and object$scientist are left blank for WOCE files.

References

The Sea-Bird SBE 19plus profiler is described at http://www.seabird.com/products/spec_sheets/19plusdata.htm. The company recommends the use of their own software, and perhaps for this reason it is difficult to find a specification for the data files. Inspection of data files led to most of the code used in Oce. If the company ever publishes standards for the data formats, of course Oce will be adjusted. In the meantime, it does a reasonable job in many instances.

The WOCE-exchange format is described at http://www.nodc.noaa.gov/woce_V2/disk02/exchange/exchange_format_desc.htm

See Also

The generic function read.oce provides an alternative to this.

Data from a CTD cast may be assembled into a ctd object using as.ctd. A ctd object may be summarized with summary.ctd. Overview plots may be made with plot.ctd, while plot.TS produces TS plots and plot.ctd.scan produces scan plots that may help with data editing. Extraneous data such as those collected during upcasts and equilibration intervals may be trimmed with ctd.trim, and the data may be cast onto specified pressure levels with ctd.decimate. Low-level manipulation may be done with ctd.add.column and ctd.update.header, as well as by direct manipulation of the items within ctd objects.

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.

Examples

Run this code
library(oce)
x <- read.ctd("BED0301.cnv")
plot(x) # summary with TS and profiles
plot.TS(x) # just the TS

Run the code above in your browser using DataLab