<div dir="ltr"><div dir="ltr"><div dir="ltr">Hi Soma,<div>I missed that there is indeed a function that does the exact same thing as qsort but works on multi-dimensional arrays. See the documentation here:<br><a href="https://www.ncl.ucar.edu/Document/Functions/Built-in/dim_pqsort.shtml">https://www.ncl.ucar.edu/Document/Functions/Built-in/dim_pqsort.shtml<br></a></div><div><br></div><div>Modifying the coding I sent yesterday:</div><div><div>arr95 = prc(0,:,:)</div><div>arr95 = arr95@_FillValue</div><div>arr5 = arr95</div><div>ntime = dimsizes(prc&time)</div><div>i5 = toint(ntime*.05)-1    ; approximate 5% index</div><div>i95 = toint(ntime*.95)-1  ; approximate 95% index</div></div><div><div>ip    = dim_pqsort_n(prc, 2, 0)   ; ascending order, sort prc in ascending order at the 0th dimension. </div><div>prc05 = prc(i05,:,:)</div><div>prc95 = prc(i95,:,:)</div></div><div><br></div><div>Either method will work.</div><div>Adam</div><div><br></div></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Dec 5, 2018 at 3:38 PM Adam Phillips <<a href="mailto:asphilli@ucar.edu">asphilli@ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">Hi Soma,<div>You can use qsort:</div><div><a href="https://www.ncl.ucar.edu/Document/Functions/Built-in/qsort.shtml" target="_blank">https://www.ncl.ucar.edu/Document/Functions/Built-in/qsort.shtml</a><br></div><div>Note that qsort only accepts a single dimension, so you'll have to call qsort for each lat/lon point individually:</div><div>; untested</div><div>arr95 = prc(0,:,:)</div><div>arr95 = arr95@_FillValue</div><div>arr5 = arr95</div><div>ntime = dimsizes(prc&time)</div><div>i5 = toint(ntime*.05)-1    ; approximate 5% index</div><div>i95 = toint(ntime*.95)-1  ; approximate 95% index</div><div>do gg = 0,dimsizes(prc&lat)-1</div><div>    do hh = 0,dimsizes(prc&lon)-1</div><div>        temp = prc(:,gg,hh)</div><div>        qsort(temp)</div><div>        arr5(gg,hh) = temp(i5)    </div><div>        arr95(gg,hh) = temp(i95)   </div><div>        delete(temp)</div><div>    end do</div><div>end do</div><div><br></div><div>As always with any donated script on ncl-talk, make sure you understand what is happening in the script by using print statements and printVarSummary, and verify that the script is doing what you think it should be doing.</div>If you have any further questions about ncl please respond to ncl-talk.</div><div dir="ltr">Adam<br class="gmail-m_3237796119568032208gmail-Apple-interchange-newline"><div>          </div></div></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Dec 5, 2018 at 12:49 PM Soma Roy <<a href="mailto:somaroy892@gmail.com" target="_blank">somaroy892@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto"><span style="font-family:sans-serif;font-size:12.8px">Hello,</span><div dir="auto" style="font-family:sans-serif;font-size:12.8px"><br></div><div dir="auto" style="font-family:sans-serif;font-size:12.8px">I want to compute rainfall (gridded) values greater than 95th percentile and less than 10th percentile.</div><div dir="auto" style="font-family:sans-serif;font-size:12.8px"><br></div><div dir="auto" style="font-family:sans-serif;font-size:12.8px">printVarSummary of the input data is as follows;</div><div dir="auto" style="font-family:sans-serif;font-size:12.8px"><div dir="auto" style="font-size:12.8px"><div>Variable: prc</div><div>Type: double</div><div>..[snip]</div><div>Dimensions and sizes:   [time 14965| ] x [lat | 129] x [lon | 135]</div><div dir="auto">[snip]</div><div dir="auto">......</div><div>  _FillValue :  -999</div><div>  long_name :   GRIDDED RAINFALL</div><div>  missing_value :       -999</div><div> </div><div dir="auto">Please kindly suggest me a suitable way to execute it.</div><div dir="auto">I would like to get my output results over latitude-longitude.</div><div dir="auto"><br></div><div dir="auto">Thank you,</div><div dir="auto">Soma</div></div></div></div>
_______________________________________________<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/mailman/listinfo/ncl-talk</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail-m_3237796119568032208gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div><div><span><font color="#888888">Adam Phillips <br></font></span></div><span><font color="#888888">Associate Scientist,  </font></span><span><font color="#888888">Climate and Global Dynamics Laboratory, NCAR<br></font></span></div></div><div><span><font color="#888888"><a href="http://www.cgd.ucar.edu/staff/asphilli/" target="_blank">www.cgd.ucar.edu/staff/asphilli/</a>   </font></span><span><font color="#888888">303-497-1726 </font></span></div><span><font color="#888888"></font></span><div><div><span><font color="#888888"><br></font></span><div><span><font color="#888888"><a href="http://www.cgd.ucar.edu/staff/asphilli" target="_blank"></a></font></span></div></div></div></div></div></div></div></div></div></div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div><div><span><font color="#888888">Adam Phillips <br></font></span></div><span><font color="#888888">Associate Scientist,  </font></span><span><font color="#888888">Climate and Global Dynamics Laboratory, NCAR<br></font></span></div></div><div><span><font color="#888888"><a href="http://www.cgd.ucar.edu/staff/asphilli/" target="_blank">www.cgd.ucar.edu/staff/asphilli/</a>   </font></span><span><font color="#888888">303-497-1726 </font></span></div><span><font color="#888888"></font></span><div><div><span><font color="#888888"><br></font></span><div><span><font color="#888888"><a href="http://www.cgd.ucar.edu/staff/asphilli" target="_blank"></a></font></span></div></div></div></div></div></div></div></div></div></div></div>