简体   繁体   English

np.fft.fft到底返回什么?

[英]What exactly does np.fft.fft return?

I'm confused about understanding FFT's and how to apply them in python. 我对理解FFT以及如何在python中应用它们感到困惑。 From my understanding applying an fft to a 10-pixel 1D array should contain a list of 10 numbers (+2 for the "DC" component): (A_0, P_0, A_1, P_1, A_2, P_2, A_3, P_3, A_4, P_4, A_5, P_5) 根据我的理解,将fft应用于10像素的1D数组应包含10个数字的列表(“ DC”分量为+2):( (A_0, P_0, A_1, P_1, A_2, P_2, A_3, P_3, A_4, P_4, A_5, P_5)

A_0 = Amplitude of the average value, "DC" \lambda = \infty component
P_0 = Flat wave, so phase doesn't say anything meaningful
A_1 = Amplitude of the fundamental, \lambda = 1a
P_1 = Phase of the fundamental frequency component
A_2 = Amplitude of the first harmonic \lambda = 2a
P_2 = Phase of the first harmonic frequency component
A_3 = Amplitude of the second harmonic \lambda = 3a
P_3 = Phase of the second harmonic frequency component
A_4 = Amplitude of the third harmonic \lambda = 4a
P_4 = Phase of the third harmonic frequency component
A_5 = Amplitude of the Nyquist frequency
P_5 = Phase of the Nyquist

where a is the period. 其中a是周期。 The Nyquist frequency is the highest frequency component that is present in the 1D array. 奈奎斯特频率是一维阵列中存在的最高频率分量。 The array below is of length 10 therefore 10 pixels. 下面的数组的长度为10,因此为10个像素。 The fastest frequency possible is one in which the max value is in pixel i and the min value is in pixel i+1 . 最快的频率是最大值在像素i而最小值在像素i+1频率。 In other words the Nyquist frequency ( f_{Nyq} = pixel_{total}/2 ) for 10 pixels is 5. 换句话说,10个像素的奈奎斯特频率( f_{Nyq} = pixel_{total}/2 )是5。

Looking at the code below, when I use np.fft.fft(array) I get 10 numbers. 看下面的代码,当我使用np.fft.fft(array)我得到10个数字。 What are these 10 numbers? 这10个数字是什么?

one_d_pixel_vals =  np.array([0.3, 0.4, 1.3, 3.4, 4.5, 4.2, 2.8, 2.4, 1.4, 0.1])
print(one_d_pixel_vals)

plt.plot(one_d_pixel_vals)
plt.yticks(np.arange(5))
plt.xticks(np.arange(9))
plt.grid(True)
plt.show()

one_d_fft = np.fft.fft(one_d_pixel_vals, norm='ortho')
print(one_d_fft)
print(len(one_d_fft))

>>> [ 6.57753753 +0.00000000e+00j -3.27588825 -6.42423464e-01j
0.01065311 +6.25512087e-01j  0.22429031 -4.34214340e-01j
0.25814049 -7.06019011e-02j -0.06324555 -1.12346671e-15j
0.25814049 +7.06019011e-02j  0.22429031 +4.34214340e-01j
0.01065311 -6.25512087e-01j -3.27588825 +6.42423464e-01j]
10

No, your interpretation is erroneous. 不,您的解释是错误的。

  • a[0] is the mean. a[0]是平均值。
  • a[1] = np.conjugate(a[-1]) : represent the fundamental a[1]*exp(jwt)+a[-1]*exp(-jwt). a[1] = np.conjugate(a[-1]) :表示基本a [1] * exp(jwt)+ a [-1] * exp(-jwt)。
  • a[k],a[-k] represent the k-th harmonic. a[k],a[-k]表示第k-th谐波。

so the Fourier representation is sum(a[k] exp (kwt)) , k = -n//2 .. n//2 . 因此傅里叶表示为sum(a[k] exp (kwt)) , k = -n//2 .. n//2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM