Skip to content

Commit d8c84a1

Browse files
committed
detection and deployment load-in are more or less working, though I think I can squeeze more data out of them.
1 parent d89898c commit d8c84a1

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

R/ato_dep_from_glatos.R

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ ato_dep_from_glatos <- function(glatos_file, glatos_detection_data = "", type =
33
glatos_data <- load_file(glatos_file)
44

55
#Detection data is an optional pass-through but if we have it, we can join it to the receiver dataframe to get additional transmitter data.
6-
if (glatos_detection_data != "" && is.data.frame(glatos_detection_data) {
6+
if (glatos_detection_data != "" && is.data.frame(glatos_detection_data)) {
77
#TODO: Join the two dataframes to get transmitter data passed through.
88
}
99

@@ -15,16 +15,17 @@ ato_dep_from_glatos <- function(glatos_file, glatos_detection_data = "", type =
1515
receiver_serial = glatos_data$ins_serial_no,
1616
receiver_codeset = glatos_data$code_map,
1717
deploy_location = glatos_data$station,
18-
deploy_datetime = glatos_data$deploy_date_time,
18+
deploy_datetime = as.POSIXct(glatos_data$deploy_date_time),
19+
tz = "UTC",
1920
deploy_lat = glatos_data$deploy_lat,
2021
deploy_lon = glatos_data$deploy_long,
2122
deploy_z = glatos_data$bottom_depth,
22-
recover_datetime = glatos_data$recover_date_time, # ??? We might be able to get this from another part of the sheet
23+
recover_datetime = as.POSIXct(glatos_data$recover_date_time),
2324
recover_lat = glatos_data$recover_lat,
2425
recover_lon = glatos_data$recover_long,
2526
transmitter = NA_character_, # ???
2627
transmitter_manufacturer = NA_character_, # ???
27-
transmitter_ping_rate = NA_character_, # ???
28+
transmitter_ping_rate = as.numeric(glatos_data$glatos_ins_frequency), #is this accurate? I think this mapping is right.
2829
transmitter_model = NA_character_, # ???
2930
transmitter_serial = NA_integer_
3031
)
@@ -97,13 +98,13 @@ ato_dep_from_glatos <- function(glatos_file, glatos_detection_data = "", type =
9798
receiver_serial = as.integer(rcvr_grouped$receiver_sn),
9899
receiver_codeset = NA_character_,
99100
deploy_location = rcvr_grouped$station,
100-
deploy_datetime = rcvr_grouped$minDetectionDate,
101+
deploy_datetime = as.POSIXct(rcvr_grouped$minDetectionDate),
101102
deploy_lat = rcvr_grouped$deploy_lat,
102-
deploy_lon = rcvr_grouped$deploy_lon,
103-
recover_datetime = rcvr_grouped$maxDetectionDate,
103+
deploy_lon = rcvr_grouped$deploy_long,
104+
recover_datetime = as.POSIXct(rcvr_grouped$maxDetectionDate),
104105
recover_lat = NA_real_,
105106
recover_lon = NA_real_,
106-
transmitter = paste(rcvr_grouped$transmitter_code_space, "-", rcvr_grouped$transmitter_id),
107+
transmitter = paste(rcvr_grouped$transmitter_codespace, "-", rcvr_grouped$transmitter_id, sep=""),
107108
transmitter_model = NA_character_,
108109
transmitter_serial = rcvr_grouped$transmitter_id,
109110
tz = "UTC"

R/glatos_to_ato.R

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ glatos_to_ato <- function(glatos_detections, glatos_receivers = "", glatos_tags
2626
datetime = as.POSIXct(glatos_detections$detection_timestamp_utc),
2727
frac_second = NA_real_,
2828
receiver_serial = as.integer(glatos_detections$receiver_sn),
29-
transmitter = NA_character_ #Might have to synthesize this from other fields
29+
transmitter = paste(glatos_detections$transmitter_codespace, "-", glatos_detections$transmitter_id, sep=""), #Might have to synthesize this from other fields
3030
sensor_value = as.numeric(glatos_detections$sensor_value),
3131
tz = "UTC"
3232
)
@@ -50,14 +50,14 @@ glatos_to_ato <- function(glatos_detections, glatos_receivers = "", glatos_tags
5050
GLATOS_ATO <- add(GLATOS_ATO, dep)
5151

5252
#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.
53-
if (glatos_tags != "") {
54-
tag <- ato_tag_from_glatos(glatos_tags, type = "meta")
53+
#if (glatos_tags != "") {
54+
# tag <- ato_tag_from_glatos(glatos_tags, type = "meta")
5555

56-
} else {
57-
tag <- ato_tag_from_glatos(glatos_detections, type = "extract")
58-
}
56+
#} else {
57+
# tag <- ato_tag_from_glatos(glatos_detections, type = "extract")
58+
#}
5959

60-
GLATOS_ATO <- add(GLATOS_ATO, tag)
60+
#GLATOS_ATO <- add(GLATOS_ATO, tag)
6161

6262
return(GLATOS_ATO)
6363
}

0 commit comments

Comments
 (0)