Reputation: 129
I am trying to compute and plot the DTFT of bartlett window in dB scale but strange peaks appear instead of the round ones. I first compute the DTFT transform of the window, I am also shifting the DTFT and freqs, I compute the abs of the DTFT and I normalize the values of the shifted DTFT but the strange shapes/peaks appear as seen in the image below. I know that the DTFT of bartlett window is smoother. Am I doing something wrong?
N = 100
lobeWidth = 1 / fo
# creating the barlett window
bartlett = windows.bartlett(N, sym = True)
plt.plot(bartlett)
plt.show()
bartlett_fft = np.fft.fft(bartlett)
bartlett_freq = freq(bartlett_fft.shape[-1])
db_psd = 10 * np.log10(np.abs(shift((bartlett_fft + 0.00000000000001) / abs(bartlett_fft).max())))
plt.plot(shift(bartlett_freq), db_psd)
plt.show()
Upvotes: 1
Views: 134
Reputation: 4138
nothing wrong, spectrum is smooth, the thing is with you are sampling this smooth spectrum sparsely, so it looks like it is sharp.
Provide more samples (zeros) to spectrum calculation at the end and you will have better spectrum resolution:
bartlett_fft = np.fft.fft(bartlett, n=1024)
Upvotes: 1