I have a signal that I have recorded from a AirSpyHF and want to remove a unwanted narrow signal with a notch filter (see figure).
The spike in the image below appears to be a center spike, however it is 5knhz above the center freq (Fc), and follows Fc around if I move Fc. Apparently this is normal behaviour for AirspyHF.
A PSD plot of the signal looks like:
Signal Details:
Fc : 160400000 Hz
Fsamp : 912000 Hz
F_unwanted : 160405343
from scipy.io import wavfile
from scipy import signal
import numpy as np
from matplotlib import pyplot as plt
samples = np.fromfile('../data/test_160400.fc32', dtype=np.complex64)
sample_rate = 912000
center_freq = 160400000
x = samples
fs = 768000.0
f0 = 500.0
Q = 10.0
b, a = signal.iirnotch(f0, Q, fs )
x = signal.lfilter(b, a, x)
# PLOT THE PSD
fft_freqs = np.linspace(sample_rate / -2, sample_rate / 2, 1024) + center_freq
plt.figure(figsize=(45,12))
psd = plt.psd(x, NFFT=1024, Fs=912000, Fc=160400000)
peaks = signal.find_peaks(psd[0], prominence=0.00000000001)
for peak, prominence in zip(peaks[0], peaks[1]["prominences"]):
peak_freq = ((peak/1024)*sample_rate) + (center_freq-(sample_rate/2))
plt.annotate(peak_freq, xy=( peak_freq , 10 * np.log10(prominence)))
plt.show()
The Scipy documentation on this iirnotch is not making sense when I try to come up with values for f0 and Q.
I unable to enter the actual frequency I want to remove 160405343. I note the documentation says *"Frequency to remove from a signal.
If fs is specified, this is in the same units as fs. By default, it is a normalized scalar that must satisfy 0 < w0 < 1, with w0 = 1 corresponding to half of the sampling frequency.
From this are the valid values for f0 (i.e. w0) between 0-912000/2 ?
And if so how do I remove a frequency which is higher than the sampling rate?
In summary what values should be plugged into this filter to remove the unwanted signal?