- 积分
- 36702
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2019-5-13
- 最后登录
- 1970-1-1
![[一大碗年糕ARS] 粉丝数:48 微博数:141 新浪微博达人勋](source/plugin/sina_login/img/light.png)
|
发表于 2021-8-14 20:55:34
|
显示全部楼层
回帖奖励 +10 金钱
本帖最后由 一大碗年糕 于 2021-8-14 20:58 编辑
单这样问也不太清楚。。之前参照别人的代码用台风所数据集画的,看看是不是打点部分有区别?
begin
;----------reading data-----------------
fiTY = "/home/ramsey/gs/data/TC/In-Fa.txt"
nrow = numAsciiRow(fiTY) ;读取txt中的总行数
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(:,4:5))
DD = chartostring(DateChar(:,6:7))
HH = chartostring(DateChar(:,8:9))
;HHi = mod(stringtoint(YYYYMMDDHH), 100)
;DDi = mod(stringtoint(YYYYMMDDHH)/100, 100)
;MMi = mod(stringtoint(YYYYMMDDHH)/10000, 100)
;--------------plot---------------------------
wks = gsn_open_wks("png", "track-In-Fa")
gsn_define_colormap(wks,"rainbow")
res = True
res@gsnDraw = False
res@gsnFrame = False
res@mpMinLatF = -10
res@mpMaxLatF = 40
res@mpMinLonF = 112
res@mpMaxLonF = 170
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
|
-
|