简体   繁体   English

使用Python Numpy / Scipy进行FFT确定超低频过程

[英]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. 我正在开始分析从csv文件获得的低频数据(能量监测)。
I retrieve the datas (approximatly 12000 points but could be more) and I know that there is a data every minute. 我检索了数据(大约12000点,但可能会更多),并且我知道每分钟都有一个数据。
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. 所以我想我在绘制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) 它显示了一周的能源消耗,并且您可以看到,定义了5天(更大的值) 屏幕截图

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. 我无法正确分析该图,但如果将第二个纯正弦波信号添加到y值,并且不对总和进行滤波,则可以从FFT中检索正弦频率。
As a frequency of a daily process should be 1.0E-5 Hz, it is difficult to read the FFT. 由于日常处理的频率应为1.0E-5 Hz,因此很难读取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 ? 我是否应该考虑将原始数据加速1.0E5,然后以1Hz的频率获取图片?

Here is a pythonfiddle with the array of data stored into y variable : http://pythonfiddle.com/fft-test 这是一个将数据数组存储到y变量中的pythonfiddle: 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? 如果您想得出一些结论,那么,以天为单位,为什么不设置采样频率,以使FFT中的1 Hz对应于每天1次振荡而不是每秒1次振荡? 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? PS我不确定,因为我看不到整个脚本,但是当您调用butter并使用cutoff /(T / 2)作为参数时,它是否应该以Hz为单位? Because now it seems to be just a number: 因为现在似乎只是一个数字:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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