Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. def bandpass(x, lowcut, highcut, fs, order=5, axis=-1, kind='butter'):
  2. """
  3. Parameters
  4. ----------
  5. x : ndarray
  6. 1d time series data
  7. lowcut : float
  8. Defines lower frequency cutoff (e.g. in Hz)
  9. highcut : float
  10. Defines upper frequency cutoff (e.g. in Hz)
  11. fs : float
  12. Sampling frequency (e.g. in Hz)
  13. order : int
  14. Filter order parameter
  15. kind : str
  16. Specifies the kind of filter
  17. axis : int
  18. Axis along which to bandpass filter data
  19. """
  20. nyq = 0.5 * fs
  21. low = lowcut / nyq
  22. high = highcut / nyq
  23. if kind == "butter":
  24. b, a = butter(order, [low, high], btype="band")
  25. else:
  26. raise ValueError("Filter kind not recognized.")
  27. return filtfilt(b, a, x, axis=axis)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement