Besz15
Besz15

Reputation: 165

How to compute the distance between neighbouring peaks in python?

I have been playing around with the scipy find_peaks() function. I would be interested in finding the vertical distance between a peak and its side lobes, but so far I haven’t been able to find it with the find_peaks() function. Does anyone have any suggestions?

Thanks!

Upvotes: 1

Views: 2654

Answers (1)

Ari Cooper-Davis
Ari Cooper-Davis

Reputation: 3515

It's more usual to look at peak_prominences() than the difference between the height of the peak and adjacent peaks.

That being said, scipy.signal.find_peaks() returns the x-indices of the peaks that it finds, which you can use to determine the heights at each peak.

Identify the highest peak (numpy.max/numpy.argmax) then take the peak before (index-1) and after (index+1), which correspond to the sidelobes. Choose an algorithm to work out the height you're interested in e.g. difference = peak - mean(sidelobes) and voila!

Upvotes: 1

Related Questions