# identifying peaks in data

I have data with peaks on some background, for example:

The two prominent peaks at ~390 and ~450, as well as the much smaller peak at ~840. What are some options to programmatically find the position (i. e. the x-coordinate) of such peaks using Python/SciPy?

• what you're asking for is pretty ad hoc and in the eye of the beholder. So maybe calculate the forward and backwards derivative at each point, if they have different sign then you have a peak and can store the value and location. But to winnow the small peaks (that you want to ignore) from the larger ones, maybe take a long windowed average (or function fit) and only keep the peaks more than 50% away from the average/function. You could play with the percentage till you get roughly what you want. At the end you'll get the value and position of every peak more than x% from the windowed average.
– EMP
May 28 '19 at 21:52
• docs.scipy.org/doc/scipy/reference/generated/… May 29 '19 at 11:34
• Just out of curiosity, what sort of data is this? NMR? Photo-emission? May 29 '19 at 15:01
• @mathewgunther It's the energy of gamma rays from radioactive decay (some cobalt isotope). x-axis is the energy and y-axis is the number of events with that energy. May 30 '19 at 11:29
• Do the peaks of interest have a closed form analytic expression? (e.g. Gaussian, Lorenzian, Voigt, etc...) Also, does the background and broad peaks below 380 have a closed form analytic expression? Finally, what sort of x-axis peak position resolution is needed? May 30 '19 at 18:19