Validate the Data Structure of CrossSpectra Data
Source:R/SeaSondeRCS.R
seasonder_validateCSDataStructure.RdThis function checks the validity of the data structure for CrossSpectra (CS) data. It ensures that all required fields are present,
the dimensions of the matrices are correct based on nRanges and nDoppler, and that the types of the data fields are as expected.
Details
The function expects the following structure for the data list:
SSA1,SSA2,SSA3,QC: Matrices with numeric values, with dimensionsnRangesxnDoppler.CS12,CS13,CS23: Matrices with complex values, with dimensionsnRangesxnDoppler.
Error Management
This function utilizes the rlang package to manage errors and provide detailed and structured error messages:
Condition Classes:
seasonder_CS_data_structure_validation_error: An error class indicating a problem with the data structure of the CrossSpectra (CS) data.
Condition Cases:
Missing fields in the data.
Incorrect dimensions for the matrices in the data.
Incorrect data type for the fields in the data.
Examples
# Example with all required fields
data <- list(
SSA1 = matrix(rep(NA_real_, 10 * 20), ncol = 20, byrow = TRUE),
SSA2 = matrix(rep(NA_real_, 10 * 20), ncol = 20, byrow = TRUE),
SSA3 = matrix(rep(NA_real_, 10 * 20), ncol = 20, byrow = TRUE),
CS12 = matrix(complex(real = NA, imaginary = NA), nrow = 10, ncol = 20),
CS13 = matrix(complex(real = NA, imaginary = NA), nrow = 10, ncol = 20),
CS23 = matrix(complex(real = NA, imaginary = NA), nrow = 10, ncol = 20),
QC = matrix(rep(NA_real_, 10 * 20), ncol = 20, byrow = TRUE)
)
seasonder_validateCSDataStructure(data, 10, 20)