Learn R Programming

oce (version 0.8-3)

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, 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.odf(file, columns=NULL, station=NULL, missing.value=-999, 
  monitor=FALSE, debug=getOption("oceDebug"), processingLog, ...)

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 turns on debugging. Set to 1 to get a moderate amount of debugging information, or to 2 to get more.
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.)
missing.value
optional missing-value flag; data matching this value will be set to NA upon reading.
monitor
boolean, set to TRUE to provide an indication of line of data read. (This may be useful in debugging problems in reading files that are misconfigured.)
processingLog
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.)
...
additional arguments, passed to called routines.

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$sigmatheta. ($\sigma_\theta$ is calculated using swSigmaTheta.)
  • 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]
  • processingLoga processingLog of processing, in the standard oce format.

Details

These functions read CTD datasets that have been stored in common formats, and could be extended to accommodate other formats if needed. read.ctd is a dispatch function that analyzes some of the file contents, and then calls either read.ctd.sbe (for files created by Seabird CTD instruments) or read.ctd.woce (for files stored in the exchange format used by the World Ocean Circulation Experiment.)

The functions attempt to infer a wide range of meta-information from file headers, but variations in these headers impose some limitations on the process. For example, in the first file tested during development, the sampling rate was written as * sample rate = 1 scan every 0.5 seconds, while the second test file had * Real-Time Sample Interval = 0.125 seconds; dealing with such variations is not easy. Similarly, the functions can be challenged in parsing latitudes and longitudes in the wide variety of ways that humans choose (decimal versus degree-minute-second, signed versus "east" and "west", or "e" and "w".). The solution to the challenge is simple: do a reasonable job with common file formats, and provide users with the tools to correct (or insert) information that would ideally be gleaned from the headers. This can be done by direct manipulation of the entries in the object's metadata, e.g. writing 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@metadata$institute and object@metadata$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://woce.nodc.noaa.gov/woce_v3/wocedata_1/whp/exchange/exchange_format_desc.htm, and a sample file is at http://woce.nodc.noaa.gov/woce_v3/wocedata_1/whp/exchange/example_ct1.csv

The ODF format, used by the Canadian Department of Fisheries and Oceans, is described at http://slgo.ca/app-sgdo/en/docs_reference/documents.html, and this was used as a base for 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.

See Also

The documentation for sealevel-class explains the structure of sealevel objects, and also outlines the other functions dealing with them.

Examples

Run this code
library(oce)
woce <- read.oce(
  "http://woce.nodc.noaa.gov/woce_v3/wocedata_1/whp/exchange/example_ct1.csv")
plot(woce)

Run the code above in your browser using DataLab