scientimate.replacespike3dps#

xDespiked, Indx = scientimate.replacespike3dps(x, nrpeat=1, DespikeScaleFactor=1, interpMethod='linear', dispout='yes')

Description#

Remove spikes in the time series based on 3D phase space method by Goring and Nikora (2002)

Inputs#

x

Input data

nrpeat=1

Number of time despiking procedure is repeating

DespikeScaleFactor=1

Scaling a despiking threshold

interpMethod=’linear’
Interpolation method for replacing spike points:
Matlab/Octave: ‘linear’, ‘nearest’, ‘next’, ‘previous’, ‘pchip’, ‘cubic’, ‘spline’
Python/Scipy : ‘linear’, ‘nearest’, ‘zero’, ‘slinear’, ‘quadratic’, ‘cubic’
dispout=’no’

Define to display outputs or not (‘yes’: display, ‘no’: not display)

Outputs#

xDespiked

Dispiked data

Indx

Index of despiked points

Examples#

import scientimate as sm
import numpy as np
import scipy as sp
from scipy import signal

fs=128
t=np.linspace(0,9.5,10*fs)
x=np.sin(2*np.pi*0.3*t)+0.1*np.sin(2*np.pi*4*t)
spikeloc=np.arange(10,len(t),100)
x[np.int64(spikeloc+np.round(2*np.random.randn(len(spikeloc))))]=np.sign(np.random.randn(len(spikeloc)))
x[220:225]=1.5
x=x+5
xDespiked,Indx=sm.replacespike3dps(x,2,1,'linear','yes')

fs=2
t=np.linspace(0,1023.5,1024*fs)
x=sp.signal.detrend(0.5*np.cos(2*np.pi*0.2*t)+(-0.1+(0.1-(-0.1)))*np.random.rand(1024*fs))
spikeloc=np.arange(10,len(t),100)
x[np.int64(spikeloc+np.round(2*np.random.randn(len(spikeloc))))]=np.sign(np.random.randn(len(spikeloc)))
xDespiked,Indx=sm.replacespike3dps(x,1,1,'linear','yes')

References#

Goring, D. G., & Nikora, V. I. (2002). Despiking acoustic Doppler velocimeter data. Journal of Hydraulic Engineering, 128(1), 117-126.