[SciPy-User] scipy.signal.periodogram problem
mr_lin
lzh at mwlab.pmo.ac.cn
Thu Nov 7 01:22:17 EST 2013
when using periodogram() to calculate sine wave spectrum with hanning
window, I find a problem, the following is data processing :
case one: 1) sine-wave is modulated with hanning window first, 2) then
periodogram function is used to estimate sine-wave amplitude
spectrum(parameter window=None);3) a factor U=1/N*sum(win[i]**2) is
corrected in spectrum.
case two: 1) periodogram is directly used to calculate sine-wave(window is
set hanning window); 2) then amplitude spectrum is calculated.
the result in case two/the one in case on = 1.2247822....
WHY two results is not equal in these two case?
post my code:
fs = 10e3
N = 16384
f0 = 2345
time = np.arange(N)/fs
sig = 5.* np.sin(2*np.pi*f0*time)
h_win = han_win(N)
U = 0.
for i in range(N):
U += h_win[i]**2
U /= N
sig_win = (sig-np.mean(sig))* h_win
freq1,Pxx_spec_w1 =
sp_sig.periodogram(sig,fs,h_win,return_onesided=True,scaling='spectrum')
freq2,Pxx_spec_w2 =
sp_sig.periodogram(sig_win,fs,window=None,return_onesided=True,scaling='spectrum')
sig_amp_w1 = np.sqrt(Pxx_spec_w1)
sig_amp_w2 = np.sqrt(Pxx_spec_w2/U)
print 'E{sig_amp_w1/sig_amp_w2}=',np.mean(sig_amp_w1[1:]/sig_amp_w2[1:])
--
View this message in context: http://scipy-user.10969.n7.nabble.com/scipy-signal-periodogram-problem-tp18844.html
Sent from the Scipy-User mailing list archive at Nabble.com.
More information about the SciPy-User
mailing list