seasonder_readSeaSondeCSFileBlock: Read and Apply Quality Control to a Block of Fields

View source: R/SeaSondeRCS.R

seasonder_readSeaSondeCSFileBlockR Documentation

Read and Apply Quality Control to a Block of Fields

Description

Reads a block of fields from a binary file based on provided specifications. Each field is read and then processed with a specified quality control function.

Usage

seasonder_readSeaSondeCSFileBlock(spec, connection, endian = "big")

Arguments

spec

A named list of specifications for fields to read. Each specification should be in the form: list(type = "data_type", qc_fun = "qc_function_name", qc_params = list(param1 = value1, ...)) Where:

  • type: is the data type to read, which will be passed to seasonder_readCSField.

  • qc_fun: is the name of a quality control function. This function should be present in the shared environment seasonder_the and must accept field_value as its first argument, followed by any other arguments specified in qc_params.

  • qc_params: is a list of additional parameters to pass to the quality control function.

connection

A connection to the binary file.

endian

A character string indicating the byte order. Options are "big" and "little" (default is "big").

Details

The quality control (QC) functions (qc_fun) specified within spec play a pivotal role in ensuring the reliability of the data that's read. Here's the expected behavior of these QC functions:

  • Input:

    • field_value: Value of the field that has been read from the binary file using the seasonder_readCSField function.

    • ...: Additional parameters specified in qc_params that are passed to qc_fun for quality control.

  • Functioning: The QC function receives a read value and performs checks or transformations based on defined rules or parameters.

    • On QC failure:

      • The QC function itself is responsible for determining the action to take. It can log an error, return a default value, impute the value, and more.

      • For critical errors, the QC function could halt the execution. However, note that logging is managed by the QC function and won't necessarily halt execution in every case.

    • On success: The QC function will return the value (either unchanged or transformed).

  • Output: Value that has been validated or transformed based on quality control rules.

  • Additional Notes:

    • The action on QC failure is directly implemented within the QC function.

    • Reading errors are managed by the seasonder_readCSField function, which returns NULL in the case of an error. It is up to the QC function to decide what to do if it receives a NULL.

Value

A named list where each entry corresponds to a field that has been read. Each key is the field name, and its associated value is the data for that field after quality control.

See Also

read_and_qc_field

Examples

spec <- list(field1 = list(type = "UInt8", qc_fun = "qc_check_unsigned", qc_params = list()))
con <- rawConnection(as.raw(c(0x01)))
block <- seasonder_readSeaSondeCSFileBlock(spec, con, endian = "big")
print(block)
close(con)

SeaSondeR documentation built on June 8, 2025, 10:50 a.m.