Up | Example 1 : arrlib matrix math | Example 2 : Two-dimentional geometry | Example 3 : Member functions | Example 4 : Setting sub matrices | Example 5 : Locating peaks in a list

 

  

 
Example 5 : Locating peaks in a list
import arrlib as arr

def peaks(v,b,c,d,t):
#---------------------------------------------------------------------------------
# v  - a list or tuple with values;
# b  - smoothbase
# c  - smoothcount; 
# d  - order of differentiation
# t  -  threshold for peak detection
# returns a list of tuples - [(pos,val)...]
#--------------------------------------------------------------------------------
L=len(v)
w=arr.floatVec(L);
for i in range(L): w[i]=v[i]
p=arr.xyfVec(L)
p.setLength(0)
w,h,s=arr.smooDiff(w,b,c,d)
arr.findPeaks(w,t,p)
return [(x[0]+h,x[1]/s) for x in p if x[1]>0]

Example 1: Locate peaks in a list

from math import *
v=[sin(i/4.0) for i in range(50)]
base=2
count=1
diff=0
thresh=0.5
print peaks(v,base,count,diff,thresh)
 

Scorpion Vision Version XII : Build 646 - Date: 20170225
Scorpion Vision Software® is a registered trademark of Tordivel AS.
Copyright © 2000 - 2017 Tordivel AS.