频率域中的振幅与python中FFT后不匹配时域信号。解释?

发布于 2025-02-06 13:37:29 字数 929 浏览 3 评论 0原文

我正在尝试在Python中创建功率频谱密度函数,该功能输出幅度频谱密度和累积功率频谱密度图。我正在使用scipy.fft来计算输出数据的FFT。然后进行计算PSD的操作。可以在下面看到代码。

df = nyquistFreq/(N/2-1) #frequency increment
spacing = 1
freq = df*(np.linspace(start = 0, stop = (N/2+1)*spacing, num = int((N/2)*spacing),  endpoint= True)) #creatiing frequency vector
fftData = fft(output.values) #taking the fft of the data
Pxx = (2*(pow(abs(fftData[1:int((N/2+1))]/N), 2)/df))

然后,我以正弦信号的振幅为68,

N = 10000
sampleTime = 0.0001
timE = np.linspace(0, N*sampleTime, N, endpoint = False)
amp = 68*np.sin(2*np.pi*21*timE) 

在图上的频率为21个值,但是峰值的振幅为48.08326112068523,而不是68。这是1/sqrt的降低( 2)无论我使用什么振幅,这一直是不变的。有什么办法可以解决此幅度降低,以便频域中的幅度是时域的振幅?可能与Python执行FFT,光谱缩放/密度的方式有关。

enter image description here

I am trying to create a Power spectral density function in python that outputs the amplitude spectral density and cumulative power spectral density graphs. I am using scipy.fft to compute the FFT of my output data. Then an operation to compute the PSD. The code can be seen below for this.

df = nyquistFreq/(N/2-1) #frequency increment
spacing = 1
freq = df*(np.linspace(start = 0, stop = (N/2+1)*spacing, num = int((N/2)*spacing),  endpoint= True)) #creatiing frequency vector
fftData = fft(output.values) #taking the fft of the data
Pxx = (2*(pow(abs(fftData[1:int((N/2+1))]/N), 2)/df))

I am then running this function with a sine signal with an amplitude of 68 and a frequency of 21

N = 10000
sampleTime = 0.0001
timE = np.linspace(0, N*sampleTime, N, endpoint = False)
amp = 68*np.sin(2*np.pi*21*timE) 

Values on plot are hard to see, but the peak frequency has an amplitude of 48.08326112068523, not 68. This is a reduction of 1/sqrt(2) that has been constant no matter what amplitude I've used. Is there a way I can get around this amplitude reduction, so that the amplitude in the frequency domain is that of the time domain? Possibly might have something to do with the way python performs FFT, spectral scaling/density.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文