爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 12235|回复: 3

求一个画WRFout台风路径的NCL脚本,不要官网的,要自己写的好用的!!谢谢!

[复制链接]

新浪微博达人勋

发表于 2017-5-25 21:51:19 | 显示全部楼层 |阅读模式
3金钱
利用WRF模拟台风,想用NCL台风路径
求一个画wrfout_d0*_2012_**_**_**:00:00台风路径的NCL脚本,不要官网的,要自己写的、好用的,最好带注释的!!谢谢!
下面这两个是官网给出的脚本及应用,改了几天了,一直出错,一方面赶时间,另外也实在没耐心了,因此来求一个。先谢啦~
官网链接如下,有耐心的童鞋可以试试。
http://www2.mmm.ucar.edu/wrf/OnLineTutorial/Graphics/NCL/Examples/SPECIAL/wrf_Vortex.htm
http://www.ncl.ucar.edu/Applications/wrftrack.shtml

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

新浪微博达人勋

发表于 2017-5-25 21:51:20 | 显示全部楼层
本帖最后由 sun_shine_Xia 于 2017-5-28 10:14 编辑
  1. ;*********************************************
  2. ; route.ncl
  3. ;*********************************************
  4. load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
  5. load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
  6. load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
  7. load "/nuist/scratch/Xiayang/regcm_output/work/picture/cnmap/cnmap.ncl"

  8. begin

  9.   lines = new((/29,4/),"float")
  10.   
  11.   lines = asciiread("real_route.txt",(/29,4/),"float") ;以字符串形式读取参数文件入数组argu
  12.    t   = lines(:,0)                                     ;从数组lines中获取时间
  13.   lat  = lines(:,1)                                     ;从数组lines中获取经度值lon
  14.   lon  = lines(:,2)                                     ;从数组lines中获取纬度值lat
  15.   cslp = lines(:,3)
  16.   times= flt2string(t)
  17.   ;print(times)

  18. ;***************** DATES ******************************
  19.   ndate = dimsizes(t)
  20.   
  21.     f   = addfile("../wrfout_d02_2014-09-14_00:00:00.nc","r")
  22.   lat2d = f->XLAT(0,:,:)
  23.   lon2d = f->XLONG(0,:,:)
  24.    times1 = wrf_user_getvar(f,"times",-1)  ; get all times in the file
  25.   print(times1)
  26.    slp  = wrf_user_getvar(f,"slp",-1)
  27.    dims = dimsizes(slp(0,:,:))
  28.   printVarSummary(slp)

  29. ; Array for track
  30.    time = new(79,string)
  31.    imin = new(79,integer)
  32.    jmin = new(79,integer)
  33.    smin = new(79,integer)
  34.    slpmin = new(79,float)
  35. ;***************************
  36. ;  ndate
  37. ; ***************************

  38.   do ifs=0,78
  39.     slp2d = wrf_user_getvar(f,"slp",ifs)

  40. ; We need to convert 2-D array to 1-D array to find the minima.
  41.     slp1d     = ndtooned(slp2d)
  42.     smin(ifs) = minind(slp1d)
  43.     slpmin(ifs)= min(slp1d)
  44. ; Convert the index for 1-D array back to the indeces for 2-D array.
  45.     minij     = ind_resolve(ind(slp1d.eq.min(slp2d)),dims)
  46.     imin(ifs) = minij(0,0)
  47.     jmin(ifs) = minij(0,1)
  48.   end do

  49. ;***********************************************
  50.   wks = gsn_open_wks("pdf","route2")               
  51.      gsn_define_colormap(wks,"WhiteBlueGreenYellowRed")
  52.   
  53.   res                   = True
  54.   res@gsnDraw           = False    ; will panel later
  55.   res@gsnFrame          = False    ; will panel later

  56.   res@mpLimitMode       = "LatLon"  
  57.   res@mpMinLatF         = 12
  58.   res@mpMaxLatF         = 28
  59.   res@mpMinLonF         = 95
  60.   res@mpMaxLonF         = 125
  61.   res@mpCenterLonF      = 110
  62.   res@gsnMajorLatSpacing= 4
  63.   res@gsnMajorLonSpacing= 5
  64.   res@gsnMinorLatSpacing= 2
  65.   res@gsnMinorLonSpacing= 5
  66.   res@tmXBLabelFontHeightF = 0.0175
  67.   res@tmYLLabelFontHeightF = 0.0175
  68.   
  69.   
  70.   ;res@gsnAddCyclic      = False

  71.   res@mpFillOn                = False
  72.   res@mpFillDrawOrder         = "PreDraw"
  73.   res@mpOutlineOn             = True
  74.   res@mpDataBaseVersion       = "MediumRes"
  75.   res@mpDataSetName           = "Earth..4"
  76.   ;res@mpAreaMaskingOn         = True
  77.   ;res@mpMaskAreaSpecifiers    = (/"China","Taiwan","Disputed area between India and China","India:Arunachal Pradesh"/)
  78.   res@mpLandFillColor         = -1
  79.   res@mpInlandWaterFillColor  = -1
  80.   res@mpOceanFillColor        = -1
  81.   ;res@mpOutlineBoundarySets   = "NoBoundaries"

  82.   cnres           = True
  83.   cnres@china     = True       ;draw china map or not
  84.   cnres@river     = False       ;draw changjiang&huanghe or not
  85.   cnres@province  = True       ;draw province boundary or not
  86.   cnres@nanhai    = False       ;draw nanhai or not
  87.   cnres@diqu      = False       ; draw diqujie or not


  88.   plot = gsn_csm_map_ce(wks,res)


  89. ;***********************************************
  90. ;            添加观测台风中心标示
  91. ;***********************************************
  92.    txres                 = True
  93.    txres@txFont          = 137
  94.    txres@txFontHeightF   = 0.025
  95.    txres@txFontThicknessF= 4.0
  96.    txres@txFontColor     = "black"
  97.   do i = 10,28,4
  98.     text=gsn_add_text(wks,plot,"p",lon(i),lat(i),txres)
  99.   delete(text)
  100.   end do
  101.     text=gsn_add_text(wks,plot,"p",lon(28),lat(28),txres)
  102.    
  103. ;************************************************
  104. ; add the Line
  105. ;************************************************
  106.   resp                  = True                      ; polyline mods desired
  107.   resp@gsLineColor      = "black"                     ; color of lines
  108.   resp@gsLineThicknessF = 5.0                       ; thickness of lines
  109.   resp@gsLineLabelString= ""
  110.   
  111.     gsn_polyline(wks,plot,lon(10:28),lat(10:28),resp)     

  112.   delete(resp)
  113.   
  114.   
  115. ;************************************************
  116. ; add the Time
  117. ;************************************************  
  118.    tres                 = True
  119.    tres@txFont          = 25
  120.    tres@txFontHeightF   = 0.0175
  121.    tres@txFontThicknessF= 5
  122.     do i = 10,28,4                 
  123.         text=gsn_add_text(wks,plot,times(i),lon(i),lat(i)+1.8,tres)
  124.     delete(text)
  125.     end do
  126.         text=gsn_add_text(wks,plot,times(28),lon(28)-1,lat(28)+1.8,tres)
  127.     delete(text)
  128.    
  129. ;************************************************
  130. ; add the (a)
  131. ;************************************************  
  132.    tres@txFontHeightF   = 0.0225
  133.    text=gsn_add_text(wks,plot,"(a)",96,27,tres)

  134. ;************************************************
  135. ; add the simulaton line
  136. ;************************************************   
  137.   
  138.    resp                  = True                      ; polyline mods desired
  139.    resp@gsLineColor      = "red"                     ; color of lines
  140.    resp@gsLineThicknessF = 5.0                       ; thickness of lines
  141.    resp@gsLineLabelString= ""
  142.    
  143.    tres@txFontHeightF   = 0.02
  144.    tres@txFontColor     = "red"
  145.    txres@txFontColor    = "red"
  146.      j=10
  147.   do i = 24,77
  148.      xx=(/lon2d(imin(i),jmin(i)),lon2d(imin(i+1),jmin(i+1))/)
  149.      yy=(/lat2d(imin(i),jmin(i)),lat2d(imin(i+1),jmin(i+1))/)
  150.        gsn_polyline(wks,plot,xx,yy,resp)
  151.      
  152.      if(.not.mod(i,12))then
  153.        text1 = gsn_add_text(wks,plot,times(j),lon2d(imin(i),jmin(i)),lat2d(imin(i),jmin(i))-2,tres)
  154.       
  155.        text2 = gsn_add_text(wks,plot,"p",lon2d(imin(i),jmin(i)),lat2d(imin(i),jmin(i)),txres)   
  156.        j=j+4
  157.        delete(text1)
  158.        delete(text2)     
  159.      end if
  160.   end do
  161.        i = 78
  162.        text1 = gsn_add_text(wks,plot,times(28),lon2d(imin(i),jmin(i))-1,lat2d(imin(i),jmin(i))-2,tres)
  163.        text2 = gsn_add_text(wks,plot,"p",lon2d(imin(i),jmin(i)),lat2d(imin(i),jmin(i)),txres)

  164.    print(slpmin)  
  165.   
  166.    write_table("simu_route.txt","w",[/times1(24),lat2d(imin(24),jmin(24)),lon2d(imin(24),jmin(24)),slp(24,imin(24),jmin(24))/],"%s %6.1f %6.1f %7.1f")
  167.   do i=0,78,3
  168.    write_table("simu_route.txt","a",[/times1(i),lat2d(imin(i),jmin(i)),lon2d(imin(i),jmin(i)),slp(i,imin(i),jmin(i))/],"%s %6.1f %6.1f %7.1f")
  169.   end do
  170.       
  171. ;************************************************
  172. ; add the China map
  173. ;************************************************   
  174.   chinamap = add_china_map(wks,plot,cnres)

  175.   tres@txFontHeightF    = 0.0165
  176.   txres@txFontHeightF   = 0.0172
  177.   txres@txFontThicknessF= 3.0      
  178.     lgtext1  = gsn_add_text(wks,plot,"p",99,16,txres)
  179.     lgtext11 = gsn_add_text(wks,plot,"Simulation",102,16,tres)
  180.    
  181.   txres@txFontColor     = "black"
  182.   tres@txFontColor      = "black"
  183.     lgtext2 = gsn_add_text(wks,plot,"p",99,14.3,txres)
  184.     lgtext22 = gsn_add_text(wks,plot,"Observation",102.2,14.3,tres)         
  185.          
  186.   draw(plot)
  187.   frame(wks)
  188. end
复制代码
密码修改失败请联系微信:mofangbao
回复

使用道具 举报

新浪微博达人勋

 楼主| 发表于 2017-5-26 00:26:37 | 显示全部楼层
sun_shine_Xia 发表于 2017-5-25 23:50
画出来就是上面这样的。红色的就是从模式读出来的台风中心路径

请问:
(1)第11行中,29,4是什么意思?
(2)第13行中,real_route.txt是什么文件?
(3)第34-38行中,79是什么意思?
谢谢!
密码修改失败请联系微信:mofangbao
回复

使用道具 举报

新浪微博达人勋

 楼主| 发表于 2017-5-26 16:39:05 | 显示全部楼层
sun_shine_Xia 发表于 2017-5-25 23:50
画出来就是上面这样的。红色的就是从模式读出来的台风中心路径

谢谢,这几个数基本上都猜出来了
密码修改失败请联系微信:mofangbao
回复

使用道具 举报

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

本版积分规则

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

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

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