我收到的信号如下所示,这个数据捕获只有10秒钟(由于此处的空间有限)现在我想编写一个显示每分钟位数的代码,我正在考虑将值3.00作为一点
我做了什么:
我只是用一个阈值打印数据来计算每分钟的位数
as
threshold = 2.8 # Threshold to do something if value is more than to that.
if signal >= 2.8:
print signal
counter = counter +1 # to count how many times we get value more than 2.8 or (near by 3)
bits_per_mint = counterx6 # captured for 10 second so converted it to minute
print bits_per_mint
data out put in 10 second
1.7646050347
1.6970572917
1.6774392361
0
3.486762153
1.6310026042
1.6582465278
1.6384114583
1.6501171875
1.6769661458
3.9909898997
0
1.6688020833
1.6627473958
1.6689800347
1.6756423611
1.6579513889
0
1.6809592014
1.6504774306
3.7684857685
1.6463671875
1.67640625
0
1.6509635417
1.6736501736
3.5653423434
1.6581206597
1.6516666667
0
1.6449348958
1.6630338542
1.6605772569
1.6500824653
3.4554564564
0
1.6839409722
1.6495399306
1.6393663194
1.6684244792
------------
--------- so on
如何使用快速傅立叶变换
来完成此操作谢谢
答案 0 :(得分:0)
试试这个并告诉我它是否对您有所帮助。您可以使用time
模块在外部while
循环中引入延迟(以秒为单位),然后检查信号是否大于阈值,如果是,则打印它并将其附加到列表中bits_per_min
。示例代码如下所示。
import time
threshold = 2.8 # Threshold to do something if value is more than to that.
seconds = 0
counter = 0
while seconds != 60:
bits_per_min = [] # this part of code runs for one min duration
if signal >= threshold: # to compare if signal is greater than the threshold value
print signal
bits_per_min.append(signal)
counter += 1
time.sleep(1)
seconds += 1
print bits_per_min