3

I'm currently facing a filter that amplifies frequencies at the Nyquist frequency. The sampling frequency is $f_s = 10$ Mhz.

What's a typical application for such a filter?

enter image description here

This is how I generated the plots:

import numpy as np
import matplotlib.pyplot as plt

def fir(x, taps): # Convolve signal with filter coefficients return np.convolve(x, taps, mode="same")

def filt(x): # FIR filter coefficients taps = [-0.0625, 0.125, -0.25, 0.5, -0.25, 0.125, -0.0625]

# Apply FIR filter 
return fir(x, taps)


def calc_fft(x, fs : float, N : int): # Perform FFT, truncate freqs above nyquist, and calc abs signal magnitude X = 2 * np.abs(np.fft.fft(x[:N], N))[0:N//2 + 1] / N

# Correct DC component
X[0] = X[0] / 2

# Calculate frequency steps
f = np.linspace(0, fs / 2, N // 2 + 1)

return f, X

def plot_amp_freq_response(t, x, f, X, title : str = ""): # Create figure fig = plt.figure(title) fig.clf()

# Create subplots
ax1 = fig.add_subplot(211)
ax2 = fig.add_subplot(212)

# Plot results in time domain
ax1.set_title(title)
ax1.plot(t, x, '.-')
ax1.set_xlabel("time [s]")
ax1.set_ylabel("Magnitude")
ax1.grid()

# Plot results in frequency domain
X_dB = 20*np.log10(X)
ax2.plot(f, X_dB, '-')
ax2.set_xlabel("freq [Hz]")
ax2.set_ylabel("Magnitude [dB]")
ax2.set_xscale('log')
ax2.grid()

plt.tight_layout()
plt.show()



###########################

Filter Impulse Response

###########################

def impulse_response(filter_func, title): # Sampling frequency fs = 10e6

# Sampling period
ts = 1 / fs

# Number of samples
N = 100

# Generate Impulse
x = np.zeros(N)
x[10] = 1

# Apply filter
y = filter_func(x)

# Response length
N = len(y)

# Generate sample points
t = np.linspace(0, ts * N, N)

# Calc FFT
f, Y = calc_fft(y, fs, N)

# Plot response
plot_amp_freq_response(t, y, f, Y, title)

return t, y, f, Y


Filter System Impulse Response

t, y, f, Y = impulse_response(filt, "Filter System Impulse Response")

filter_response = np.trim_zeros(y)

print("INFO: Filter System Response: " + str(filter_response))

The program plots the frequency response plot and the FIR filter coefficients:

INFO: Filter System Response: [-0.0625  0.125  -0.25    0.5    -0.25    0.125  -0.0625]
lennon310
  • 3,590
  • 19
  • 24
  • 27

2 Answers2

5

Such a filter is used to complete the frequency tiling of a strictly analytic (no negative frequencies) bandpass filterbank, as in CWT or (unusual) STFT. One will notice there's no way, with bell-shaped filters, to cover every frequency uniformly, but with such a filter.

enter image description here

It's readily seen, that unless one fitler peaks at Nyquist, then Nyquist can't be covered equally as other filters. However, merely having a peak at Nyquist isn't enough, as it lacks overlap from filters from the right, so it must amplify the input's Nyquist:

enter image description here

Still not uniform since we need more wavelets, but a slightly amplified Nyquist is necessary either way.

Uniform tiling enables one-integral inversion, which itself enables algorithms like synchrosqueezing.

If the question is what such a filter can do by itself - well, it preserves peak center frequency at Nyquist while remaining strictly analytic, which is a sort of windowed analysis of AM/FM behavior near Nyquist. Though I've never encountered this. Also note @MattL's answer, the specific filter in question isn't great.

OverLordGoldDragon
  • 8,912
  • 5
  • 23
  • 74
2

The answer below refers to the question in its original form which asked if a highpass filter with cut-off frequency at Nyquist makes any sense.


I'm not sure why you think that the filter's cut-off frequency equals Nyquist.

The amplitude response of the given filter at Nyquist is

$$H\left(e^{j\pi}\right)=\sum_{n=-N/2}^{N/2}(-1)^nh[n]=1.375$$

So it does pass (actually amplifies) input frequencies at Nyquist.

The magnitude response looks like this:

enter image description here

The filter is just a relatively bad high-pass filter. However, its coefficients are all powers of $\frac12$, so it could be implemented very efficiently.

Matt L.
  • 89,963
  • 9
  • 79
  • 179
  • Okay, you are right. The filter amplifies frequencies at Nyquist. So, what could be an application for such a filter? – Julian Sarcher Sep 04 '22 at 10:42
  • @JulianSarcher: I don't know, you know where you have those filter coeffs from. – Matt L. Sep 04 '22 at 10:49
  • The coeffs where given to me without context, that's why I am wondering about an application it could be used for. – Julian Sarcher Sep 04 '22 at 10:59
  • @JulianSarcher: Might just be an exercise without any specific application in mind. As a highpass filter it's close to useless. Implementation can be very efficient due to all coefficients being powers of $\frac12$. – Matt L. Sep 04 '22 at 11:07
  • Yes, I recognized the implementation-friendly coefficients as well. Thanks. – Julian Sarcher Sep 04 '22 at 11:12