Example 1
x = (/3.,2.,5.,1.,5.,2.,5.,1.,3.,2./) i = maxind(x) ; Should be 2.Example 2
Find the index of the maximum value in a multi-dimensional array.
;---Create a dummy 2 x 2 x 4 array. a = (/(/(/1,2,3,4/), (/5,6,7,8/)/), (/(/9,1,9,8/),(/7,6,1,4/)/)/) ;---Convert to 1D a1D = ndtooned(a) dsizes_a = dimsizes(a) ;---Resolve the 1D indices back to their original 3D array. indices = ind_resolve(maxind(a1D),dsizes_a) print(indices)Example 3
Find the latitude and longitude location of the maximum value in a two dimensional array.
;---X is a two dimensional array dimensioned lat x lon dims = dimsizes(X) x1d = ndtooned(X) ; convert 2D array to 1D for use in maxind inds = ind_resolve(maxind (x1d), dims) ; convert 1D array back to 2D ilat = inds(0,0) ; select the latitude index where the X array is at its' maximum ilon = inds(0,1) ; select the longitude index where the X array is at its' maximum lat_max = X&lat(ilat) ; insert the latitude index into the lat coordinate variable lon_max = X&lon(ilon) ; insert the longitude index into the lon coordinate variable print("Maximum value located at "+lat_max+", "+lon_max) 不得不说感觉ncl在这个函数上有点不人性呀,有没有啥好的方法?Copyright ©2011-2014 bbs.06climate.com All Rights Reserved. Powered by Discuz! (京ICP-10201084)
本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论