爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 10235|回复: 6

画矢量图维度不匹配

[复制链接]

新浪微博达人勋

发表于 2014-4-17 11:55:42 | 显示全部楼层 |阅读模式
NCL
系统平台:
问题截图: -
问题概况: 在官网上找到画垂直矢量的例子,自己加了个时间循环,提示维度不匹配,自己看了半天都没看出来什么原因,请大家帮忙看看
我看过提问的智慧: 看过
自己思考时长(天): 1

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

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

x
在官网上找到画垂直矢量的例子,自己加了个时间循环,提示维度不匹配,自己看了半天都没看出来什么原因,旁观者清,请大家帮忙看看。还有这个 w       = f->W(it,:,0,:)              ; import data + meta info

我把0改成70,是不是就把剖面改成south_north的第70个格点了呢?不是很懂
错误提示:
(0)     Working on time: 2010-07-25_06:00:00
warning:VarVarWrite: Dimension names for dimension number (0) don't match, assigning name of rhs dimension to lhs and overwriting coordinate variable, use "(/../)" if this change is not desired
warning:VarVarWrite: rhs has no coordinate variable for dimension number (1), destroying coordinate var,  use "(/../)" if this is not desired outcome
warning:["Execute.c":8567]:Execute: Error occurred at or near line 28 in file /home/Huanglei/WRF_2d_4.ncl
第28行就是  w       = f->W(it,:,0,:)              ; import data + meta info
脚本:

;********************************************************
; WRF: vector overlaid upon a contour of a scalar field
;********************************************************
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/WRFUserARW.ncl"
begin
;********************************************************
; open file
;********************************************************
  f = addfile ("/home/Huanglei/data/d03"+".nc","r")
;********************************************************
; Read character variable Times
; Convert to type string for plotting purposes
;********************************************************
  ;times   = chartostring(f->Times)     ; built-in function
; What times and how many time steps are in the data set?
  times = wrf_user_getvar(f,"times",-1)  ; get all times in the file
  ntimes = dimsizes(times)         ; number of times in the file
do it = 2,ntimes-1        ; TIME LOOP

    print("Working on time: " + times(it) )
  ;  res@TimeLabel = times(it)   ; Set Valid time to use on plots
;********************************************************
; Read W at Time=6, south_north=0, convert to cm/sec
;********************************************************
  w       = f->W(it,:,0,:)              ; import data + meta info
  w       = w*100.                     ; demo: convert to cm/s
  w@units = "cm/s"                     ; update units attribute

  dimw    = dimsizes(w)                ; get dimensions
  mx      = dimw(1)

;********************************************************
; Associate vertical and horizontal coords to w
;********************************************************
  znw     = f->ZNW(it,:)                ; znw(bottom_top_stag)
  w!0     = "znw"
  w&znw   =  znw                       ; assign values to named dimensions

  dx      = f@DX/1000.                 ; dx (km)
  west_east = ispan(0,mx-1,1)*dx       ; calculate x values
  west_east@long_name = "west_east"
  west_east@units = "km"
  w&west_east     = west_east          ; associate "x" values with w
  printVarSummary (w)

;********************************************************
; create a bogus wind array with all values 0.0
;********************************************************
  u = w
  u = 0.0
;********************************************************
; create plots  
;********************************************************
  wks = gsn_open_wks("pdf" ,"WRF_2d")          ; ps,pdf,x11,ncgm,eps
  gsn_define_colormap(wks,"BlWhRe")           ; select color map

  res                       = True            ; plot mods desired
;;res@gsnMaximize           = True            ; uncomment to maximize size
  res@trYReverse            = True            ; reverse to go bot[1.0 to top [0.0]
  res@tiMainString          = times(it)        ; main title

  res@vcRefMagnitudeF          = 150.            ; define vector ref mag
  res@vcRefLengthF             = 0.0080          ; define length of vec ref
  res@vcLineArrowHeadMaxSizeF  = 0.0075          ; default: 0.05 (LineArrow), 0.012 (CurlyVector)
  plot                      = gsn_csm_vector(wks,u(::2,::4),w(::2,::4),res)

  res@vcRefAnnoOrthogonalPosF  = -0.18           ; move ref vector
  res@vcMinDistanceF           = 0.02            ; larger means sparser
  plot                      = gsn_csm_vector(wks,u(::2,::4),w(::2,::4),res)
end do
end


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

新浪微博达人勋

发表于 2014-4-17 12:09:11 | 显示全部楼层
w       = f->W(it,:,0,:)
这句等号前加个冒号!
w       := f->W(it,:,0,:)
密码修改失败请联系微信:mofangbao
回复 支持 1 反对 0

使用道具 举报

新浪微博达人勋

发表于 2014-4-17 16:16:17 | 显示全部楼层
黄小仙儿 发表于 2014-4-17 15:42
而且改了之后只有最后一个时次的两张图,我frame(wks)后还是不行

检查循环设置,就是do后面的部分。我这边没有问题,出图数量上是对的。
密码修改失败请联系微信:mofangbao
回复 支持 1 反对 0

使用道具 举报

新浪微博达人勋

发表于 2014-4-17 12:12:50 | 显示全部楼层
本帖最后由 longlivehj 于 2014-4-17 12:17 编辑

原因是你w!0     = "znw"改动了w的第一维的名称,下次循环到w       = f->W(it,:,0,:)时就会和W(it,:,0,:)的第一维名称不同,ncl要用等号右边变量的信息覆盖左边变量时就出现这样的warning。
密码修改失败请联系微信:mofangbao
回复 支持 1 反对 0

使用道具 举报

新浪微博达人勋

 楼主| 发表于 2014-4-17 15:21:15 | 显示全部楼层
longlivehj 发表于 2014-4-17 12:12
原因是你w!0     = "znw"改动了w的第一维的名称,下次循环到w       = f->W(it,:,0,:)时就会和W(it,:,0,:) ...

那这个冒号的作用的是?
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2014-4-17 15:42:01 | 显示全部楼层
黄小仙儿 发表于 2014-4-17 15:21
那这个冒号的作用的是?

而且改了之后只有最后一个时次的两张图,我frame(wks)后还是不行
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2014-4-17 16:15:38 | 显示全部楼层
黄小仙儿 发表于 2014-4-17 15:21
那这个冒号的作用的是?

reassignment,可以理解为把w删了重新赋值。具体看看ncl官网吧!
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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