- 积分
- 875
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2011-10-14
- 最后登录
- 1970-1-1
|

楼主 |
发表于 2012-10-23 11:00:53
|
显示全部楼层
随缘 发表于 2012-9-19 21:50
楼主能否把改对的脚本放上来,我们学习学习啊,谢谢啊!具体是怎么改的,我也是遇到维数不对,不知道怎 ...
不好意思一直没有上,这是我自己写的最后程序,跟最开始的算法有改动,你看看合不合用吧
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
;********************Symbol Settings****************************
undef("create_hurricane_symbol")
function create_hurricane_symbol(wks)
begin
mstring = "p"
fontnum = 37
xoffset = 0.0
yoffset = 0.0
ratio = 1.0
size = 1.0
angle = 0.0
new_index = NhlNewMarker(wks, mstring, fontnum, xoffset, yoffset, \
ratio, size, angle)
return(new_index)
end
;*******************Symbol Settings End*****************************
begin
a = addfile("./wrfout_d01_2011-07-25_00:00:00.nc","r")
b = addfile("./geo_em.d01.nc","r") ; Open a file
type = "png"
pltres=True
mpres=True
times=wrf_user_list_times(a)
ntimes=dimsizes(times)
wks=gsn_open_wks(type,"tracksplot")
gsn_define_colormap(wks,"rainbow+white+gray")
;################Finding Typhoon Eyes Settings##############
lon2d = a->XLONG(0,:,:)
lat2d = a->XLAT(0,:,:)
fx = new(ntimes,integer)
fy = new(ntimes,integer)
temp = new(ntimes,integer)
mres = True
mres@gsMarkerIndex = create_hurricane_symbol(wks)
mres@gsMarkerSizeF = 15
mres@gsMarkerColor = "green"
pres = True ; polyline resources
pres@gsLineThicknessF = 2.0 ; line thickness
pres@gsLineColor = "Blue"
mpres@gsnDraw = False
mpres@gsnFrame = False
mpres@gsnMaximize = True
mpres@tiMainString = "Typhoon track"
mpres@pmLabelBarWidthF = 0.6
mpres@pmLabelBarHeightF = 0.1
mpres@mpMinLatF = min(lat2d)
mpres@mpMaxLatF = max(lat2d)
mpres@mpMinLonF = min(lon2d)
mpres@mpMaxLonF = max(lon2d)
;################Finding Typhoon Eyes Settings End##############
;#################Finding Typhoon Eyes##########################
do it=0,ntimes-1
slp2d = wrf_user_getvar(a,"slp",it) ; slp
wrf_smooth_2d( slp2d, 6 ) ; smooth slp
dims = dimsizes(slp2d)
slp1d = ndtooned(slp2d)
if (it .eq. 0) then
slp = slp2d(14:(dims(0)-50),100:(dims(1)-5))
else
if (fx(it-1) .gt. (dims(0)-16)) then
slp = slp2d((fx(it-1)-15):fx(it-1),(fy(it-1)-15):(fy(it-1)+15))
else
if (fx(it-1) .lt. 14) then
slp = slp2d(fx(it-1):(fx(it-1)+15),(fy(it-1)-15):(fy(it-1)+15))
else
if (fy(it-1) .gt. (dims(1)-16)) then
slp = slp2d((fx(it-1)-15):(fx(it-1)+15),(fy(it-1)-15):fy(it-1))
else
if (fy(it-1) .lt. 14) then
slp = slp2d((fx(it-1)-15):(fx(it-1)+15),fy(it-1):(fy(it-1)+15))
else
slp = slp2d((fx(it-1)-15):(fx(it-1)+15),(fy(it-1)-15):(fy(it-1)+15))
end if
end if
end if
end if
end if
minij = ind_resolve(ind(slp1d.eq.min(slp)),dims)
fx(it) = minij(0,0)
fy(it) = minij(0,1)
temp(it) = get1Dindex(slp1d,slp2d(fx(it),fy(it)))
delete(slp)
end do
;#################Finding Typhoon Eyes End#######################
;###########################Drawing##############################
ter = b->HGT_M(0,:,:) ; Read the variable to memory
ter@lon2d = b->XLONG_M(0,:,:)
ter@lat2d = b->XLAT_M(0,:,:)
terrain = gsn_csm_contour_map(wks,ter,mpres)
dot = new(ntimes,graphic) ; Make sure each gsn_add_polyxxx call
line = new(ntimes-1,graphic) ; is assigned to a unique variable.
do it=0,ntimes-2
xx = (/lon2d(fx(it),fy(it)),lon2d(fx(it+1),fy(it+1))/)
yy = (/lat2d(fx(it),fy(it)),lat2d(fx(it+1),fy(it+1))/)
line(it) = gsn_add_polyline(wks,terrain,xx,yy,pres)
end do
lon1d = ndtooned(lon2d)
lat1d = ndtooned(lat2d)
do it=0,ntimes-1,10
dot(it)=gsn_add_polymarker(wks,terrain,lon1d(temp(it)),lat1d(temp(it)),mres)
end do
;##################draw the track##########
do it=1,ntimes-1
; gsn_polyline(wks,terrain,(/lon2d(fx(it-1),fy(it-1)),lon2d(fx(it),fy(it))/),(/lat2d(fx(it-1),fy(it-1)),lat2d(fx(it),fy(it))/),pres)
end do
do it=0,ntimes-1,10
; gsn_polymarker(wks,terrain,lon2d(fx(it),fy(it)),lat2d(fx(it),fy(it)),mres)
end do
draw(terrain)
frame(wks)
end
|
|