[Thread Prev][Thread Next][Index]

Re: [ferret_users] Percentile Calculations



Hi Lawal,
Try this and see if it works for the first L (based on a script from Russell Fiedler,2009):

! Get data
use Jan_Rain.nc
sh d
     currently SET data sets:
    1> ./Jan_Rain.nc  (default)
 name     title                             I         J         K         L
 PR       Precipitation                    1:110     1:100     1:1600    1:50

! Make a variable with the sorted indices.

let rainsortedindices=sortl(pr[k=1:1600,l=1])

! Save indices to a file. and read back

save/file=indices.nc/clob/jlimits==1:100/j=1 rainsortedindices
repeat/j=2:110 save/file=indices.nc/append rainsortedindices
can var rainsortedindices
use indices.nc

! Make a dummy variable containing the indices of rainfall

let dummy=l[g=pr[d=1]]

! Pick out the indices corresponding to the top 10 & bottom 10 percentiles
! We have a 1 wherever the 90% cutoff is and zeros elsewhere

let masktop10=if(dummy eq rainsortedindices[l=`int(1600*0.9)`]) then 1 else 0       ! 90th percentile
let maskbottom10=if(dummy eq rainsortedindices[l=`int(1600*0.1)`]) then 1 else 0    !10th percentile

! Mask with  the 0/1 array by the original rain to pick out our values
let  maskraintop10=masktop10[gl=rain[d=1]@asn]*rain[d=1]
let maskrainbottom10=maskbottom10[gl=rain[d=1]@asn]*rain[d=1]

! Sum to get the result

let/title="rain 90th percentile"   raintop10=maskraintop10[l=1:1600@sum]
let/title="rain 10th percentile"  rainbottom10=maskrainbottom10[l=1:1600@sum]

! plot the result
shade raintop10
shade rainbottom10




On 9 July 2012 15:07, Kamoru Abiodun Lawal <lawal_ka@xxxxxxxxxxx> wrote:
Dear Ferreters,
Can someone help with a hint on how to find 90th and 10th percentile of axis K for each axis L in the data structure below:

yes? use Jan_Rain.nc
yes? sh d
     currently SET data sets:
    1> ./Jan_Rain.nc  (default)
 name     title                                      I         J                K         L
 PR       Precipitation                    1:110     1:100     1:1600    1:50

Thank you!
 
Kamoru Abiodun LAWAL
Climate System Analysis Group,
Department of Environmental and Geographical Science,
University of Cape Town, Private Mail Bag X3,
Rondebosch, Cape Town, 7701, South Africa.




--

Izidine S. Pinto



[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement