爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 7481|回复: 4

ncl画台风路径。。求大神改一个错误

[复制链接]

新浪微博达人勋

发表于 2018-4-4 20:52:00 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

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



密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2019-3-26 07:21:17 | 显示全部楼层
把下载的TXT文档 回车加一行,再保存试试
密码修改失败请联系微信:mofangbao
回复 支持 1 反对 0

使用道具 举报

新浪微博达人勋

发表于 2019-3-8 13:12:59 | 显示全部楼层
同求
密码修改失败请联系微信:mofangbao
回复

使用道具 举报

新浪微博达人勋

发表于 2020-11-1 14:07:17 | 显示全部楼层
请问有没有解决这个问题
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

发表于 2021-3-15 19:02:46 | 显示全部楼层

请问有没有解决这个问题
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表