Commit 6bea1937 authored by Chris Holbrook's avatar Chris Holbrook

add ties='ordered' to all approx calls

parent 5358f26e
......@@ -2,7 +2,7 @@ Package: glatos
Type: Package
Title: A package for the Great Lakes Acoustic Telemetry Observation System
Description: Functions useful to members of the Great Lakes Acoustic Telemetry Observation System www.glatos.glos.us; many more broadly relevant to simulating, processing, analysing, and visualizing acoustic telemetry data.
Version: 0.4.1.9001
Version: 0.4.1.9002
Date: 2020-02-17
Depends: R (>= 3.2.0)
Imports:
......
......@@ -3,10 +3,33 @@
# glatos 0.4.1
#### 2020-02-12
#### 2020-02-17
### Minor changes
- make_video
- overhauled to no longer require ffmpeg. now is a simple wrapper for
av::av_encode_video
- added input argument 'duration' to set total video duration in seconds
previous version of make_video renamed 'make_video_ffmpeg'
- calls to new 'make_video' with "old" arguments are caught and
redirected to 'make_video_ffmpeg' for backward compatibility
- make_frames
- modified to call revised make_video (ffmpeg not required)
- deprecated ffmpeg input argument
- interpolate_path
- set `ties = "ordered"` for all calls to `stats::approx`
- fixes issue #93
### Bug fixes
- abacus_plot
- fix issue where optional plot args passed as expressions
(e.g., `panel.first` and `panel.last`) had to be wrapped in `quote`
- fixes issue #87
- abacus_plot
- fix issue where optional plot args passed as expressions
(e.g., `panel.first` and `panel.last`) had to be wrapped in `quote`
......
......@@ -62,6 +62,10 @@
#' be used for all points when \code{lnl_thresh} > 1 and linear
#' interpolation will be used for all points when \code{lnl_thresh}
#' = 0.
#'
#' @details All linear interpolation is done by code{stats::approx} with
#' argument \code{ties = "ordered"} controlling how tied \code{x} values
#' are handled. See \code{\link{approxfun}}.
#'
#' @return A dataframe with animal_id, bin_timestamp,
#' latitude, longitude, and record_type.
......@@ -260,9 +264,9 @@ interpolate_path <- function(det, trans = NULL, start_time = NULL,
bin_stamp := bin]
dtc[, i_lat := approx(detection_timestamp_utc, deploy_lat,
xout = bin_stamp)$y, by = animal_id]
xout = bin_stamp, ties = "ordered")$y, by = animal_id]
dtc[, i_lon := approx(detection_timestamp_utc, deploy_long,
xout = bin_stamp)$y, by = animal_id]
xout = bin_stamp, ties = "ordered")$y, by = animal_id]
dtc[is.na(deploy_long), record_type := "interpolated"]
dtc <- dtc[, c("animal_id", "bin_stamp", "i_lat", "i_lon", "record_type")]
......@@ -393,12 +397,15 @@ interpolate_path <- function(det, trans = NULL, start_time = NULL,
c("detection_timestamp_utc", "deploy_lat")];
approx(c(tmp$detection_timestamp_utc),
c(tmp$deploy_lat),
xout = c(bin_stamp))$y}, by = i.start]
xout = c(bin_stamp),
ties = "ordered")$y},
by = i.start]
ln[, i_lon := {tmp = .SD[c(1, .N),
c("detection_timestamp_utc", "deploy_long")];
approx(c(tmp$detection_timestamp_utc),
c(tmp$deploy_long),
xout = c(bin_stamp))$y},
xout = c(bin_stamp),
ties = "ordered")$y},
by = i.start]
ln[is.na(deploy_long), record_type := "interpolated"]
}
......@@ -481,7 +488,8 @@ arch <- nln_small
## by = i.start]
# interpolate missing timestamps for interpolated coordinates
nln_small[, i_time := as.POSIXct(approx(cumdist, i_time, xout = cumdist)$y,
nln_small[, i_time := as.POSIXct(approx(cumdist, i_time, xout = cumdist,
ties = "ordered")$y,
origin = "1970-01-01 00:00:00",
tz = attr(nln_small$i_time, "tzone")),
by = i.start]
......@@ -497,12 +505,16 @@ arch <- nln_small
nln[, i_lat := {tmp = nln_small[.(.SD[1, "i.start"]),
c("i_time", "nln_latitude")];
approx(tmp$i_time, tmp$nln_latitude,
xout = bin_stamp)$y}, by = grp]
xout = bin_stamp,
ties = "ordered")$y},
by = grp]
nln[, i_lon := {tmp = nln_small[.(.SD[1, "i.start"]),
c("i_time", "nln_longitude")];
approx(tmp$i_time, tmp$nln_longitude,
xout = bin_stamp)$y}, by = grp]
xout = bin_stamp,
ties = "ordered")$y},
by = grp]
nln[is.na(deploy_long), record_type := "interpolated"]
}
......
......@@ -83,6 +83,10 @@ Linear interpolation is used for all points when
be used for all points when \code{lnl_thresh} > 1 and linear
interpolation will be used for all points when \code{lnl_thresh}
= 0.
All linear interpolation is done by code{stats::approx} with
argument \code{ties = "ordered"} controlling how tied \code{x} values
are handled. See \code{\link{approxfun}}.
}
\examples{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment