On Tue, Dec 6, 2011 at 2:51 AM, Xavier Barthelemy
<xabart@gmail.com> wrote:
ok let me be more precise
I have an Z array which is the elevation
from this I extract a discrete array of Zero Crossing, and another discrete array of Crests.
len(crest) is different than len(Xzeros). I have a threshold method to detect my "valid" crests, and sometimes there are 2 crests between two zero-crossing (grouping effect)
Crest and Zeros are 2 different arrays, with positions. example: Zeros=[1,2,3,4] Arrays=[1.5,1.7,3.5]
and yes arrays can be sorted. not a problm with this.
Xavier
I may be oversimplifying this, but does searchsorted do what you want?
In [314]: xzeros=[1,2,3,4]; xcrests=[1.5,1.7,3.5]
In [315]: np.searchsorted(xzeros, xcrests)
Out[315]: array([1, 1, 3])
This returns the indexes of xzeros to the left of xcrests.
-Tony