6
\$\begingroup\$

I have current values and respective time.

enter image description here

There is noise in the signal. But when I am calculating FFT, it is not showing

enter image description here

I have recorded the values at every 5ms.

below is my code:

time = data['Time'].values
current = data['Current'].values

# 2. FFT Computation
fs = 200  # 5ms sampling interval means a 50 Hz sampling rate
current_fft = np.fft.fft(current)
frequencies = np.fft.fftfreq(len(current), 1/fs)

Can someone help me to find the noise?

I am a newbie and please spare me if I am wrong somewhere

\$\endgroup\$
2
  • 5
    \$\begingroup\$ I'm always annoyed that none of these signal processing packages have a built in convenience method mean_subtracted_fft(X) that does fft(X-mean(X)). \$\endgroup\$ Commented Aug 11, 2023 at 14:33
  • \$\begingroup\$ If you zero the first output from the FFT with something like current_fft[0]=min(current_fft), then you will be able to see that your "flat" transformed signal is not that flat. \$\endgroup\$ Commented Aug 13, 2023 at 18:53

2 Answers 2

17
\$\begingroup\$

it is not showing

That's because you're not using logarithmic scale for the magnitude.

Even without DC removal, a dB-scaled plot of the fft magnitude will show the noise all right.

In most cases, linear-scaled spectrum plots are useless, since a linearly scaled graph has a mediocre dynamic range.

Suppose you got a 300 DPI printer, and the graph is 7in high - say printed in landscape on letter-sized paper. Suppose that the graph line thickness is 1 pixel, or 1/300th of an inch.

The dynamic range of such a linearly scaled plot is $$ \frac{\frac{1}{300}{\,\rm in}}{7 {\,\rm in}}=5\cdot10^{-4}\approx66{\,\rm dB}. $$

That is not very much to say the least, and you only can really use this range if you get a printout or are viewing the graph on a 300DPI screen - for example, on a "retina" screen of a tablet. And even then, you need to have corrected vision better than 20/20 to actually see the individual pixels and take advantage of this range. In practice, the dynamic range of a single-pixel-wide line plot on a 7" high on a retina tablet screen is around 60 dB.

That thick line plot you have shown has the line about 2 pixels high, and the vertical range is about 220 pixels. That is a measly 40dB of dynamic range - less than 7 bits of resolution!

\$\endgroup\$
14
\$\begingroup\$

Your signal's measurements are centered around 21.5 or so, and as a result your signal has a large DC offset. In current_fft, the AC components are still there, just very small compared to your large spike at/near DC. They should be visible if you plotted your current chart, with the data kept as-is, with the Y axis in logarithmic scale.

If you want to remove the observed DC component from your data, subtract the mean of the data from all of the observations in current before taking the Fourier transform. Due to the mathematical properties of FT, this should be the same as zeroing out the bin corresponding to the DC component in current_fft and leaving all other bins unchanged.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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