Frequency is wrong in numpy fft

time = np.array(range(100))/100
wave = np.sin(2 * np.pi * 10 * time) + np.sin(2* np.pi* 70 * time)

fft_wave = np.fft.fft(np.fft.fftshift(wave))
psd = (fft_wave * np.conj(fft_wave))/len(wave)
freq = 1/(0.01 * len(wave)) * np.arange(len(wave))
l = np.arange(0, np.floor(len(freq)/2), dtype = "int")

plt.figure(figsize = (20,4))
plt.plot(time, wave)
plt.plot(freq[l], psd[l])

This is the code i have written. I have applied FFt and the power spectral against the frequencies the peaks are coming at the write time till when the second frequency is 40 but when it is more than 40 the the frequency is being shown at some other number. attaching the graph.

enter image description here

Can someone help me with this?

One more thing is how to reconstruct the wave manually from fft result. Applying ifft is helping me. But i want to extend the ifft to few more time periods. The only way i can think of is to manually make the sinusoidal waves using the frequency we obtain above but it isn’t helping me in getting the wave that we get from ifft. Thanks in advance

Read more here: Source link