Skip to content

Commit

Permalink
Merge pull request #19 from ocean-tracking-network/shannon_fixes_rece…
Browse files Browse the repository at this point in the history
…iver

Shannon fixes receiver
  • Loading branch information
jackVanish authored Apr 1, 2024
2 parents 3847fd0 + cdfb060 commit 9ad4bda
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 10 deletions.
44 changes: 35 additions & 9 deletions R/imos_to_otn_receivers.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,57 @@ imos_to_otn_receivers <- function(rcvr_dataframe) {
depth_below_surface,
receiver_name,
receiver_status,
receiver_recovery_datetime
receiver_recovery_datetime,
receiver_recovery_latitude,
receiver_recovery_longitude
) %>%
mutate(
BOTTOM_DEPTH = NA,
RISER_LENGTH = NA,
CODE_SET = NA,
AR_MODEL_NUMBER = NA,
AR_SERIAL_NUMBER = NA,
AR_MODEL_NO = NA,
AR_SERIAL_NO = NA,
DATA_DOWNLOADED = NA,
DOWNLOAD_DATE_TIME = NA,
COMMENTS = NA
COMMENTS = NA,
TRANSMITTER = NA,
TRANSMITTER_MODEL = NA,
DEPLOYED_BY = NA,
FILENAME = NA
) %>%
rename(
OTN_ARRAY = receiver_project_name,
STATION_NO = station_name,
DEPLOY_DATE_TIME = receiver_deployment_datetime,
`DEPLOY_DATE_TIME (yyyy-mm-ddThh:mm:ss)` = receiver_deployment_datetime,
DEPLOY_LAT = receiver_deployment_latitude,
DEPLOY_LONG = receiver_deployment_longitude,
INSTRUMENT_DEPTH = depth_below_surface,
RECOVERED = receiver_status,
RECOVER_DATE_TIME = receiver_recovery_datetime
RECOVER_DATE_TIME = receiver_recovery_datetime,
RECOVER_LAT = receiver_recovery_latitude,
RECOVER_LONG = receiver_recovery_longitude
) %>%
separate(
col = receiver_name,
into = c("INS_MODEL_NUMBER", "INS_SERIAL_NUMBER", sep = "-")
separate_wider_delim(
cols = receiver_name,
delim = "-",
names = c("INS_MODEL_NO", "INS_SERIAL_NO")
)

# We have to do some cleaning up of date formats in the appropriate columns.
# First we'll hit them with Lubridate to make sure they're real dates, formatted correctly.
# Then, since they need a "T" in there, we'll cast them back to character strings and slot a 'T'
# in where once there was whitespace. Simple! I don't love calling multiple near-identical mutates, but I also
# don't like how unreadable and cursed it is to do the requisite jiggery-pokery to get multiple functions into a single
# mutate(across())
rcvr_return <- rcvr_return %>%
mutate(
across(ends_with("_DATE_TIME"), lubridate::ymd_hms)
) %>%
mutate(
across(ends_with("_DATE_TIME"), as.character)
) %>%
mutate(
across(ends_with("_DATE_TIME"), ~ stringr::str_replace(.x, " ", "T"))
)

# Have to do a little extra manipulation on the dataframe to give "RECOVERED"
Expand Down
2 changes: 1 addition & 1 deletion R/otn_imos_column_map.R
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ otn_imos_column_map <- function(det_dataframe, rcvr_dataframe = NULL, tag_datafr
WORMS_species_aphia_id = sapply(det_dataframe$scientificname, USE.NAMES = FALSE, FUN = get_aphiaid_from_lookup, lookup = lookup),
animal_sex = NA,
receiver_name = receiver,
receiver_project_name = receiver_group,
receiver_project_name = detectedby,
transmitter_serial_number = NA,
transmitter_type = NA,
transmitter_sensor_type = NA,
Expand Down

0 comments on commit 9ad4bda

Please sign in to comment.