Created
September 24, 2021 20:39
-
-
Save kwinkunks/ac5a06619401ec96b222a7592a95a406 to your computer and use it in GitHub Desktop.
A minimum phase wavelet
This file contains 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
from scipy.signal import remez, minimum_phase | |
import matplotlib.pyplot as plt | |
# Based on this example from the scipy docs: | |
# https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.minimum_phase.html | |
freq = [0, 0.2, 0.3, 1.0] | |
desired = [1, 0] | |
h_linear = remez(151, freq, desired, Hz=2.0) | |
h_min_hil = minimum_phase(h_linear, method='hilbert') | |
fig, axs = plt.subplots(ncols=2, figsize=(12, 4), facecolor='w', sharey=True) | |
axs[0].plot(h_linear) | |
axs[0].set(xlim=[0, len(h_linear) - 1], ylabel='Amplitude', xlabel='Samples') | |
axs[0].axhline(0, c='k', alpha=0.25, lw=1.25) | |
axs[0].grid(c='k', alpha=0.15) | |
axs[0].set_title('Zero phase') | |
axs[1].plot(h_min_hil, c='C1') | |
axs[1].set(xlim=[0, len(h_linear) - 1], xlabel='Samples') | |
axs[1].axhline(0, c='k', alpha=0.25, lw=1.25) | |
axs[1].grid(c='k', alpha=0.15) | |
axs[1].set_title('Minimum phase') | |
plt.tight_layout() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment