Actually this can be a good idea. i didn't thought using he sorting.
i'll try

thanks for yours ideas
Xavier

2011/12/7 Tony Yu <tsyu80@gmail.com>


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

_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion




--
 « Quand le gouvernement viole les droits du peuple, l'insurrection est, pour le peuple et pour chaque portion du peuple, le plus sacré des droits et le plus indispensable des devoirs »

Déclaration des droits de l'homme et du citoyen, article 35, 1793