Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOC: Specify cut-off frequency in firwin as half-ampltude vs half-power #20638

Open
gerazov opened this issue May 3, 2024 · 0 comments
Open
Labels
Documentation Issues related to the SciPy documentation. Also check https://github.com/scipy/scipy.org scipy.signal

Comments

@gerazov
Copy link

gerazov commented May 3, 2024

Issue with current documentation:

The documentation could be made more clear that when designing a filter with firwin the cutoff-frequency is half-amplitude, i.e. 20 * np.log10(abs(signal.freqz(b)) gives -6 dB at the cutoff rather than -3 dB.

For IIR desing via signal.iirdesign the cutoff is half-power, so -3 dB. This could also be explicitly stated.

Idea or request for content:

No response

Additional context (e.g. screenshots, GIFs)

import numpy as np
from matplotlib import pyplot as plt
from scipy import signal as sig

fs = 16000
b = sig.firwin(101, 2500, fs=fs)
f, h_fft = sig.freqz(b, fs=fs)
h_amp = 20 * np.log10(np.abs(h_fft))
plt.figure()
plt.plot(f, h_amp)
plt.grid()

b, a = sig.iirfilter(15, 2500, btype="low", fs=fs)
f, h_fft = sig.freqz(b, a, fs=fs)
h_amp = 20 * np.log10(np.abs(h_fft))
plt.plot(f, h_amp)
plt.axis([2100, 2900, -10, 2])
plt.legend(["FIR", "IIR"])
@gerazov gerazov added the Documentation Issues related to the SciPy documentation. Also check https://github.com/scipy/scipy.org label May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Issues related to the SciPy documentation. Also check https://github.com/scipy/scipy.org scipy.signal
Projects
None yet
Development

No branches or pull requests

2 participants