seasonder_CSSY2CSData {SeaSondeR} | R Documentation |
Transform CSSY Body to SeaSonde CS Data Structure
Description
This function converts the body structure of a CSSY file into a list of matrices that conform to the data structure required for creating a SeaSondeRCS object. The conversion is performed by mapping specific fields:
- SSA1, SSA2, SSA3
Matrices are built using the numeric vectors found in the
cs1a
,cs2a
andcs3a
fields respectively.- CS12, CS13, CS23
Each complex cross-spectra matrix is formed by combining the real parts from
c12r
,c13r
andc23r
with the corresponding imaginary parts fromc12i
,c13i
andc23i
.- QC
The quality control matrix is obtained directly from the
csqf
field.
Usage
seasonder_CSSY2CSData(body)
Arguments
body |
A list representing the body of a CSSY file. Each element of the list is expected to be a
cell containing the following fields: |
Details
Each row in the output matrices corresponds to the index provided by cell$indx$index
in the input list.
The function first determines the maximum index among the cells in the body, which defines the number of rows
for the matrices. Then, it calculates the number of columns for each matrix based on the length of the corresponding
vectors from the first cell where they appear. Finally, each cell's data is inserted into the appropriate row
of the matrices as indicated by the cell's indx$index
value.
Value
A list with the following components:
- SSA1
A numeric matrix containing self-spectra from
cs1a
.- SSA2
A numeric matrix containing self-spectra from
cs2a
.- SSA3
A numeric matrix containing self-spectra from
cs3a
.- CS12
A complex matrix formed by pairing
c12r
(real) andc12i
(imaginary).- CS13
A complex matrix formed by pairing
c13r
(real) andc13i
(imaginary).- CS23
A complex matrix formed by pairing
c23r
(real) andc23i
(imaginary).- QC
A numeric matrix containing the quality control data from
csqf
.
Examples
# Example with a single cell
cell <- list(
indx = list(index = 1),
cs1a = c(1, 2, 3),
cs2a = c(4, 5, 6),
cs3a = c(7, 8, 9),
c12r = c(10, 11, 12),
c12i = c(13, 14, 15),
c13r = c(16, 17, 18),
c13i = c(19, 20, 21),
c23r = c(22, 23, 24),
c23i = c(25, 26, 27),
csqf = c(28, 29, 30)
)
body <- list(cell)
transformed <- seasonder_CSSY2CSData(body)
print(transformed)