real_sensor_values: Add 'real'-scale sensor values to glatos detetections

View source: R/proc-real_sensor_values.r

real_sensor_valuesR Documentation

Add 'real'-scale sensor values to glatos detetections

Description

Get transmitter sensor (e.g., depth, temperature) conversion parameters (e.g., intercept, slope) from a Vemco transmitter specification object (e.g., from read_vemco_tag_specs, calculate 'real'-scale values (e.g., depth in meters), and add real values to detection data in a new column.

Usage

real_sensor_values(det, tag_specs)

Arguments

det

A glatos_detections object (e.g., produced by read_glatos_detections).

OR A data frame containing detection data with the following columns:

transmitter_codespace

A character string with transmitter code space (e.g., "A69-1061" for Vemco PPM coding").

transmitter_id

A character string with transmitter ID code (e.g., "1363" for Vemco PPM coding").

sensor_value

A numeric sensor measurement (e.g., an integer for 'raw' Vemco sensor tags).

sensor_unit

A character string with sensor_value units (e.g., "ADC" for 'raw' Vemco sensor tag detections).

tag_specs

An object produced by read_vemco_tag_specs.

OR A data frame containing transmitter specification data with the following columns:

code_space

A character string with transmitter code space (e.g., "A69-1061" for Vemco PPM coding").

id_code

A character string with transmitter ID code (e.g., "1363" for Vemco PPM coding").

sensor_type

A numeric sensor measurement (e.g., an integer for 'raw' Vemco sensor tags).

sensor_range

A numeric with max. range of the sensor in 'real' units (e.g., "Meters" for Vemco depth tags).

sensor_units

A character string with 'real'-scale units (e.g., "Meters" for 'raw' Vemco pressure tags).

The following columns are also required for depth and temperature sensors:

sensor_slope

Slope parameter, for converting 'raw' (ADC) to 'real' measurements.

sensor_intercept

Intercept parameter, for converting 'raw' (ADC) to 'real' measurements.

The following columns are also required for acceleration sensors:

accel_algorithm

The algorithm used, accelerometers only.

accel_sample_rate

Sample rate used, accelerometers only.

sensor_transmit_ratio

Sensor transmit rate used, accelerometers only.

Details

Tag spec data are joined to detection data and then raw-scale sensor measurements are converted to real-scale using sensor_value_real = sensor_intercept + (sensor_value * sensor_slope), where sensor_value is in raw scale.

It is possible that transmitter_codespace and transmitter_id are not unique among transmitters, so users must ensure that the each combination of those columns occurs only once in tag_specs and is the correct record for the corresponding tags in det.

Value

The input data frame, data.table, or tibble with the following columns added (see column descriptions above):

  • sensor_range

  • sensor_units

  • sensor_slope

  • sensor_intercept

  • accel_algorithm

  • accel_sample_rate

  • sensor_transmit_ratio

  • sensor_value_real

Author(s)

Chris Holbrook, cholbrook@usgs.gov

Examples


#get path to example detection file
det_file <- system.file("extdata", 
  "lamprey_detections.csv", package="glatos")
  
lamprey_detections <- read_glatos_detections(det_file)

#get path to example Vemco tag spec file
spec_file <- system.file("extdata", 
  "lamprey_tag_specs.xls", package="glatos")
  
lamprey_tags <- read_vemco_tag_specs(spec_file, file_format = "vemco_xls")

#note use of '$specs' in tag_specs argument
dtc <- real_sensor_values(lamprey_detections, lamprey_tags$specs)

#now view records with sensor measurements
dtc[!is.na(dtc$sensor_value_real),]


jsta/glatos documentation built on July 11, 2022, 7:01 a.m.