def squareModulusFourier(data): """Compute square modulus Fourier coefficient of array data. """ # fft package from scipy.fftpack import fftn as fft_sc #from anfft import fftn as fft_an # compute fft data_fft = fft_sc(data) # abs(fft)^2 data_fftabs =data_fft * data_fft.conjugate() # return real part return np.real(data_fftabs)
def tfft_scipy(df): X=fft_sc(df['accel-x']) Y=fft_sc(df['accel-y']) Z=fft_sc(df['accel-z']) return pd.DataFrame({'x': [sum(abs(X)**2)/len(df)],'y': [sum(abs(Y)**2)/len(df)], 'z':[sum(abs(Z)**2)/len(df)]})
def bench_fft_scipy(data): """Test scipy fft""" fft_sc(data)