Read and Apply Quality Control to a Block of Fields
Source:R/SeaSondeRCS.R
seasonder_readSeaSondeCSFileBlock.Rd
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.
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 toseasonder_readCSField
.qc_fun
: is the name of a quality control function. This function should be present in the shared environmentseasonder_the
and must acceptfield_value
as its first argument, followed by any other arguments specified inqc_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").
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.
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 theseasonder_readCSField
function....
: Additional parameters specified inqc_params
that are passed toqc_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.