From 035b658710c4bdf25857ec7bbfa0df0dcd09975f Mon Sep 17 00:00:00 2001 From: David Rotermund <54365609+davrot@users.noreply.github.com> Date: Thu, 16 Nov 2023 18:30:46 +0100 Subject: [PATCH] Update README.md Signed-off-by: David Rotermund <54365609+davrot@users.noreply.github.com> --- scipy.signal_butterworth/README.md | 35 ++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/scipy.signal_butterworth/README.md b/scipy.signal_butterworth/README.md index a70b831..90a7c87 100644 --- a/scipy.signal_butterworth/README.md +++ b/scipy.signal_butterworth/README.md @@ -4,3 +4,38 @@ Sometimes we need to remove of frequency range from a time series. For this we can use a Butterworth filter [scipy.signal.butter](https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.butter.html) and the [scipy.signal.filtfilt](https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.filtfilt.html) command. Questions to [David Rotermund](mailto:davrot@uni-bremen.de) + +| | | +| ------------- |:-------------:| +| [scipy.signal.filtfilt](https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.filtfilt.html) | Apply a digital filter forward and backward to a signal. | +| [scipy.signal.butter](https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.butter.html) | Butterworth digital and analog filter design. | + +## Example data + +```python +import numpy as np +import matplotlib.pyplot as plt + +samples_per_second: int = 1000 +dt: float = 1.0 / samples_per_second + +# 10 secs +t: np.ndarray = np.arange(0, int(10 * samples_per_second)) * dt + +f_low = 1 # Hz +f_mid = 10 # Hz +f_high = 100 # Hz + +sin_low = np.sin(2 * np.pi * t * f_low) +sin_mid = np.sin(2 * np.pi * t * f_mid) +sin_high = np.sin(2 * np.pi * t * f_high) + +plt.figure(1) +plt.plot(t, sin_low) +plt.plot(t, sin_mid + 3) +plt.plot(t, sin_high + 6) +plt.xlabel("Time [s]") +plt.ylabel("Waveform shifted") +plt.title("unfiltered data") +plt.show() +```