compile_HOBO_data: Compiles temperature data from HOBO and TidbiT sensors

View source: R/compile_HOBO_data.R

compile_HOBO_dataR Documentation

Compiles temperature data from HOBO and TidbiT sensors

Description

Compiles and formats data from HOBO and TidbiT sensors.

Usage

compile_HOBO_data(
  path.HOBO,
  area.name = "",
  serial.table.HOBO,
  deployment.range,
  trim = TRUE,
  rm.DST = FALSE,
  correct.DO = FALSE,
  Sal = NULL,
  method = "garcia-gordon",
  export.csv = FALSE
)

Arguments

path.HOBO

File path to the Hobo folder. All of the excel files in the Hobo folder will be compiled. The name of each file must be the serial number of the sensor, and the excel files must be in either .csv or .xlsx format. The timestamp columns must be in the order "ymd IMS p", "Ymd IMS p", "Ymd HM", "Ymd HMS", "dmY HM", or "dmY HMS".

area.name

Area where the sensor(s) was deployed.

serial.table.HOBO

A table with the serial number of each HOBO and TidBiT sensor on the string, in the form "HOBO-xxxxxxxx" or "TidbiT-xxxxxxxx" (first column) and corresponding depth at which it was deployed in the form "2m" (second column).

deployment.range

A dataframe with two columns. The first column holds the deployment date (a Date object, POSIXct object, or character string in the order year, month, day), and the second column holds the retrieval date (a Date object, POSIXct object, or character string in the order year, month, day).

trim

Logical value indicating whether to trim the data to the dates specified in deployment.range. (Note: four hours are added to the retrieval date to account for AST, e.g., in case the sensor was retrieved after 20:00 AST, which is 00:00 UTC the next day.) Default is trim = TRUE.

rm.DST

Option to remove daylight savings time. Here, daylight savings is as defined for Nova Scotia, Canada (begins in March and end in November). Only works for 2015 - 2021. It is strongly recommended that the data is in the correct timezone before using this function, and that the default rm.DST = FALSE is used.

correct.DO

Logical value. If TRUE, dissolved oxygen will be corrected for salinity (argument Sal must be specified).

If FALSE, no correction factor will be applied. If the sensor did not record dissolved oxygen data, use the default correct.DO = FALSE.

Sal

A single value of salinity (psu), used to calculate the salinity correction factor for dissolved oxygen.

method

Equation to use to calculate dissolved oxygen solubility. Options are method = "garcia-gordon" (the default) and method = "benson-krause".

export.csv

Logical value indicating whether to export the compiled data as a .csv file. If export.csv = TRUE, the compiled data will not be returned to the global environment. Default is export.csv = FALSE.

Details

The raw HOBO and TidBiT data must be saved in a folder named Hobo in .csv or .xlsx format.

All columns are read in as characters to ensure the timestamp is parsed correctly. Timestamp must be saved in Excel as a number or a character in the order ""ymd IMS p", "Ymd IMS p", "Ymd HM", "Ymd HMS", "dmY HM", or "dmY HMS".

Dissolved oxygen can be corrected for salinity using equation 32 in Benson and Krause. See ?apply_salinity_correction for more detail.

CMAR NOTES: Data should be exported from the Hobo software in GMT+00 as a csv file so that the timestamp is in UTC.

If exported as a .xlsx file, the timestamp accounts for daylight savings time (this seems to be a bug in the HOBO software). compile_HOBO_data() can convert .xlsx files to true UTC by setting rm.DST = TRUE. This will subtract 1 hour from each datetime that occurs during daylight savings.

The functions used to convert to true UTC are convert_HOBO_datetime_to_true_UTC() and dates_to_fix(), which are NOT exported to the strings package (i.e., they are only used internally).

convert_HOBO_datetime_to_true_UTC() identifies which datetimes are during daylight savings by creating two additional columns: ADT_force = force_tz(TIMESTAMP, tzone = "America/Halifax"), and DAYLIGHT_SAVINGS = dst(ADT_force). Where DAYLIGHT_SAVINGS == TRUE, the TIMESTAMP is shifted back by 1 hour.

This leaves apparent duplicates for the hour of 1 am on the day that daylight savings ends. dates_to_fix() identifies these n observations (e.g. 1:00, 1:15, 1:30, 1:45, 1:00, 1:15, 1:30, 1:45), and shifts the first n/2 back by one hour (e.g. 00:00, 00:15, 00:30, 00:45, 1:00, 1:15, 1:30, 1:45).The function is hard-coded 2015 - 2021.

If for some reason, there is an ODD number of duplicates, the function might break.

Value

Returns a dataframe or exports a spreadsheet with the data compiled from each of the HOBO and TidbiT sensors. Columns alternate between timestamp (in the format "Y-m-d H:M:S") and temperature value (rounded to three decimal places). Metadata at the top of each column indicates the deployment and retrieval dates, the sensor serial number, the depth of the sensor, the temperature units, and the timezone of the timestamp.

To include the metadata, all values were converted to class character. To manipulate the data, the values must be converted to the appropriate class (e.g., POSIXct for the timestamps and numeric for temperature values). This can be done using the function convert_to_tidydata().

Author(s)

Danielle Dempsey

See Also

Other compile: compile_all_data(), compile_aquaMeasure_data(), compile_vemco_data(), read_deployment_log()

Examples

# path to "Hobo" folder
path <- system.file("extdata", package = "strings")
# Sensor and depth at which it was deployed
serial.table <- data.frame("SENSOR" = "HOBO-10755220", "DEPTH" = "2m")
# deployment and retrieval dates
deployment <- data.frame("START" = "2019-05-30", "END" = "2019-10-19")

hobo_data <- compile_HOBO_data(path.HOBO =  path,
serial.table.HOBO = serial.table,
deployment.range = deployment)

Centre-for-Marine-Applied-Research/strings documentation built on Aug. 21, 2023, 8 a.m.