[Numpy-discussion] idea of optimisation?
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.
> I may be oversimplifying this, but does searchsorted do what you want?
In : xzeros=[1,2,3,4]; xcrests=[1.5,1.7,3.5]
In : np.searchsorted(xzeros, xcrests)
Out: array([1, 1, 3])
This returns the indexes of xzeros to the left of xcrests.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion