trynerror
trynerror

Reputation: 229

How to extract specific parts of a numpy array?

I have the following looking correlation function. enter image description here I want to extract only the main peak of the function in a seperate array. The central peak has the form of a gaussian.enter image description here. I want to seperate the peak with a width arround the peak of approximately four times the FWHM of the gaussian peak. I have the correlation function stored in a numpy array. Any tips/ideas how to approach this ?

Upvotes: 1

Views: 558

Answers (1)

belfner
belfner

Reputation: 232

Numpy's argmax (Docs) function returns the index of the max value of a numpy array. With that value you could then get the values around that index.

Example:

m = numpy.argmax(arr)
values = arr[m-width:m+width]

Upvotes: 2

Related Questions