Skip to contents

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:

SSA1, SSA2, SSA3

Matrices are built using the numeric vectors found in the cs1a, cs2a and cs3a fields respectively.

CS12, CS13, CS23

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.

QC

The quality control matrix is obtained directly from the csqf field.

Usage

seasonder_CSSW2CSData(body)

Arguments

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: indx (which includes an index), cs1a, cs2a, cs3a, c12m, c12a, c13m, c13a, c23m, c23a and csqf.

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 c12m (real) and c12a (imaginary).

CS13

A complex matrix formed by pairing c13m (real) and c13a (imaginary).

CS23

A complex matrix formed by pairing c23m (real) and c23a (imaginary).

QC

A numeric matrix containing the quality control data from csqf.

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.

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),
    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)
#> $SSA1
#>      [,1] [,2] [,3]
#> [1,]    1    2    3
#> 
#> $SSA2
#>      [,1] [,2] [,3]
#> [1,]    4    5    6
#> 
#> $SSA3
#>      [,1] [,2] [,3]
#> [1,]    7    8    9
#> 
#> $CS12
#>                    [,1]               [,2]               [,3]
#> [1,] 9.743701+2.249511i 10.67325+2.661141i 11.59111+3.105829i
#> 
#> $CS13
#>                  [,1]               [,2]               [,3]
#> [1,] 15.1283+5.20909i 15.97477+5.814342i 16.80445+6.450623i
#> 
#> $CS23
#>                    [,1]               [,2]               [,3]
#> [1,] 19.93877+9.297602i 20.67226+10.08254i 21.38416+10.89577i
#> 
#> $QC
#>      [,1] [,2] [,3]
#> [1,]   28   29   30
#>