Skip to content

Instantly share code, notes, and snippets.

@PadreSVK

PadreSVK/script.py

Created Jan 7, 2020
Embed
What would you like to do?
low pass
import pandas as pd
import csv
import matplotlib.pyplot as plt
from scipy import signal
x = []
y = []
z = []
xOffset = None
yOffset = None
zOffset = None
with open('PatrikInGs.csv','r') as csvfile:
data = csv.reader(csvfile, delimiter=',')
for row in data:
if xOffset==None:
xOffset = float(row[0])
yOffset = float(row[1])
zOffset = float(row[2])
x.append(float(row[0])-xOffset)
y.append(float(row[1])-yOffset)
z.append(float(row[2])-zOffset)
fmax=1000
fs=1000
f=fmax/(fs/2)
# f=(fs/2)/fmax
b,a= signal.butter(N= 2,Wn = 500, btype= 'lowpass', analog= True, output= 'ba')
output=signal.filtfilt(b,a,x)
plt.plot(seconds, output, 'b-', label='fs 500 Hz')
out1,out2= signal.butter(N= 2,Wn = 1000, btype= 'lowpass', analog= True, output= 'ba' )
output=signal.filtfilt(out1,out2,x)
plt.plot(seconds, output, 'r-', label='fs 1000 Hz')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.