Skip to content

Instantly share code, notes, and snippets.

@kastnerkyle
Last active August 29, 2015 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kastnerkyle/aa65cafe5e19ab84f621 to your computer and use it in GitHub Desktop.
Save kastnerkyle/aa65cafe5e19ab84f621 to your computer and use it in GitHub Desktop.
Super crude filtering
# Author: Kyle Kastner
# License: BSD 3-clause
import numpy as np
from scipy.signal import lfilter
import matplotlib.pyplot as plt
sine = np.sin(np.linspace(-4 * np.pi, 4 * np.pi, 10000))
noise = 0.2 * np.random.randn(len(sine))
s = sine + noise
plt.plot(s)
plt.figure()
low_pass = [1, 1] * 128
plt.plot(lfilter(low_pass, [1], s))
plt.figure()
high_pass = [1, -1] * 128
plt.plot(lfilter(high_pass, [1], s))
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment