calibrateDepth {diveMove} | R Documentation |
Detect periods of major activities in a TDR
record, calibrate depth readings, and generate a
TDRcalibrate
object essential for subsequent summaries
of diving behaviour.
calibrateDepth(x, dry.thr=70, wet.thr=3610, dive.thr=4, offset, descent.crit.q=0.1, ascent.crit.q=0.1, wiggle.tol=0.8)
x |
An object of class TDR for
calibrateDepth or an object of class
TDRcalibrate for calibrateSpeed . |
dry.thr |
Dry error threshold in seconds. Dry phases shorter than this threshold will be considered as wet. |
wet.thr |
Wet threshold in seconds. At-sea phases shorter than this threshold will be considered as trivial wet. |
dive.thr |
Threshold depth below which an underwater phase should be considered a dive. |
offset |
Argument to zoc . If not provided, the
offset is obtained using an interactive plot of the data. |
descent.crit.q |
Critical quantile of rates of descent below which descent is deemed to have ended. |
ascent.crit.q |
Critical quantile of rates of ascent above which ascent is deemed to have started. |
wiggle.tol |
Proportion of maximum depth above which wiggles should not be allowed to define the end of descent. It's also the proportion of maximum depth below which wiggles should be considered part of bottom phase. |
This function is really a wrapper around .detPhase
and
.detDive
, which perform the work on simplified objects. It
performs zero-offset correction of depth, wet/dry phase detection, and
detection of dives, as well as proper labelling of the latter.
The procedure starts by first creating a factor with value “L”
(dry) for rows with NAs for depth
and value “W” (wet)
otherwise. It subsequently calculates the duration of each of these
phases of activity. If the duration of an dry phase (“L”) is
less than dry.thr
, then the values in the factor for that phase
are changed to “W” (wet). The duration of phases is then
recalculated, and if the duration of a phase of wet activity is less
than wet.thr
, then the corresponding value for the factor is
changed to “Z” (trivial wet). The durations of all phases are
recalculated a third time to provide final phase durations.
The next step is to detect dives whenever the zero-offset corrected depth in an underwater phase is below the supplied dive threshold. A new factor with finer levels of activity is thus generated, including “U” (underwater), and “D” (diving) in addition to the ones described above.
Once dives have been detected and assigned to a period of wet activity, phases within dives are detected using the descent, ascent and wiggle criteria. This procedure generates a factor with levels “D”, “DB”, “B”, “BA”, “A”, “DA”, and “X”, breaking the input into descent, descent/bottom, bottom, bottom/ascent, ascent, and non-dive, respectively.
An object of class TDRcalibrate
.
A bottom depth is defined as the maximum depth multiplied by a factor
(wiggle.tol
, [0, 1])
descent.crit.q
) of all the positive rates of descent. This
subsetting avoids defining a critical rate that may be negative, due
to wiggling during the descent.
To allow detection of wiggles during descent, a vector of the indices of the rates of descent that were lower than the critical value is defined, and a logical vector with TRUE for rates of descent >= 0 above the bottom depth defined previously is also created.
The following tests are performed (in order):
If there were any rates below the critical value, as well as any descent wiggles, the indices where the wiggles occurred are removed. If this resulted in removal of all indices, then the index defining the end of descent is the number of rates of descent, otherwise it is the last after the removal.
If there were not any rates below the critical value, the index defining the end of descent is the number of rates of descent, otherwise it is the first of them.
ascent.crit.q
) of
all the positive rates of ascent, analogously to the descent
detection procedure.
To allow detection of bottom wiggling, a vector of the indices of the rates of ascent that were higher than the critical value is defined, and a logical vector with TRUE for rates of ascent <= 0 below the bottom depth defined previously is also created.
The following tests are performed (in order):
If there were any bottom wiggles, then the index defining the beginning of ascent is that corresponding to the maximum depth plus that corresponding to the last bottom wiggle, otherwise:
If there were no rates above the critical value, then the index defining the beginning of ascent is the last reading below the surface. Otherwise, it is the one corresponding to the maximum depth plus the first of the indices of rates above the critical value.
The particular dive phase categories are subsequently defined using simple set operations.
Sebastian P. Luque spluque@gmail.com
data(divesTDR) divesTDR ## Consider a 3 m offset, and a dive threshold of 3 m dcalib <- calibrateDepth(divesTDR, dive.thr=3, offset=3) if (dev.interactive(orNone=TRUE)) { plotTDR(dcalib, labels="dive.phase", surface=TRUE) }