Created
July 14, 2020 15:08
-
-
Save yhirano/b2032dbbeba7c18bb71b3b7eb40dfb31 to your computer and use it in GitHub Desktop.
CSV plot with lowpassfilter.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pandas as pd | |
| import matplotlib.pyplot as plt | |
| def lowpass(values, strength): | |
| result = [] | |
| f = 0 | |
| for v in values: | |
| if not result: | |
| result.append(v) | |
| f = v | |
| else: | |
| f = ((1 - strength) * f) + (strength * v) | |
| result.append(f) | |
| return result | |
| df = pd.read_csv('file.csv', names=['x', 'y']) | |
| t = [] | |
| for v in df['x']: | |
| t.append(v - df['x'][0]) | |
| plt.xlabel("x") | |
| plt.ylabel("y") | |
| plt.plot(t, df['y'], label='Raw') | |
| plt.plot(t, lowpass(df['y'], 0.1), label='a=0.1') | |
| plt.legend() | |
| plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment