downsample: Interpolate time series at higher sample rate.

View source: R/downsample.R

downsampleR Documentation

Interpolate time series at higher sample rate.

Description

Interpolate a times series with a higher/lower sample rate for processes that are sensitive to low samples.

Usage


downsample(sig, dt=0.001, newdt=0.01, PLOT=FALSE )

Arguments

sig

time series vector

dt

sample rate s/sample

newdt

New, lower sample rate

PLOT

logical, plot both traces, default=FALSE

Details

Linear interpolation is performed between samples. If the newdt is an integer multiple of the old dt, The samples will not be modified.

Value

time series vector with new sample rate.

Author(s)

Jonathan M. Lees<jonathan.lees@unc.edu>

Examples

data(KH)
sig = KH$JSTR[[1]]
####  reduce samples from 125 (0.008)  to 25Hz (0.04) 
newdt = KH$dt[1]*5
sig2 = downsample(sig, dt = KH$dt[1], newdt = newdt )

L0 = length(sig)
L1 = length(sig2)

op <- par(no.readonly = TRUE)
par(mfrow=c(2,1) )
  plot.ts(ts(sig, deltat=KH$dt[1] ), xlab='s',
ylab='Amplitude', main=paste('Orignal', L0) )
grid()
     plot.ts(ts(sig2, deltat=newdt ), xlab='s',
ylab='Amplitude', main=paste('Downsample', L1) )
grid()
par(op)


RSEIS documentation built on Sept. 13, 2024, 1:09 a.m.