Skip to content

Commit

Permalink
Merge branch 'dev' into detection_range_model
Browse files Browse the repository at this point in the history
  • Loading branch information
jdpye authored Mar 5, 2024
2 parents daa77fe + f016ab1 commit 05fff7f
Show file tree
Hide file tree
Showing 76 changed files with 3,795 additions and 2,206 deletions.
7 changes: 4 additions & 3 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
^Meta$
^doc$
ReadMe.md
CONTRIBUTING.md
glatos.pdf
^ReadMe\.md$
^CONTRIBUTING\.md$
^glatos\.pdf$
^data-raw$
^.*\.Rproj$
^\.Rproj\.user$
^README\.Rmd$
^README-.*\.png$
^\.github$
^R/util-intern_pkg_man\.r$
3 changes: 2 additions & 1 deletion .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

Expand All @@ -47,3 +47,4 @@ jobs:
- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
error-on: '"error"'
2 changes: 1 addition & 1 deletion .github/workflows/document.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-commands.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/pr-fetch@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/style.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down
20 changes: 11 additions & 9 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,40 @@ 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 https://glatos.glos.us; many more broadly relevant to simulating, processing, analysing, and visualizing acoustic telemetry data.
Version: 0.8.0.9000
Date: 2024-01-04
Version: 0.8.0.9004
Date: 2024-02-16
Depends: R (>= 3.5.0)
Imports:
av,
data.table,
dplyr,
fasterize,
fasttime,
gdalUtilities,
geodist,
gdistance,
geosphere,
jsonlite,
knitr,
lubridate,
magrittr,
methods,
plotrix,
purrr,
raster,
readxl,
rmarkdown,
sf,
sp,
tibble,
tidyr
tidyr,
units,
zip
Suggests:
gganimate,
gifski,
knitr,
methods,
png,
testthat (>= 3.0.0),
rmarkdown,
terra,
testthat (>= 3.0.0),
tint
URL: https://github.com/ocean-tracking-network/glatos
BugReports: https://github.com/ocean-tracking-network/glatos/issues
Expand All @@ -49,7 +51,7 @@ Authors@R: c(
License: GPL-2
LazyLoad: yes
LazyData: true
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
VignetteBuilder: knitr
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
Expand Down
37 changes: 36 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,36 @@
----

# glatos 0.8.0 (dev)


### Bug fixes
### Bug fixes and minor changes

- Add `@srs` slot to `greatLakesTrLayer` data object and rename file
'data/greatLakesTrLayer.rda'.
- fixes [issue #213](https://github.com/ocean-tracking-network/glatos/issues/213)

- Fix bug in `read_glatos_workbook()` where timestamps during daylight savings
were shifted one hour on linux operating system (not an issue on windows or
mac).
- fixes [issue #208](https://github.com/ocean-tracking-network/glatos/issues/208)

- Omit data.table from class of object returned by `read_glatos_detections()`
and `read_glatos_receivers()`.
- fixes [issue #200](https://github.com/ocean-tracking-network/glatos/issues/200)

- Fix typo in Description to Suggest 'gifski' (not 'gifsky').
- fixes [issue #185](https://github.com/ocean-tracking-network/glatos/issues/185)


### New features

#### 2024-01-19

- In `make_frames()`, allow `terra::SpatVector` input for background map
(`bg_map` arg).
- add test for `terra::SpatVector` input


#### 2023-08-30

- Add new functions to create, check, and validate `glatos_animals` objects:
Expand Down Expand Up @@ -62,6 +83,20 @@
using VDAT.exe (e.g., using `vdat_convert()`).


----

# glatos 0.7.1 (2024-01-19)


### Bug fixes and minor changes


- Fix bug introduced in glatos 0.7.0 where x and y limits were switched
when `bg_map` was supplied.
- Add test for various inputs of `background_xlim`, `background_ylim`, and
`bg_map` to function `make_frames`.


----

# glatos 0.7.0 (2024-01-04)
Expand Down
14 changes: 9 additions & 5 deletions R/class-glatos_animals.r
Original file line number Diff line number Diff line change
Expand Up @@ -71,24 +71,28 @@
#' ga_tbl <- as_glatos_animals(x_tbl)
#'
#'
#' # All below will error as invalid
#'
#' # data.frame input; missing column name
#' library(dplyr) # for rename
#' x2 <- rename(x,
#' fish_name = animal_id,
#' release_timestamp = utc_release_date_time
#' )
#'
#' ga2 <- as_glatos_animals(x2)
#'
#' try(
#' ga2 <- as_glatos_animals(x2)
#' )
#'
#' # data.grame input; wrong column class
#' # data.frame input; wrong column class
#' x3 <- mutate(x,
#' animal_id = as.integer(animal_id),
#' utc_release_date_time = as.character(utc_release_date_time)
#' )
#'
#' ga3 <- as_glatos_animals(x3)
#'
#' try(
#' ga3 <- as_glatos_animals(x3)
#' )
#'
#' # Validation and checking
#'
Expand Down
12 changes: 8 additions & 4 deletions R/class-glatos_detections.r
Original file line number Diff line number Diff line change
Expand Up @@ -73,24 +73,28 @@
#' gd_tbl <- as_glatos_detections(x_tbl)
#'
#'
#' # All below will error as invalid
#'
#' # data.frame input; missing column name
#' library(dplyr) # for rename
#' x2 <- rename(x,
#' fish_id = animal_id,
#' det_date_time = detection_timestamp_utc
#' )
#'
#' gd2 <- as_glatos_detections(x2)
#'
#' try(
#' gd2 <- as_glatos_detections(x2)
#' )
#'
#' # data.frame input; wrong column class
#' x3 <- mutate(x,
#' animal_id = as.integer(animal_id),
#' detection_timestamp_utc = as.character(detection_timestamp_utc)
#' )
#'
#' gr3 <- as_glatos_detections(x3)
#'
#' try(
#' gr3 <- as_glatos_detections(x3)
#' )
#'
#' # Validation and checking
#'
Expand Down
11 changes: 7 additions & 4 deletions R/class-glatos_receivers.r
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
#'
#' gr_tbl <- as_glatos_receivers(x_tbl)
#'
#' # All below will error as invalid
#'
#' # data.frame input; missing column name
#' library(dplyr) # for rename
Expand All @@ -94,17 +95,19 @@
#' deploy_timestamp = deploy_date_time
#' )
#'
#' gr2 <- as_glatos_receivers(x2)
#'
#' try(
#' gr2 <- as_glatos_receivers(x2)
#' )
#'
#' # data.frame input; wrong column class
#' x3 <- mutate(x,
#' ins_serial_no = as.integer(ins_serial_no),
#' deploy_date_time = as.character(deploy_date_time)
#' )
#'
#' gr3 <- as_glatos_receivers(x3)
#'
#' try(
#' gr3 <- as_glatos_receivers(x3)
#' )
#'
#' # Validation and checking
#'
Expand Down
26 changes: 14 additions & 12 deletions R/load-read_glatos_detections.r
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ read_glatos_detections <- function(det_file, version = NULL) {
# Identify detection file version
id_det_version <- function(det_file) {
det_col_names <- names(data.table::fread(det_file, nrows = 0))
if (all(glatos:::glatos_detection_schema$v1.4$name %in% det_col_names)) {
if (all(glatos_detection_schema$v1.4$name %in% det_col_names)) {
return("1.4")
} else if (all(glatos:::glatos_detection_schema$v1.3$name %in% det_col_names)) {
} else if (all(glatos_detection_schema$v1.3$name %in% det_col_names)) {
return("1.3")
} else {
stop("Detection file version could not be identified.")
Expand All @@ -65,15 +65,15 @@ read_glatos_detections <- function(det_file, version = NULL) {
if (is.null(version)) {
version <- id_det_version(det_file)
} else if (!(paste0("v", version) %in%
names(glatos:::glatos_detection_schema))) {
names(glatos_detection_schema))) {
stop(paste0("Detection file version ", version, " is not supported."))
}

#-Detections v1.3 or v1.4-----------------------------------------------------
if (version %in% c("1.3", "1.4")) {
vversion <- paste0("v", version)

col_classes <- glatos:::glatos_detection_schema[[vversion]]$type
col_classes <- glatos_detection_schema[[vversion]]$type
timestamp_cols <- which(col_classes == "POSIXct")
date_cols <- which(col_classes == "Date")
col_classes[c(timestamp_cols, date_cols)] <- "character"
Expand All @@ -89,9 +89,9 @@ read_glatos_detections <- function(det_file, version = NULL) {
options(lubridate.fasttime = TRUE)
for (j in timestamp_cols) {
data.table::set(dtc,
j = glatos:::glatos_detection_schema[[vversion]]$name[j],
j = glatos_detection_schema[[vversion]]$name[j],
value = lubridate::parse_date_time(
dtc[[glatos:::glatos_detection_schema[[vversion]]$name[j]]],
dtc[[glatos_detection_schema[[vversion]]$name[j]]],
orders = "ymd HMS",
tz = "UTC"
)
Expand All @@ -100,15 +100,15 @@ read_glatos_detections <- function(det_file, version = NULL) {
# coerce dates to date
for (j in date_cols) {
data.table::set(dtc,
j = glatos:::glatos_detection_schema[[vversion]]$name[j],
value = ifelse(dtc[[glatos:::glatos_detection_schema[[vversion]]$name[j]]] == "",
j = glatos_detection_schema[[vversion]]$name[j],
value = ifelse(dtc[[glatos_detection_schema[[vversion]]$name[j]]] == "",
NA,
dtc[[glatos:::glatos_detection_schema[[vversion]]$name[j]]]
dtc[[glatos_detection_schema[[vversion]]$name[j]]]
)
)
data.table::set(dtc,
j = glatos:::glatos_detection_schema[[vversion]]$name[j],
value = as.Date(dtc[[glatos:::glatos_detection_schema[[vversion]]$name[j]]])
j = glatos_detection_schema[[vversion]]$name[j],
value = as.Date(dtc[[glatos_detection_schema[[vversion]]$name[j]]])
)
}
}
Expand All @@ -128,7 +128,9 @@ read_glatos_detections <- function(det_file, version = NULL) {
))
}

# assign class
# strip data.table and assign glatos_detections class
data.table::setDF(dtc)

dtc <- as_glatos_detections(dtc)

return(dtc)
Expand Down
12 changes: 7 additions & 5 deletions R/load-read_glatos_receivers.r
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ read_glatos_receivers <- function(rec_file, version = NULL) {
# Identify file version
id_file_version <- function(rec_file) {
col_names <- names(data.table::fread(rec_file, nrows = 0))
if (all(glatos:::glatos_receivers_schema$v1.1$name %in% col_names)) {
if (all(glatos_receivers_schema$v1.1$name %in% col_names)) {
return("1.1")
} else if (all(glatos:::glatos_receivers_schema$v1.0$name %in% col_names)) {
} else if (all(glatos_receivers_schema$v1.0$name %in% col_names)) {
return("1.0")
} else {
stop("Receiver location file version could not be identified.")
Expand All @@ -61,7 +61,7 @@ read_glatos_receivers <- function(rec_file, version = NULL) {
if (is.null(version)) {
version <- id_file_version(rec_file)
} else if (!(paste0("v", version) %in%
names(glatos:::glatos_receivers_schema))) {
names(glatos_receivers_schema))) {
stop(paste0(
"Receiver locations file version ", version,
" is not supported."
Expand All @@ -72,7 +72,7 @@ read_glatos_receivers <- function(rec_file, version = NULL) {
if (version %in% c("1.0", "1.1")) {
ver_txt <- paste0("v", version)

col_classes <- glatos:::glatos_receivers_schema[[ver_txt]]$type
col_classes <- glatos_receivers_schema[[ver_txt]]$type
timestamp_cols <- which(col_classes == "POSIXct")
date_cols <- which(col_classes == "Date")
col_classes[c(timestamp_cols, date_cols)] <- "character"
Expand Down Expand Up @@ -109,7 +109,9 @@ read_glatos_receivers <- function(rec_file, version = NULL) {
}
#-end v1.x----------------------------------------------------------------

# assign class
# strip data.table and assign glatos_receivers class
data.table::setDF(rec)

rec <- as_glatos_receivers(rec)

return(rec)
Expand Down
Loading

0 comments on commit 05fff7f

Please sign in to comment.