R: Class to Store CTD (or general hydrographic) Data

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. `as.ctd` acts similarly. 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 multiplying 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, the `data` slot for `ctd` objects is a `list` containing the main data for the object. The key items stored in this slot are: `salinity`, `temperature`, and `pressure`, although in many instances there are quite a few additional items.

`metadata`

  As with all `oce` objects, the `metadata` slot for `ctd` objects is a `list` containing information about the `data` or about the object itself. An example of the former might be the location at which a `ctd` measurement was made, stored in `longitude` and `latitude`, and of the latter might be `filename`, the name of the data source.

`processingLog`

  As with all `oce` objects, the `processingLog` slot for `ctd` objects is a `list` with entries describing the creation and evolution of the object. The contents are updated by various `oce` functions to keep a record of processing steps. Object summaries and `processingLogShow` 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 that will save an entry in the `processingLog` to describe the change.

### Retrieving slot contents

The full contents of the `data` and `metadata` slots of a `ctd` object named `ctd` may be retrieved in the standard R way. For example, `slot(ctd, "data")` and `slot(ctd, "metadata")` return the `data` and `metadata` slots, respectively. The `[[,ctd-method` operator can also be used to access slots, with `ctd[["data"]]` and `ctd[["metadata"]]`, respectively. Furthermore, `[[,ctd-method` can be used to retrieve named items (and potentially some derived items) within the `metadata` and `data` slots, the former taking precedence over the latter in the lookup. It is also possible to find items more directly, using `oceGetData` and `oceGetMetadata`, but this cannot 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 discussed above, and skilled users may also manipulate the contents directly.

### Author(s)

Dan Kelley

### See Also

Other things related to `ctd` data: `[[,ctd-method`, `[[<-,ctd-method`, `as.ctd`, `cnvName2oceName`, `ctdDecimate`, `ctdFindProfiles`, `ctdRaw`, `ctdTrim`, `ctd`, `handleFlags,ctd-method`, `initialize,ctd-method`, `initializeFlagScheme,ctd-method`, `oceNames2whpNames`, `oceUnits2whpUnits`, `plot,ctd-method`, `plotProfile`, `plotScan`, `plotTS`, `read.ctd.itp`, `read.ctd.odf`, `read.ctd.sbe`, `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`

### 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")

[Package oce version 1.0-1 Index]