[ncl-talk] how to get min index within different sequences

Mary Haley haley at ucar.edu
Sun Sep 21 21:26:47 MDT 2014


​Lili,

In the future, please do not post questions to individual developers when
you don't get a response on ncl-talk.  It's okay to repost to ncl-talk
after a few days, because we generally try to answer all questions.

You will need to loop through your array and get the start and end index of
each consecutive sequence of numbers, and then use NCL's minind function to
get the index of the minimum of this subset, "i =
minind(x(beg_index:end_index)". There may be a "cleaner" way to do this,
but this script should work.

See attached script which uses a slightly more complex input array.

--Mary

On Sat, Sep 20, 2014 at 12:55 AM, Verena Lili <verena.prick at gmail.com>
wrote:

> Hi Mary,
>
> I posted this email to ncl talk (see below) and not getting any response
> since then. Would you please help me on this simple issue?
> I've been struggling to figure this out, but not yet get a conclusive
> result
>
> thank you
>
>
> =======================
> Subject: how to get min index within different sequences
> To: "ncl-talk at ucar.edu" <ncl-talk at ucar.edu>
>
>
>
> Hallo,
>
> Anyone can suggest how to get the index of the minimum values within
> different
> sequences:
>
> e.g.:
>
>  x = (/-3, -2, -1, 4, 5, 6, 0, -2, 5/)
>
>  x at _FillValue=-999
>  x = where(x.gt.3,x, x at _FillValue)  ; only x>3
>  print(x)
>
> Variable: x
> (0)     -999
> (1)     -999
> (2)     -999
> (3)     4
> (4)     5
> (5)     6
> (6)     -999
> (7)     -999
> (8)     5
>
> ; then, how to get *index* pointing the minimum value within these two
> sequences (3)-(5) and (8),
> so that the out put will be index:
>
> *3 and 8*
>
> Thank you.
>
>
> --
> Regards,
> Dr. Verena.
> School of Marine and Atmospheric Sciences
> Stony Brook University
> homepage: http://www.somas.stonybrook.edu/
>
>
>
> --
> Regards,
> Dr. Verena.
> School of Marine and Atmospheric Sciences
> Stony Brook University
> homepage: http://www.somas.stonybrook.edu/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20140921/c7581166/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: xmin.ncl
Type: application/octet-stream
Size: 1382 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20140921/c7581166/attachment.obj 


More information about the ncl-talk mailing list