[ncl-talk] Using NCL function get_unique_values, but maintain original array order

Mary Haley haley at ucar.edu
Fri May 26 10:18:29 MDT 2017


Hi Alan,

That's a good question, and I'm afraid we don't have a function to do that.
The problem is that the function has to sort the values in order to
effectively find the unique elements, and it doesn't bother unsorting them
when done. This would add a potentially expensive extra step that people
may not want. However, I do see the value of not sorting the values.

I've attached a function that unsorts the values after you call
get_unique_values. If you have a lot of values, this may add noticeable
time to execute. Also, this will currently only work on a 1D array.

I created a ticket for this, in case we get more requests for this and need
to create a more elegant solution (NCL-2618).

--Mary




On Thu, May 25, 2017 at 11:33 AM, Alan Rhoades <alan.m.rhoades at gmail.com>
wrote:

> Hello,
>
> I'm currently using this nifty NCL function get_unique_values to sort
> through an array and extract unique strings and/or floats from in-situ
> station data.
>
> My problem is that the extracted values are then sorted alphabetically
> and/or lowest to highest.
>
> Is it possible to use this function (or a similar) and maintain the
> ordering from the original array which the strings/floats were extracted
> from?
>
> Best,
>
> AR
>
> --
>
> *Alan Rhoades, Ph.D. | Lawrence Berkeley National Laboratories*
> *Hydroclimate Uncertainty Postdoctoral Fellow | Project Hyperion
> <http://climate.ucdavis.edu/hyperion/>*
> *arhoades at lbl.gov <arhoades at lbl.gov> | alan.m.rhoades at gmail.com
> <alan.m.rhoades at gmail.com>*
> *Website <http://alanrhoades.weebly.com/> | Research Gate
> <https://www.researchgate.net/profile/Alan_Rhoades> **| **Google Scholar
> <https://scholar.google.gr/citations?user=AVFLiFsAAAAJ&hl=en> **| LinkedIn
> <https://www.linkedin.com/pub/alan-rhoades/22/5bb/52a>*
> * <https://scholar.google.gr/citations?user=AVFLiFsAAAAJ&hl=en>*
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170526/3443dd5a/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: get_unique_test.ncl
Type: application/octet-stream
Size: 898 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170526/3443dd5a/attachment.obj 


More information about the ncl-talk mailing list