ctd.decimate {oce} | R Documentation |
Smooth and decimate a CTD profile.
ctd.decimate(x, p, method=c("approx","boxcar","lm"), e=1.5)
x |
a ctd object, e.g. as read by read.ctd . |
p |
an optional pressure increment, or list of pressures. If
p is not supplied, a list of regularly-spaced pressures is
computed based on the mean pressure difference between samples
(converted to a round value using pretty ). This list
goes from 0 to the maximum pressure in the profile (rounded to the
pressure increment). If a single p value is specified, then
it is used as the increment. Finally, if a list of pressures is
provided, then interpolation is done to these pressures. |
method |
the method to be used for calculating decimated
values. The default "approx" method is based on the R
function approx and is a simple linear interpolation
between neighbouring points. The "boxcar" method is based on
the mean of local data , while the "lm" method is based on a
local linear regression model. (The e parameter sets the
locality, as explained in the next item.) |
e |
is an expansion coefficient used to calculate the local
neighbourhoods for the "boxcar" and "lm" methods. If
e=1 , then the neighbourhood for the i-th pressure extends from
the (i-1 )-th pressure to the (i+1 )-th pressure. At the
endpoints it is assumed that the outside bin is of the same pressure
range as the first inside bin. For other values of e , the
neighbourhood is expanded linearly in each direction. If the
"lm" method produces warnings about "prediction from a
rank-deficient fit", a larger value of "e" should be used. |
The "approx"
method is best for bottle data, in which
the usual task is to interpolate from a coarse sampling grid to a
finer one. For CTD data, the "boxcar"
method is probably the
best choice, because the task is normally to sub-sample, and some
degree of smoothing is usually desired. (The "lm"
method is
quite slow, and the results are similar to those of the boxcar
method.)
NB. A sort of numerical cabeling effect can result from this procedure, but it can be avoided as follows
xd <- ctd.decimate(x) xd$data$sigma.theta <- sw.sigma.theta(xd$data$salinity, xd$data$temperature, xd$data$pressure)
An object of class
"ctd"
, with pressures that are as set by the "p"
parameter. In other respects, the return value is identical with the input ctd
object (apart from its having an additional log entry indicating that the data have been altered.)
Dan Kelley
A ctd
object may be read with read.ctd
,
and ctd.trim
is useful in trimming spurious data
(e.g. those obtained during the upcast).
library(oce) data(ctd.raw) ctd.clean <- ctd.decimate(ctd.trim(ctd.raw)) summary(ctd.clean)