A peak finding algorithm in X-Y data.
Source code name: "mining_peak_finder_sc.py"
Programming language: Python
Topic: Data mining/finders
DMelt Version 1. Last modified: 12/08/2015. License: Pro
https://datamelt.org/code/cache/mining_peak_finder_sc_5422.py
To run this script using the DMelt IDE, copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.



"""
Peak finder algorithm based on
A non-parametric peak finder algorithm and its application in searches for new physics
S.Chekanov, M.Erickson
E-print: arxiv.org:1110.3772 ANL-HEP-PR-11-63
"Advances in High Energy Physics", vol. 2013, Article ID 162986, 4 pages, 2013. doi:10.1155/2013/162986.
http://www.hindawi.com/journals/ahep/contents/
http://www.hindawi.com/journals/ahep/2013/162986/ 
"""
 
from jhplot import *
from java.awt import Color
import sys
sys.path.append(SystemDir+'/python/packages/npfinder/')
from npfinder import GetData, FindPeaks, MakeGraph

c1 = HPlot("Canvas",600,400)
c1.visible()
c1.setLegend(0)
c1.setGTitle("Automatic peak identification")
c1.setRange(50,1000,1,1000)
# c1.setAutoRange()
# c1.setLogScale(1,1)

h=H1D("data",50,0,1000)
h.fillGauss(30000,0,300) # background 
h1=h.copy()
h.fillGauss(1000,400,20) # peak 1
h.fillGauss(500,700,10)  # peak 2 
data = GetData(h)
# 3-sigma approach
minSig=3
peaks = FindPeaks(data, 0.6, minSig) 
print 'RESULTS OF PEAK SEARCH:\n'
for i in range(len(peaks)):
    print 'Peak Number:', peaks[i].GetPeakNumber(), 'Peak Start:', peaks[i].GetPeakStart().x, 'Peak End:', peaks[i].GetPeakEnd().x, 'Peak Stat Sig:', peaks[i].GetStatSig(), 'Residuals:', peaks[i].GetResiduals(), '\n'
    print peaks[i].GetPeakStart().GetYErrLow(), peaks[i].GetPeakEnd().GetYErrLow()
print 'END OF PEAK SEARCH RESULTS'

c1.draw(h)
h1.setFill(1) # show background
c1.draw(h1)
peak,lreg = MakeGraph(peaks)

# always ignore the first point
for i in range(1,len(peak)):
  if (peaks[i].GetStatSig() 

You see the box below because you did not login.