Skip to contents

Classifies a single three-component record, preserves provider channel names in OCID, and records canonical processed directions in DIR (H1, H2, UP). This helper is for processed products; raw extraction continues to preserve provider OCID values.

Usage

mapComponents(DT, rotate = TRUE, output = c("long", "wide"))

Arguments

DT

LONG data.table(t, OCID, s) or WIDE data.table(t, <OCID1>, <OCID2>, <OCID3>) for ONE record.

rotate

Logical scalar. If TRUE, rotate the two horizontal components to their principal axes and store attr(out, "theta").

output

"long" (default) returns provider OCID, canonical DIR, and signal s; "wide" returns data.table(t, H1, H2, UP).

Value

A data.table in the requested output shape, or NULL when the record cannot be mapped. Both shapes carry attr(out, "componentMap") and attr(out, "rotate"); rotated outputs also carry attr(out, "theta").

See also

Examples

t <- seq(0, 1, by = 0.1)
x <- data.table::rbindlist(list(
  data.table::data.table(t = t, OCID = "N", s = sin(2 * pi * t)),
  data.table::data.table(t = t, OCID = "E", s = 0.5 * cos(2 * pi * t)),
  data.table::data.table(t = t, OCID = "Z", s = 0.1 * sin(2 * pi * t))
))
mapped <- mapComponents(x, rotate = FALSE)
head(mapped)
#>        t   OCID    DIR            s
#>    <num> <char> <char>        <num>
#> 1:   0.0      N     H1 0.000000e+00
#> 2:   0.1      N     H1 5.877853e-01
#> 3:   0.2      N     H1 9.510565e-01
#> 4:   0.3      N     H1 9.510565e-01
#> 5:   0.4      N     H1 5.877853e-01
#> 6:   0.5      N     H1 1.224647e-16