Re: 10th and 90th percentile

From: Marston Johnston <shejo284_at_nyahnyahspammersnyahnyah>
Date: Mon Apr 14 2014 - 06:23:33 MDT

Here's an example that I made for my own use. It uses a function designed
to keep only non-missing values, which is simple to make.

undef("Percentile")
function Percentile(x:numeric,P:float)
begin
  if(P.gt.0) then
    P = P/100.
  end if
  x@_FillValue = default_fillvalue(typeof(x))
  print("Rain rates for project greater than 0 and less than 1000...")
  x = where((x.gt.0 .and. x.lt.1000.),x,x@_FillValue)
  nx = Crop(ndtooned(x))
  index = round(P*dimsizes(nx),3)
  print("Index of percentile: "+index+ " of size: "+dimsizes(nx))
  ib = dim_pqsort(nx,2)
  print("The "+P*100+" percentile: "+nx(index))
  return(nx(index))
end

Hope this helps,
/M

On Mon, Apr 14, 2014 at 2:16 PM, Ahmad Farsyud <a.farsyud@gmail.com> wrote:

> Hi Marston, thanks,
> could you suggest me an example?
>
>
> On Mon, Apr 14, 2014 at 2:13 PM, Marston Johnston <shejo284@gmail.com>wrote:
>
>> Hi,
>>
>> I've not seen such a function in NCL, but it's fairly simple to code in
>> NCL.
>> It involves sorting your array, make it 1D first, removing any invalid
>> data points, and then
>> calculating the 10th and 90th percentile position in the array. The 10th
>> and 90th are positions of the
>> 10% and 90% indices in the array.
>>
>> Hope this helps,
>>
>> /M
>>
>>
>> On Mon, Apr 14, 2014 at 2:03 PM, Ahmad Farsyud <a.farsyud@gmail.com>wrote:
>>
>>> Dear NCL,
>>>
>>> Anyone can suggest what a function that i can use to calculate 10th and
>>> 90th percentile in NCL?
>>>
>>> Thanks
>>> AF
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>>
>>
>>
>> --
>> Only the fruitful thing is true!
>>
>
>

-- 
Only the fruitful thing is true!

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Apr 14 06:23:47 2014

This archive was generated by hypermail 2.1.8 : Tue Apr 15 2014 - 10:45:19 MDT