(编辑:我现在已经设法完成上述操作,但是该功能仅给我5个峰,却错过了最后一个第6个峰):
#xnb is x data without any background, for example:
xnb=[1.1,1.2,1.3,1.4,1.5,3.4,3.5,3.6,3.7,7.8,7.9,10.8,10.9,11.0,11.1] #4 peaks
def peakfinder(xnb):
pn=[]
peakarrays=[]
prevpoint=xnb[0]
for point in xnb:
dif=point-prevpoint
if dif<=0.3 and dif>=-0.3:
pn.append(point)
else:
peakarrays.append(pn)
pn=[]
prevpoint=point
return peakarrays