From d49a728720befcc3068f56234723a902efad2348 Mon Sep 17 00:00:00 2001 From: Bruce Delo Date: Wed, 18 Mar 2026 15:44:05 -0300 Subject: [PATCH 1/6] Initial build of glatos to animals. --- R/ato_ani_from_glatos.R | 20 ++++++++++++++++++++ R/glatos_to_ato.R | 21 ++++++++------------- 2 files changed, 28 insertions(+), 13 deletions(-) create mode 100644 R/ato_ani_from_glatos.R diff --git a/R/ato_ani_from_glatos.R b/R/ato_ani_from_glatos.R new file mode 100644 index 0000000..61f5563 --- /dev/null +++ b/R/ato_ani_from_glatos.R @@ -0,0 +1,20 @@ +ato_ani_from_glatos <- function(glatos_file) { + #Load the data file we've been given- probably detections data since published glatos data will only have detections and receivers. + glatos_data <- load_file(glatos_file) + + #We don't really have the option here to get this from an 'animal metadata' file so we're always going to be deriving. + ani <- make_ani( + animal = as.character(glatos_data$animal_id), + capture_location = as.character(glatos_data$capture_location), + capture_datetime = as.POSIXct(glatos_data$glatos_caught_date), + capture_lat = NA_real_, + capture_lon = NA_real_, + release_loaction = glatos_data$release_location, + release_datetime = as.POSIXct(glatos_data$utc_release_date_time), + release_lat = glatos_data$release_latitude, + release_lon = glatos_data$release_longitude, + tz = "UTC" + ) + + return (ani) +} \ No newline at end of file diff --git a/R/glatos_to_ato.R b/R/glatos_to_ato.R index bf5428b..2245d8f 100644 --- a/R/glatos_to_ato.R +++ b/R/glatos_to_ato.R @@ -1,6 +1,6 @@ ##' @title Convert GLATOS detection data to an ATO object. ##' -##' @description Takes a GLATOS detection sheet and optionally receiver/tag metadata and returns an ATO object. +##' @description Takes a GLATOS detection sheet and optionally receiver metadata and returns an ATO object. ##' ##' @param otn_detections The dataframe containing detection information. ##' @param otn_receivers The dataframe containing receiver information. @@ -15,7 +15,7 @@ ##' @export ##' -glatos_to_ato <- function(glatos_detections, glatos_receivers = "", glatos_tags = "") { +glatos_to_ato <- function(glatos_detections, glatos_receivers = "") { glatos_detections <- load_file(glatos_detections) # Now we have a dataframe we can start loading into an ATO object. Let's make an instance of the object. @@ -34,9 +34,8 @@ glatos_to_ato <- function(glatos_detections, glatos_receivers = "", glatos_tags GLATOS_ATO <- add(GLATOS_ATO, det) # I used to have a 'derive' argument as in some of the original OTN-to-IMOS functions but then I realised it was safer to just - # automatically try to derive receiver/tag metadata from the extract if no file is supplied. + # automatically try to derive receiver metadata from the extract if no file is supplied. dep <- "" - tag <- "" # In both cases, if a file is supplied, we'll make the metadata objects using the information therein; # otherwise, we'll attempt to make approximately correct receiver/tag metadata from only what's contained in @@ -49,15 +48,11 @@ glatos_to_ato <- function(glatos_detections, glatos_receivers = "", glatos_tags GLATOS_ATO <- add(GLATOS_ATO, dep) - # In the detection extract zip I had for reference there didn't seem to be a bespoke Tag metadata file. I'll leave this structure here in case we need to build it out further but I think it's only ever going to flop into the else. - # if (glatos_tags != "") { - # tag <- ato_tag_from_glatos(glatos_tags, type = "meta") - - # } else { - # tag <- ato_tag_from_glatos(glatos_detections, type = "extract") - # } - - # GLATOS_ATO <- add(GLATOS_ATO, tag) + # Tag information is not part of what's distributed in glatos publications so we can neither load it nor meaningfully derive it. + + ani <- ato_ani_from_glatos(glatos_detections) + + GLATOS_ATO <- add(GLATOS_ATO, ani) return(GLATOS_ATO) } From de62419cf524a6128ae1add26e4d305f98a65c7e Mon Sep 17 00:00:00 2001 From: jackVanish Date: Wed, 18 Mar 2026 18:45:46 +0000 Subject: [PATCH 2/6] Style code (GHA) --- R/ato_ani_from_glatos.R | 14 +++++++------- R/glatos_to_ato.R | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/R/ato_ani_from_glatos.R b/R/ato_ani_from_glatos.R index 61f5563..aebfab7 100644 --- a/R/ato_ani_from_glatos.R +++ b/R/ato_ani_from_glatos.R @@ -1,8 +1,8 @@ ato_ani_from_glatos <- function(glatos_file) { - #Load the data file we've been given- probably detections data since published glatos data will only have detections and receivers. + # Load the data file we've been given- probably detections data since published glatos data will only have detections and receivers. glatos_data <- load_file(glatos_file) - - #We don't really have the option here to get this from an 'animal metadata' file so we're always going to be deriving. + + # We don't really have the option here to get this from an 'animal metadata' file so we're always going to be deriving. ani <- make_ani( animal = as.character(glatos_data$animal_id), capture_location = as.character(glatos_data$capture_location), @@ -14,7 +14,7 @@ ato_ani_from_glatos <- function(glatos_file) { release_lat = glatos_data$release_latitude, release_lon = glatos_data$release_longitude, tz = "UTC" - ) - - return (ani) -} \ No newline at end of file + ) + + return(ani) +} diff --git a/R/glatos_to_ato.R b/R/glatos_to_ato.R index 2245d8f..06dbee8 100644 --- a/R/glatos_to_ato.R +++ b/R/glatos_to_ato.R @@ -48,10 +48,10 @@ glatos_to_ato <- function(glatos_detections, glatos_receivers = "") { GLATOS_ATO <- add(GLATOS_ATO, dep) - # Tag information is not part of what's distributed in glatos publications so we can neither load it nor meaningfully derive it. - + # Tag information is not part of what's distributed in glatos publications so we can neither load it nor meaningfully derive it. + ani <- ato_ani_from_glatos(glatos_detections) - + GLATOS_ATO <- add(GLATOS_ATO, ani) return(GLATOS_ATO) From ef16dbd6c651fa37d767e2c75d278256ca0a88b8 Mon Sep 17 00:00:00 2001 From: Bruce Delo Date: Wed, 18 Mar 2026 15:59:12 -0300 Subject: [PATCH 3/6] Initial commit of the OTN animal-from-tag code. --- R/ato_ani_from_otn.R | 18 ++++++++++++++++++ R/otn_to_ato.R | 2 ++ 2 files changed, 20 insertions(+) create mode 100644 R/ato_ani_from_otn.R diff --git a/R/ato_ani_from_otn.R b/R/ato_ani_from_otn.R new file mode 100644 index 0000000..13c8d03 --- /dev/null +++ b/R/ato_ani_from_otn.R @@ -0,0 +1,18 @@ +ato_ani_from_otn <- function(otn_file) { + #Import the file we've got. + otn_data <- load_file(otn_file) + + #OTN doesn't have a bespoke animal file so we'll take what we get from the tag file. + ani <- make_ani( + animal = otn_data$ANIMAL_ID, + capture_location = otn_data$CAPTURE_LOCATION, + capture_datetime = as.POSIXct(NA_real_), + capture_lat = otn_data$CAPTURE_LAT, + capture_lon = otn_data$CAPTURE_LON, + release_location = otn_data$RELEASE_LOCATION, + release_datetime = as.POSIXct(otn_data$UTC_RELEASE_DATE_TIME), + release_lat = otn_data$RELEASE_LATITUDE, + release_lon = otn_data$RELEASE_LONGITUDE, + tz = "UTC", + ) +} \ No newline at end of file diff --git a/R/otn_to_ato.R b/R/otn_to_ato.R index 6a22d80..87c6916 100644 --- a/R/otn_to_ato.R +++ b/R/otn_to_ato.R @@ -68,6 +68,8 @@ otn_to_ato <- function(otn_detections, otn_receivers = "", otn_tags = "") { } OTN_ATO <- add(OTN_ATO, tag) + + return(OTN_ATO) From 7a40fbeb033959858cff4497fce38d48ba9dd68f Mon Sep 17 00:00:00 2001 From: jackVanish Date: Wed, 18 Mar 2026 19:00:45 +0000 Subject: [PATCH 4/6] Style code (GHA) --- R/ato_ani_from_otn.R | 8 ++++---- R/otn_to_ato.R | 2 -- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/R/ato_ani_from_otn.R b/R/ato_ani_from_otn.R index 13c8d03..f9c8e37 100644 --- a/R/ato_ani_from_otn.R +++ b/R/ato_ani_from_otn.R @@ -1,8 +1,8 @@ ato_ani_from_otn <- function(otn_file) { - #Import the file we've got. + # Import the file we've got. otn_data <- load_file(otn_file) - - #OTN doesn't have a bespoke animal file so we'll take what we get from the tag file. + + # OTN doesn't have a bespoke animal file so we'll take what we get from the tag file. ani <- make_ani( animal = otn_data$ANIMAL_ID, capture_location = otn_data$CAPTURE_LOCATION, @@ -15,4 +15,4 @@ ato_ani_from_otn <- function(otn_file) { release_lon = otn_data$RELEASE_LONGITUDE, tz = "UTC", ) -} \ No newline at end of file +} diff --git a/R/otn_to_ato.R b/R/otn_to_ato.R index 87c6916..6a22d80 100644 --- a/R/otn_to_ato.R +++ b/R/otn_to_ato.R @@ -68,8 +68,6 @@ otn_to_ato <- function(otn_detections, otn_receivers = "", otn_tags = "") { } OTN_ATO <- add(OTN_ATO, tag) - - return(OTN_ATO) From 90b9b56307aa1015a2b71433e883f12473ee7ae2 Mon Sep 17 00:00:00 2001 From: Bruce Delo Date: Fri, 20 Mar 2026 09:07:55 -0300 Subject: [PATCH 5/6] Callout to otn animals in otn_to_ato plus some namespace additions --- NAMESPACE | 2 ++ R/otn_to_ato.R | 4 ++++ man/glatos_to_ato.Rd | 21 +++++++++++++++++++++ man/otn_to_ato.Rd | 21 +++++++++++++++++++++ 4 files changed, 48 insertions(+) create mode 100644 man/glatos_to_ato.Rd create mode 100644 man/otn_to_ato.Rd diff --git a/NAMESPACE b/NAMESPACE index 5e80fbe..2434667 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,5 +1,6 @@ # Generated by roxygen2: do not edit by hand +export(glatos_to_ato) export(imos_otn_column_map) export(imos_to_otn_detections) export(imos_to_otn_receivers) @@ -7,6 +8,7 @@ export(imos_to_otn_tags) export(map_otn_file) export(otn_imos_column_map) export(otn_imos_new_style_column_map) +export(otn_to_ato) export(rollup) importFrom(dplyr,'%>%') importFrom(dplyr,arrange) diff --git a/R/otn_to_ato.R b/R/otn_to_ato.R index 87c6916..45ce298 100644 --- a/R/otn_to_ato.R +++ b/R/otn_to_ato.R @@ -63,6 +63,10 @@ otn_to_ato <- function(otn_detections, otn_receivers = "", otn_tags = "") { if (otn_tags != "") { tag <- ato_tag_from_otn(otn_tags, type = "meta") + #If we have a tag metadata file, we can derive an animal object; if we don't, there's hardly enough information to bother, + #and if people are so inclined they can add it manually through the ATO's default functions and ATools. + ani <- ato_ani_from_otn(otn_tags) + OTN_ATO <- add(OTN_ATO, ani) } else { tag <- ato_tag_from_otn(otn_detections, type = "extract") } diff --git a/man/glatos_to_ato.Rd b/man/glatos_to_ato.Rd new file mode 100644 index 0000000..a6f6cb9 --- /dev/null +++ b/man/glatos_to_ato.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/glatos_to_ato.R +\name{glatos_to_ato} +\alias{glatos_to_ato} +\title{Convert GLATOS detection data to an ATO object.} +\usage{ +glatos_to_ato(glatos_detections, glatos_receivers = "") +} +\arguments{ +\item{otn_detections}{The dataframe containing detection information.} + +\item{otn_receivers}{The dataframe containing receiver information.} + +\item{otn_tags}{The dataframe containing tag information.} +} +\value{ +Returns an ATO object. +} +\description{ +Takes a GLATOS detection sheet and optionally receiver metadata and returns an ATO object. +} diff --git a/man/otn_to_ato.Rd b/man/otn_to_ato.Rd new file mode 100644 index 0000000..93556eb --- /dev/null +++ b/man/otn_to_ato.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/otn_to_ato.R +\name{otn_to_ato} +\alias{otn_to_ato} +\title{Convert OTN detection data to an ATO object.} +\usage{ +otn_to_ato(otn_detections, otn_receivers = "", otn_tags = "") +} +\arguments{ +\item{otn_detections}{The dataframe containing detection information.} + +\item{otn_receivers}{The dataframe containing receiver information.} + +\item{otn_tags}{The dataframe containing tag information.} +} +\value{ +Returns an ATO object. +} +\description{ +Takes an OTN detection extract and optionally receiver/tag metadata and returns an ATO object. +} From 913d766cbb7da18d302c1cbf2139259a698a6aa7 Mon Sep 17 00:00:00 2001 From: jackVanish Date: Fri, 20 Mar 2026 12:11:07 +0000 Subject: [PATCH 6/6] Style code (GHA) --- R/otn_to_ato.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/otn_to_ato.R b/R/otn_to_ato.R index 87e7192..34f3a2b 100644 --- a/R/otn_to_ato.R +++ b/R/otn_to_ato.R @@ -63,8 +63,8 @@ otn_to_ato <- function(otn_detections, otn_receivers = "", otn_tags = "") { if (otn_tags != "") { tag <- ato_tag_from_otn(otn_tags, type = "meta") - #If we have a tag metadata file, we can derive an animal object; if we don't, there's hardly enough information to bother, - #and if people are so inclined they can add it manually through the ATO's default functions and ATools. + # If we have a tag metadata file, we can derive an animal object; if we don't, there's hardly enough information to bother, + # and if people are so inclined they can add it manually through the ATO's default functions and ATools. ani <- ato_ani_from_otn(otn_tags) OTN_ATO <- add(OTN_ATO, ani) } else {