Learn R Programming

oce (version 0.9-19)

ctdFindProfiles: Find Profiles within a Tow-Yow CTD Record

Description

Examine the pressure record looking for extended periods of either ascent or descent, and return either indices to these events or a vector of CTD records containing the events.

Usage

ctdFindProfiles(x, cutoff = 0.5, minLength = 10, minHeight = 0.1 * diff(range(x[["pressure"]])), smoother = smooth.spline, direction = c("descending", "ascending"), arr.ind = FALSE, debug = getOption("oceDebug"), ...)

Arguments

x
A ctd object, i.e. one inheriting from ctd-class.
cutoff
criterion on pressure difference; see “Details”.
minLength
lower limit on number of points in candidate profiles.
minHeight
lower limit on height of candidate profiles.
smoother
The smoothing function to use for identifying down/up casts. The default is smooth.spline, which performs well for a small number of cycles; see “Examples” for a method that is better for a long tow-yo. The return value from smoother must be either a list containing an element named y or something that can be coerced to a vector with as.vector. To turn smoothing off, so that cycles in pressure are determined by simple first difference, set smoother to NULL.
direction
String indicating the travel direction to be selected.
arr.ind
Logical indicating whether the array indices should be returned; the alternative is to return a vector of ctd objects.
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.
...
Optional extra arguments that are passed to the smoothing function, smoother.

Value

If arr.ind=TRUE, a data frame with columns start and end, the indices of the downcasts. Otherwise, a vector of ctd objects.

Details

The method works by examining the pressure record. First, this is smoothed using smoother() (see “Arguments”), and then the result is first-differenced using diff. Median values of the positive and negative first-difference values are then multiplied by cutoff. This establishes criteria for any given point to be in an ascending profile, a descending profile, or a non-profile. Contiguous regions are then found, and those that have fewer than minLength points are discarded. Then, those that have pressure ranges less than minHeight are discarded.

Caution: this method is not well-suited to all datasets. For example, the default value of smoother is smooth.spline, and this works well for just a few profiles, but poorly for a tow-yo with a long sequence of profiles; in the latter case, it can be preferable to use simpler smoothers (see “Examples”). Also, depending on the sampling protocol, it is often necessary to pass the resultant profiles through ctdTrim, to remove artifacts such as an equilibration phase, etc. Generally, one is well-advised to use the present function for a quick look at the data, relying on e.g. plotScan to identify profiles visually, for a final product.

See Also

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

Other things related to ctd data: [[,ctd-method, [[<-,ctd-method, as.ctd, cnvName2oceName, ctd-class, ctdAddColumn, ctdDecimate, ctdRaw, ctdTrim, ctdUpdateHeader, ctd, gps-class, 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
## Not run: 
# library(oce)
# d <- read.csv("towyow.csv", header=TRUE)
# towyow <- as.ctd(d$salinity, d$temperature, d$pressure)
# 
# casts <- ctdFindProfiles(towyow)
# par(mfrow=c(length(casts), 3))
# for (cast in casts) {
#   plotProfile(cast, "salinity")
#   plotProfile(cast, "temperature")
#   plotTS(cast, type='o')
# }
# 
# ## Using a moving average to smooth pressure, instead of the default
# ## smooth.spline() method. This avoids a tendency of smooth.spline()
# ## to smooth out the profiles in a tow-yo with many (dozens or more) cycles.
# movingAverage <- function(x, n = 11, ...) 
# {
#    f <- rep(1/n, n)
#    stats::filter(x, f, ...)
# }
# casts <- ctdFindProfiles(towyo, smoother=movingAverage)
# ## End(Not run)

Run the code above in your browser using DataLab