# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
#' Konno Ohmachi smoothing
#'
#' Apply Konno Ohmachi smoothing to the Fourier Amplitude Spectra (FAS)
#'
#' @useDynLib RCTC
#' @importFrom Rcpp sourceCpp
#' @param freq An array of the frequency
#' @param amp An array of the corresponding FAS
#' @param b The coefficient of bandwidth. A smaller value will lead to more smoothing
#' @param rate The truncation rate of KO smoothing. A larger value will be more accurate but more time consuming
#' @return The smoothed FAS
#' @references Konno, K., Ohmachi, T. Ground-motion characteristics estimated from spectral ratio between horizontal and vertical components of microtremor.
#' Bulletin of the Seismological Society of America. 1998.88 (1): 228-241.
#' @export
KO_smooth <- function(freq, amp, b = 20, rate = 2.5) {
.Call('_RCTC_KO_smooth', PACKAGE = 'RCTC', freq, amp, b, rate)
}
#' Response computation
#'
#' Compute response acceleration, pseudo-spectral acceleration (PSA), and spectral displacement
#'
#' @param data An acceleration time series array (in g)
#' @param period_t An array of oscillator periods
#' @param damping Damping ratio, expressed as a decimal
#' @param time_dt Time step, in sec
#' @param type_return A dummy variable controlling output type, set to either 1 or 2.
#' If 1 is selected, it returns a four-row matrix with actual spectral acceleration (in g)
#' in the first row, PSA (in g) in the second row, PSV (cm/s) in the third row, and
#' spectral displacement (cm) in the fourth row at each of the specified periods in \code{period_t}.
#' If 2 is selected, it returns a matrix with response displacement (cm)
#' (number of periods in \code{period_t} by data points)
#' @return The response acceleration and PSA, or spectral velocity and spectral displacement.
#' It depends on \code{type_return}.
#' @export
PS_cal_cpp <- function(data, period_t, damping, time_dt, type_return) {
.Call('_RCTC_PS_cal_cpp', PACKAGE = 'RCTC', data, period_t, damping, time_dt, type_return)
}
#' Subset selection
#'
#' Select subsets of two components of ground motions.
#'
#' @param data1 One horizontal component of ground motions
#' @param data2 Another horizontal component of ground motions
#' @param fraction A factor to specify how much subset will be selected.
#' 0 means select all dataset.
#' @param length The minimum length of two input time sereis, integer type
#' @param time_dt Time step, double type
#' @param type_return Either 1 or 2. It specifies what does this \code{subset_select} return.
#' If set as 1, it will return a matirx (length is the length of selected subset,
#' width is 3) for subset. The first row is subset selection for \code{data1}, the second row is
#' subset selection for \code{data2}, while the third row is subset selection for time.
#' If set as 2, it will return only a double type value, which is threshold value for subset selection
#' @return \code{subset_select} returns two subsets of \code{data1} and \code{data2}, or a threshold value.
#' It depends on \code{type_return}.
#' @export
subset_select <- function(data1, data2, fraction, length, time_dt, type_return) {
.Call('_RCTC_subset_select', PACKAGE = 'RCTC', data1, data2, fraction, length, time_dt, type_return)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.