[英]power spectral density-scipy.signal
While trying to compute the Power spectral density with an acquisition rate of 300000hz using ... signal.periodogram(x, fs,nfft=4096) , I get the graph upto 150000Hz and not upto 300000. Why is this upto half the value ? 尝试使用... signal.periodogram(x,fs,nfft = 4096)以300000hz的采集速率计算功率谱密度时,我得到的图形最高为150000Hz而不是最高为300000。为什么这是最高值的一半? What is the meaning of sampling rate here?
这里的采样率是什么意思?
In the example given in scipy documentation , the sampling rate is 10000Hz but we see in the plot only upto 5000Hz. 在scipy文档中给出的示例中,采样率是10000Hz,但是在图中只能看到高达5000Hz的频率。
https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.signal.periodogram.html https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.signal.periodogram.html
If you check the length of f
in the example: 如果在示例中检查
f
的长度:
>>> len(f)
>>> 50001
This is NOT 50000 Hz. 这不是50000 Hz。 This is because
scipy.signal.periodogram
calls scipy.signal.welch
with the parameter nperseg=x.shape[-1]
by default. 这是因为
scipy.signal.periodogram
默认情况下使用参数nperseg=x.shape[-1]
调用scipy.signal.welch
。 This is the correct input for scipy.signal.welch
. 这是
scipy.signal.welch
的正确输入。 However, if dig into source and see lines 328-329 (as of now), you'll see the reason why the size of output is 50001. 但是,如果深入研究源代码并看到第328-329行(截至目前),您将看到输出大小为50001的原因。
if nfft % 2 == 0: # even
outshape[-1] = nfft // 2 + 1
The spectrum of real-valued signal is always symmetric with respect to the Nyquist frequency (half of the sampling rate). 实值信号的频谱始终相对于奈奎斯特频率 (采样率的一半)对称。 As a result, there is often no need to store or plot the redundant symmetric portion of the spectrum.
结果,通常不需要存储或绘制频谱的冗余对称部分。
If you still want to see the whole spectrum, you can set the return_onesided
argument to True
as follows: 如果仍想查看整个频谱,可以将
return_onesided
参数设置为True
,如下所示:
f, Pxx_den = signal.periodogram(x, fs, return_onesided=False)
The resulting plot of the same example provided in scipy.periodogram
documentation would then cover a 10000Hz frequency range as would be expected: scipy.periodogram
文档中提供的相同示例的结果图将覆盖预期的scipy.periodogram
频率范围:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.