Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def logarytm(x):
- for i in range(0, x.size):
- if x[i] != 0:
- x[i] = log(x[i])
- return x
- T = 1
- Fs = 10000
- t = arange(0,T,1/Fs)
- #Tworzymy wykresy
- fig,ax = subplots(10, 4, figsize=(20,50))
- #Generujemy sygnał
- y = sin(2*pi*999.5*t)
- ax[0,0].plot(t,y)
- ax[0,0].set_title('Oryginalny sygnał')
- ax[0,0].set_xlim(0,0.01)
- #Obliczamy jego FFT
- Y = fft.fft(y)
- f = linspace(0,Fs,Y.size)
- ax[0,2].plot(f,abs(Y))
- ax[0,2].set_title('FFT sygnału')
- ax[0,2].set_xlim(990,1010)
- ax[0,3].plot(f,logarytm(abs(Y)))
- ########################## BARTLETT ##########################
- h = bartlett(y.size)
- ax[1,0].plot(t,h)
- ax[1,0].set_title('Bartlett')
- ny = h * y
- Y = fft.fft(ny)
- f = linspace(0,Fs,Y.size)
- H = fft.fft(h)
- ax[1,1].plot(f, logarytm(abs(H)))
- ax[1,1].set_title('FFT Bartlett')
- ax[1,2].plot(f,abs(Y))
- ax[1,2].set_xlim(990,1010)
- ax[1,3].plot(f,logarytm(abs(Y)))
- ########################## BLACKMAN ##########################
- h = blackman(y.size)
- ax[2,0].plot(t,h)
- ax[2,0].set_title('Blackman')
- ny = h * y
- Y = fft.fft(ny)
- f = linspace(0,Fs,Y.size)
- H = fft.fft(h)
- ax[2,1].plot(f, logarytm(abs(H)))
- ax[2,1].set_title('FFT Blackman')
- ax[2,2].plot(f,abs(Y))
- ax[2,2].set_xlim(990,1010)
- ax[2,3].plot(f,logarytm(abs(Y)))
- ########################## HAMMING ##########################
- h = hamming(y.size)
- ax[3,0].plot(t,h)
- ax[3,0].set_title('Hamming')
- ny = h * y
- Y = fft.fft(ny)
- f = linspace(0,Fs,Y.size)
- H = fft.fft(h)
- ax[3,1].plot(f, logarytm(abs(H)))
- ax[3,1].set_title('FFT Hamming')
- ax[3,2].plot(f,abs(Y))
- ax[3,2].set_xlim(990,1010)
- ax[3,3].plot(f,logarytm(abs(Y)))
- ########################## HANNING ##########################
- h = hanning(y.size)
- ax[4,0].plot(t,h)
- ax[4,0].set_title('Hanning')
- ny = h * y
- Y = fft.fft(ny)
- f = linspace(0,Fs,Y.size)
- H = fft.fft(h)
- ax[4,1].plot(f, logarytm(abs(H)))
- ax[4,1].set_title('FFT Hanning')
- ax[4,2].plot(f,abs(Y))
- ax[4,2].set_xlim(990,1010)
- ax[4,3].plot(f,logarytm(abs(Y)))
- ########################## KAISER ##########################
- ks = [0, 5, 6, 8.6, 14]
- for i in range(0, 5):
- h = kaiser(y.size, ks[i])
- ax[5 + i, 0].plot(t,h)
- ax[5 + i, 0].set_title('Kaiser %.1f' % (ks[i]))
- ny = h * y
- Y = fft.fft(ny)
- f = linspace(0,Fs,Y.size)
- H = fft.fft(h)
- ax[5 + i, 1].plot(f, logarytm(abs(H)))
- ax[5 + i, 1].set_title('FFT Kaiser %.1f' % (ks[i]))
- ax[5 + i, 2].plot(f,abs(Y))
- ax[5 + i, 2].set_xlim(990,1010)
- ax[5 + i, 3].plot(f,logarytm(abs(Y)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement