-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathlevant_post.py
More file actions
37 lines (29 loc) · 790 Bytes
/
levant_post.py
File metadata and controls
37 lines (29 loc) · 790 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python
from pylab import *
from scipy.signal import lfilter, butter
import velocity
# Test some Levant post-processing filters
sr = 10000.0
t = arange(int(sr))/sr
f0 = 10
p = cos(t*2*pi*f0)*exp(-t*0.5)
v = lfilter([1,-1],1,p)*sr
noise = uniform(-0.001,0.001,len(t))
C = max(lfilter([1,-1],1,v)*sr)
n = 70
lv = velocity.levant(C=C,sr=sr,pos=p+noise)
v2 = velocity.avgfilt(lv, n=n)
v3 = velocity.maxmin(lv, n=n)
v4 = lfilter(*butter(2,0.02,'low'),x=lv)
clf()
subplot(2,1,1)
plot(t,v)
plot(t,lv)
subplot(2,1,2)
plot(t[4900:5100],v[4900:5100], label='true vel')
plot(t[4900:5100],lv[4900:5100], label='levant')
plot(t[4900:5100],v2[4900:5100], label='avgfilt')
plot(t[4900:5100],v3[4900:5100], label='maxmin')
plot(t[4900:5100],v4[4900:5100], label='bw')
legend()
show()