[Numpy-discussion] Recognizing a cycle in a vector

Eric Firing efiring at hawaii.edu
Thu Dec 3 10:39:56 EST 2015


On 2015/12/02 10:45 PM, Manolo Martínez wrote:
> 1) this func sorts the absolute value of the amplitudes to find the two
> most important  components, and this seems overkill for large vectors.

Try

inds = np.argpartition(-np.abs(ft), 2)[:2]

Now inds holds the indices of the two largest components.

Eric



More information about the NumPy-Discussion mailing list