# [ncl-talk] Percentile

Soma Roy somaroy892 at gmail.com
Thu Dec 6 08:56:33 MST 2018

```Thank you so much.

Soma

On Thu, Dec 6, 2018, 04:08 Adam Phillips <asphilli at ucar.edu wrote:

> Hi Soma,
> You can use qsort:
> https://www.ncl.ucar.edu/Document/Functions/Built-in/qsort.shtml
> Note that qsort only accepts a single dimension, so you'll have to call
> qsort for each lat/lon point individually:
> ; untested
> arr95 = prc(0,:,:)
> arr95 = arr95 at _FillValue
> arr5 = arr95
> ntime = dimsizes(prc&time)
> i5 = toint(ntime*.05)-1    ; approximate 5% index
> i95 = toint(ntime*.95)-1  ; approximate 95% index
> do gg = 0,dimsizes(prc&lat)-1
>     do hh = 0,dimsizes(prc&lon)-1
>         temp = prc(:,gg,hh)
>         qsort(temp)
>         arr5(gg,hh) = temp(i5)
>         arr95(gg,hh) = temp(i95)
>         delete(temp)
>     end do
> end do
>
> 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.
> If you have any further questions about ncl please respond to ncl-talk.
>
>
> On Wed, Dec 5, 2018 at 12:49 PM Soma Roy <somaroy892 at gmail.com> wrote:
>
>> Hello,
>>
>> I want to compute rainfall (gridded) values greater than 95th percentile
>> and less than 10th percentile.
>>
>> printVarSummary of the input data is as follows;
>> Variable: prc
>> Type: double
>> ..[snip]
>> Dimensions and sizes:   [time 14965| ] x [lat | 129] x [lon | 135]
>> [snip]
>> ......
>>   _FillValue :  -999
>>   long_name :   GRIDDED RAINFALL
>>   missing_value :       -999
>>
>> Please kindly suggest me a suitable way to execute it.
>> I would like to get my output results over latitude-longitude.
>>
>> Thank you,
>> Soma
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>
>
> --