python 峰_python-如何在具有多个峰的数据集中查找FWH...
我正在使用Python脚本,该脚本在特定值范围内沿一维轮廓查找峰(在我的情况下为谷)的索引.我的目的是测量每个感兴趣谷的半高宽.
This is an example of 1D profile
这是脚本:
def detect_peaks (x, mnph=None, mxph=None, mpd=1, threshold=0, edge='rising',
kpsh=False, valley=False, show=False, ax=None):
#from __future__ import division, print_function
import numpy as np
x = np.atleast_1d(x).astype('float64')
if x.size < 3:
return np.array([], dtype=int)
if valley:
x = -x
# find indices of all peaks
dx = x[1:] - x[:-1]
# handle NaN's
indnan = np.where(np.isnan(x))[0]
if indnan.size:
x[indnan] = np.inf
dx[np.where(np.isnan(dx))[0]] = np.inf
ine, ire, ife = np.array([[], [], []], dtype=int)
if not edge:
ine = np.where((np.hstack((dx, 0)) < 0) & (np.hstack((0, dx)) > 0))[0]
else:
if edge.lower() in ['rising', 'both']:
ire = np.where((np.hstack((dx, 0)) <= 0) & (np.hstack((0, dx)) > 0))[0]
if edge.lower() in ['falling', 'both']:
ife = np.where((np.hstack((dx, 0)) < 0) & (np.hstack((0, dx)) >= 0))[0]
ind = np.unique(np.hstack((ine, ire, ife)))
# handle NaN's
if ind.size and indnan.size:
# NaN's and values close to NaN's cannot be peaks
ind = ind[np.in1d(ind, np.unique(np.hstack((indnan, indnan-1, indnan+1))), invert=True)]
# first and last values of x cannot be peaks
if ind.size and ind[0] == 0:
ind = ind[1:]
if ind.size and ind[-1] == x.size-1:
ind = ind[:-1]
"""ABOUT mnph and mxph => It works just on valleys, for peaks: REMOVE the minus ("-") below in the code"""
# remove valleys < minimum peak height
if ind.size and mnph is not None:
ind = ind[-x[ind] >= mnph]
# remove valleys > maximum peak height
if ind.size and mxph is not None:
ind = ind[-x[ind] <= mxph]
return ind
如何执行此操作?
python 峰_python-如何在具有多个峰的数据集中查找FWH...相关推荐
- python 月报_python实践--月报分析之获取jira缺陷数据
首先安装jira,同其他第三方库,直接可以 easy_install jira. 判断jira是否按转成功输入:from jira import JIRA,如果没有报错则说明安装成功: #连接jira ...
- kafka python框架_Python中如何使用Apache Avro——Apache的数据序列化系统
了解如何创建和使用基于Apache Avro的数据,以实现更好,更有效的传输. 在这篇文章中,我将讨论Apache Avro,这是一种开源数据序列化系统,Spark,Kafka等工具正在使用该工具进行 ...
- python喜马拉雅_Python爬虫实战案例:取喜马拉雅音频数据详解!
前言 喜马拉雅是专业的音频分享平台,汇集了有声小说,有声读物,有声书,FM电台,儿童睡前故事,相声小品,鬼故事等数亿条音频,我最喜欢听民间故事和德云社相声集,你呢? 今天带大家爬取喜马拉雅音频数据,一 ...
- python 离群值_python:删除离群值操作(每一行为一类数据)
删除有多行字符串的json文件中的离群值 def processhold(eachsubject,directory,newfile): filename = 'cmudatacol/hold/sub ...
- spark python教程_Python Spark 2.0 Hadoop机器学习与大数据实战 完整pdf_IT教程网
资源名称:Python Spark 2.0 Hadoop机器学习与大数据实战 完整pdf 第1章 Python Spark机器学习与Hadoop大数据 1 第2章 VirtualBox虚拟机软件的安装 ...
- python画代码-Python教程_Python画Mandelbrot集 代码
Python教程_Python画Mandelbrot集 代码 作者:Comet 来源: 课课家 www.kokojia.com点击数:278发布时间:2015-06-19 11:17:19 曼德勃罗集 ...
- c语言实现爬虫功能,用C/C 扩展Python语言_python 调用c语言 python实现简单爬虫功能_python实现简单爬虫...
用C/C 扩展Python语言 Python是一门功能强大的脚本语言,它的强大不仅表现在功能上,还表现在其扩展性上.她提供大量的API以方便程序员利用C/C++对Python进行扩展.因为执行速度慢几 ...
- python编程语言_python编程语言的简要历史
python编程语言 The Python programming language is a general-purpose programming language that has carved ...
- python可视化_python商业智能可视化
python可视化 Why are visualizations worth thousands of words? They have the power of telling stories an ...
最新文章
- 为自己搭建一个鹊桥 -- Native Page与Web View之间的JSBridge实现方式
- Ubuntu系统的安装
- 【学习笔记】opencv的python接口 几何变换
- 对手机支付安全机制的思考
- 在mac中使用git-flow
- Keras 获取中间某一层输出
- thinkphp仿素材火教程_国外都用古风效果图获奖了,为什么你连素材都没有?
- 如何在cocoapods中使用更新版本的pod
- Docker-Compose 基础与实战,看这一篇就够了 | 原力计划
- 《Spring1之 第一次站立会议(重发)》
- SQL 2008R2 安装失败问题
- 航空信息指挥调度系统_应急指挥中心指挥调度系统解决方案(一)
- HTML网页设计期末课程大作业~旅游住宿酒店的HTML网页设计(14页) ~学生网页设计作业源码 旅游网页代码 学生网页设计与制作期末作业下载 DW旅游网页作业代码下载...
- C语言中报段错误(核心已转储)的常见问题
- 微信小程序button修改边框样式after
- 操作系统 FCFS,SPF,HRRN算法的实现
- android手机截图 视频,安卓Android手机相册视频如何隐藏
- sed命令定义和常用方式
- discuzdiy图片模块_dz论坛diy教程,discuz论坛DIY详细教程 论坛diy教程
- python判断谁是小偷_警察抓了A、B、C、D四名偷窃嫌疑犯,但其中只有一人是真正的小偷。审问记录如下:...