- 积分
- 814
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2016-12-13
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
我用热带气旋txt文件画台风路径,格式是这样的66666 0000 49 0001 0000 0 6 Carmen 201107291949011300 0 57 1399 1006 0
1949011306 0 59 1393 1006 0
。。。。。
脚本如下(显示黑体附近有错)
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"
;********************************************************
begin
fiTY = "./typhoon.txt"
nrow = numAsciiRow(fiTY)
YYYYMMDDHH = new(nrow, "string")
lat = new(nrow, "float")
lon = new(nrow, "float")
vmax = new(nrow, "integer")
mslp = new(nrow, "integer")
data = asciiread(fiTY,-1,"string")
YYYYMMDDHH = str_get_field(data, 1,",")
lat = stringtofloat(str_get_field(data, 3,","))*0.1
lon = stringtofloat(str_get_field(data, 4,","))*0.1
mslp = stringtoint(str_get_field(data, 5,"," ))
vmax = stringtoint(str_get_field(data, 6, ","))
print(vmax)
DateChar = stringtochar(YYYYMMDDHH)
MM = chartostring(DateChar(:,5:6))
DD = chartostring(DateChar(:,7:8))
HH = chartostring(DateChar(:,9:10))
HHi = mod(stringtoint(YYYYMMDDHH), 100)
DDi = mod(stringtoint(YYYYMMDDHH)/100, 100)
MMi = mod(stringtoint(YYYYMMDDHH)/10000, 100)
wks = gsn_open_wks("png", "besttrack")
gsn_define_colormap(wks,"rainbow")
res = True
res@gsnDraw = False
res@gsnFrame = False
res@mpMinLatF = 5
res@mpMaxLatF = 37
res@mpMinLonF = 110
res@mpMaxLonF = 135
res@mpLandFillColor = 160
res@tmXBLabelFontHeightF = 0.025
res@tmYLLabelFontHeightF = 0.025
res@mpGridAndLimbOn = "True"
res@mpGridMaskMode = "MaskNotOcean"
res@mpGridLineDashPattern = 15
res@mpGridSpacingF = 5.0
res@mpOutlineOn = True
res@mpOutlineBoundarySets = "National"
res@mpDataBaseVersion = "MediumRes"
res@mpDataSetName = "Earth..4"
res@mpOutlineSpecifiers = "China:States"
plot = gsn_csm_map_ce(wks,res)
colours = (/3, 20, 60, 120, 180/)
resDot = True
resLine = True
dumDot= new(nrow, graphic)
dumLine = new(nrow, graphic)
resLine@gsLineThicknessF = 3
do i = 0, nrow-2
xx = (/ lon(i), lon(i+1)/)
yy = (/ lat(i), lat(i+1)/)
if (vmax(i).le.17) then
resLine@gsLineColor = colours(0)
end if
if (vmax(i) .ge. 17 .and. vmax(i).le.32) then
resLine@gsLineColor = colours(1)
end if
if (vmax(i).ge.32 .and. vmax(i) .le. 42) then
resLine@gsLineColor = colours(2)
end if
if (vmax(i).ge.42 .and. vmax(i) .lt. 51) then
resLine@gsLineColor = colours(3)
end if
if (vmax(i).ge.51) then
resLine@gsLineColor = colours(4)
end if
dumLine(i) = gsn_add_polyline(wks, plot, xx, yy, resLine)
end do
resDot@gsMarkerIndex = 1
resDot@gsMarkerColor = "black"
do i = 0, nrow-1
if (HH(i) .eq. "00") then
resDot@gsMarkerSizeF = 0.02
dumDot(i) = gsn_add_polymarker(wks, plot, lon(i), lat(i), resDot)
else
resDot@gsMarkerSizeF = 0.005
dumDot(i) = gsn_add_polymarker(wks, plot, lon(i), lat(i), resDot)
end if
end do
resLg = True
resLg@lgItemType = "MarkLines"
resLg@lgMonoMarkerIndex = True
resLg@lgMarkerColors = colours
resLg@lgMarkerIndex = 1
resLg@lgMarkerSizeF = 0.02
resLg@lgMonoDashIndex = True
resLg@lgDashIndex = 0
resLg@lgLineColors = colours
resLg@lgLineThicknessF = 3
resLg@vpWidthF = 0.14
resLg@vpHeightF = 0.13
resLg@lgPerimFill = 0
resLg@lgPerimFillColor = "Background"
resLg@lgLabelFontHeightF = 0.3
resLg@lgTitleFontHeightF = 0.015
resLg@lgTitleString = "Best Track"
lbid = gsn_create_legend(wks, 5, (/" 17m/s or less"," 17 to 32m/s"," 32 to 42m/s"," 42 to 51m/s"," 51 or more"/), resLg)
amres = True
amres@amParallelPosF = 0.3
amres@amOrthogonalPosF = -0.3
dumLg = gsn_add_annotation(plot, lbid, amres)
dumDate = new(nrow,graphic)
resTx = True
resTx@txFontHeightF = 0.015
resTx@txFontColor = "black"
resTx@txJust = "BottomLeft"
do i = 0, nrow-1
if (HH(i) .ne. "00" ) then
continue
end if
dumDate(i) = gsn_add_text(wks,plot, MM(i)+DD(i), lon(i)+0.5, lat(i), resTx)
end do
draw(wks)
frame(wks)
end
|
|