def fft_test2(self):
axis = str(self.axis_combobox.currentText())
if axis.startswith('a'):
normal_para = 16384.0
elif axis.startswith('g'):
normal_para = 131.0
signal =( self.raw_data[axis] - self.bias_dict[axis])/ normal_para
n = signal.size # Number of data points
dx = 0.007 # Sampling period (in meters)
Fk = np.fft.fft(signal) # Fourier coefficients (divided by n)
nu = np.fft.fftfreq(n,dx) # Natural frequencies
#Fk = np.fft.fftshift(Fk) # Shift zero freq to center
#nu = np.fft.fftshift(nu) # Shift zero freq to center
f, ax = plt.subplots(3,1,sharex=True)
ax[0].plot(nu, np.real(Fk)) # Plot Cosine terms
ax[0].set_ylabel(r'$Re[F_k]$', size = 'x-large')
ax[1].plot(nu, np.imag(Fk)) # Plot Sine terms
ax[1].set_ylabel(r'$Im[F_k]$', size = 'x-large')
ax[2].plot(nu, np.absolute(Fk)**2) # Plot spectral power
ax[2].set_ylabel(r'$\vert F_k \vert ^2$', size = 'x-large')
ax[2].set_xlabel(r'$\widetilde{\nu}$', size = 'x-large')
plt.title(axis)
plt.show()
ShowTrace.py 文件源码
python
阅读 32
收藏 0
点赞 0
评论 0
评论列表
文章目录