Learn R Programming

oce (version 0.9-20)

as.ctd: Coerce data into CTD object

Description

Assemble data into a ctd-class dataset.

Usage

as.ctd(salinity, temperature = NULL, pressure = NULL, conductivity = NULL, scan = NULL, time = NULL, other = NULL, units = NULL, flags = NULL, missingValue = NULL, type = "", serialNumber = "", ship = "", cruise = "", station = "", startTime = NULL, longitude = NA, latitude = NA, deploymentType = "unknown", pressureAtmospheric = 0, sampleInterval = NA, debug = getOption("oceDebug"))

Arguments

salinity
There are three choices for salinity. (1) It can be a vector indicating the practical salinity through the water column. In that case, as.ctd employs the other arguments listed below. (2) It can be something (a data frame, a list or an oce object) 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. Note that if this first argument is an object of rsk-class, the present function merely passes it and pressureAtmospheric to rsk2ctd, which does the real work. (3) It can be unspecified, in which case conductivity becomes a mandatory argument, because it will be needed for computing actual salinity, using swSCTp.
temperature
in-situ temperature [$^\circ deg$C], defined on the ITS-90 scale; see “Temperature units” in the documentation for swRho.
pressure
Vector of pressure values, one for each salinity and temperature pair, or just a single pressure, which is repeated to match the length of salinity.
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).
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, defaults are set for pressure, temperature, salinity, and conductivity. Since these are simply guesses, users are advised strongly to supply units. See “Examples”.
flags
if supplied, this is a list containing data-quality flags. The elements of this list must have names that match the data provided to the object.
missingValue
optional missing value, indicating data that should be taken as NA. Set to NULL to turn off this feature.
type
optional type of CTD, e.g. "SBE"
serialNumber
optional serial number of instrument
ship
optional string containing the ship from which the observations were made.
cruise
optional string containing a cruise identifier.
station
optional string containing a station identifier.
startTime
optional indication of the start time for the profile, which is used in some several plotting functions. This is best given as a POSIXt time, but it may also be a character string that can be converted to a time with as.POSIXct, using UTC as the timezone.
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
A numerical value (a constant or a vector), that is subtracted from pressure before storing it in the return value. (This altered pressure is also used in calculating salinity, if that is to be computed from conductivity, etc., using swSCTp (see salinity above).
sampleInterval
optional numerical value indicating the time between samples in the profile.
debug
an integer specifying whether debugging information is to be printed during the processing. This is a general parameter that is used by many oce functions. Generally, setting debug=0 turns off the printing, while higher values suggest that more information be printed.

Value

An object of ctd-class.

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.

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

Other things related to ctd data: [[,ctd-method, [[<-,ctd-method, cnvName2oceName, ctd-class, ctdDecimate, ctdFindProfiles, ctdRaw, ctdTrim, ctd, handleFlags,ctd-method, plot,ctd-method, plotProfile, plotScan, plotTS, read.ctd.itp, read.ctd.odf, read.ctd.sbe, read.ctd.woce.other, read.ctd.woce, read.ctd, subset,ctd-method, summary,ctd-method, woceNames2oceNames, write.ctd

Examples

Run this code
library(oce)
## 1. fake data, with default units
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)
# Add a new column
fluo <- 5 * exp(-pressure / 20)
ctd <- oceSetData(ctd, name="fluorescence", value=fluo,
                  unit=list(unit=expression(mg/m^3), scale=""))
summary(ctd)

## 2. fake data, with supplied units (which are the defaults, actually)
ctd <- as.ctd(salinity, temperature, pressure,
    units=list(salinity=list(unit=expression(), scale="PSS-78"),
    temperature=list(unit=expression(degree*C), scale="ITS-90"),
    pressure=list(unit=expression(dbar), scale="")))

Run the code above in your browser using DataLab