爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 7333|回复: 5

求助:NCL绘制台风路径出错

[复制链接]

新浪微博达人勋

发表于 2017-6-12 11:03:08 | 显示全部楼层 |阅读模式
NCL
系统平台:
问题截图: -
问题概况: 我用WRF官网上WRF_track_1.ncl绘制台风路径时报错:fatal:Subscript out of range, error in subscript #0
fatal:An error occurred reading lon1d
fatal:["Execute.c":8575]:Execute: Error occurred at or near line 154 in file WRF_track_1.ncl
我看过提问的智慧: 看过
自己思考时长(天): 3

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

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

x
本帖最后由 15918702650 于 2017-6-12 11:07 编辑

我用WRF官网上WRF_track_1.ncl绘制台风路径时报错:fatal:Subscript out of range, error in subscript #0
fatal:An error occurred reading lon1d
fatal:["Execute.c":8575]:Execute: Error occurred at or near line 154 in file WRF_track_1.ncl
还有就是ii = ((/129,119,109/))  ; ilat
     jj = ((/110,110,110/))  ; jlon
这两行数字表示什么呢
脚本如下(154是我红色标出部分):
;********************************************************
; Plot storm stracks from wrfout files.
;********************************************************
;
; JUN-18-2005
; So-Young Ha (MMM/NCAR)
; SEP-01-2006
; Slightly modified by Mary Haley to add some extra comments.
; ===========================================

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/wrf/WRF_contributed.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"


begin

; DATES
  date = (/1300,1400,1500,1600,1700/)
  ndate = dimsizes(date)

  sdate = sprinti("%4.0i",date)

; Experiment name (for legend)
  EXP = (/"EXP_I"/)                ; (/"EXP_I","EXP_II","EXP_III"/)
  nexp = dimsizes(EXP)

; To get lat/lon info.

  a = addfile("wrfout_d01_1999-09-13_00:00:00.nc","r")

  lat2d = a->XLAT(0,:,:)
  lon2d = a->XLONG(0,:,:)
  dimll = dimsizes(lat2d)
  nlat  = dimll(0)
  mlon  = dimll(1)

; Sea Level Pressure
  slp = wrf_user_getvar(a,"slp",0)
  dims = dimsizes(slp)

; Array for track
  time = new(ndate,string)
  imin = new(ndate,integer)
  jmin = new(ndate,integer)
  smin = new(ndate,integer)

; =======
;  ndate
; =======
  fs = systemfunc("ls wrfout*00")
  nfs= dimsizes(fs)
  if(nfs .ne. ndate) then
     print("Check input data:"+nfs+" .ne. "+ndate)
  end if

  do ifs=0,nfs-1
    f = addfile(fs(ifs)+".nc","r")
    time(ifs) = wrf_user_list_times(f)
;    print(time(ifs))
    slp2d = wrf_user_getvar(f,"slp",0)

; We need to convert 2-D array to 1-D array to find the minima.
    slp1d     = ndtooned(slp2d)
    smin(ifs) = minind(slp1d)

; Convert the index for 1-D array back to the indeces for 2-D array.
    minij     = ind_resolve(ind(slp1d.eq.min(slp2d)),dims)
    imin(ifs) = minij(0,0)
    jmin(ifs) = minij(0,1)

;    print(time(ifs)+" : "+min(slp2d)+" ("+imin(ifs)+","+jmin(ifs)+")")
  end do
;

; Graphics section

  wks=gsn_open_wks("ps","track")              ; Open PS file.
  gsn_define_colormap(wks,"BlGrYeOrReVi200")  ; Change color map.

  res                     = True
  res@gsnDraw             = False             ; Turn off draw.
  res@gsnFrame            = False             ; Turn off frame advance.
  res@gsnMaximize         = True              ; Maximize plot in frame.

  res@tiMainString = "Hurricane Isabel"       ; Main title

  WRF_map_c(a,res,0)                          ; Set up map resources
                                              ;    (plot options)
  plot = gsn_csm_map(wks,res)                 ; Create a map.

; Set up resources for polymarkers.
  gsres                = True
  gsres@gsMarkerIndex  = 16                  ; filled dot
  ;gsres@gsMarkerSizeF = 0.005               ; default - 0.007
  cols                  = (/5,160,40/)

; Set up resources for polylines.
  res_lines                      = True
  res_lines@gsLineThicknessF     = 3.           ; 3x as thick

  dot  = new(ndate,graphic)    ; Make sure each gsn_add_polyxxx call
  line = new(ndate,graphic)    ; is assigned to a unique variable.

; Loop through each date and add polylines to the plot.
  do i = 0,ndate-2
     res_lines@gsLineColor           = cols(0)
     xx=(/lon2d(imin(i),jmin(i)),lon2d(imin(i+1),jmin(i+1))/)
     yy=(/lat2d(imin(i),jmin(i)),lat2d(imin(i+1),jmin(i+1))/)
     line(i) = gsn_add_polyline(wks,plot,xx,yy,res_lines)
  end do

  lon1d = ndtooned(lon2d)
  lat1d = ndtooned(lat2d)

; Loop through each date and add polymarkers to the plot.
  do i = 0,ndate-1
     print("dot:"+lon1d(smin(i))+","+lat1d(smin(i)))
     gsres@gsMarkerColor  = cols(0)
     dot(i)=gsn_add_polymarker(wks,plot,lon1d(smin(i)),lat1d(smin(i)),gsres)
  end do

; Date (Legend)
  txres               = True
  txres@txFontHeightF = 0.015
  txres@txFontColor   = cols(0)

  txid1 = new(ndate,graphic)
; Loop through each date and draw a text string on the plot.
  do i = 0, ndate-1
     txres@txJust = "CenterRight"
     ix = smin(i) - 4
     print("Eye:"+ix)
     if(i.eq.1) then
        txres@txJust = "CenterLeft"
        ix = ix + 8
     end if
     txid1(i) = gsn_add_text(wks,plot,sdate(i),lon1d(ix),lat1d(ix),txres)
  end do

; Add marker and text for legend. (Or you can just use "pmLegend" instead.)
  txres@txJust = "CenterLeft"

  txid2 = new(nexp,graphic)
  pmid2 = new(nexp,graphic)
  do i = 0,nexp-1
     gsres@gsMarkerColor  = cols(i)
     txres@txFontColor    = cols(i)
     ii = ((/91,92,137/))  ; ilat
     jj = ((/97,92,137/))  ; jlon
     ji = ii*mlon+jj         ; col x row
     pmid2(i) = gsn_add_polymarker(wks,plot,lon1d(ji(i)),lat1d(ji(i)),gsres)
     txid2(i) = gsn_add_text(wks,plot,EXP(i),lon1d(ji(i)+5),lat1d(ji(i)),txres)
  end do

  draw(plot)
  frame(wks)
end
搜狗截图20170612110538.png
搜狗截图20170612110941.png
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2017-7-5 09:29:07 | 显示全部楼层
七星飄一虫 发表于 2017-7-4 17:00
大神们看过来555求回复,我是一个菜鸟,写一篇论文要用NCL画一幅图,画全国300多个市某种气体的分布,我想 ...

去气象家园群里(176212282)问问,说不定有人能搞
本群创建于2012/3/22:  致力于学习中尺度大气模式和环评软件(加群请说出wrf3.4.1的边界层方案第一项是什么/wrf包括的投影系统都有哪几种,否则不予批准,谢谢!)      
密码修改失败请联系微信:mofangbao
回复 支持 1 反对 0

使用道具 举报

新浪微博达人勋

发表于 2017-6-12 12:35:44 | 显示全部楼层

回帖奖励 +1 金钱

这个脚本我用也有问题,一直提示第62行来是哪行来的左右维数不一致,改了几次都没成功就懒得改了。后来我把这个程序读懂之后自己仿照着写了一个出来,说白了这个程序就是在各个时刻找slp的最小值点所在的经纬度,画出一个折线出来,然后在每个点的附近把时间加上,最后画一个legend
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2017-6-12 14:55:53 | 显示全部楼层
snowie 发表于 2017-6-12 12:35
这个脚本我用也有问题,一直提示第62行来是哪行来的左右维数不一致,改了几次都没成功就懒得改了。后来我把 ...

可否分享下脚本,卡这好久了
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2017-7-4 17:00:36 | 显示全部楼层
大神们看过来555求回复,我是一个菜鸟,写一篇论文要用NCL画一幅图,画全国300多个市某种气体的分布,我想找个大神帮我画一下,自己实在没时间学这个软件也学不会,尝试过放弃了,哎,不知道找谁,或者有没有什么可以制图的公司啥的,网上也没找到,求支招,非常感谢
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2017-7-5 09:42:12 | 显示全部楼层
15918702650 发表于 2017-7-5 09:29
去气象家园群里(176212282)问问,说不定有人能搞
本群创建于2012/3/22:  致力于学习中尺度大气模式和 ...

太谢谢了,终于有人回复我了,我马上去加群,万分感谢
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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