- 积分
- 387
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2018-3-24
- 最后登录
- 1970-1-1
|
楼主 |
发表于 2020-1-5 15:27:49
|
显示全部楼层
http://www.ncl.ucar.edu/Applicat ... percentile_plot.ncl
undef("percent_to_value")
function percent_to_value( \
i_data : numeric, \
i_percentiles : numeric \
)
local None
begin
retVal = new( dimsizes(i_percentiles), float )
data1d = ndtooned( i_data )
notMissing = data1d( ind(.not.ismissing(data1d) ) )
qsort(notMissing)
do p = 0, dimsizes(i_percentiles)-1
; pInd = round( i_percentiles(p) * .01 * dimsizes(notMissing) + 0.5, 3 ) -1
; pInd = where( pInd.ge.dimsizes(notMissing), dimsizes(notMissing)-1, pInd )
floatInd = i_percentiles(p) * .01 * dimsizes(notMissing) - 0.5
floorInd = toint( floor(floatInd) )
floorInd = where( floorInd.lt.0, 0, floorInd )
ceilInd = toint( ceil(floatInd) )
ceilInd = where( ceilInd.ge.dimsizes(notMissing), \
dimsizes(notMissing)-1, ceilInd )
; print(pInd + " " + dimsizes(notMissing))
if( ceilInd.eq.floorInd ) then
retVal(p) = notMissing(floorInd)
else
retVal(p) = notMissing(floorInd) * ( ceilInd - floatInd ) \
+ notMissing(ceilInd) * ( floatInd - floorInd )
end if
end do
return(retVal)
end ; percent_to_value |
|