История изменений
Исправление djzielony, (текущая версия) :
Поправочка. Фильтрация ускорения (можно и скорости, операция то линейная) до 4 гертз.
Например так: http://oi50.tinypic.com/2z6t3is.jpg
import numpy as np
import scipy.signal as ss
import re
Fs = 1/0.05
expr = re.compile('''DEBUG curr speed km/h: (.+)''')
txt = open('in.txt')
speed_in_kmh = []
for line in txt:
match = expr.search(line)
if match:
print line
print match.group(1)
speed_in_kmh.append(float(match.group(1)))
speed_in_ms = 1000/60/60. *np.array(speed_in_kmh)
acc = (speed_in_ms[1:] - speed_in_ms[:-1])*Fs
acc[-1] = 0 #manual artifact hacking
np.savetxt('acc_table.txt', acc)
f = 4
rz = 3
b,a = ss.butter(rz, f/Fs/2, btype='low')
acc_filt = ss.lfilter(b,a, acc)
#for painting
import pylab as py
py.figure()
t = np.arange(0, len(acc)/Fs, 1/Fs)
py.subplot(311)
py.plot(t, speed_in_ms[0:-1])
py.xlabel('Time, [s]')
py.ylabel('Speed, [m/s]')
py.subplot(312)
py.plot(t, acc)
py.xlabel('Time, [s]')
py.ylabel('Acceleration, [m/s^2]')
py.subplot(313)
py.plot(t, acc_filt)
py.xlabel('Time, [s]')
py.ylabel('Acceleration filtered, [m/s^2]')
py.show()
Исправление djzielony, :
Поправочка. Фильтрация ускорение (можно и скорости, операция то линейная) до 4 гертз.
Например так: http://oi50.tinypic.com/2z6t3is.jpg
import numpy as np
import scipy.signal as ss
import re
Fs = 1/0.05
expr = re.compile('''DEBUG curr speed km/h: (.+)''')
txt = open('in.txt')
speed_in_kmh = []
for line in txt:
match = expr.search(line)
if match:
print line
print match.group(1)
speed_in_kmh.append(float(match.group(1)))
speed_in_ms = 1000/60/60. *np.array(speed_in_kmh)
acc = (speed_in_ms[1:] - speed_in_ms[:-1])*Fs
acc[-1] = 0 #manual artifact hacking
np.savetxt('acc_table.txt', acc)
f = 4
rz = 3
b,a = ss.butter(rz, f/Fs/2, btype='low')
acc_filt = ss.lfilter(b,a, acc)
#for painting
import pylab as py
py.figure()
t = np.arange(0, len(acc)/Fs, 1/Fs)
py.subplot(311)
py.plot(t, speed_in_ms[0:-1])
py.xlabel('Time, [s]')
py.ylabel('Speed, [m/s]')
py.subplot(312)
py.plot(t, acc)
py.xlabel('Time, [s]')
py.ylabel('Acceleration, [m/s^2]')
py.subplot(313)
py.plot(t, acc_filt)
py.xlabel('Time, [s]')
py.ylabel('Acceleration filtered, [m/s^2]')
py.show()
Исходная версия djzielony, :
Поправочка. Фильтрация до 3 гертз.
Например так: http://oi50.tinypic.com/2z6t3is.jpg
import numpy as np
import scipy.signal as ss
import re
Fs = 1/0.05
expr = re.compile('''DEBUG curr speed km/h: (.+)''')
txt = open('in.txt')
speed_in_kmh = []
for line in txt:
match = expr.search(line)
if match:
print line
print match.group(1)
speed_in_kmh.append(float(match.group(1)))
speed_in_ms = 1000/60/60. *np.array(speed_in_kmh)
acc = (speed_in_ms[1:] - speed_in_ms[:-1])*Fs
acc[-1] = 0 #manual artifact hacking
np.savetxt('acc_table.txt', acc)
f = 4
rz = 3
b,a = ss.butter(rz, f/Fs/2, btype='low')
acc_filt = ss.lfilter(b,a, acc)
#for painting
import pylab as py
py.figure()
t = np.arange(0, len(acc)/Fs, 1/Fs)
py.subplot(311)
py.plot(t, speed_in_ms[0:-1])
py.xlabel('Time, [s]')
py.ylabel('Speed, [m/s]')
py.subplot(312)
py.plot(t, acc)
py.xlabel('Time, [s]')
py.ylabel('Acceleration, [m/s^2]')
py.subplot(313)
py.plot(t, acc_filt)
py.xlabel('Time, [s]')
py.ylabel('Acceleration filtered, [m/s^2]')
py.show()