knitr::opts_chunk$set(collapse = TRUE, comment = "#>", eval = FALSE)
# Minimal executable example library(gmsp) library(data.table) t_vec <- seq(0, 10, by = 0.01) tsl <- data.table(RSN = "R1", OCID = "H1", ID = "AT", t = t_vec, s = 500 * sin(2 * pi * 2 * t_vec)) im <- TSL2IM(tsl, units.source = "mm", units.target = "mm") head(im)
TSL2IM() computes intensity measures from a long TSL table
containing acceleration (AT), velocity (VT) and displacement (DT)
series. getIntensity() remains as a compatibility wrapper around
TSL2IM().
References: Arias (1970), Trifunac & Brady (1975), Campbell & Bozorgnia (2012), Inoue et al. (1996), Rathje et al. (1998).
TSL must be a data.table with columns:
RSN — record id,OCID — channel id,ID ∈ {AT, VT, DT},t — time (s),s — amplitude.The function takes:
units.source — source units for s ("mm", "cm", "m", "gal",
"g"),units.target — target base-length units
("mm", "cm", "m"; default "mm").A single factor SFU = .getSF(units.source, units.target) is applied to
s for all rows, regardless of ID. This works if your AT, VT
and DT series are already consistent in the same base-length unit
(e.g. output of AT2TS / VT2TS / DT2TS in units.target).
Warning: if you mix incompatible units (e.g. units.source = "g" while
also having VT / DT in the same table), the scaling will be wrong.
After scaling:
AT: s is acceleration in units.target/s^2.VT: s is velocity in units.target/s.DT: s is displacement in units.target.The acceleration of gravity in target units is
$g = .getG(\mathrm{units.target})$ (e.g. 9806.65 mm/s² for
units.target = "mm").
Measures are computed per group $(RSN, OCID, ID)$.
The default output is long IML, with columns for metadata, OCID, ID,
IM, value, and units. Use output = "IMW" when a pipeline needs one
row per metadata and OCID with intensity measures as columns:
imw <- TSL2IM(tsl, units.source = "mm", output = "IMW") names(imw)[1:min(6, length(names(imw)))]
The same projection is available for existing long results:
IML2IMW(im).
Peak and RMS:
$$\mathrm{PGA} = \max_t |a(t)|, \qquad \mathrm{ARMS} = \sqrt{\frac{1}{N}\sum_{i=1}^{N} a_i^2}.$$
Zero crossings and edges:
AZC — number of zero crossings (discrete count).ATo, ATn — first $a(t_1)$ and last $a(t_N)$ value.Arias intensity (discretised with $\Delta t = \mathrm{mean}(t_i - t_{i-1})$):
$$\mathrm{AI} = \frac{\pi}{2g}\sum_{i=1}^{N} a_i^2\,\Delta t.$$
AI — total Arias intensity.AIu — uses $a_+(t) = \max(a, 0)$ only.AId — uses $a_-(t) = \min(a, 0)$ only.Units: units.target/s.
Significant duration (Husid): the code builds a cumulative curve proportional to energy,
$$H(t_k) = \pi\,\Delta t \sum_{i=1}^{k} a_i^2,$$
and measures the time interval between two fractions of the total.
D0595 — 5 % → 95 %.D0575 — 5 % → 75 %.D2080 — 20 % → 80 %.Units: s.
Mean period $T_m$ (Rathje et al. 1998), from the Fourier amplitude spectrum over a frequency band:
$$T_m = \frac{\sum_{f \in [f_{\min}, f_{\max}]} C(f)^2 / f} {\sum_{f \in [f_{\min}, f_{\max}]} C(f)^2}.$$
TmA is computed on AT with $f_{\min} = 0.1$ Hz, $f_{\max} = 25$ Hz.
Duration / sampling:
NP — number of samples.dt — mean $\Delta t$.Fs — $1/\Delta t$.Dmax — last time last(t).Cumulative absolute velocity (CAV):
$$\mathrm{CAV} = \sum_{i=1}^{N} |a_i|\,\Delta t.$$
CAV5 applies the same sum but only over indices where
$|a_i| \ge 0.05\,g$. Units: units.target/s.
Derived indices (as implemented; not standardised):
$$\mathrm{EPI} = \frac{0.9}{\pi}\,\mathrm{AI}\,(2g)\,D_{05\text{–}95}, \qquad \mathrm{PDI} = \mathrm{AI}\,\left(\frac{D_{\max}}{\mathrm{AZC}}\right)^{!2}.$$
Units: units.target^2/s^2 for EPI; units.target·s for PDI (with
AZC treated as dimensionless).
Note: if AZC = 0, PDI becomes Inf/NaN.
PGV — $\max_t |v(t)|$.VRMS — RMS of $v$.VZC — zero crossings.VTo, VTn — first / last value.TmV — mean period from the Fourier amplitude spectrum.Units: units.target/s for PGV / VRMS / VTo / VTn; s for TmV.
PGD — $\max_t |d(t)|$.DRMS — RMS of $d$.DZC — zero crossings.DTo, DTn — first / last value.TmD — mean period from the Fourier amplitude spectrum.Units: units.target for PGD / DRMS / DTo / DTn; s for TmD.
OCID.TSL2PS().Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.