View source: R/SeaSondeRCSSY.R
seasonder_CSSY2CSData | R Documentation |
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:
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 c12r
, c13r
and c23r
with the corresponding imaginary parts
from c12i
, c13i
and c23i
.
The quality control matrix is obtained directly from the csqf
field.
seasonder_CSSY2CSData(body)
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: |
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 c12r
(real) and c12i
(imaginary).
A complex matrix formed by pairing c13r
(real) and c13i
(imaginary).
A complex matrix formed by pairing c23r
(real) and c23i
(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),
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.