Hi Peng, I did this in the dim distant past by saving the sorted data to a file and then picked the appropriate values out. use coads_climatology let numpoints=`sst,return=lend` let numlats=`sst,return=jend]` let/title="sorted indices" sorted_by_time=sortl(sst[l=1:`numpoints`]) ! I found that I ran out of memory if I tried to sort too much for some GB sized datasets. It depends on the size of your dataset. ! You might be able to make larger windows or even do it in one go. save/j=1/jlimits=1:`numlats`/clob/file=sorted.nc sorted_by_time repeat/j=2:`numlats` save/app/file=sorted.nc sorted_by_time can var sorted_by_time use sorted ! Make a variable with time indices let index_2d=0*x[g=sorted_by_time] + 0*y[g=sorted_by_time] + l[g=sorted_by_time] ! Create an integrating kernel for the percentile wanted 1 for the limit we want and missing elsewhere. !25 percentile say. Make sure at least 1 valid point is used let k25 = if l[g=index_2d] eq max(int(0.25*ignore0(sorted_by_time[l=1:`numpoints`@ngd])),1) then 1 ! Show the indices used in the sorted data. Note that missing values are accounted for. shade k25[l=@loc:1] ! Multiply by SST and sum up let sst_k25 = k25[gl=sst[d=coads_climatology]@asn]*sst[d=coads_climatology] let/title="sst at 25 percentile" sst25=sst_k25[l=1:`numpoints`@sum] shade sst25 Cheers, Russ On 30/03/16 05:32, Ge Peng - NOAA Affiliate wrote:
|