<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""></div><div class=""><span style="font-size: 12.800000190734863px;" class=""><br class=""></span></div><div class=""><span style="font-size: 12.800000190734863px;" class=""><br class=""></span></div><div class=""><span style="font-size: 12.800000190734863px;" class=""><br class=""></span></div><div class=""><br class=""><div class="">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; border-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-stroke-width: 0px;"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">##############################<br class="">Alan Brammer,<div class="">Post-Doc Researcher</div><div class=""><br class=""></div><div class="">Department of Atmospheric and&nbsp;Environmental Sciences,<br class="">University at Albany,&nbsp;State University of New&nbsp;York,&nbsp;Albany, NY, 12222<div class=""><a href="mailto:abrammer@albany.edu" class="">abrammer@albany.edu</a><br class="">##############################</div></div></div></span></div></div>
</div>
<br class=""><div><blockquote type="cite" class=""><div class="">On 27 May 2017, at 08:05, Hoffman Cheung &lt;<a href="mailto:hoffmancheung@gmail.com" class="">hoffmancheung@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hi Mary,<div class=""><br class=""></div><div class="">If one wants to get the indices of an unsorted array after sorting by qsort, one can manually assign a unique index for the array before reordering.</div><div class=""><br class=""></div><div class="">For example,</div><div class=""><br class=""></div><div class="">a = (/6,8,10,2,4/)</div><div class="">a!0 = "index"</div><div class="">a&amp;index = (/0,1,2,3,4/)</div><div class=""><br class=""></div><div class="">qsort(a)</div><div class=""><br class=""></div><div class="">print(a + " " + a&amp;index)&nbsp;</div><div class=""><br class=""></div><div class="">The result is:&nbsp;</div><div class="">2 3</div><div class="">4 4&nbsp;</div><div class="">6 0</div><div class="">8 1&nbsp;</div><div class="">10 2</div><div class=""><br class=""></div><div class="">Is it possible to modify the function get_unique_index in such a way that it can also return the associated coordinate variable?</div><div class="">If it is possible, this would be easy to get the index of the unsorted array (for 1-D and multiple-dimensional array).</div><div class=""><br class=""></div><div class="">Best Regards,</div><div class="">Hoffman</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">2017-05-26 18:18 GMT+02:00 Mary Haley <span dir="ltr" class="">&lt;<a href="mailto:haley@ucar.edu" target="_blank" class="">haley@ucar.edu</a>&gt;</span>:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class=""><div class="gmail_default" style="font-size:small">Hi Alan,</div><div class="gmail_default" style="font-size:small"><br class=""></div><div class="gmail_default" style="font-size:small">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.</div><div class="gmail_default" style="font-size:small"><br class=""></div><div class="gmail_default" style="font-size:small">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.</div><div class="gmail_default" style="font-size:small"><br class=""></div><div class="gmail_default" style="font-size:small">I created a ticket for this, in case we get more requests for this and need to create a more elegant solution (NCL-2618).</div><div class="gmail_default" style="font-size:small"><br class=""></div><div class="gmail_default" style="font-size:small">--Mary</div><div class="gmail_default" style="font-size:small"><br class=""></div><div class="gmail_default"><div class="gmail_default"><div style="font-size:small" class=""><br class=""></div></div></div><div class="gmail_default" style="font-size:small"><br class=""></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote"><div class=""><div class="h5">On Thu, May 25, 2017 at 11:33 AM, Alan Rhoades <span dir="ltr" class="">&lt;<a href="mailto:alan.m.rhoades@gmail.com" target="_blank" class="">alan.m.rhoades@gmail.com</a>&gt;</span> wrote:<br class=""></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class=""><div class="h5"><div dir="ltr" class=""><img width="0" height="0" class="m_6922334391695434589m_-3916837355478959127mailtrack-img" style="float:right" alt="" src="https://mailtrack.io/trace/mail/abd9355b95c51f735edb13e546f6e7fbe1ac95ae.png?u=1126611"><span style="font-size:12.8px" class="">Hello,</span><div style="font-size:12.8px" class=""><br class=""></div><div style="font-size:12.8px" class="">I'm currently using this nifty NCL function&nbsp;get_unique_values to sort through an array and extract unique strings and/or floats from in-situ station data.</div><div style="font-size:12.8px" class=""><br class=""></div><div style="font-size:12.8px" class="">My problem is that the extracted values are then sorted alphabetically and/or lowest to highest. &nbsp;</div><div style="font-size:12.8px" class=""><br class=""></div><div style="font-size:12.8px" class="">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?</div><div style="font-size:12.8px" class=""><br class=""></div><div style="font-size:12.8px" class="">Best,</div><div style="font-size:12.8px" class=""><br class=""></div><div style="font-size:12.8px" class="">AR</div><span class="m_6922334391695434589HOEnZb"><font color="#888888" class=""><div class=""><br class=""></div>-- <br class=""><div class="m_6922334391695434589m_-3916837355478959127gmail_signature"><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div style="font-weight:bold" class=""><font class=""><br class=""></font></div><div class=""><font class=""><font size="1" class=""><b class="">Alan Rhoades, Ph.D. | Lawrence Berkeley National Laboratories</b></font></font></div><div class=""><font size="1" class=""><b class="">Hydroclimate Uncertainty Postdoctoral Fellow | <a href="http://climate.ucdavis.edu/hyperion/" target="_blank" class="">Project Hyperion</a></b></font></div><div class=""><div class=""><font class=""><b class=""><font size="1" face="arial, helvetica, sans-serif" class=""><i class=""><a href="mailto:arhoades@lbl.gov" target="_blank" class="">arhoades@lbl.gov</a> | <a href="mailto:alan.m.rhoades@gmail.com" target="_blank" class="">alan.m.rhoades@gmail.com</a></i></font></b></font></div><div class=""><font class=""><b class=""><i class=""><font size="1" class=""><u class=""><a href="http://alanrhoades.weebly.com/" target="_blank" class="">Website</a></u></font><span style="font-size:12.8px" class="">&nbsp;|</span><span style="font-size:12.8px" class="">&nbsp;</span><font size="1" class=""><u class=""><a href="https://www.researchgate.net/profile/Alan_Rhoades" target="_blank" class="">Research Gate</a></u></font><span style="font-size:12.8px" class="">&nbsp;</span></i></b><b style="font-size:12.8px" class=""><i class=""><span style="font-size:12.8px" class="">|&nbsp;</span></i></b></font><b style="font-size:12.8px" class=""><i class=""><font size="1" class=""><font class=""><a href="https://scholar.google.gr/citations?user=AVFLiFsAAAAJ&amp;hl=en" target="_blank" class="">Google Scholar</a>&nbsp;</font></font></i></b><b style="font-size: 12.8px;" class=""><i class=""><span style="font-size:12.8px" class="">|</span><font size="1" class="">&nbsp;</font><u style="font-size:12.8px" class=""><font size="1" class=""><a href="https://www.linkedin.com/pub/alan-rhoades/22/5bb/52a" target="_blank" class="">LinkedIn</a></font></u></i></b><b style="font-size: 12.8px;" class=""><i class=""><span style="font-size:12.8px" class="">&nbsp;</span></i></b><b style="font-size:12.8px" class=""><i class=""><font size="1" class=""><u class=""><a href="https://scholar.google.gr/citations?user=AVFLiFsAAAAJ&amp;hl=en" target="_blank" class=""><br class=""></a></u></font></i></b></div></div></div></div></div></div></div></div></div></div></div></div></div>
</font></span></div>
<br class=""></div></div>______________________________<wbr class="">_________________<br class="">
ncl-talk mailing list<br class="">
<a href="mailto:ncl-talk@ucar.edu" target="_blank" class="">ncl-talk@ucar.edu</a><br class="">
List instructions, subscriber options, unsubscribe:<br class="">
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank" class="">http://mailman.ucar.edu/mailma<wbr class="">n/listinfo/ncl-talk</a><br class="">
<br class=""></blockquote></div><br class=""></div>
<br class="">______________________________<wbr class="">_________________<br class="">
ncl-talk mailing list<br class="">
<a href="mailto:ncl-talk@ucar.edu" class="">ncl-talk@ucar.edu</a><br class="">
List instructions, subscriber options, unsubscribe:<br class="">
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank" class="">http://mailman.ucar.edu/<wbr class="">mailman/listinfo/ncl-talk</a><br class="">
<br class=""></blockquote></div><br class=""></div>
_______________________________________________<br class="">ncl-talk mailing list<br class=""><a href="mailto:ncl-talk@ucar.edu" class="">ncl-talk@ucar.edu</a><br class="">List instructions, subscriber options, unsubscribe:<br class="">http://mailman.ucar.edu/mailman/listinfo/ncl-talk<br class=""></div></blockquote></div><br class=""></div></body></html>