Functions used for very particular tasks within larger functions in diveMove
1 2 3 4 5 6 7 8 9 10
Numeric vector with depth in m.
Vector of moving window width integers (coerced to integer by
Vector of quantiles to extract at each step indicated by
Numeric vector of length two, with minimum and maximum depth to bound the search for the surface.
Numeric (or character for
Numeric vector of unique dive indices to extract from
Vertical distance travelled during this time. If
A numeric vector indicating the activity for every element
Sampling interval in seconds.
Character string to indicate the method to use for zero offset correction. One of “visual”, “offset”, or “filter” (see ‘Details’).
Named list of control parameters to be used for ZOC
These functions are not meant to be called directly by the
user, as he/she could not care less (right?). This may change in the
future. Nonetheless, they can be called in the usual way for
functions that are not exported:
.depthFilter performs the zero-offset correction with
method=“filter”. It takes a numeric vector and applies a
running quantile to it, and the process is repeated zero or more times
on the filtered/smooth vector from the previous process.
.derivStats obtains summary statistics (summary() and sd()) of
derivatives for descent, bottom, and ascent phases for each dive.
It takes a
.diveIndices takes a numeric vector with sequences of dive
numbers, and selects the indices of dive numbers listed uniquely in
the vector given as its second argument.
.diveMatches takes a numeric or character vector with sequences
of dive numbers, and selects the indices of dive numbers listed
uniquely in the vector given as its first argument. Stops if no
matches are found, and warns if some were ignored.
.getInterval takes a
POSIXct object and
calculates the the most frequent interval between successive elements.
.plotTDR is the underlying plotting function for
TDR objects. Arguments are documented in the main S4
plotZOCtdrs are the underlying
plotting functions for visually assessing the ZOC procedure.
Arguments are documented in the main S4 methods
.speedStats takes matrix of time and speed, and an optional
vector of vertical distance travelled between segments, and calculates
the total vertical distance travelled, mean speed, and angle. Input
and output correspond to a single section of a dive.
.night takes a
POSIXct object, sunrise and sunset
time strings to provide a list of sunrise and sunset times for each
day in the
.rleActivity takes a factor indicating different activity
phases, their associated time, and the sampling interval to return a
factor uniquely identifying each phase of activity, i.e. labelling
them. In addition, it returns the duration of each phase, and their
beginning and end times.
.speedNames is a character vector with possible names for a
.speedCol takes a
data.frame and checks whether
there is a column with a name matching one of those in
.zoc is the main workhorse for the zero-offset correction
ZOC procedure in
calibrateDepth. It takes a
POSIXct object, corresponding
depth vector, a string representing a method to use for the procedure,
and a list of control parameters for the chosen method to perform ZOC.
.diveIndices returns a numeric vector with the indices of dives
(and their beginning/end indices) in
.getInterval returns a scalar, the mode of intervals between
.speedStats returns a 3-column matrix with total distance, mean
speed, and angle for a section of a dive.
.night returns a list with sunrise and sunset times for dates
.speedCol returns column number where speed is located in x.
.rleActivity returns a list with components:
time.br: A factor dividing
act into different periods
time.peract: The duration of each period of activity.
beg.time, end.time: POSIXct objects indicating the beginning and ending times of each period of activity.
.zoc returns a vector with all corrected depths based on
‘method’. Depths < 0 are set to 0.
.depthFilter returns a
matrix with the filtered
depths at each step, and corrected depth as last column, so it has
length(depth) rows by
length(k) + 1 columns.
Sebastian P. Luque [email protected]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
data(divesTDR) times <- getTime(divesTDR) depths <- getDepth(divesTDR) ## Not run: ## This can take too long ## .depthFilter d.filter <- diveMove:::.depthFilter(depth=depths, k=c(3, 5760), probs=c(0.5, 0.02), depth.bounds=c(0, 5), na.rm=TRUE) ## Set negative depths to zero d.filter[d.filter[, 3] < 0, 3] <- 0 ## Plotting idx <- seq(95, 6000) # try different slices idx <- seq(nrow(d.filter)) ## Look at the top 10 m only plus a few meters above ylim <- c(-10, 5) layout(seq(3)) plot(times[idx], -depths[idx], type="l", col="gray", ylab="Depth (m)", ylim=ylim) abline(h=0, lty=2) legend("topleft", legend="original", lty=1, col="gray") plot(times[idx], -d.filter[idx, 1], type="l", col=2, ylab="Depth (m)", ylim=ylim) abline(h=0, lty=2) lines(times[idx], -d.filter[idx, 2]) legend("topleft", legend=colnames(d.filter)[-3], lty=1, col=c(2, 1)) plot(times[idx], -d.filter[idx, 3], type="l", ylim=ylim, ylab="Depth (m)"); abline(h=0, lty=2) legend("topleft", legend=paste("Original -", colnames(d.filter)), lty=1) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.