爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 13071|回复: 7

NCL画图

[复制链接]
发表于 2012-10-13 17:00:53 | 显示全部楼层 |阅读模式

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

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

x
想画一个温度在高度上的插值,可是总是提示有错,大家帮我看看,谢谢啦。错误提示是
[img]file:///C:\Users\sparrow\AppData\Roaming\Tencent\Users\245450868\QQ\WinTemp\RichOle\J%AQXZ_KF3V[9PYODKY@]8L.jpg[/img]


[img]file:///C:\Users\sparrow\AppData\Roaming\Tencent\Users\245450868\QQ\WinTemp\RichOle\J%AQXZ_KF3V[9PYODKY@]8L.jpg[/img]

fatal:Number of subscripts do not match number of dimensions of variable,(4) Subscripts used, (3) Subscripts expectedfatal:Execute: Error occurred at or near line 107 in file wrf_Heightoverlay-TZ.ncl

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"

begin
;
; The WRF ARW input file.  
; This needs to have a ".nc" appended, so just do it.
  a = addfile("/disk1/guocw/WRF/WRFV3/test/em_real/data34/wrfout_d01_2009-04-28_18:00:00.nc","r")

; We generate plots, but what kind do we prefer?
  type = "x11"
; type = "pdf"
  type = "ps"
; type = "ncgm"
  wks = gsn_open_wks(type,"plt_HeightLeveloverlayT")


; Set some basic resources
  res = True

  res@MainTitle = "REAL-TIME WRF"
  res@Footer = False

  pltres = True

  mpres = True

  mpres@mpDataBaseVersion="MediumRes"
  mpres@mpDataSetName="Earth..4"
  mpres@mpOutlineSpecifiers="China:Provinces"
  mpres@mpGeophysicalLineColor = "Black"
  mpres@mpNationalLineColor    = "Black"
  mpres@mpUSStateLineColor     = "Black"
  mpres@mpGridLineColor        = "Black"
  mpres@mpLimbLineColor        = "Black"
  mpres@mpPerimLineColor       = "Black"
  mpres@mpGridAndLimbOn        =  False

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; What times and how many time steps are in the data set?
  times = wrf_user_getvar(a,"times",-1)  ; get all times in the file
  ntimes = dimsizes(times)         ; number of times in the file

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; First get the variables we will need        

    tc = wrf_user_getvar(a,"tc",-1)        ; T in C
    u  = wrf_user_getvar(a,"ua",-1)        ; u averaged to mass points
    v  = wrf_user_getvar(a,"va",-1)        ; v averaged to mass points
    p  = wrf_user_getvar(a, "pressure",-1) ; pressure is our vertical coordinate
    z  = wrf_user_getvar(a, "z",-1)        ; grid point height
    ;z  =z*0.1;
    rh = wrf_user_getvar(a,"rh",-1)        ; relative humidity

; The specific height levels that we want the data interpolated to.
; And interpolate to these levels
  z_levels = (/ 1000./)
; height levels to plot - in meter
  nlevels       = dimsizes(z_levels)     ; number of height levels

  ;z_plane  = wrf_user_intrp3d( z,p,"h", pressure_levels,0.,False)
  tc_plane = wrf_user_intrp3d(tc,z,"h", z_levels,0.,False)
  rh_plane = wrf_user_intrp3d(rh,z,"h", z_levels,0.,False)
  u_plane  = wrf_user_intrp3d( u,z,"h", z_levels,0.,False)
  v_plane  = wrf_user_intrp3d( v,z,"h", z_levels,0.,False)
  p_plane=wrf_user_intrp3d( p,z,"h", z_levels,0.,False)

  ;u_plane = u_plane*1.94386     ; kts
  ;v_plane = v_plane*1.94386     ; kts
    ;u_plane@units = "kts"
    ;v_plane@units = "kts"

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

  do it = 0,ntimes-1,1             ; TIME LOOP

    print("Working on time: " + times(it) )
    res@TimeLabel = times(it)   ; Set Valid time to use on plots


    do level = 0,nlevels-1                 ; LOOP OVER LEVELS

z = z_levels(level)

    ; Add some level into to the plot
      res@PlotLevelID =z+ "m"



    ; Plotting options for T               
      opts = res  
      opts@gsnFrame         = False                 ; don't advance frame yet
      opts@gsnDraw         = False                 ; don't draw yet
      opts@cnFillOn=True                  
      opts@cnLineColor = "Red"
      opts@ContourParameters = (/ 1.0 /)
      opts@cnInfoLabelOrthogonalPosF = 0.02  ; offset second label information
      opts@gsnContourLineThicknessesScale = 4.0
      contour_tc = wrf_contour(a,wks,tc_plane(it,level,:,:),opts)
      delete(opts)


    ; Plotting options for Pressure
      opts = res  
      opts@gsnFrame         = False                 ; don't advance frame yet
      opts@gsnDraw         = False                 ; don't draw yet

      opts@cnLineColor = "Black"
      opts@ContourParameters = (/ 2.0 /)
      opts@gsnContourLineThicknessesScale =4.0
      contour_p = wrf_contour(a,wks,p_plane(it,level,:,:),opts)
      delete(opts)






    ; Plotting options for Wind Vectors                 
      opts = res  
      opts@gsnFrame         = False                 ; don't advance frame yet
      opts@gsnDraw         = False                 ; don't draw yet

      opts@FieldTitle = "Wind"   ; overwrite Field Title
      opts@NumVectors = 47       ; wind barb density
      vector = wrf_vector(a,wks,u_plane(it,level,:,:),v_plane(it,level,:,:),opts)
      delete(opts)


    ; MAKE PLOTS                                       
      plot = wrf_map_overlays(a,wks,(/contour_tc,contour_p, \
                                vector/),pltres,mpres)
lats = (/41.2,  41.2,  41.4, 41.4, 41.2/)
      lons = (/114.6, 114.8, 114.8, 114.6, 114.6/)

     resp                  = True                      ; polyline mods desired
     resp@gsLineColor      = "Blue"                     ; color of lines
     resp@gsLineThicknessF = 3                       ; thickness of lines
     resp@gsLineLabelString= ""                    ; adds a line label string
     resp@gsLineDashPattern=1   

     dum=gsn_add_polyline(wks,plot,lons,lats,resp)

     draw(plot)
     frame(wks)




    end do      ; END OF LEVEL LOOP

  end do        ; END OF TIME LOOP
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;





end


J%AQXZ_KF3V[9PYODKY@]8L.jpg
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2012-10-14 20:02:55 | 显示全部楼层
木有人回答吗  啊啊啊啊
密码修改失败请联系微信:mofangbao
发表于 2012-11-21 17:28:45 | 显示全部楼层
密码修改失败请联系微信:mofangbao
发表于 2013-5-6 21:31:15 | 显示全部楼层
问题解决了吗  我也遇到了
密码修改失败请联系微信:mofangbao
发表于 2014-4-11 10:20:43 | 显示全部楼层
必须在这标记一下,总是遇到问题,不知道怎么解决
密码修改失败请联系微信:mofangbao
发表于 2014-4-11 10:25:58 | 显示全部楼层
The error is telling you exactly what's wrong. You are treating a variable as if it had 3 dimensions, when it really has 4 dimensions.

You should use "printVarSummary" in cases like this, to see what your variable looks like:

   printVarSummary(zz)

Also, you probably don't need to loop calculate zmax. If you really did have just three dimensions, you could use:

   zmax = max(zz(:,1,1))

Also, don't forget that NCL array indexing is 0-based. If you want the first elements of the rightmost two dimensions, you would use:

   zmax = max(zz(:,0,0))

It looks like "zz" is 4D, so please correct the subscripting appropriately.
密码修改失败请联系微信:mofangbao
发表于 2014-7-10 20:25:57 | 显示全部楼层
lisixiuhe 发表于 2014-4-11 10:25
The error is telling you exactly what's wrong. You are treating a variable as if it had 3 dimensions ...

请问您是在哪里查到的呢?
密码修改失败请联系微信:mofangbao
发表于 2015-7-29 15:17:29 | 显示全部楼层
字面意思是四维数组被硬当成三维数组处理了吗
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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