<div dir="ltr">Hi Mary,<div><br></div><div>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><br></div><div>For example,</div><div><br></div><div>a = (/6,8,10,2,4/)</div><div>a!0 = "index"</div><div>a&index = (/0,1,2,3,4/)</div><div><br></div><div>qsort(a)</div><div><br></div><div>print(a + " " + a&index) </div><div><br></div><div>The result is: </div><div>2 3</div><div>4 4 </div><div>6 0</div><div>8 1 </div><div>10 2</div><div><br></div><div>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>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><br></div><div>Best Regards,</div><div>Hoffman</div><div><br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-05-26 18:18 GMT+02:00 Mary Haley <span dir="ltr"><<a href="mailto:haley@ucar.edu" target="_blank">haley@ucar.edu</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-size:small">Hi Alan,</div><div class="gmail_default" style="font-size:small"><br></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></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></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></div><div class="gmail_default" style="font-size:small">--Mary</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default"><div class="gmail_default"><div style="font-size:small"><br></div></div></div><div class="gmail_default" style="font-size:small"><br></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Thu, May 25, 2017 at 11:33 AM, Alan Rhoades <span dir="ltr"><<a href="mailto:alan.m.rhoades@gmail.com" target="_blank">alan.m.rhoades@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><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">Hello,</span><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">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.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">My problem is that the extracted values are then sorted alphabetically and/or lowest to highest. </div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">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"><br></div><div style="font-size:12.8px">Best,</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">AR</div><span class="m_6922334391695434589HOEnZb"><font color="#888888"><div><br></div>-- <br><div class="m_6922334391695434589m_-3916837355478959127gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div style="font-weight:bold"><font color="#000000"><br></font></div><div><font color="#000000"><font size="1"><b>Alan Rhoades, Ph.D. | Lawrence Berkeley National Laboratories</b></font></font></div><div><font color="#000000" size="1"><b>Hydroclimate Uncertainty Postdoctoral Fellow | <a href="http://climate.ucdavis.edu/hyperion/" target="_blank">Project Hyperion</a></b></font></div><div><div><font color="#000000"><b><font size="1" face="arial, helvetica, sans-serif"><i><a href="mailto:arhoades@lbl.gov" target="_blank">arhoades@lbl.gov</a> | <a href="mailto:alan.m.rhoades@gmail.com" target="_blank">alan.m.rhoades@gmail.com</a></i></font></b></font></div><div><font color="#000000"><b><i><font size="1"><u><a href="http://alanrhoades.weebly.com/" target="_blank">Website</a></u></font><span style="font-size:12.8px"> |</span><span style="font-size:12.8px"> </span><font size="1"><u><a href="https://www.researchgate.net/profile/Alan_Rhoades" target="_blank">Research Gate</a></u></font><span style="font-size:12.8px"> </span></i></b><b style="font-size:12.8px"><i><span style="font-size:12.8px">| </span></i></b></font><b style="font-size:12.8px"><i><font size="1"><font color="#000000"><a href="https://scholar.google.gr/citations?user=AVFLiFsAAAAJ&hl=en" target="_blank">Google Scholar</a> </font></font></i></b><b style="font-size:12.8px;color:rgb(0,0,0)"><i><span style="font-size:12.8px">|</span><font size="1"> </font><u style="font-size:12.8px"><font size="1"><a href="https://www.linkedin.com/pub/alan-rhoades/22/5bb/52a" target="_blank">LinkedIn</a></font></u></i></b><b style="font-size:12.8px;color:rgb(0,0,0)"><i><span style="font-size:12.8px"> </span></i></b><b style="font-size:12.8px"><i><font size="1"><u><a href="https://scholar.google.gr/citations?user=AVFLiFsAAAAJ&hl=en" target="_blank"><br></a></u></font></i></b></div></div></div></div></div></div></div></div></div></div></div></div></div>
</font></span></div>
<br></div></div>______________________________<wbr>_________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailma<wbr>n/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>
<br>______________________________<wbr>_________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/<wbr>mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>