...
 
Commits (19)
......@@ -2,8 +2,8 @@ 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.3.2.9004
Date: 2019-10-17
Version: 0.4.0
Date: 2019-11-06
Depends: R (>= 3.2.0)
Imports:
cellranger,
......@@ -13,8 +13,9 @@ Imports:
gdalUtils,
gdistance,
geosphere,
lubridate,
jsonlite,
knitr,
lubridate,
magrittr,
methods,
openxlsx (>= 4.0.0),
......@@ -22,6 +23,7 @@ Imports:
plotrix,
plotly,
plyr,
purrr,
raster,
readxl,
rgdal,
......@@ -45,8 +47,9 @@ Authors@R: c(
person("Todd", "Hayden", role = "aut"),
person("Thomas", "Binder", role = "aut"),
person("Jon", "Pye", role = "aut"),
person("Alex", "Nunes", role = "aut"),
person("Angela", "Dini", role = "ctb"))
person("Alex", "Nunes", role = "ctb"),
person("Angela", "Dini", role = "ctb"),
person("Ryan", "Goss", role = "ctb"))
License: GPL-2
LazyLoad: yes
LazyData: true
......
......@@ -5,6 +5,8 @@ export(abacus_plot)
export(adjust_playback_time)
export(calc_collision_prob)
export(check_dependencies)
export(convert_glatos_to_att)
export(convert_otn_erddap_to_att)
export(crw)
export(crw_in_polygon)
export(detect_transmissions)
......
----
# glatos 0.4.0
#### 2019-11-06
### New features
- functions
- convert_glatos_to_att
- convert_otn_erddap_to_att
- example data
- walleye_att
- blue_shart_att
### Minor changes
- change1
----
# glatos 0.3.2
#### 2019-10-17
......@@ -29,6 +50,17 @@
- deprecated *show_receiver_status* argument. Receiver status will
be shown on plot whenever 'receiver_history' is given.
----
# glatos 0.3.1
#### 2019-02-27
### bug fixes
- fix missing brackets in glatos.Rd
----
# glatos 0.3.0
......@@ -102,7 +134,6 @@
----
# glatos 0.2.7
#### 2018-08-29
......
......@@ -85,3 +85,50 @@ NULL
#' @source \url{http://glatos.glos.us/home}
NULL
#' @title Example animal data from the OTN ERDDAP
#'
#' @description An example animal data file from the OTN ERDDAP
#'
#' @format CSV
##'
#' @name otn_aat_animals
#'
#' @section Filename: otn_aat_animals.csv
#'
#' @usage
#' system.file("extdata", "otn_aat_animals.csv", package = "glatos")
#'
#' @source Ryan Gosse, Ocean Tracking Network
NULL
#' @title Example station data from the OTN ERDDAP
#'
#' @description An example receiver station data file from the OTN ERDDAP
#'
#' @format CSV
##'
#' @name otn_aat_receivers
#'
#' @section Filename: otn_aat_receivers.csv
#'
#' @usage
#' system.file("extdata", "otn_aat_receivers.csv", package = "glatos")
#'
#' @source Ryan Gosse, Ocean Tracking Network
NULL
#' @title Example tag release data from the OTN ERDDAP
#'
#' @description An example tag release data file from the OTN ERDDAP
#'
#' @format CSV
##'
#' @name otn_aat_tag_releases
#'
#' @section Filename: otn_aat_tag_releases.csv
#'
#' @usage
#' system.file("extdata", "otn_aat_tag_releases.csv", package = "glatos")
#'
#' @source Ryan Gosse, Ocean Tracking Network
NULL
......@@ -101,6 +101,17 @@
#' and receiver network designs.}
#' }
#'
#' @section Convert glatos data objects to other package classes: \describe{
#' \item{\link{convert_glatos_to_att}}{ Converts glatos_detections and
#' glatos_receiver objects to ATT for compatibility with the Animal Tracking
#' Toolbox(https://github.com/vinayudyawer/ATT) and the VTrack package.}
#'
#' \item{\link{convert_otn_erddap_to_att}}{ Converts glatos_detections and
#' transmitter, receiver, and animal metadata from the OTN ERDDAP to ATT format
#' for compatibility with the Animal Tracking
#' Toolbox(https://github.com/vinayudyawer/ATT) and the VTrack package.}
#' }
#' @docType package
#' @name glatos
#' @import data.table sp
......@@ -117,7 +128,7 @@ globalVariables(".") #to avoid R CMD check note
#package startup message
.onAttach <- function(libname, pkgname) {
packageStartupMessage(paste0("version ",utils::packageVersion("glatos"),
" ('dreamsicle-snow-cone')"))
" ('full-english-breakfast')"))
}
......
No preview for this file type
#' Convert detections and receiver metadata to a format that
#' ATT accepts.
#'
#' Convert \code{glatos_detections} and \code{glatos_receiver} objects to \code{ATT} for compatibility with the Animal Tracking Toolbox (\url{https://github.com/vinayudyawer/ATT}).
#'
#' @param detectionObj a list from \code{read_glatos_detections}
#'
#' @param receiverObj a list from \code{read_glatos_receivers}
#'
#' @details This function takes 2 lists containing detection and reciever data
#' and transforms them into one list containing 3 \code{tibble::tibble}
#' objects. The input that AAT uses to get this data product is located here:
#' https://github.com/vinayudyawer/ATT/blob/master/README.md and our mappings
#' are found here: https://gitlab.oceantrack.org/GreatLakes/glatos/issues/83
#' in a comment by Ryan Gosse.
#'
#' @author Ryan Gosse
#'
#' @return a list of 3 tibble::tibbles containing tag dectections, tag metadata,
#' and station metadata, to be ingested by VTrack/ATT
#'
#' @examples
#'
#' #--------------------------------------------------
#' # EXAMPLE #1 - loading from the vignette data
#'
#' library(glatos)
#' wal_det_file <- system.file("extdata", "walleye_detections.csv",
#' package = "glatos")
#' walleye_detections <- read_glatos_detections(wal_det_file) # load walleye data
#'
#' rec_file <- system.file("extdata", "sample_receivers.csv",
#' package = "glatos")
#' rcv <- read_glatos_receivers(rec_file) # load receiver data
#'
#' ATTdata <- convert_glatos_to_att(walleye_detections, rcv)
#' @export
convert_glatos_to_att <- function(detectionObj, receiverObj) {
transmitters <-
if(all(grepl("-", detectionObj$transmitter_id, fixed=TRUE))) {
detectionObj$transmitter_id
} else {
concat_list_strings(detectionObj$transmitter_codespace,
detectionObj$transmitter_id)
}
tagMetadata <- unique(tibble::tibble( # Start building Tag.Metadata table
Tag.ID = as.integer(detectionObj$animal_id),
Transmitter = as.factor(transmitters),
Common.Name = as.factor(detectionObj$common_name_e)
))
tagMetadata <- unique(tagMetadata) # Cut out dupes
nameLookup <- tibble::tibble( # Get all the unique common names
Common.Name = unique(tagMetadata$Common.Name)
)
nameLookup <- dplyr::mutate(nameLookup, # Add scinames to the name lookup
Sci.Name = as.factor(purrr::map(nameLookup$Common.Name, query_worms_common))
)
# Apply sci names to frame
tagMetadata <- dplyr::left_join(tagMetadata, nameLookup)
releaseData <- tibble::tibble( # Get the rest from detectionObj
Tag.ID = as.integer(detectionObj$animal_id),
Tag.Project = as.factor(detectionObj$glatos_project_transmitter),
Release.Latitude = detectionObj$release_latitude,
Release.Longitude = detectionObj$release_longitude,
Release.Date = as.Date(detectionObj$utc_release_date_time),
Sex = as.factor(detectionObj$sex)
)
releaseData <- dplyr::mutate(releaseData,
# Convert sex text and null missing columns
Sex = as.factor(purrr::map(Sex, convert_sex)),
Tag.Life = as.integer(NA),
Tag.Status = as.factor(NA),
Bio = as.factor(NA)
)
# Final version of Tag.Metadata
tagMetadata <- dplyr::left_join(tagMetadata, releaseData)
detectionObj <- detectionObj %>%
dplyr::mutate(dummy = TRUE) %>%
dplyr::left_join(dplyr::select(receiverObj %>%
dplyr::mutate(dummy=TRUE),
glatos_array, station_no, deploy_lat, deploy_long,
station, dummy, ins_model_no, ins_serial_no,
deploy_date_time, recover_date_time)) %>%
dplyr::filter(detection_timestamp_utc >= deploy_date_time,
detection_timestamp_utc <= recover_date_time) %>%
dplyr::mutate(ReceiverFull = concat_list_strings(ins_model_no,
ins_serial_no)) %>%
dplyr::select(-dummy)
detections <- unique(tibble::tibble(
Date.Time = detectionObj$detection_timestamp_utc,
Transmitter = as.factor(
concat_list_strings(detectionObj$transmitter_codespace,
detectionObj$transmitter_id)),
Station.Name = as.factor(detectionObj$station),
Receiver = as.factor(detectionObj$ReceiverFull),
Latitude = detectionObj$deploy_lat,
Longitude = detectionObj$deploy_long,
Sensor.Value = as.integer(detectionObj$sensor_value),
Sensor.Unit = as.factor(detectionObj$sensor_unit)
))
stations <- unique(tibble::tibble(
Station.Name = as.factor(receiverObj$station),
Receiver = as.factor(concat_list_strings(receiverObj$ins_model_no,
receiverObj$ins_serial_no)),
Installation = as.factor(NA),
Receiver.Project = as.factor(receiverObj$glatos_project),
Deployment.Date = receiverObj$deploy_date_time,
Recovery.Date = receiverObj$recover_date_time,
Station.Latitude = receiverObj$deploy_lat,
Station.Longitude = receiverObj$deploy_long,
Receiver.Status = as.factor(NA)
))
att_obj <- list(
Tag.Detections = detections,
Tag.Metadata = unique(tagMetadata),
Station.Information = unique(stations)
)
class(att_obj) <- "ATT"
return(att_obj)
}
# Function for taking 2 lists of string of the same length and concatenating the
# columns, row by row.
concat_list_strings <- function(list1, list2, sep = "-") {
if (length(list1) != length(list2)) {
stop(sprintf("Lists are not the same size. %d != %d.",
length(list1), length(list2)))
}
return (paste(list1, list2, sep = sep))
}
# Simple query to WoRMS based on the common name and returns the sci name
query_worms_common <- function(commonName) {
url <- utils::URLencode(
sprintf("http://www.marinespecies.org/rest/AphiaRecordsByVernacular/%s",
commonName))
tryCatch({
print(url)
payload <- jsonlite::fromJSON(url)
return(payload$scientificname)
}, error = function(e){
print(geterrmessage())
stop(sprintf('Error in querying WoRMS, %s was probably not found.',
commonName))
})
}
# Convert the sex from 'F' and 'M' to 'FEMALE' and 'MALE'
convert_sex <- function(sex) {
if (toupper(sex) %in% c("F", "FEMALE")) return("FEMALE")
if (toupper(sex) %in% c("M", "MALE")) return("MALE")
return(sex)
}
# Converts the reciever reference id to station name
extract_station <- function(reciever_ref) {
reciever_ref <- as.character(reciever_ref)
return( # Split the string by _ and drop the array name
unlist(
strsplit(c(reciever_ref), c("_"))
)[-1]
)
}
#' Convert detections, transmitter, receiver, and animal metadata to a format
#' that ATT accepts.
#'
#' Convert \code{glatos_detections} and transmitter, receiver, and animal
#' metadata from the OTN ERDDAP to \code{ATT} format for use in the Animal
#' Tracking Toolbox (\url{https://github.com/vinayudyawer/ATT}).
#'
#' @param detectionObj a data frame from \code{read_glatos_detections}
#'
#' @param erdTags a data frame with tag release data from the OTN ERDDAP
#'
#' @param erdRcv a data frame with receiver station data from the OTN ERDDAP
#'
#' @param erdAni a data frame with animal data from the OTN ERDDAP
#'
#'
#' @details This function takes 4 data frames containing detection, and ERDDAP
#' data from the tags, receivers, and animals tables, and transforms them into
#' 3 \code{tibble::tibble} objects inside of a list. The input that AAT uses
#' to get this data product is located here:
#' https://github.com/vinayudyawer/ATT/blob/master/README.md and our mappings
#' are found here: https://gitlab.oceantrack.org/GreatLakes/glatos/issues/83
#' in a comment by Ryan Gosse. The OTN ERDDAP instance is here:
#' https://members.oceantrack.org/erddap/tabledap/index.html but please note
#' that this only contains public data.
#'
#' @author Ryan Gosse
#'
#' @return a list of 3 tibble::tibbles containing tag dectections, tag metadata,
#' and station metadata, to be ingested by VTrack/ATT
#'
#' @examples
#'
#' #--------------------------------------------------
#' # EXAMPLE #1 - loading from the OTN ERDDAP + vignettes
#'
#' library(glatos)
#'
#' #get path to example files from OTN ERDDAP
#' ani_erd_file <- system.file("extdata", "otn_aat_animals.csv",
#' package = "glatos")
#' animals <- read.csv(ani_erd_file) # load the CSVs from ERDDAP
#'
#' tags_erd_file <- system.file("extdata", "otn_aat_tag_releases.csv",
#' package = "glatos")
#' tags <- read.csv(tags_erd_file)
#'
#' rcv_erd_file <- system.file("extdata", "otn_aat_receivers.csv",
#' package = "glatos")
#' stations <- read.csv(rcv_erd_file)
#'
#' #Remove first row; (blank or metadata about the column)
#' animals <- animals[-1,]
#' tags <- tags[-1,]
#' stations <- stations[-1,]
#'
#' #get blue shark example data
#' shrk_det_file <- system.file("extdata", "blue_shark_detections.csv",
#' package = "glatos")
#' blue_shark_detections <- read_otn_detections(shrk_det_file) # load shark data
#'
#' ATTdata <- convert_otn_erddap_to_att(blue_shark_detections,
#' tags, stations, animals)
#' @export
convert_otn_erddap_to_att <- function(detectionObj, erdTags, erdRcv, erdAni) {
transmitters <-
if(all(grepl("-", detectionObj$transmitter_id, fixed=TRUE))){
detectionObj$transmitter_id
} else {
concat_list_strings(detectionObj$transmitter_codespace, detectionObj$transmitter_id)
}
tagMetadata <- unique(tibble::tibble( # Start building Tag.Metadata table
Tag.ID = detectionObj$animal_id,
Transmitter = as.factor(transmitters),
Common.Name = as.factor(detectionObj$common_name_e)
))
tagMetadata <- unique(tagMetadata) # Cut out dupes
nameLookup <- tibble::tibble( # Get all the unique common names
Common.Name = unique(tagMetadata$Common.Name)
)
nameLookup <- dplyr::mutate(nameLookup, # Add scinames to the name lookup
Sci.Name = as.factor(purrr::map(nameLookup$Common.Name, query_worms_common))
)
# Apply sci names to frame
tagMetadata <- dplyr::left_join(tagMetadata, nameLookup)
# Matching cols that have different names
colnames(erdTags)[colnames(erdTags) == "tag_device_id"] <- "transmitter_id"
detectionObj <- dplyr::left_join(detectionObj, erdTags)
erdRcv <- dplyr::mutate(erdRcv,
station = as.character(purrr::map(erdRcv$receiver_reference_id,
extract_station))
)
# Matching cols that have different names
colnames(erdAni)[colnames(erdAni) == "animal_reference_id"] <- "animal_id"
detectionObj <- dplyr::left_join(detectionObj, erdAni)
releaseData <- tibble::tibble( # Get the rest from detectionObj
Tag.ID = detectionObj$animal_id,
Tag.Project = as.factor(detectionObj$animal_project_reference),
Release.Latitude = as.double(detectionObj$latitude),
Release.Longitude = as.double(detectionObj$longitude),
Release.Date = as.Date(detectionObj$time),
Sex = as.factor(detectionObj$sex)
)
releaseData <- dplyr::mutate(releaseData,
# Convert sex text and null missing columns
Sex = as.factor(purrr::map(Sex, convert_sex)),
Tag.Life = as.integer(NA),
Tag.Status = as.factor(NA),
Bio = as.factor(NA)
)
# Final version of Tag.Metadata
tagMetadata <- unique(dplyr::left_join(tagMetadata, releaseData))
detectionObj <- detectionObj %>%
dplyr::mutate(dummy=TRUE) %>%
dplyr::left_join(dplyr::select(erdRcv %>% dplyr::mutate(dummy = TRUE),
rcv_latitude = latitude,
rcv_longitude = longitude,
station,
receiver_model,
receiver_serial_number,
dummy,
deploy_datetime_utc = time,
recovery_datetime_utc)) %>%
dplyr::mutate(deploy_datetime_utc = as.POSIXct(deploy_datetime_utc,
format = "%Y-%m-%dT%H:%M:%OS"),
recovery_datetime_utc = as.POSIXct(recovery_datetime_utc,
format="%Y-%m-%dT%H:%M:%OS")) %>%
dplyr::filter(detection_timestamp_utc >= deploy_datetime_utc,
detection_timestamp_utc <= recovery_datetime_utc) %>%
dplyr::mutate(ReceiverFull = concat_list_strings(receiver_model,
receiver_serial_number)) %>%
dplyr::select(-dummy)
detections <- tibble::tibble(
Date.Time = detectionObj$detection_timestamp_utc,
Transmitter = as.factor(detectionObj$transmitter_id),
Station.Name = as.factor(detectionObj$station),
Receiver = as.factor(detectionObj$ReceiverFull),
Latitude = detectionObj$deploy_lat,
Longitude = detectionObj$deploy_long,
Sensor.Value = as.integer(detectionObj$sensorvalue),
Sensor.Unit = as.factor(detectionObj$sensorunit)
)
stations <- unique(tibble::tibble(
Station.Name = as.factor(detectionObj$station),
Receiver = as.factor(detectionObj$ReceiverFull),
Installation = as.factor(NA),
Receiver.Project = as.factor(detectionObj$collectioncode),
Deployment.Date = detectionObj$deploy_datetime_utc,
Recovery.Date = detectionObj$recovery_datetime_utc,
Station.Latitude = as.double(detectionObj$deploy_lat),
Station.Longitude = as.double(detectionObj$deploy_long),
Receiver.Status = as.factor(NA)
))
att_obj <- list(
Tag.Detections = detections,
Tag.Metadata = tagMetadata,
Station.Information = stations
)
class(att_obj) <- "ATT"
return(att_obj)
}
# Function for taking 2 lists of string of the same length and concatenating
# the columns, row by row.
concat_list_strings <- function(list1, list2, sep = "-") {
if (length(list1) != length(list2)) {
stop(sprintf("Lists are not the same size. %d != %d.",
length(list1), length(list2)))
}
return (paste(list1, list2, sep = sep))
}
# Simple query to WoRMS based on the common name and returns the sci name
query_worms_common <- function(commonName) {
url <- utils::URLencode(
sprintf("http://www.marinespecies.org/rest/AphiaRecordsByVernacular/%s",
commonName))
tryCatch({
print(url)
payload <- jsonlite::fromJSON(url)
return(payload$scientificname)
}, error = function(e){
print(geterrmessage())
stop(sprintf('Error in querying WoRMS, %s was probably not found.',
commonName))
})
}
# Convert the sex from 'F' and 'M' to 'FEMALE' and 'MALE'
convert_sex <- function(sex) {
if (toupper(sex) %in% c("F", "FEMALE")) return("FEMALE")
if (toupper(sex) %in% c("M", "MALE")) return("MALE")
return(sex)
}
# Converts the reciever reference id to station name
extract_station <- function(reciever_ref) {
reciever_ref <- as.character(reciever_ref)
return( # Split the string by _ and drop the array name
unlist(
strsplit(c(reciever_ref), c("_"))
)[-1]
)
}
......@@ -58,3 +58,11 @@ species and individual animals.
4. [`adjust_playback_time`](https://gitlab.oceantrack.org/GreatLakes/glatos/blob/master/R/vis-adjust_playback_time.r) modify playback speed of videos and optionally convert between video file formats. Requires *FFmpeg*
#### Data Exporting
1. [`convert_glatos_to_att`](https://gitlab.oceantrack.org/GreatLakes/glatos/blob/master/R/util-convert_glatos_to_att.r) converts the glatos
detection and receiver objects to a format supported by [VTrack](https://github.com/RossDwyer/VTrack)/[ATT](https://github.com/vinayudyawer/ATT).
2. [`convert_otn_erddap_to_att`](https://gitlab.oceantrack.org/GreatLakes/glatos/blob/master/R/util-convert_otn_erddap_to_att.r) converts the OTN
detection and ERDDAP csvs of OTN animals, tags and stations to a format supported by [VTrack](https://github.com/RossDwyer/VTrack)/[ATT](https://github.com/vinayudyawer/ATT).
#Make internal data object blue_shark_att for testing
# (example data object)
#get blue shark example data
dtc_file <- system.file("extdata",
"blue_shark_detections.csv", package = "glatos")
shrk_det_file <- system.file("extdata", "blue_shark_detections.csv",
package = "glatos")
blue_shark_detections <- read_otn_detections(shrk_det_file)
#get path to example files from OTN ERDDAP
ani_erd_file <- system.file("extdata", "otn_aat_animals.csv",
package = "glatos")
animals <- read.csv(ani_erd_file, as.is = TRUE) # load the CSVs from ERDDAP
tags_erd_file <- system.file("extdata", "otn_aat_tag_releases.csv",
package = "glatos")
tags <- read.csv(tags_erd_file, as.is = TRUE)
rcv_erd_file <- system.file("extdata", "otn_aat_receivers.csv",
package = "glatos")
stations <- read.csv(rcv_erd_file, as.is = TRUE)
#Remove first row; (blank or metadata about the column)
animals <- animals[-1,]
tags <- tags[-1,]
stations <- stations[-1,]
#create ATT object
blue_shark_att <- convert_otn_erddap_to_att(blue_shark_detections,
tags, stations, animals)
#----------------------------------------------------
#add to sysdata.rda
rda_file <- file.path(".","R/sysdata.rda")
glatos:::add_internal_data(blue_shark_att, rda_file)
#for exported ('public') data
#devtools::use_data(walleye_detections, pkg = "..", overwrite = TRUE)
#Make internal data object walleye_att for testing
# (example data object)
#get path to example detections file
dtc_file <- system.file("extdata",
"walleye_detections.csv", package = "glatos")
#get path to example receiver file
rec_file <- system.file("extdata", "sample_receivers.csv",
package = "glatos")
#create new objects
walleye_detections <- read_glatos_detections(dtc_file)
rcv <- read_glatos_receivers(rec_file) # load receiver data
walleye_att <- convert_glatos_to_att(walleye_detections, rcv)
#----------------------------------------------------
#add to sysdata.rda
rda_file <- file.path(".","R/sysdata.rda")
glatos:::add_internal_data(walleye_att, rda_file)
#for exported ('public') data
#devtools::use_data(walleye_detections, pkg = "..", overwrite = TRUE)
......@@ -5,7 +5,7 @@
dtc_file <- system.file("extdata",
"walleye_detections.csv", package = "glatos")
#create new object
#create new objects
walleye_detections <- read_glatos_detections(dtc_file)
#----------------------------------------------------
......
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/util-convert_glatos_to_att.r
\name{convert_glatos_to_att}
\alias{convert_glatos_to_att}
\title{Convert detections and receiver metadata to a format that
ATT accepts.}
\usage{
convert_glatos_to_att(detectionObj, receiverObj)
}
\arguments{
\item{detectionObj}{a list from \code{read_glatos_detections}}
\item{receiverObj}{a list from \code{read_glatos_receivers}}
}
\value{
a list of 3 tibble::tibbles containing tag dectections, tag metadata,
and station metadata, to be ingested by VTrack/ATT
}
\description{
Convert \code{glatos_detections} and \code{glatos_receiver} objects to \code{ATT} for compatibility with the Animal Tracking Toolbox (\url{https://github.com/vinayudyawer/ATT}).
}
\details{
This function takes 2 lists containing detection and reciever data
and transforms them into one list containing 3 \code{tibble::tibble}
objects. The input that AAT uses to get this data product is located here:
https://github.com/vinayudyawer/ATT/blob/master/README.md and our mappings
are found here: https://gitlab.oceantrack.org/GreatLakes/glatos/issues/83
in a comment by Ryan Gosse.
}
\examples{
#--------------------------------------------------
# EXAMPLE #1 - loading from the vignette data
library(glatos)
wal_det_file <- system.file("extdata", "walleye_detections.csv",
package = "glatos")
walleye_detections <- read_glatos_detections(wal_det_file) # load walleye data
rec_file <- system.file("extdata", "sample_receivers.csv",
package = "glatos")
rcv <- read_glatos_receivers(rec_file) # load receiver data
ATTdata <- convert_glatos_to_att(walleye_detections, rcv)
}
\author{
Ryan Gosse
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/util-convert_otn_erddap_to_att.r
\name{convert_otn_erddap_to_att}
\alias{convert_otn_erddap_to_att}
\title{Convert detections, transmitter, receiver, and animal metadata to a format
that ATT accepts.}
\usage{
convert_otn_erddap_to_att(detectionObj, erdTags, erdRcv, erdAni)
}
\arguments{
\item{detectionObj}{a data frame from \code{read_glatos_detections}}
\item{erdTags}{a data frame with tag release data from the OTN ERDDAP}
\item{erdRcv}{a data frame with receiver station data from the OTN ERDDAP}
\item{erdAni}{a data frame with animal data from the OTN ERDDAP}
}
\value{
a list of 3 tibble::tibbles containing tag dectections, tag metadata,
and station metadata, to be ingested by VTrack/ATT
}
\description{
Convert \code{glatos_detections} and transmitter, receiver, and animal
metadata from the OTN ERDDAP to \code{ATT} format for use in the Animal
Tracking Toolbox (\url{https://github.com/vinayudyawer/ATT}).
}
\details{
This function takes 4 data frames containing detection, and ERDDAP
data from the tags, receivers, and animals tables, and transforms them into
3 \code{tibble::tibble} objects inside of a list. The input that AAT uses
to get this data product is located here:
https://github.com/vinayudyawer/ATT/blob/master/README.md and our mappings
are found here: https://gitlab.oceantrack.org/GreatLakes/glatos/issues/83
in a comment by Ryan Gosse. The OTN ERDDAP instance is here:
https://members.oceantrack.org/erddap/tabledap/index.html but please note
that this only contains public data.
}
\examples{
#--------------------------------------------------
# EXAMPLE #1 - loading from the OTN ERDDAP + vignettes
library(glatos)
#get path to example files from OTN ERDDAP
ani_erd_file <- system.file("extdata", "otn_aat_animals.csv",
package = "glatos")
animals <- read.csv(ani_erd_file) # load the CSVs from ERDDAP
tags_erd_file <- system.file("extdata", "otn_aat_tag_releases.csv",
package = "glatos")
tags <- read.csv(tags_erd_file)
rcv_erd_file <- system.file("extdata", "otn_aat_receivers.csv",
package = "glatos")
stations <- read.csv(rcv_erd_file)
#Remove first row; (blank or metadata about the column)
animals <- animals[-1,]
tags <- tags[-1,]
stations <- stations[-1,]
#get blue shark example data
shrk_det_file <- system.file("extdata", "blue_shark_detections.csv",
package = "glatos")
blue_shark_detections <- read_otn_detections(shrk_det_file) # load shark data
ATTdata <- convert_otn_erddap_to_att(blue_shark_detections,
tags, stations, animals)
}
\author{
Ryan Gosse
}
......@@ -117,3 +117,16 @@ and receiver network designs.}
}
}
\section{Convert glatos data objects to other package classes}{
\describe{
\item{\link{convert_glatos_to_att}}{ Converts glatos_detections and
glatos_receiver objects to ATT for compatibility with the Animal Tracking
Toolbox(https://github.com/vinayudyawer/ATT) and the VTrack package.}
\item{\link{convert_otn_erddap_to_att}}{ Converts glatos_detections and
transmitter, receiver, and animal metadata from the OTN ERDDAP to ATT format
for compatibility with the Animal Tracking
Toolbox(https://github.com/vinayudyawer/ATT) and the VTrack package.}
}
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/extdata.r
\name{otn_aat_animals}
\alias{otn_aat_animals}
\title{Example animal data from the OTN ERDDAP}
\format{CSV}
\source{
Ryan Gosse, Ocean Tracking Network
}
\usage{
system.file("extdata", "otn_aat_animals.csv", package = "glatos")
}
\description{
An example animal data file from the OTN ERDDAP
}
\section{Filename}{
otn_aat_animals.csv
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/extdata.r
\name{otn_aat_receivers}
\alias{otn_aat_receivers}
\title{Example station data from the OTN ERDDAP}
\format{CSV}
\source{
Ryan Gosse, Ocean Tracking Network
}
\usage{
system.file("extdata", "otn_aat_receivers.csv", package = "glatos")
}
\description{
An example receiver station data file from the OTN ERDDAP
}
\section{Filename}{
otn_aat_receivers.csv
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/extdata.r
\name{otn_aat_tag_releases}
\alias{otn_aat_tag_releases}
\title{Example tag release data from the OTN ERDDAP}
\format{CSV}
\source{
Ryan Gosse, Ocean Tracking Network
}
\usage{
system.file("extdata", "otn_aat_tag_releases.csv", package = "glatos")
}
\description{
An example tag release data file from the OTN ERDDAP
}
\section{Filename}{
otn_aat_tag_releases.csv
}
context("Check convert_glatos_to_att")
#check against internal data object 'walleye_att' in R/sysdata.r
# Actual result
#get path to example detection file
wd_file <- system.file("extdata",
"walleye_detections.csv", package = "glatos")
wald <- read_glatos_detections(wd_file)
#get path to example receiver file
rec_file <- system.file("extdata", "sample_receivers.csv",
package = "glatos")
recd <- read_glatos_receivers(rec_file) # load receiver data
watt <- convert_glatos_to_att(wald, recd)
# Test using testthat library
test_that("walleye_att gives expected result", {
# Check if expected and actual results are the same
expect_equal(watt, walleye_att)
})
context("Check convert_otn_erddap_to_att")
#check against internal data object 'blue_shark_att' in R/sysdata.r
# Actual result
#get blue shark example data
dtc_file <- system.file("extdata",
"blue_shark_detections.csv", package = "glatos")
shrk_det_file <- system.file("extdata", "blue_shark_detections.csv",
package = "glatos")
blue_shark_detections <- read_otn_detections(shrk_det_file)
#get path to example files from OTN ERDDAP
ani_erd_file <- system.file("extdata", "otn_aat_animals.csv",
package = "glatos")
animals <- read.csv(ani_erd_file, as.is = TRUE) # load the CSVs from ERDDAP
tags_erd_file <- system.file("extdata", "otn_aat_tag_releases.csv",
package = "glatos")
tags <- read.csv(tags_erd_file, as.is = TRUE)
rcv_erd_file <- system.file("extdata", "otn_aat_receivers.csv",
package = "glatos")
stations <- read.csv(rcv_erd_file, as.is = TRUE)
#Remove first row; (blank or metadata about the column)
animals <- animals[-1,]
tags <- tags[-1,]
stations <- stations[-1,]
#create ATT object
bs_att <- convert_otn_erddap_to_att(blue_shark_detections,
tags, stations, animals)
# Test using testthat library
test_that("blue_shark_att gives expected result", {
# Check if expected and actual results are the same
expect_equal(bs_att, blue_shark_att)
})