快速傅立叶变换python
我想了解适当的方法来计算Python上的FFT的适当方法,以获得真实的非周期信号。我对编码和信号分析是相对较新的,因此该帖子将包含与两个领域的亲戚有关的问题。
要提供一些上下文,这是我的信号(时域)的图形表示:
,这是我正在工作的数据:
t_norm acc_norm
1 0.000000 0.000000
2 0.031918 2.336610
3 0.063340 1.817758
4 0.095058 0.544868
5 0.126293 -0.953833
6 0.157302 0.217959
7 0.188844 -1.331151
8 0.219892 -1.548037
9 0.251234 2.288458
10 0.282859 2.837413
11 0.314361 1.835081
12 0.345838 1.659622
13 0.376913 1.309823
14 0.408362 1.035765
15 0.439503 0.771576
16 0.470980 1.235591
17 0.502364 2.456847
18 0.533518 1.668552
19 0.564633 1.076637
20 0.595747 1.377580
21 0.626756 0.673881
22 0.658192 0.529822
23 0.689240 0.483709
24 0.720207 1.354278
25 0.751281 2.072109
26 0.782463 1.027122
27 0.813699 0.333459
28 0.844841 0.406036
29 0.875902 0.401840
30 0.906883 0.044780
31 0.937957 0.557944
32 0.968992 1.962894
33 1.000000 1.446186
请注意,用于记录信号的设备使用可变速率采样使用交叉检测以捕获数据点。它将其限制为每秒50点(50Hz)。我已经制作了一个直方图,以显示所有数据测量之间的时间间隔的分布:
“ https://i.sstatic.net/sa8tj.png” alt =“在此处输入图像描述”>
方法论问题:
关于我的信号的整体形状(图1)在进行FFT之前,请逐渐降低它(我只对高频感兴趣)?
如果采样率不统一,FFT是否一定需要重新采样数据,即使测量之间的时间间隔的分布并不是真正分布(图2)?
技术问题(Python):
我在Internet上看到的有关如何计算FFT的所有示例都从合成信号(直接在Python中制成)。我试图重现所使用的方法,并将其调整以适合从“现实世界”数据中得出的信号。第一步似乎是计算信号的某些特征,然后计算FFT。
信号特性
spl_nbr =#信号样本数
d_fs =#采样频率,赫兹
i_ns =(2*d_fs)
d_time = np.linspace(0,(I_NS-1),i_ns)/d_fs#时间序列,秒
d_f_sig =#signal freqeuncy,hertz
d_sig =#信号本身
计算FFT
cx_y = rfft(d_sig)/float(i_ns/2。)
d_ws = rfftfreq(i_ns,1。/d_fs)
d_ws = 来自我的数据。我知道我可以使用.count()
函数来计算信号的样本数量,但这几乎是我现在所能做的。我特别想知道如何将信号信息(D_SIG)传递给Python。
预先感谢您的贡献,并随时评论我在方法中可能缺少的事情!
I would like some guidance on the proper way to compute a FFT on python for a real, non-periodic signal. I am relatively new to coding and signal analysis, so this post will contain questions relatives to both domains.
To give some context, here is a graphical representation of my signal (time domain):
and this is the data I am working from:
t_norm acc_norm
1 0.000000 0.000000
2 0.031918 2.336610
3 0.063340 1.817758
4 0.095058 0.544868
5 0.126293 -0.953833
6 0.157302 0.217959
7 0.188844 -1.331151
8 0.219892 -1.548037
9 0.251234 2.288458
10 0.282859 2.837413
11 0.314361 1.835081
12 0.345838 1.659622
13 0.376913 1.309823
14 0.408362 1.035765
15 0.439503 0.771576
16 0.470980 1.235591
17 0.502364 2.456847
18 0.533518 1.668552
19 0.564633 1.076637
20 0.595747 1.377580
21 0.626756 0.673881
22 0.658192 0.529822
23 0.689240 0.483709
24 0.720207 1.354278
25 0.751281 2.072109
26 0.782463 1.027122
27 0.813699 0.333459
28 0.844841 0.406036
29 0.875902 0.401840
30 0.906883 0.044780
31 0.937957 0.557944
32 0.968992 1.962894
33 1.000000 1.446186
Note that the device used to record the signal use a variable rate sampling with cross detection to capture data points. It limits (down samples) this to a maximum of 50 points per seconde (50Hz). I have made an histogram to show the distribution of the time intervals between measurements of all my datas :
METHODOLOGICAL QUESTIONS:
In regards to the overall shape of my signal (Fig 1), should I detrend it before doing the FFT (I am only interested in the high frequencies) ?
Does the FFT necessarily require to resample the datas if the rate of sampling is not uniform, even if the distribution of the time intervals between measurements is not really spread out (Fig 2) ?
TECHNICAL QUESTIONS (PYTHON):
All the examples I have seen on internet on how to compute a FFT works from a synthetic signals (directly made in python). I have tried to reproduce the methodology used and adapt it to fit for my signal derived from 'real world' data. The first steps seems to be to calculate some characteristics of the signal, and then to compute the FFT.
Signal characteristics
spl_nbr = # number of sample of the signal
d_fs = # sampling frequency, hertz
i_ns = (2*d_fs)
d_time = np.linspace(0, (i_ns-1), i_ns)/d_fs # Time series, seconds
d_f_sig = # signal freqeuncy, hertz
d_sig = # signal itself
Compute the FFT
cx_y = rfft(d_sig)/float(i_ns/2.)
d_ws = rfftfreq(i_ns,1./d_fs)
Therefore, I would like to know how to calculate each elements from my datas. I know I can use .count()
function to calculate the number of sample of the signal, but that is pretty much all I can do for now. I am especially wondering on how I should pass the signal information (d_sig) to python.
Thank you in advance for your contributions, and feel free to comment on things that I could be missing in my approach !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论