爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 9950|回复: 8

[作图] cl画风矢量图例受阻 向高手求教

[复制链接]

新浪微博达人勋

发表于 2012-10-26 16:29:18 | 显示全部楼层 |阅读模式

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

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

x
本帖最后由 tulipwaugh 于 2012-10-26 16:34 编辑

本人想将WRFDA同化出的数据与原始背景场做差值,画出风速增量的矢量图,但不知为何,表示单位长度箭头所表示风速大小的图例无法画出,特向高手求教。
以下为本人的ncl脚本:

load "$NCARG_ROOT/lib/ncarg/nclex/gsun/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"   

begin
  cdf_analysis = addfile("/home/wy/WRFDA_model/WRFDA/workdir/200804/2008040500/00d01/wrfvar_output.nc","r")
  cdf_bk = addfile("/home/wangy/WRFV3/test/em_real/wrfinput_d01.nc","r")
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; First get the variables we will need        
  it=0
  Za  = wrf_user_getvar(cdf_analysis, "z",0)        ; grid point height
  Zb  = wrf_user_getvar(cdf_bk, "z",0)        ; grid point height

  Ua = wrf_user_getvar(cdf_analysis,"ua",0)  ; u averaged to mass points
  Ub = wrf_user_getvar(cdf_bk,"ua",0)

  Va = wrf_user_getvar(cdf_analysis,"va",0)
  Vb = wrf_user_getvar(cdf_bk,"va",0)
  
; The specific height levels that we want the data interpolated to.
; And interpolate to these levels
  height_levels = (/1500.,3000.,5500./)            ; height levels to plot - in meter
  nlevels       = dimsizes(height_levels)     ; number of height levels
  refvec        = 3.                               ; value of reference vector
; We generate plots, but what kind do we prefer?
;  type = "x11"
; type = "pdf"
  type = "ps"
; type = "ncgm"
  wks = gsn_open_wks(type,"Wind_INCREMENT")
  gsn_define_colormap(wks,"RainBow")
; Set some basic resources
  res = True
  res@MainTitle = "REAL-TIME WRF"
  res@Footer = False
  res@pmLegendDisplayMode         = "Always"
  res@vcRefMagnitudeF             = refvec           ; make vectors larger
  res@vcRefLengthF                = 0.030            ; ref vector length
  res@vcGlyphStyle                = "CurlyVector"    ; turn on curly vectors
  res@vcMinDistanceF              = 0.018            ; thin the vectors
  res@vcRefAnnoOrthogonalPosF     = -0.125           ; move ref vector
;  res@lgOrientation               = "horizontal"
;  res@pmLegendWidthF              = 0.6
;  res@pmLegendHeightF             = 0.3
   res@mpOutlineOn                 = True             ; turn on map outline
;  res@lgTitleOn                   = True
;  res@lgTitleString               = "wind"
;  res@vcRefAnnoString2            = "m/s"           ; unit string
;  res@vcRefAnnoString2On          = True            ; turn on second string
  

  pltres = True
  mpres = True
  mpres@mpGeophysicalLineColor = "Black"
  mpres@mpNationalLineColor    = "Black"
  mpres@mpUSStateLineColor     = "Black"
  mpres@mpGridLineColor        = "Black"
  mpres@mpLimbLineColor        = "Black"
  mpres@mpPerimLineColor       = "Black"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; What times and how many time steps are in the data set?
  times = wrf_user_getvar(cdf_bk,"times",-1)  ; get all times in the file
  ntimes = dimsizes(times)         ; number of times in the file
it = 0
    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
      height = height_levels(level)
    ; Add some level into to the plot
      res@PlotLevelID = .001*height + " km"
    Ua_plane  = wrf_user_intrp3d( Ua,Za,"h",height,0.,False)
    Ub_plane  = wrf_user_intrp3d( Ub,Zb,"h",height,0.,False)
    Va_plane  = wrf_user_intrp3d( Va,Za,"h",height,0.,False)
    Vb_plane  = wrf_user_intrp3d( Vb,Zb,"h",height,0.,False)
    du_plane  = Ua_plane - Ub_plane  
    dv_plane  = Va_plane - Vb_plane
printMinMax(du_plane,True)
printMinMax(dv_plane,True)
;print(aaaaaaaaaaaaaa)

; Plotting options for Wind Vectors                 
      opts = res         
      opts@FieldTitle = "Increment of Wind"   ; overwrite Field Title
      opts@NumVectors = 57       ; wind barb density
      vector = wrf_vector(cdf_bk,wks,du_plane,dv_plane,opts)
;      delete(opts)

; MAKE PLOTS                                       
      plot = wrf_map_overlays(cdf_bk,wks,(/vector/),pltres,mpres)
    end do      ; END OF LEVEL LOOP
end


此处为该脚本出的图,共3张,只贴1张

111.JPG



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

新浪微博达人勋

发表于 2012-10-26 21:07:02 | 显示全部楼层
res@vcRefMagnitudeF=refvec  这句有问题
改为res@vcRefMagnitudeF=4.0  后面值的大小根据你的需要来设置
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2012-10-27 21:42:51 | 显示全部楼层

我的refvec在前面有定义,为3...除了这个没问题了?还是画不出啊?请教~~~
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2012-10-27 22:32:01 | 显示全部楼层
  res@vcRefAnnoOrthogonalPosF     = -0.125  这句话是改变箭头图列在图中位置的,估计是图列的位置不对。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2012-10-29 17:02:11 | 显示全部楼层
尽头的尽头 发表于 2012-10-27 22:32
res@vcRefAnnoOrthogonalPosF     = -0.125  这句话是改变箭头图列在图中位置的,估计是图列的位置不对。

我把这句注释掉之后依旧不行啊。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2013-1-10 21:26:01 | 显示全部楼层
我也遇到了同样的问题,请问你解决了么
?
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2013-1-16 12:15:14 | 显示全部楼层
可以问个小问题吗,画出来的图怎么才能复制黏贴出来啊
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2013-1-17 11:03:53 | 显示全部楼层
微博评论 发表于 2013-1-16 16:31
回复@路边摊1990:最好画成eps矢量图,用Adobe Illustrator打开,复制下就可以粘到word里,超级清晰!

来自 ...

谢谢啦,刚学ncl,这种小问题又不好意思专门开帖子问
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2013-3-1 19:31:56 | 显示全部楼层
vbop 发表于 2013-1-10 21:26
我也遇到了同样的问题,请问你解决了么
?

将 res@vcRefAnnoOn  = True 开关打开即可
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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