as.ctd {oce} | R Documentation

## Coerce data into ctd dataset

### Description

Coerces a dataset into a ctd dataset.

### Usage

    as.ctd(salinity, temperature=NULL, pressure=NULL, conductivity=NULL,
           SA=NULL, CT=NULL, oxygen=NULL,
           nitrate=NULL, nitrite=NULL, phosphate=NULL, silicate=NULL,
           scan=NULL, time=NULL, other=NULL,
           units=NULL, pressureType="sea",
           missingValue=NA, quality=NULL,
           filename="", type="", model="", serialNumber="",
           ship="", scientist="", institute="", address="", cruise="", station="",
           date="", startTime="", recovery="",
           longitude=NA, latitude=NA,
           deploymentType="unknown",
           pressureAtmospheric=0, waterDepth=NA,
           sampleInterval=NA, src="",
           debug=getOption("oceDebug"))

### Arguments

`salinity` | There are two choices for `salinity`. First, it can be a vector indicating the practical salinity through the water column. In that case, `as.ctd` employs the other arguments listed below. The second choice is that `salinity` is something from which practical salinity, temperature, etc., can be inferred. In that case, the relevant information is extracted and the other arguments to `as.ctd` are ignored, except for `pressureAtmospheric`; see “Details”.
`temperature` | in-situ temperature [degC], defined on the ITS-90 scale; see “Temperature units” in the documentation for `swRho`.
`pressure` | pressure through the water column. If only one value is given, then it is repeated to match the length of the temperature vector.
`conductivity` | electrical conductivity ratio through the water column (optional). To convert from raw conductivity in milliSeimens per centimeter divide by 42.914 to get conductivity ratio (see Culkin and Smith, 1980).
`SA` | absolute salinity (as in TEOS-10). If given, the supplied absolute salinity is converted internally to UNESCO-defined practical salinity.
`CT` | conservative temperature (as in TEOS-10). If given, the supplied conservative temperature is converted internally to UNESCO-defined in-situ temperature.
`oxygen` | optional oxygen concentration
`nitrate` | optional nitrate concentration [micromole/kg]
`nitrite` | optional nitrite concentration [micromole/kg]
`phosphate` | optional phosphate concentration [micromole/kg]
`silicate` | optional silicate concentration [micromole/kg]
`scan` | optional scan number. If not provided, this will be set to `1:length(salinity)`.
`time` | optional vector of times of observation
`other` | optional list of other data columns that are not in the standard list

`units` | an optional list containing units. If not supplied, a default of `list(temperature=list(unit=expression(degree*C), scale="ITS-90"), salinity=list(unit=expression(ratio), scale="", pressure=list(unit=expression(dbar), scale="")` is used. This is quite typical of archived datasets, but for some instrumental files it will make sense to use `salinity=list(unit=expression(uS/cm), scale="")` or `salinity=list(unit=expression(S/m), scale="")`.
`pressureType` | a character string indicating the type of pressure; may be `"absolute"`, for total pressure, i.e. the sum of atmospheric pressure and sea pressure, or `"sea"`.
`missingValue` | optional missing value, indicating data that should be taken as `NA`.
`quality` | quality flag, e.g. from the salinity quality flag in WOCE data. (In WOCE, `quality=2` indicates good data, `quality=3` means questionable data, and `quality=4` means bad data.
`filename` | filename to be stored in the object
`type` | type of CTD, e.g. "SBE"
`model` | model of instrument
`serialNumber` | serial number of instrument
`ship` | optional string containing the ship from which the observations were made.
`scientist` | optional string containing the chief scientist on the cruise.
`institute` | optional string containing the institute behind the work.
`address` | optional string containing the address of the institute.
`cruise` | optional string containing a cruise identifier.
`station` | optional string containing a station identifier.
`date` | optional string containing the date at which the profile was started.
`startTime` | optional string containing the start time.
`recovery` | optional string indicating the recovery time.
`longitude` | optional numerical value containing longitude in decimal degrees, positive in the eastern hemisphere. If this is a single number, then it is stored in the `metadata` slot of the returned value; if it is a vector of numbers, they are stored in `data` and a mean value is stored in `metadata`.
`latitude` | optional numerical value containing the latitude in decimal degrees, positive in the northern hemisphere. See the note on length, for the `longitude` argument.
`deploymentType` | character string indicating the type of deployment. Use `"unknown"` if this is not known, `"profile"` for a profile (in which the data were acquired during a downcast, while the device was lowered into the water column, perhaps also including an upcast; `"moored"` if the device is installed on a fixed mooring, `"thermosalinograph"` (or `"tsg"`) if the device is mounted on a moving vessel, to record near-surface properties, or `"towyo"` if the device is repeatedly lowered and raised.
`pressureAtmospheric` | if `NA` (the default), then pressure is copied from the `pressure` argument or from the contents of the first argument (as described above for `salinity`). Otherwise, if `pressureAtmospheric` is a numerical value (a constant or a vector), then it is subtracted from pressure before storing it in the return value. See “Details” for special considerations if `salinity` is a `rsk-class` object.
`waterDepth` | optional numerical value indicating the water depth in metres. This is different from the maximum recorded pressure, although the latter is used by some oce functions as a guess on water depth, the most important example being `plot.section`.
`sampleInterval` | optional numerical value indicating the time between samples in the profile.
`src` | optional string indicating data source
`debug` | a flag that can be set to `TRUE` to turn on debugging.

### Details

If the first argument is an `rsk-class` object, the pressure it contains may need to be adjusted, because `rsk` objects may contain either absolute pressure or sea pressure. This adjustment is handled automatically by `as.ctd`, by examination of the metadata item named `pressureType` (described in the documentation for `read.rsk`). Once the sea pressure is determined, adjustments may be made with the `pressureAtmospheric` argument, although in that case it is better considered a pressure adjustment than the atmospheric pressure.

`rsk-class` objects may store sea pressure or absolute pressure (the sum of sea pressure and atmospheric pressure), depending on how the object was created with `as.rsk` or `read.rsk`. However, `ctd-class` objects store sea pressure, which is needed for plotting, calculating density, etc. This poses no difficulities, however, because `as.ctd` automatically converts absolute pressure to sea pressure, if the metadata in the `rsk-class` object indicates that this is appropriate. Further alteration of the pressure can be accomplished with the `pressureAtmospheric` argument, as noted above.

### Value

An object of `class` `"ctd"` (for details, see `read.ctd`).

### Author(s)

Dan Kelley

### References

Culkin, F., and Norman D. Smith, 1980. Determination of the concentration of potassium chloride solution having the same electrical conductivity, at 15 C and infinite frequency, as standard seawater of salinity 35.0000 ppt (Chlorinity 19.37394 ppt). IEEE Journal of Oceanic Engineering, 5, pp 22-23.

### See Also

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

### Examples

    library(oce)
    pressure <- 1:50
    temperature <- 10 - tanh((pressure - 20) / 5) + 0.02*rnorm(50)
    salinity <- 34 + 0.5*tanh((pressure - 20) / 5) + 0.01*rnorm(50)
    ctd <- as.ctd(salinity, temperature, pressure)
    summary(ctd)
    plot(ctd)

[Package oce version 0.9-18 Index]