Skip to contents

Divides the signal column s by the peak amplitude of a reference quantity (norm) for every (metadata, OCID) group. The same scale factor is applied to all ID values within each group so that the physical relationship between AT, VT, and DT is preserved.

The default norm = "PGA" scales by 1 / max(abs(s)) computed from ID == "AT" rows, making max(abs(AT)) = 1 for every channel. The same SF is then applied to the corresponding VT and DT rows.

Modifies .x in place; returns .x[].

Usage

normalizeTS(.x, norm = "PGA")

Arguments

.x

Canonical TSL data.table with columns t, s, ID, and OCID, plus optional metadata columns.

norm

character. Reference quantity used to derive the scale factor. "PGA" (default) uses max(abs(AT)), "PPV" uses max(abs(VT)), "PGD" uses max(abs(DT)).

Value

.x with s scaled in place.

Examples

t <- seq(0, 1, by = 0.01)
tsl <- data.table::rbindlist(list(
  data.table::data.table(t = t, s = 2 * sin(2 * pi * t),
                         ID = "AT", OCID = "H1"),
  data.table::data.table(t = t, s = cos(2 * pi * t),
                         ID = "VT", OCID = "H1"),
  data.table::data.table(t = t, s = sin(pi * t),
                         ID = "DT", OCID = "H1")
))
normalizeTS(tsl)
#> Index: <ID>
#>          t            s     ID   OCID
#>      <num>        <num> <char> <char>
#>   1:  0.00 0.000000e+00     AT     H1
#>   2:  0.01 6.279052e-02     AT     H1
#>   3:  0.02 1.253332e-01     AT     H1
#>   4:  0.03 1.873813e-01     AT     H1
#>   5:  0.04 2.486899e-01     AT     H1
#>  ---                                 
#> 299:  0.96 6.266662e-02     DT     H1
#> 300:  0.97 4.705416e-02     DT     H1
#> 301:  0.98 3.139526e-02     DT     H1
#> 302:  0.99 1.570538e-02     DT     H1
#> 303:  1.00 6.123234e-17     DT     H1
max(abs(tsl[ID == "AT", s]))
#> [1] 1