Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev1.2.2.9000 #32

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
e67fec4
branch dev1.2.2.9000
baktoft Jan 21, 2021
03fa199
update readme
baktoft Jan 21, 2021
e0a2f66
add codecov
baktoft Jan 21, 2021
94d2029
add codecov to test yaml
baktoft Jan 21, 2021
4562937
forgot to add
baktoft Jan 21, 2021
e8653e3
add option to use TMB smartsearch
baktoft Jan 23, 2021
af17411
add test of getSyncModel(tmb_smartsearch=FALSE)
baktoft Jan 23, 2021
454d6ba
make fineTuneSyncModel aware of tmb smartsearch
baktoft Jan 23, 2021
83098e2
make fineTuneSyncModel aware of max_iter used in getSyncModel()
baktoft Jan 23, 2021
50d3d24
add more tests
baktoft Jan 23, 2021
81eaad5
document param tmb_smartsearch in getSyncModel()
baktoft Jan 23, 2021
e8a9d83
document param tmb_smartsearch in getSyncModel()
baktoft Jan 23, 2021
cac64bf
remove a yaps::: entry
baktoft Jan 23, 2021
639ef32
bug fix for tests
baktoft Jan 23, 2021
4e70feb
add test of testYaps()
baktoft Jan 23, 2021
4496214
add test for opt_fun=nloptr in testYaps() and disable test for plsd
baktoft Jan 23, 2021
b246c07
add examples and clean up docs 1/??
baktoft Jan 24, 2021
a2c8fe4
re-enable travis for now
baktoft Jan 24, 2021
156e94a
examples and docs 2/??
baktoft Jan 24, 2021
3d47b7f
examples and docs 3/??
baktoft Jan 24, 2021
4d88898
OBS attempt to optimize runYaps() and getSyncModel()
baktoft Jan 24, 2021
bb795d8
add user friendly output from runYaps()
baktoft Jan 25, 2021
16fa757
examples and docs 4/??
baktoft Jan 25, 2021
5d25a8c
reduce hald$detections by one day to meet size req
baktoft Jan 25, 2021
76f2332
examples, docs and tests 5/???
baktoft Jan 25, 2021
111f911
examples and docs 5/??
baktoft Jan 25, 2021
2258cb3
examples, docs and tests 6/???
baktoft Jan 25, 2021
1f33528
9006 exs, docs and tests 7/??
baktoft Jan 26, 2021
946fd90
dev1.2.2.9009 - exs, docs and tests 8/?? - also moved example data hald
baktoft Jan 27, 2021
d30ecdb
update readme + v1.2.3
baktoft Jan 27, 2021
50c65a4
update cran-comments.md
baktoft Jan 28, 2021
ed66cea
update pkgdown site
baktoft Jan 28, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
^.*\.Rproj$
^\.Rproj\.user$
^README\.Rmd$
^README\.html$
^README_sync\.Rmd$
^_pkgdown\.yml$
^docs$
Expand All @@ -11,3 +12,6 @@
^LICENSE\.md$
^LICENSE$
^\.github$
^codecov\.yml$
^\.travis\.yml$
^cran-comments\.md$
19 changes: 14 additions & 5 deletions .github/workflows/check-standard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ jobs:
fail-fast: false
matrix:
config:
- {os: windows-latest, r: '3.6'}
- {os: windows-latest, r: 'release'}
- {os: windows-latest, r: 'devel'}
- {os: macOS-latest, r: '3.6'}
- {os: macOS-latest, r: 'release'}
- {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
- {os: ubuntu-20.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
Expand All @@ -24,6 +26,8 @@ jobs:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: ${{ matrix.config.rspm }}
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
# don't treat missing suggested packages as error
_R_CHECK_FORCE_SUGGESTS_: false

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -54,11 +58,6 @@ jobs:
# env:
# RHUB_PLATFORM: linux-x86_64-ubuntu-gcc
run: |
# # # # custom hack to ensure correct version of Matrix for TMB
# sudo apt-get install -y --allow-downgrades r-cran-matrix=1.2-18-1focal0
# R -e "install.packages('TMB', type = 'source')"
# # # # custom hack end

while read -r cmd
do
eval sudo $cmd
Expand All @@ -76,6 +75,16 @@ jobs:
run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check")
shell: Rscript {0}

- name: Run codecov
if: runner.os == 'Linux'
run: |
covr::codecov()
shell: Rscript {0}

- name: Upload coverage to Codecov
if: runner.os == 'Linux'
uses: codecov/codecov-action@v1

- name: Upload check results
if: failure()
uses: actions/upload-artifact@main
Expand Down
10 changes: 6 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ vignettes/*.pdf
# Temporary files created by R markdown
*.utf8.md
*.knit.md
man/figures/
/man/figures/
man/figures/*.png
/man/figures/*.png
# man/figures/
# /man/figures/
# man/figures/*.png
# /man/figures/*.png

# Shiny token, see https://shiny.rstudio.com/articles/shinyapps.html
rsconnect/
.Rproj.user
inst/doc
debug.log

README.html
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# R for travis: see documentation at https://docs.travis-ci.com/user/languages/r

language: R
cache: packages
addons:
apt:
packages:
- libgit2-dev

14 changes: 8 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Package: yaps
Title: Track Estimation using YAPS (Yet Another Positioning Solver)
Version: 1.2.2
Authors@R: c( person("Henrik", "Baktoft", email = "[email protected]", role = c("cre", "aut")),
Version: 1.2.3
Authors@R: c( person("Henrik", "Baktoft", email = "[email protected]", role = c("cre", "aut"), comment=c(ORCID = "0000-0002-3644-4960")),
person("Karl", "Gjelland", role=c("aut")),
person("Uffe H.", "Thygesen", role=c("aut")),
person("Finn", "Økland", role=c("aut"))
)
Description: Estimate track from acoustic data using YAPS.
Description: Estimate tracks of animals tagged with acoustic transmitters. 'yaps' was introduced in 2017 as a transparent open-source tool to estimate positions of fish (and other aquatic animals) tagged with acoustic transmitters. Based on registrations of acoustic transmitters on hydrophones positioned in a fixed array, 'yaps' enables users to synchronize the collected data (i.e. correcting for drift in the internal clocks of the hydrophones/receivers) and subsequently to estimate tracks of the tagged animals. The paper introducing 'yaps' is available in open access at Baktoft, Gjelland, Økland & Thygesen (2017) <doi:10.1038/s41598-017-14278-z>. Also check out our cookbook with a completely worked through example at Baktoft, Gjelland, Økland, Rehage, Rodemann, Corujo, Viadero & Thygesen (2019) <DOI:10.1101/2019.12.16.877688>. Additional tutorials will eventually make their way onto the project website at <https://baktoft.github.io/yaps/>.
Depends: R (>= 3.5.0)
License: GPL-3
Encoding: UTF-8
Expand All @@ -15,8 +15,10 @@ RoxygenNote: 7.1.1
LinkingTo: Rcpp, TMB, RcppEigen
Imports: circular, cowplot, data.table, ggplot2, ggrepel, nloptr, plyr, Rcpp, reshape2, splusTimeSeries, stats, tictoc, TMB, viridis, zoo
Suggests:
testthat (>= 2.1.0),
covr,
knitr,
rmarkdown
URL: https://github.com/baktoft/yaps
rmarkdown,
testthat (>= 2.1.0),
vdiffr
URL: https://github.com/baktoft/yaps, https://baktoft.github.io/yaps/
BugReports: https://github.com/baktoft/yaps/issues
5 changes: 2 additions & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

export(alignBurstSeq)
export(applySync)
export(checkInp)
export(checkInpSync)
export(fineTuneSyncModel)
export(getBbox)
export(getDatTmb)
export(getInits)
export(getInp)
export(getInpSync)
export(getParams)
export(getSyncCoverage)
export(getSyncModel)
export(getToaYaps)
Expand All @@ -35,6 +33,7 @@ importFrom(data.table,.I)
importFrom(data.table,.N)
importFrom(data.table,.SD)
importFrom(ggplot2,aes)
importFrom(ggplot2,coord_fixed)
importFrom(ggplot2,facet_grid)
importFrom(ggplot2,facet_wrap)
importFrom(ggplot2,geom_bar)
Expand Down
9 changes: 8 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# yaps v1.2.3

## New stuff
* Moved example data `hald` to an external package with yaps example data `yapsdata`. Available from github using devtools::install_github('baktoft/yapsdata')
* Lots of examples and tests added


# yaps v1.2.2

## New stuff
Expand Down Expand Up @@ -31,7 +38,7 @@
* Add option to use alternative optimization function (EXPERIMENTAL). Try nloptr() instead of default nlminb(), if you have issues with e.g. false convergence.
* Add option to use linear correction information when running the sync model (EXPERIMENTAL).
* Add option to specify all three ping types in testYaps(). PingType can be 'sbi' (default), 'rbi' or 'pbi'
* Not related to package development, but check out [yaps-live](https://baktoft.shinyapps.io/yapslive/) to see `yaps` in action.
* Not related to package development, but check out yaps-live https://baktoft.shinyapps.io/yapslive/ to see `yaps` in action.


## Minor new stuff
Expand Down
3 changes: 2 additions & 1 deletion R/alignBurstSeq.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#' @param plot_diag Logical indicating if visual diagnosis plots should be created.
#' return data.table like input, but with extra columns seq_ping_idx and seq_epo
#' @export
#' @example man/examples/example-alignBurstSeq.R
alignBurstSeq <- function(synced_dat, burst_seq, seq_lng_min=10, rbi_min, rbi_max, plot_diag=TRUE){
burst_seq_dt <- data.table::data.table(bi=burst_seq)
burst_seq_dt[, seq_ping_idx := 1:.N]
Expand Down Expand Up @@ -55,7 +56,7 @@ alignBurstSeq <- function(synced_dat, burst_seq, seq_lng_min=10, rbi_min, rbi_ma
plot(log(seq_diffs))
points(log(seq_diffs[seq_fix_idx]) ~ seq_fix_idx, col="red", pch=20, cex=2)

plot(synced_dat[, eposync - seq_epo] ~ synced_dat$ts, pch=".", main="NOTE: If the line suddenly shifts, \n tag time drift is too large!")
plot(synced_dat[, eposync - seq_epo] ~ synced_dat$ts, pch=".")
par(mfrow=c(1,1))
}

Expand Down
2 changes: 2 additions & 0 deletions R/applySync.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#' @param toa Object containing data to be synchronized. Typically a `data.table` as e.g. `ssu1$detections`, but can also be a matrix dim=(n_ping, n_hydo).
#' @param hydros data.table formatted as `ssu1$hydros`
#' @param sync_model Synchronization model obtained using `getSyncModel()`
#' @example man/examples/example-yaps_ssu1.R

#' @export
applySync <- function(toa, hydros="", sync_model){
if(is.matrix(toa)) {type <- "toa_matrix"
Expand Down
4 changes: 4 additions & 0 deletions R/checkInp.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#' Check consistency of `inp` object obtained from `getInp()`
#'
#' @param inp Object obtained using `getInp()`
#' @export
#' @example man/examples/example-yaps_ssu1.R
checkInp <- function(inp){

stopifnot(ncol(inp$datTmb$toa) == inp$datTmb$np)
Expand All @@ -11,5 +13,7 @@ checkInp <- function(inp){
stopifnot(dim(inp$datTmb$H)[2] == 3)
stopifnot(length(inp$datTmb$z_vec) == inp$datTmb$np)
}

print("checkInp passed!")

}
1 change: 1 addition & 0 deletions R/checkInpSync.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#' @inheritParams getInpSync
#' @param inp_sync Object obtained using `getInpSync()`
#' @export
#' @example man/examples/example-yaps_ssu1.R
checkInpSync <- function(inp_sync, silent_check){
# speed of sound stuff
if(!silent_check & inp_sync$dat_tmb_sync$ss_data_what != "data"){cat("WARNING: getSyncModel() will estimate speed of sound. It is strongly advised to use data instead!\n")}
Expand Down
38 changes: 12 additions & 26 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,34 +32,20 @@
#' }
"ssu1"

#' Test data from Lake Hald, Denmark
#'
#'

#' Example data for showcasing yaps function alignBurstSeq()
#'
#' @format A list containing 3 data.tables:
#' Function alignBurstSeq() is used to align synced detection data with a sequence of known random burst intervals (BI). \cr
#' This step is needed to take advantage of the extra information available when working with random BI data with a known sequence. \cr
#' This small sample is obtained from the accompanying data package `yapsdata`.
#'
#' @format A list containing 2 items:
#' \describe{
#' \item{hydros}{
#' \itemize{
#' \item serial Hydrophone serial number.
#' \item x,y,z Position of hydrophones in UTM.
#' \item sync_tag ID of co-located sync tag. Must be identical to entries in data.table detections$tag.
#' \item idx Unique values from 1:nrow(hydros).
#' }
#' }
#' \item{detections}{
#' \itemize{
#' \item ts Timestamp of detection in POSIXct().
#' \item tag ID of detected tag.
#' \item epo Timestamp as number of seconds since Unix epoch. Can be obtained using as.numeric(ts).
#' \item frac Sub-second part of detection timestamp in fractions of second [0-1].
#' \item serial Serial number of detecting hydrophone. Must match entry in data.table hydros.
#' }
#' \item{synced_dat_1315}{
#' data.table containing synced detections of tag 1315.
#' }
#' \item{gps}{
#' \itemize{
#' \item ts Timestamp of gps position in POSIXct().
#' \item utm_x, utm_y Coordinates of position. Same projection and coordinate system as used in hydros.
#' }
#' \item{synced_dat_1315}{
#' vector of small part of the complete sequence of known random BIs.
#' }
#' }
"hald"
"dat_align"
8 changes: 5 additions & 3 deletions R/fineTuneSyncModel.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
#' @param sync_model sync_model obtained using getSyncModel()
#' @param eps_threshold Maximum value of residual measured in meter assuming speed of sound = 1450 m/s
#' @param silent logical whether to make getSyncModel() silent
#' @example man/examples/example-yaps_ssu1.R
#' @export
#' @example man/examples/example-yaps_ssu1.R
fineTuneSyncModel <- function(sync_model, eps_threshold, silent=TRUE){
# original inp_sync
inp_sync <- sync_model$inp_synced
Expand Down Expand Up @@ -42,11 +44,11 @@ fineTuneSyncModel <- function(sync_model, eps_threshold, silent=TRUE){
# inp_sync$params_tmb_sync$SLOPE2 <- sync_model$pl$SLOPE2
# inp_sync$params_tmb_sync$SS <- sync_model$pl$SS # Disabled because option to use ss_data is implemented...
# inp_sync$params_tmb_sync$LOG_SIGMA_HYDROS_XY <- sync_model$pl$LOG_SIGMA_HYDROS_XY
inp_sync$params_tmb_sync$TRUE_H <- sync_model$pl$TRUE_H
inp_sync$params_tmb_sync$LOG_SIGMA_TOA <- sync_model$pl$LOG_SIGMA_TOA
# inp_sync$params_tmb_sync$TRUE_H <- sync_model$pl$TRUE_H
# inp_sync$params_tmb_sync$LOG_SIGMA_TOA <- sync_model$pl$LOG_SIGMA_TOA

# run getSyncModel() using the tuned inp_sync
sync_model_tuned <- getSyncModel(inp_sync, silent=silent)
sync_model_tuned <- getSyncModel(inp_sync, silent=silent, tmb_smartsearch=inp_sync$inp_params$tmb_smartsearch, max_iter=inp_sync$inp_params$max_iter)

return(sync_model_tuned)
}
1 change: 1 addition & 0 deletions R/getBbox.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#' @param pen Specifies the penalty multiplier.
#' @inheritParams getInp
#' @export
#' @example man/examples/example-bbox.R
getBbox <- function(hydros, buffer=5, eps=1E-3, pen=1){
x_min <- hydros[which.min(hydros$hx), hx] - buffer
x_max <- hydros[which.max(hydros$hx), hx] + buffer
Expand Down
1 change: 1 addition & 0 deletions R/getToaYaps.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#' @param synced_dat `data.table` containing synchronized data formatted as output from/or obtained using `applySync()`
#' @inheritParams getInp
#' @export
#' @example man/examples/example-yaps_ssu1.R
getToaYaps <- function(synced_dat, hydros, rbi_min, rbi_max){

# remove NAs in eposync
Expand Down
1 change: 1 addition & 0 deletions R/plotBbox.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#' Graphical representation of spatial constraints
#' @inheritParams getInp
#' @export
#' @example man/examples/example-bbox.R
plotBbox <- function(hydros, bbox){
Var1 <- Var2 <- NULL
softplus <- function(x, eps){return (0.5*(x+sqrt(x*x+eps*eps))) }
Expand Down
6 changes: 4 additions & 2 deletions R/plotYaps.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#' Basic plots of yaps output
#'
#' @param inp Input object obtained using \code{getInp()}
#' @param yaps_out Output from succesful run of \code{runYaps()}
#' @param type Plot type. \code{type="map"} prodces a basic map of estimated track and hydrophones; \code{type="coord_X"}, \code{type="coord_Y"} produces plots of X and Y coordinated including +- 1 standard error.
#' @param xlim,ylim Optional vectors of length 2 to set xlim and/or ylim.
#' @param main Title of plot - optional.
#' @export
plotYaps <- function(inp, yaps_out, type="map", xlim=NULL, ylim=NULL, main=NULL){
#' @example man/examples/example-plotYaps.R
plotYaps <- function(yaps_out, type="map", xlim=NULL, ylim=NULL, main=NULL){
inp <- yaps_out$inp

pl <- yaps_out$pl
plsd <- yaps_out$plsd

Expand Down
5 changes: 4 additions & 1 deletion R/prepFiles.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#' Prepare detections data.table from raw data - csv-files exported from vendor software
#' Experimental! Prepare detections data.table from raw data - csv-files exported from vendor software
#' @param raw_dat Data file from vendor supplied software
#' @param type Type of the vendor file. Currently only 'vemco_vue' is supported.
#' @export
#' @examples \dontrun{
#' prepped_detections <- prepDetection("path-to-raw-data-file", type="vemco_vue")
#' }
prepDetections <- function(raw_dat, type){
detections <- data.table::data.table()
if (type == "vemco_vue"){
Expand Down
Loading