I am currently working on a project where I record the accelerator's magnitude of a mobile phone doing a periodic movement, which is very visible when I visualise it in python and smooth it. However; I am trying to programmatically get the frequency of the signal (mag), and so far all my tries have failed. The data is stored in a csv, which includes several columns, but I extract the magnitude column, smooth it with a lowpass filter, and then finally try to use the numpy's fft function on my filtered magnitude array, but it doesn't give me the expected result.
Here's an image of my visualised magnitude after smoothing:
As you can see, it's quite periodic and you can tell by just looking at it, but I have no idea why FFT fails to catch that.
I have tried FFT from both numpy package as well as scipy, both give me the same results.
data = genfromtxt("data.csv", dtype=float, delimiter=',', names=True)
y = data['mag']
w = np.fft.fft(y)
freq = np.fft.fftfreq(len(w))
The output I'm getting from freq
an array where the 'highest'frequency is 0, which I don't understand. If it's relevant, I know the sampling rate at which I record the data from the device is 20 milliseconds, and I have already tried FFT with both the raw data as well as the smoothed, and still no luck.