• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Dec 8th, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. a=np.random.normal(0,1,1024)
2.
3. f1=500
4. f2=1200
5. Fs = 8000
6. x = np.arange(1024)
7. b = 0.5*np.sin(2 * np.pi * f1 * x / Fs)+np.sin(2 * np.pi * f2 * x / Fs)
8.
9. c=b+0.1*a
10.
11. plt.figure(figsize=(15,4))
12. fax, Pxx =signal.periodogram(a)
13. Pxx[0]=0
14. plt.plot(fax,10*np.log10(abs(Pxx)))
17. plt.title('Periodogram Power Spectral Densinity Estimate',fontweight='bold')
18. r=[0.0,0.1,0.2,0.3,0.4,0.5]
19. plt.xticks(r,('0','0.2','0.4','0.6','0.8','1'))
20. plt.show()
21.
22. plt.figure(figsize=(15,4))
23. fax, Pxx =signal.periodogram(b)
24. Pxx[0]=0
25. plt.plot(fax,10*np.log10(abs(Pxx)))
28. plt.title('Periodogram Power Spectral Densinity Estimate',fontweight='bold')
29. r=[0.0,0.1,0.2,0.3,0.4,0.5]
30. plt.xticks(r,('0','0.2','0.4','0.6','0.8','1'))
31. plt.show()
32.
33. plt.figure(figsize=(15,4))
34. fax, Pxx =signal.periodogram(c)
35. Pxx[0]=0
36. plt.plot(fax,10*np.log10(abs(Pxx)))
39. plt.title('Periodogram Power Spectral Densinity Estimate',fontweight='bold')
40. r=[0.0,0.1,0.2,0.3,0.4,0.5]
41. plt.xticks(r,('0','0.2','0.4','0.6','0.8','1'))
42. plt.show()
43.
44. plt.figure(figsize=(15,4))
45. fax, Pxx =signal.periodogram(signal.hann(1024)*a)
46. Pxx[0]=0
47. plt.plot(fax,10*np.log10(abs(Pxx)))
50. plt.title('Periodogram Power Spectral Densinity Estimate',fontweight='bold')
51. r=[0.0,0.1,0.2,0.3,0.4,0.5]
52. plt.xticks(r,('0','0.2','0.4','0.6','0.8','1'))
53. plt.show()
54.
55. plt.figure(figsize=(15,4))
56. fax, Pxx =signal.periodogram(signal.hann(1024)*b)
57. Pxx[0]=0
58. plt.plot(fax,10*np.log10(abs(Pxx)))
61. plt.title('Periodogram Power Spectral Densinity Estimate',fontweight='bold')
62. r=[0.0,0.1,0.2,0.3,0.4,0.5]
63. plt.xticks(r,('0','0.2','0.4','0.6','0.8','1'))
64. plt.show()
65.
66. plt.figure(figsize=(15,4))
67. fax, Pxx =signal.periodogram(signal.hann(1024)*c)
68. Pxx[0]=0
69. plt.plot(fax,10*np.log10(abs(Pxx)))
72. plt.title('Periodogram Power Spectral Densinity Estimate',fontweight='bold')
73. r=[0.0,0.1,0.2,0.3,0.4,0.5]
74. plt.xticks(r,('0','0.2','0.4','0.6','0.8','1'))
75. plt.show()
76.
77. plt.figure(figsize=(9,7))
78. fax, Pxx =signal.welch(a*signal.hann(1024),8000,nfft=256,nperseg=128)
79. Pxx[0]=0
80. plt.plot(fax,10*np.log10(abs(Pxx)),label='NFFT=256')
81. fax, Pxx =signal.welch(a*signal.hann(1024),8000,nfft=128,nperseg=64)
82. Pxx[0]=0
83. plt.plot(fax,10*np.log10(abs(Pxx)),label='NFFT=128')
84. fax, Pxx =signal.welch(a*signal.hann(1024),8000,nfft=64,nperseg=32)
85. Pxx[0]=0
86. plt.plot(fax,10*np.log10(abs(Pxx)),label='NFFT=64')
87. plt.legend()
88. plt.ylabel('PSD (dB/Hz)')
89. plt.xlabel('Frequency (Hz)')
90. plt.title('Szum gaussowski - Periodogram Welscha',fontweight='bold')
91.
92. plt.figure(figsize=(9,7))
93. fax, Pxx =signal.welch(b*signal.hann(1024),8000,nfft=256,nperseg=128)
94. Pxx[0]=0
95. plt.plot(fax,10*np.log10(abs(Pxx)),label='NFFT=256')
96. fax, Pxx =signal.welch(b*signal.hann(1024),8000,nfft=128,nperseg=64)
97. Pxx[0]=0
98. plt.plot(fax,10*np.log10(abs(Pxx)),label='NFFT=128')
99. fax, Pxx =signal.welch(b*signal.hann(1024),8000,nfft=64,nperseg=32)
100. Pxx[0]=0
101. plt.plot(fax,10*np.log10(abs(Pxx)),label='NFFT=64')
102. plt.legend()
103. plt.ylabel('PSD (dB/Hz)')
104. plt.xlabel('Frequency (Hz)')
105. plt.title('Szum gaussowski - Periodogram Welscha',fontweight='bold')
106.
107.
108. plt.figure(figsize=(9,7))
109. fax, Pxx =signal.welch(c*signal.hann(1024),8000,nfft=256,nperseg=128)
110. Pxx[0]=0
111. plt.plot(fax,10*np.log10(abs(Pxx)),label='NFFT=256')
112. fax, Pxx =signal.welch(c*signal.hann(1024),8000,nfft=128,nperseg=64)
113. Pxx[0]=0
114. plt.plot(fax,10*np.log10(abs(Pxx)),label='NFFT=128')
115. fax, Pxx =signal.welch(c*signal.hann(1024),8000,nfft=64,nperseg=32)
116. Pxx[0]=0
117. plt.plot(fax,10*np.log10(abs(Pxx)),label='NFFT=64')
118. plt.legend()
119. plt.ylabel('PSD (dB/Hz)')
120. plt.xlabel('Frequency (Hz)')
121. plt.title('Szum gaussowski - Periodogram Welscha',fontweight='bold')
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top