############################## Convert all signal to FFT spectrum############################ Function fot FFT of samples from scipy.fft import fft, fftfreq  # This fft perfectly matches with matlab fft, I checkeddef  FFT(data, N=800, Fs=40):    # N is Number of sample points, Fs is sampling rate in kHz; to show full Hz, set Fs as full    # sample spacing    T = 1.0 / Fs    yf = fft(data)    xf = fftfreq(N, T)[:N//2]    yf1=2.0/N * np.abs(yf[0:N//2])  # extract the one sided values    return (yf1)
# Import or select the sample needs to convert to FFT dt=train_40   # Data source
## Do the FFT in for loopfor i in range(1,(dt.shape[0])):    dtf=FFT(dt[i])    dft0=np.vstack((dft0, dtf))print(dft0.shape)# Save datanp.save("4class_db/fft_40k/dtf_tr_1c_40kHz.npy", dft0)