Learn R Programming

RSEIS (version 4.2-4)

downsample: 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 )

Value

time series vector with new sample rate.

Arguments

sig

time series vector

dt

sample rate s/sample

newdt

New, lower sample rate

PLOT

logical, plot both traces, default=FALSE

Author

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

Details

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

Examples

Run this code
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)

Run the code above in your browser using DataLab