[Numpy-discussion] idea of optimisation?

Tony Yu tsyu80 at gmail.com
Tue Dec 6 12:21:50 EST 2011

On Tue, Dec 6, 2011 at 2:51 AM, Xavier Barthelemy <xabart at 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.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20111206/a4e6100a/attachment.html>

More information about the NumPy-Discussion mailing list