2
$\begingroup$

Is there a difference between shifting a lowpass FIR filter to an arbitrary frequency offset versus creating an equivalent bandpass filter, such that the passband and cutoff frequencies are identical? What are the pros/cons of doing it one way vs the other?

from scipy import signal
from scipy.signal import firwin
import matplotlib.pyplot as plt
fs = 1
fc = .3     # center frequency
bw = 0.1    # filter bandwidth
N = 127     # filter length
bpf = firwin(N,[fc-bw,fc+bw],pass_zero=False,fs=fs)    # bandpass filter
lpf = firwin(N,bw,fs=fs)                               # lowpass filter
t = np.arange(lpf.size)
lpf_shifted = lpf*np.exp(1j*2*np.pi*fc*t)              # shift LPF to fc

# plot
fig = plt.figure()
plt.title('Digital filter frequency response')
ax1 = fig.add_subplot(111)
w, h = signal.freqz(bpf,fs=fs)
w2, h2 = signal.freqz(lpf_shifted,fs=fs)
plt.plot(w, 10*np.log10(abs(h)), 'b',label="BPF",marker='.',markersize=4)
plt.plot(w2, 10*np.log10(abs(h2)), 'g',label="Shifted LPF")
plt.ylabel('Amplitude [dB]', color='b')
plt.xlabel('Frequency [rad/sample]')
plt.legend()
plt.show()

Frequency response of filters

$\endgroup$
3
  • $\begingroup$ seems like you have suggested an approximation to the optimal method. see a related question dsp.stackexchange.com/a/71807/34391 $\endgroup$ Commented Jun 22, 2023 at 19:27
  • $\begingroup$ One obvious difference here is that the bandpass is real and the shifted lowpass is complex. In other words: the two filters have similar responses at positive frequencies but very different ones for negative ones. I suggest plotting with a frequency axis from -0.5 to + 0.5 $\endgroup$
    – Hilmar
    Commented Jun 22, 2023 at 20:22
  • $\begingroup$ I can drop the imaginary part and get the resultant filter $\endgroup$ Commented Jun 22, 2023 at 20:52

1 Answer 1

3
$\begingroup$

If you need several bandpass filters with the same bandwidth, it's advantageous to derive them all from the same prototype lowpass filter (e.g., modulated filter banks). You only need to store one set of filter coefficients and you can compute the coefficients of the bandpass filters by modulation.

Concerning filter performance, an optimized bandpass filter should theoretically be (slightly) better than a corresponding modulated lowpass filter. Note that a modulated lowpass filter can only be used if the bandpass specifications are symmetrical with respect to the center frequency because the (real-valued) lowpass prototype has a magnitude response that is symmetrical about DC.

Let's take a look at the two most used optimality criteria for filter design: least squares and Chebyshev (minimax, equiripple, ...). For the equiripple design we use the Parks-McClellan algorithm. Assuming that we want the same minimum attenuation in both stopbands of the bandpass filter, we can use a modulated equiripple lowpass filter. However, since the magnitude of the resulting bandpass filter is given by

$$\big|H_{BP}(f)\big|=\big|H_{LP}(f-f_c)+H_{LP}(f+f_c)\big|$$

where $f_c$ is the center frequency of the bandpass filter, the resulting worst case stopband attenuation can be $6$dB less than for an optimized bandpass filter (see figure below). In the passband we usually won't notice much difference if the stopband attenuation is sufficiently large (because it is the shifted stopband response that is added to the passband response).

The situation is different for the least squares criterion. Here, the symmetry constraint can make quite a large difference, depending on the specification. The figure below shows that the optimized bandpass filter has a large stopband attenuation close to DC. The modulated lowpass filter must be symmetrical about $f_c$ and hence it can't show that behavior around DC.

However, note that the differences between optimal and modulated bandpass filters depend on the exact specifications, and in practice the slightly superior performance of the optimized filter may not be worth the extra implementation effort if several similar bandpass filters are required.

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.