Skip to contents

Interpolates every quantile curve of one spectrum slice (one site, model, Vs30 and return period) at a target oscillator period, as the displacement sampling does when the spectrum lacks the periods \(1.3 T_s\) or \(1.5 T_s\). Each curve is interpolated independently; the slice is not grouped.

Usage

interpolateSpectrum(spectrum, Tn)

Arguments

spectrum

A table of one spectrum slice with Tn (s), p (probability labels and optionally "mean") and Sa (g). Every quantile label needs two or more rows; other columns are ignored.

Tn

One finite non-negative target oscillator period in seconds.

Value

A data.table with Tn, p and Sa, one row per quantile label plus the mean row when the slice has one, ordered by Tn and p.

Mathematics

For the rows \((T_i, S_{a,i})\) of one probability label, $$S_a(T) = \exp\, L\left(\ln T;\ \ln(T_i + 10^{-8}),\ \ln S_{a,i}\right)$$ where \(L\) is linear interpolation (stats::approx) with constant extension beyond the tabulated periods (rule = 2). The offset \(10^{-8}\) admits a zero-period node; a target of zero falls below every node and takes the lowest-period ordinate. Duplicate \((T, p)\) rows signal a warning and are averaged in \(\ln S_a\), a geometric mean. The "mean" rows follow the same rule when there are two or more; a single mean row is copied to the target period and a slice without one returns no mean row.

Examples

Spectrum <- data.frame(Tn = rep(c(0.2, 0.8), each = 3L),
                       p = rep(c("0.16", "0.84", "mean"), 2L),
                       Sa = c(1, 2, 1.5, 4, 8, 6))
interpolateSpectrum(Spectrum, Tn = 0.4)
#>       Tn      p    Sa
#>    <num> <char> <num>
#> 1:   0.4   0.16     2
#> 2:   0.4   0.84     4
#> 3:   0.4   mean     3