Convert canonical long time series to response spectra.
TSL2PS.RdTSL2PS() is the spectra helper for canonical TSL tables produced by
AT2TS(), VT2TS(), and DT2TS(). It derives grouping keys from the
TSL schema instead of exposing BY or column-name arguments.
Arguments
- .x
Canonical
TSLdata.tablewith columnst,s,ID, andOCID, plus optional metadata columns.- xi
numeric. Damping ratio(s)
0..1. Scalar input preserves the historical output schema; vector input adds anxicolumn.- Tn
numeric vector. Natural periods in seconds. Must not include
0; theTn = 0peak-value anchor is prepended internally.- output
character. One of
"PSL"or"PSW". Default"PSL".- D50
logical scalar. If
TRUE, add the median rotated horizontal component asOCID = "D50"for every metadata group withH1andH2.- D100
logical scalar. If
TRUE, add the maximum rotated horizontal component asOCID = "D100"for every metadata group withH1andH2.- nTheta
integer. Number of rotation angles in
[0, 180)forD50 = TRUEorD100 = TRUE. Default180L(1-degree step).
Value
A data.table.
output = "PSL"returns a long table with metadata columns,OCID,Tn, spectralID("PSA","PSV","SD"), andS. Ifxiis a vector, the output also includesxi.output = "PSW"returns a wide table with metadata columns,Tn, and spectral component columns such asPSA.H1,PSV.H1, andSD.H1. Ifxiis a vector, the output also includesxi. If requested, D50 and D100 appear as ordinary component suffixes such asPSA.D50andPSA.D100.
Examples
t <- seq(0, 1, by = 0.01)
tsl <- data.table::rbindlist(list(
data.table::data.table(t = t, s = 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"),
data.table::data.table(t = t, s = sin(2 * pi * t + 0.3),
ID = "AT", OCID = "H2"),
data.table::data.table(t = t, s = cos(2 * pi * t + 0.4),
ID = "VT", OCID = "H2"),
data.table::data.table(t = t, s = sin(pi * t + 0.2),
ID = "DT", OCID = "H2")
))
ps <- TSL2PS(tsl, Tn = c(0.1, 0.2))
head(ps)
#> OCID Tn ID S
#> <char> <num> <char> <num>
#> 1: H1 0.0 PSA 0.99992094
#> 2: H1 0.1 PSA 1.04187285
#> 3: H1 0.2 PSA 1.04177301
#> 4: H1 0.0 PSV 1.00000000
#> 5: H1 0.1 PSV 0.02889454
#> 6: H1 0.2 PSV 0.05530304
rot <- TSL2PS(tsl, Tn = 0.1, D50 = TRUE, D100 = TRUE, nTheta = 6L)
rot[OCID %in% c("D50", "D100")]
#> OCID Tn ID S
#> <char> <num> <char> <num>
#> 1: D100 0.0 PSA 1.3517908540
#> 2: D100 0.1 PSA 1.4659578012
#> 3: D100 0.0 PSV 1.3407634881
#> 4: D100 0.1 PSV 0.0373499495
#> 5: D100 0.0 SD 1.3596200959
#> 6: D100 0.1 SD 0.0003571946
#> 7: D50 0.0 PSA 0.9999302109
#> 8: D50 0.1 PSA 1.1066020927
#> 9: D50 0.0 PSV 0.9999987061
#> 10: D50 0.1 PSV 0.0267738149
#> 11: D50 0.0 SD 0.9999274255
#> 12: D50 0.1 SD 0.0002611824