简体   繁体   中英

FFT Determining ultra low frequency processes using Python Numpy/Scipy

I am starting an analysis of low frequency datas(energy monitoring) I got from csv file.
I retrieve the datas (approximatly 12000 points but could be more) and I know that there is a data every minute.
This sampling rate is always the same.

When I plot the datas, it seemes like a recurring process (dayly, weekly and monthly). So I imagine that I should see ultra low frequency when I plot the FFT.

Here is my code sor far. I don't show you the part where i retreive the datas since it's not revelant.
I also added a lowpass filter to get a sinus like function.

## DATAS x-axis is x
## DATAS y-axis is y
# Number of Points ie 12000 points
N = len(y)
# 1 Sample per minute
T = 1 / 60.0
# Lowpass cutoff frequency 
cutoff = 0.0001 

x = np.linspace(0, T * N , N) 
B, A = butter(4, cutoff / (T / 2), btype='low') 
filterdY = lfilter(B, A, y, axis=0)

# Generating FFT
Fourier = abs(scipy.fft(filterdY));
freqs = scipy.fftpack.fftfreq(filterdY.size, x[1]-x[0])

pylab.subplot(311)
pylab.plot(x, y)
pylab.subplot(312)
pylab.plot(x, filterdY)
pylab.subplot(313)
pylab.plot(freqs,20*scipy.log10(Fourier),'x')
pylab.show()

The here is a screen-shot of the graphs I plot.
It shows a week of energy consumption and as you can see, 5 days are well defined (bigger values) 屏幕截图

I can't analyse the graph properly but if I add a second pure sine wave signal to y values and I don't filter the sum, I can retrieve the sine frequency from the FFT.
As a frequency of a daily process should be 1.0E-5 Hz, it is difficult to read the FFT.

How can i get this frequency ? Should I consider speeding up the original datas by 1.0E5 and then get a pic at 1Hz ?

Here is a pythonfiddle with the array of data stored into y variable : http://pythonfiddle.com/fft-test

Well, I would play with sampling frequency. If you want to make some conclusions, suppose, on the scale of days why not set such sampling frequency that 1 Hz in resulting FFT would correspond to 1 oscillation per day rather than 1 oscillation per second? Following steps depend on your data.

PS I am not sure, because I can't see the whole script, but when you call butter and use cutoff / (T / 2) as an argument should't it be in Hz units? Because now it seems to be just a number:

T = [1/s]; cutoff = [Hz] = [1/s]; => cutoff/(T/2) = [1/s]/[1/s] = 1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM