View source: R/SeaSondeRCSSW.R
seasonder_CSSW2CSData | R Documentation |
This function converts the body structure of a CSSW 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:
Matrices are built using the numeric vectors found in the cs1a
, cs2a
and cs3a
fields respectively.
Each complex cross-spectra matrix is formed by combining the real parts
from c12m
, c13m
and c23m
with the corresponding imaginary parts
from c12a
, c13a
and c23a
.
The quality control matrix is obtained directly from the csqf
field.
seasonder_CSSW2CSData(body)
body |
A list representing the body of a CSSW file. Each element of the list is expected to be a
cell containing the following fields: |
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.
A list with the following components:
A numeric matrix containing self-spectra from cs1a
.
A numeric matrix containing self-spectra from cs2a
.
A numeric matrix containing self-spectra from cs3a
.
A complex matrix formed by pairing c12m
(real) and c12a
(imaginary).
A complex matrix formed by pairing c13m
(real) and c13a
(imaginary).
A complex matrix formed by pairing c23m
(real) and c23a
(imaginary).
A numeric matrix containing the quality control data from csqf
.
# 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),
c12m = c(10, 11, 12),
c12a = c(13, 14, 15),
c13m = c(16, 17, 18),
c13a = c(19, 20, 21),
c23m = c(22, 23, 24),
c23a = c(25, 26, 27),
csqf = c(28, 29, 30)
)
body <- list(cell)
transformed <- seasonder_CSSW2CSData(body)
print(transformed)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.