0
$\begingroup$

I have a time series sensor data. It is for a period of 24 hours sampled every minute (so in total 1440 data points per day). I did a fft on this to see what are the dominant frequencies. But what I got is a very noisy fft and a strong peak at zero. 1. I have already subtracted the mean to remove for the DC component at bin 0. But I still get a strong peak at zero. I'm not able to figure what could be the other reason or what should I try next to remove this. 2. The graph is very different from I have usually seen online as I was learning about fft. In the sense, I'm not able to see dominant peaks like how it is usually seen. Is my fft wrong? Attaching code that i tried and images:

import numpy as np
from matplotlib import pyplot as plt
from scipy.fftpack import fft,fftfreq
x=np.linspace(29,32,1440).tolist()
x=np.array(x)
x=x-x.mean()
N = 1440
# sample spacing
T = 1.0 / 60
yf = fft(x)
yf_abs = abs(yf).tolist()
plt.plot(abs(yf))
plt.show()
freqs = fftfreq(len(x), 60)
plt.plot(freqs,yf_abs)
plt.show()

Amplitude vs Freq - FFT curve

Since I'm new to this, I'm not able to figure out where I'm wrong or interpret the results. Any help will be appreciated. Thanks! :)

$\endgroup$
  • $\begingroup$ I (probably we) cannot tell without looking at the data. When you remove the mean, the value at DC or zero should be zero (and seems to be from the graph). The magnitude spectrum does not look noisy either. $\endgroup$ – Laurent Duval Jun 13 '20 at 16:14
  • $\begingroup$ If Dan Bochen's answer is correct (bin 0 has zero value) then this question as written has been answered. I think the larger question you need to ask -- separately -- is "why does my data have unexpectedly high low frequency content?". Show us what you've done, your FFT result, and the input data. Frankly, I'm suspecting that there's a trend in your data, or some daily variation. $\endgroup$ – TimWescott Nov 10 '20 at 21:20
1
$\begingroup$

You must be assuming you have a dominant peak at zero from only looking at the same graph you shared, but if you really did remove the mean, then value at bin 0 will be 0 (as bin 0 is directly proportional to the mean). Inspect the data carefully as their does not appear to be anything wrong with the code with respect to the FFT.

What is likely occurring is the bins close to bin 0 are non-zero, and these represent the lowest frequency fluctuations in your data. Each of these is zero-mean, but represent the slowest changing frequency components. In this case you are getting the exact results expected, representing what is in your actual data.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.