Title: | Understand your OTN data |
---|---|
Description: | This package provides functions to summarize the various type of OTN-style data. |
Authors: | Michael O'Brien [aut, cre] |
Maintainer: | Michael O'Brien <[email protected]> |
License: | CC BY 4.0 |
Version: | 0.2.3 |
Built: | 2024-11-15 20:23:42 UTC |
Source: | https://github.com/mhpob/otndo |
Create a Gantt-like chart of receiver deployments and recoveries
deployment_gantt(deployment)
deployment_gantt(deployment)
deployment |
Cleaned deployment metadata sheet(s). Assumes it was
cleaned with the internal |
## Not run: # Download a deployment metadata file td <- file.path(tempdir(), "matos_test_files") dir.create(td) download.file( paste0( "https://members.oceantrack.org/data/repository/pbsm/", "data-and-metadata/2018/pbsm-instrument-deployment-short-form-2018.xls/", "@download/file" ), destfile = file.path(td, "pbsm-instrument-deployment-short-form-2018.xls"), mode = "wb" ) # Use internal function to clean deployment_filepath <- otndo:::write_to_tempdir( type = "deployment", files = file.path(td, "pbsm-instrument-deployment-short-form-2018.xls"), temp_dir = td ) # Make the Gantt chart deployment_gantt( data.table::fread(deployment_filepath) ) ## End(Not run)
## Not run: # Download a deployment metadata file td <- file.path(tempdir(), "matos_test_files") dir.create(td) download.file( paste0( "https://members.oceantrack.org/data/repository/pbsm/", "data-and-metadata/2018/pbsm-instrument-deployment-short-form-2018.xls/", "@download/file" ), destfile = file.path(td, "pbsm-instrument-deployment-short-form-2018.xls"), mode = "wb" ) # Use internal function to clean deployment_filepath <- otndo:::write_to_tempdir( type = "deployment", files = file.path(td, "pbsm-instrument-deployment-short-form-2018.xls"), temp_dir = td ) # Make the Gantt chart deployment_gantt( data.table::fread(deployment_filepath) ) ## End(Not run)
Create summary reports of receiver project data from the OTN data push
make_receiver_push_summary( qualified = NULL, unqualified = NULL, update_push_log = FALSE, deployment = NULL, out_dir = getwd(), since = NULL, rmd = FALSE )
make_receiver_push_summary( qualified = NULL, unqualified = NULL, update_push_log = FALSE, deployment = NULL, out_dir = getwd(), since = NULL, rmd = FALSE )
qualified , unqualified
|
Default is NULL: a character vector of file paths of your qualified/unqualified detections. These can be CSVs or zipped folders. |
update_push_log |
Do you wish to use an updated push log? Default is FALSE, but switch to TRUE if you haven't updated this package since the push occurred. |
deployment |
File path of user-supplied master OTN receiver deployment metadata. |
out_dir |
Defaults to working directory. In which directory would you like to save the report? |
since |
Date in YYYY-MM-DD format. Summarizes what's new since the provided date. |
rmd |
Logical. Compile via RMarkdown rather than Quarto? |
To keep track of when ACT data pushes occur, a log is kept
on the package's GitHub page. This is automatically downloaded every time you download
or update the package, but you can avoid re-downloading the package by changing
update_push_log
to TRUE
.
You can get similar behavior by providing a date to the since
argument.
This function creates an HTML report that can be viewed in your web browser.
## Not run: td <- file.path(tempdir(), "matos_test_files") dir.create(td) download.file( paste0( "https://members.oceantrack.org/data/repository/pbsm/", "data-and-metadata/archived-records/2018/", "pbsm-instrument-deployment-short-form-2018.xls/", "@download/file" ), destfile = file.path(td, "pbsm-instrument-deployment-short-form-2018.xls"), mode = "wb" ) download.file( paste0( "https://members.oceantrack.org/data/repository/pbsm/", "detection-extracts/pbsm_qualified_detections_2018.zip/", "@download/file" ), destfile = file.path(td, "pbsm_qualified_detections_2018.zip"), mode = "wb" ) unzip( file.path(td, "pbsm_qualified_detections_2018.zip"), exdir = td ) download.file( paste0( "https://members.oceantrack.org/data/repository/pbsm/", "detection-extracts/pbsm_unqualified_detections_2018.zip/", "@download/file" ), destfile = file.path(td, "pbsm_unqualified_detections_2018.zip"), mode = "wb" ) unzip( file.path(td, "pbsm_unqualified_detections_2018.zip"), exdir = td ) qualified_files <- file.path(td, "pbsm_qualified_detections_2018.csv") unqualified_files <- file.path(td, "pbsm_unqualified_detections_2018.csv") deployment_files <- file.path(td, "pbsm-instrument-deployment-short-form-2018.xls") make_receiver_push_summary( qualified = qualified_files, unqualified = unqualified_files, deployment = deployment_files, since = "2018-11-01" ) ## End(Not run)
## Not run: td <- file.path(tempdir(), "matos_test_files") dir.create(td) download.file( paste0( "https://members.oceantrack.org/data/repository/pbsm/", "data-and-metadata/archived-records/2018/", "pbsm-instrument-deployment-short-form-2018.xls/", "@download/file" ), destfile = file.path(td, "pbsm-instrument-deployment-short-form-2018.xls"), mode = "wb" ) download.file( paste0( "https://members.oceantrack.org/data/repository/pbsm/", "detection-extracts/pbsm_qualified_detections_2018.zip/", "@download/file" ), destfile = file.path(td, "pbsm_qualified_detections_2018.zip"), mode = "wb" ) unzip( file.path(td, "pbsm_qualified_detections_2018.zip"), exdir = td ) download.file( paste0( "https://members.oceantrack.org/data/repository/pbsm/", "detection-extracts/pbsm_unqualified_detections_2018.zip/", "@download/file" ), destfile = file.path(td, "pbsm_unqualified_detections_2018.zip"), mode = "wb" ) unzip( file.path(td, "pbsm_unqualified_detections_2018.zip"), exdir = td ) qualified_files <- file.path(td, "pbsm_qualified_detections_2018.csv") unqualified_files <- file.path(td, "pbsm_unqualified_detections_2018.csv") deployment_files <- file.path(td, "pbsm-instrument-deployment-short-form-2018.xls") make_receiver_push_summary( qualified = qualified_files, unqualified = unqualified_files, deployment = deployment_files, since = "2018-11-01" ) ## End(Not run)
Create summary reports of receiver project data from the OTN data push
make_tag_push_summary( matched = NULL, update_push_log = FALSE, since = NULL, sensor_decoding = NULL, out_dir = getwd(), rmd = FALSE )
make_tag_push_summary( matched = NULL, update_push_log = FALSE, since = NULL, sensor_decoding = NULL, out_dir = getwd(), rmd = FALSE )
matched |
This argument also accepts a character vector of file paths of your matched detections. These can be CSVs or zipped folders. |
update_push_log |
Do you wish to use an updated push log? Default is FALSE, but switch to TRUE if you haven't updated this package since the push occurred. |
since |
date in YYYY-MM-DD format. Provides a summary of detections that were matched/edited since that date. |
sensor_decoding |
Not yet implemented. Will be a place to provide information to decode and summarize sensor data, |
out_dir |
Defaults to working directory. In which directory would you like to save the report? |
rmd |
Logical. Compile via RMarkdown rather than Quarto? |
## Not run: # The code below downloads some matched detections from OTN, then calls the function. td <- file.path(tempdir(), "matos_test_files") dir.create(td) download.file( paste0( "https://members.oceantrack.org/data/repository/", "pbsm/detection-extracts/pbsm_matched_detections_2018.zip/", "@download/file" ), destfile = file.path(td, "pbsm_matched_detections_2018.zip"), mode = "wb" ) unzip(file.path(td, "pbsm_matched_detections_2018.zip"), exdir = td ) # Provide the detection file(s) to the \code{matched} argument, with an # optional date to the \code{since} argument to summarize what was new since # that date. make_tag_push_summary( matched = file.path( td, "pbsm_matched_detections_2018.csv" ), since = "2018-11-01" ) ## End(Not run)
## Not run: # The code below downloads some matched detections from OTN, then calls the function. td <- file.path(tempdir(), "matos_test_files") dir.create(td) download.file( paste0( "https://members.oceantrack.org/data/repository/", "pbsm/detection-extracts/pbsm_matched_detections_2018.zip/", "@download/file" ), destfile = file.path(td, "pbsm_matched_detections_2018.zip"), mode = "wb" ) unzip(file.path(td, "pbsm_matched_detections_2018.zip"), exdir = td ) # Provide the detection file(s) to the \code{matched} argument, with an # optional date to the \code{since} argument to summarize what was new since # that date. make_tag_push_summary( matched = file.path( td, "pbsm_matched_detections_2018.csv" ), since = "2018-11-01" ) ## End(Not run)
Plot the geographic extent of OTN projects
match_map(otn_tables)
match_map(otn_tables)
otn_tables |
A list containing OTN's |
match_map( otn_query("MDWEA") )
match_map( otn_query("MDWEA") )
Create a reactable table of matched detections
match_table(extract, type = c("tag", "receiver"))
match_table(extract, type = c("tag", "receiver"))
extract |
matched (transmitter) or qualified (receiver) OTN detections |
type |
Tag or receiver data? Takes values of "tag" and "receiver"; defaults to "tag". |
## Not run: # Receiver download.file( paste0( "https://members.oceantrack.org/data/repository/pbsm/", "detection-extracts/pbsm_qualified_detections_2018.zip/", "@download/file" ), destfile = file.path(td, "pbsm_qualified_detections_2018.zip"), mode = "wb" ) unzip( file.path(td, "pbsm_qualified_detections_2018.zip"), exdir = td ) qualified_dets <- data.table::fread( file.path(td, "pbsm_qualified_detections_2018.csv") ) match_table( extract = qualified_dets, type = "receiver" ) # Transmitters download.file( paste0( "https://members.oceantrack.org/data/repository/", "pbsm/detection-extracts/pbsm_matched_detections_2018.zip/", "@download/file" ), destfile = file.path(td, "pbsm_matched_detections_2018.zip"), mode = "wb" ) unzip(file.path(td, "pbsm_matched_detections_2018.zip"), exdir = td ) matched_dets <- data.table::fread( file.path(td, "pbsm_matched_detections_2018.csv") ) match_table( extract = matched_dets, type = "tag" ) ## End(Not run)
## Not run: # Receiver download.file( paste0( "https://members.oceantrack.org/data/repository/pbsm/", "detection-extracts/pbsm_qualified_detections_2018.zip/", "@download/file" ), destfile = file.path(td, "pbsm_qualified_detections_2018.zip"), mode = "wb" ) unzip( file.path(td, "pbsm_qualified_detections_2018.zip"), exdir = td ) qualified_dets <- data.table::fread( file.path(td, "pbsm_qualified_detections_2018.csv") ) match_table( extract = qualified_dets, type = "receiver" ) # Transmitters download.file( paste0( "https://members.oceantrack.org/data/repository/", "pbsm/detection-extracts/pbsm_matched_detections_2018.zip/", "@download/file" ), destfile = file.path(td, "pbsm_matched_detections_2018.zip"), mode = "wb" ) unzip(file.path(td, "pbsm_matched_detections_2018.zip"), exdir = td ) matched_dets <- data.table::fread( file.path(td, "pbsm_matched_detections_2018.csv") ) match_table( extract = matched_dets, type = "tag" ) ## End(Not run)
Create an abacus plot of matched detections
matched_abacus(temp_dist, release)
matched_abacus(temp_dist, release)
temp_dist |
Data from the output of |
release |
Data frame of release times/locations; a subset of the matched detections data |
## Not run: # Get a detection file download.file( paste0( "https://members.oceantrack.org/data/repository/", "pbsm/detection-extracts/pbsm_matched_detections_2018.zip/", "@download/file" ), destfile = file.path(td, "pbsm_matched_detections_2018.zip"), mode = "wb" ) unzip(file.path(td, "pbsm_matched_detections_2018.zip"), exdir = td ) matched_dets <- data.table::fread( file.path(td, "pbsm_matched_detections_2018.csv") ) # Run temporal_distribution temporal <- temporal_distribution(matched_dets, "tag") # Run matched_abacus matched_abacus(temporal$data, matched_dets[receiver == "release"]) ## End(Not run)
## Not run: # Get a detection file download.file( paste0( "https://members.oceantrack.org/data/repository/", "pbsm/detection-extracts/pbsm_matched_detections_2018.zip/", "@download/file" ), destfile = file.path(td, "pbsm_matched_detections_2018.zip"), mode = "wb" ) unzip(file.path(td, "pbsm_matched_detections_2018.zip"), exdir = td ) matched_dets <- data.table::fread( file.path(td, "pbsm_matched_detections_2018.csv") ) # Run temporal_distribution temporal <- temporal_distribution(matched_dets, "tag") # Run matched_abacus matched_abacus(temporal$data, matched_dets[receiver == "release"]) ## End(Not run)
Query the OTN Geoserver
otn_query(projects)
otn_query(projects)
projects |
Character vector of OTN project codes for which you'd like project metadata. Prepended networks can be provided, but are not necessary. |
list of the "otn_resources_metadata_points" and "project_metadata" for the given projects
otn_query(c("EST", "FACT.SCDNRDFP", "ACT.MDBSB", "MDBSB"))
otn_query(c("EST", "FACT.SCDNRDFP", "ACT.MDBSB", "MDBSB"))
Prepare the detection match summary data
prep_match_table(extract, type = c("tag", "receiver"))
prep_match_table(extract, type = c("tag", "receiver"))
extract |
matched (transmitter) or qualified (receiver) OTN detections |
type |
Tag or receiver data? Takes values of "tag" and "receiver"; defaults to "tag". |
Summarize OTN extract data by station and convert to a spatial object
prep_station_spatial(extract, type = c("tag", "receiver"))
prep_station_spatial(extract, type = c("tag", "receiver"))
extract |
OTN extract data |
type |
type of extract data: "tag" or "receiver" |
## Not run: # Get an extract file download.file( paste0( "https://members.oceantrack.org/data/repository/", "pbsm/detection-extracts/pbsm_matched_detections_2018.zip/", "@download/file" ), destfile = file.path(td, "pbsm_matched_detections_2018.zip"), mode = "wb" ) unzip(file.path(td, "pbsm_matched_detections_2018.zip"), exdir = td ) matched_dets <- data.table::fread( file.path(td, "pbsm_matched_detections_2018.csv") ) # Convert to spatial prep_station_spatial(matched_dets, "tag") ## End(Not run)
## Not run: # Get an extract file download.file( paste0( "https://members.oceantrack.org/data/repository/", "pbsm/detection-extracts/pbsm_matched_detections_2018.zip/", "@download/file" ), destfile = file.path(td, "pbsm_matched_detections_2018.zip"), mode = "wb" ) unzip(file.path(td, "pbsm_matched_detections_2018.zip"), exdir = td ) matched_dets <- data.table::fread( file.path(td, "pbsm_matched_detections_2018.csv") ) # Convert to spatial prep_station_spatial(matched_dets, "tag") ## End(Not run)
Extract and combine the contacts for matched projects
project_contacts(extract, type = c("receiver", "tag"))
project_contacts(extract, type = c("receiver", "tag"))
extract |
data.frame of transmitter/receiver detections matched by OTN: matched detections for tags and qualified detections for receivers |
type |
Type of extract data: "tag" or "receiver" |
a data.table containing project names, principal investigators (PI), points of contact (POC), and their respective emails. Multiple emails are separated by commas.
## Not run: # Set up example data td <- file.path(tempdir(), "otndo_example") dir.create(td) download.file( paste0( "https://members.oceantrack.org/data/repository/", "pbsm/detection-extracts/pbsm_matched_detections_2018.zip/", "@download/file" ), destfile = file.path(td, "pbsm_matched_detections_2018.zip"), mode = "wb" ) unzip(file.path(td, "pbsm_matched_detections_2018.zip"), exdir = td ) matched <- read.csv(file.path( td, "pbsm_matched_detections_2018.csv" )) # Actually run the function project_contacts(matched, type = "tag") # Clean up unlink(td, recursive = TRUE) ## End(Not run)
## Not run: # Set up example data td <- file.path(tempdir(), "otndo_example") dir.create(td) download.file( paste0( "https://members.oceantrack.org/data/repository/", "pbsm/detection-extracts/pbsm_matched_detections_2018.zip/", "@download/file" ), destfile = file.path(td, "pbsm_matched_detections_2018.zip"), mode = "wb" ) unzip(file.path(td, "pbsm_matched_detections_2018.zip"), exdir = td ) matched <- read.csv(file.path( td, "pbsm_matched_detections_2018.csv" )) # Actually run the function project_contacts(matched, type = "tag") # Clean up unlink(td, recursive = TRUE) ## End(Not run)
This function estimates the transmitters remaining in the system by finding the last date of detection for each transmitter and summing all available transmitters in a given day. This is a very coarse measure and likely to be very inaccurate with sparse data or short time scales.
remaining_transmitters(matched, push_log, release = NULL)
remaining_transmitters(matched, push_log, release = NULL)
matched |
matched OTN transmitter detections |
push_log |
data.frame containing the date of the most-recent data push. This requirement is very likely to change in the future. |
release |
Optional. Data frame of release times/locations; a subset of the matched detections data |
## Not run: #' # Set up example data td <- file.path(tempdir(), "otndo_example") dir.create(td) # For tag data download.file( paste0( "https://members.oceantrack.org/data/repository/", "pbsm/detection-extracts/pbsm_matched_detections_2018.zip/@download/file" ), destfile = file.path(td, "pbsm_matched_detections_2018.zip") ) unzip(file.path(td, "pbsm_matched_detections_2018.zip"), exdir = td ) matched <- read.csv(file.path( td, "pbsm_matched_detections_2018.csv" )) # Run remaining_transmitters() remaining_transmitters(matched_dets, data.frame(date = as.Date("2020-01-01"))) ## End(Not run)
## Not run: #' # Set up example data td <- file.path(tempdir(), "otndo_example") dir.create(td) # For tag data download.file( paste0( "https://members.oceantrack.org/data/repository/", "pbsm/detection-extracts/pbsm_matched_detections_2018.zip/@download/file" ), destfile = file.path(td, "pbsm_matched_detections_2018.zip") ) unzip(file.path(td, "pbsm_matched_detections_2018.zip"), exdir = td ) matched <- read.csv(file.path( td, "pbsm_matched_detections_2018.csv" )) # Run remaining_transmitters() remaining_transmitters(matched_dets, data.frame(date = as.Date("2020-01-01"))) ## End(Not run)
Create the station summary table
station_table(extract, type = c("tag", "receiver"))
station_table(extract, type = c("tag", "receiver"))
extract |
OTN detections. "Matched" detections for tag data and "qualified" detections for receiver data |
type |
type of data to be summarized. |
For tag data, a data.table with the PI, project, station, number of detections, and number of individuals heard. For receiver data, a data.table with the station, number of detections, and number of individuals heard (assuming that the PI and POC is you).
## Not run: # Set up example data td <- file.path(tempdir(), "otndo_example") dir.create(td) # For tag data download.file( paste0( "https://members.oceantrack.org/data/repository/", "pbsm/detection-extracts/pbsm_matched_detections_2018.zip/@download/file" ), destfile = file.path(td, "pbsm_matched_detections_2018.zip") ) unzip(file.path(td, "pbsm_matched_detections_2018.zip"), exdir = td ) matched <- read.csv(file.path( td, "pbsm_matched_detections_2018.csv" )) # Actually run the function prep_station_table(matched, type = "tag") # For receiver data download.file( paste0( "https://members.oceantrack.org/data/repository/pbsm/", "detection-extracts/pbsm_qualified_detections_2018.zip/", "@download/file" ), destfile = file.path(td, "pbsm_qualified_detections_2018.zip"), mode = "wb" ) unzip( file.path(td, "pbsm_qualified_detections_2018.zip"), exdir = td ) qualified <- read.csv(file.path(td, "pbsm_qualified_detections_2018.csv")) # Actually run the function station_table(qualified, type = "receiver") # Clean up unlink(td, recursive = TRUE) ## End(Not run)
## Not run: # Set up example data td <- file.path(tempdir(), "otndo_example") dir.create(td) # For tag data download.file( paste0( "https://members.oceantrack.org/data/repository/", "pbsm/detection-extracts/pbsm_matched_detections_2018.zip/@download/file" ), destfile = file.path(td, "pbsm_matched_detections_2018.zip") ) unzip(file.path(td, "pbsm_matched_detections_2018.zip"), exdir = td ) matched <- read.csv(file.path( td, "pbsm_matched_detections_2018.csv" )) # Actually run the function prep_station_table(matched, type = "tag") # For receiver data download.file( paste0( "https://members.oceantrack.org/data/repository/pbsm/", "detection-extracts/pbsm_qualified_detections_2018.zip/", "@download/file" ), destfile = file.path(td, "pbsm_qualified_detections_2018.zip"), mode = "wb" ) unzip( file.path(td, "pbsm_qualified_detections_2018.zip"), exdir = td ) qualified <- read.csv(file.path(td, "pbsm_qualified_detections_2018.csv")) # Actually run the function station_table(qualified, type = "receiver") # Clean up unlink(td, recursive = TRUE) ## End(Not run)
Create an abacus plot of detections by project
temporal_distribution(extract, type = c("tag", "receiver"))
temporal_distribution(extract, type = c("tag", "receiver"))
extract |
OTN data extract file |
type |
Transmitter (tag) or receiver detections? |
## Not run: # Set up example data td <- file.path(tempdir(), "otndo_example") dir.create(td) # For tag data download.file( paste0( "https://members.oceantrack.org/data/repository/", "pbsm/detection-extracts/pbsm_matched_detections_2018.zip/@download/file" ), destfile = file.path(td, "pbsm_matched_detections_2018.zip") ) unzip(file.path(td, "pbsm_matched_detections_2018.zip"), exdir = td ) matched <- read.csv(file.path( td, "pbsm_matched_detections_2018.csv" )) temporal_distribution(matched, "tag") ## End(Not run)
## Not run: # Set up example data td <- file.path(tempdir(), "otndo_example") dir.create(td) # For tag data download.file( paste0( "https://members.oceantrack.org/data/repository/", "pbsm/detection-extracts/pbsm_matched_detections_2018.zip/@download/file" ), destfile = file.path(td, "pbsm_matched_detections_2018.zip") ) unzip(file.path(td, "pbsm_matched_detections_2018.zip"), exdir = td ) matched <- read.csv(file.path( td, "pbsm_matched_detections_2018.csv" )) temporal_distribution(matched, "tag") ## End(Not run)