栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

峰值检测电路(峰峰值和峰值)

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

峰值检测电路(峰峰值和峰值)

峰值检测

import matplotlib.pyplot as plt
import numpy as np
import h5py

def nms_3(data):
    length=len(data)
    ans=[]
    for i in range(2,length-2):
        if data[i] >= data[i-1] and data[i] >= data[i+1] :
            ans.append(i)
    return ans

if __name__ == '__main__':
    f = h5py.File("data.hdf5", "r")
    keys = f.keys()
    pulse = []
    time = []
    for e in f['pulse']:
        pulse.append(e)
    for e in f['time']:
        time.append(e)
    print("the len of pulse is %d" % (len(pulse)))
    print("the len of time is %d" % (len(time)))

    pulse = np.array(pulse)
    plt.figure()
    
    # # 时间为横轴,单位转换复杂 不知道抽样频率。 还是以样本数量为横轴,刚好对应
    # plt.plot(time, pulse)
    # plt.xlabel('time')  # 时间60s
    # plt.title('time-pulse')  # 添加图片标题
    
    # 以样本数量为横轴,刚好对应
    plt.plot(np.arange(len(pulse)), pulse)
    plt.xlabel('Number of samples')  # 样本数量 len(pulse)=len(time)
    plt.title('Number of samples-pulse-pulse')  # 添加图片标题
    point = nms_3(pulse)
    plt.plot(point, pulse[point], "o")
    print(point)
    plt.show()
    exit()
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/772780.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号