请选择 进入手机版 | 继续访问电脑版
爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 8781|回复: 17

NCL画图 已解决

[复制链接]

新浪微博达人勋

发表于 2014-3-26 19:43:09 | 显示全部楼层 |阅读模式

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

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

x
本帖最后由 腐朽的我Zero 于 2014-3-27 10:03 编辑

file:///C:\Program Files\TENCENT\QQ\Users\841719192\Image\~%ZTLJ$DS6HZ]GC}RLL$K_9.jpg

错误显示

错误显示
不知道哪里错了!先谢了



;*************************************************
; WRF: near surface winds and total precipitation
;************************************************
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/wrf/WRF_contributed.ncl"
begin
;************************************************
; open file
; Read U10 and V10, Cumulus (rinc) and Non-cumulus (rainnc) prc
;************************************************
  f = addfile ("wrfout_d01_2009-07-02_00:00:00.nc", "r")
    o3 = f->o3   
    o3    = o3*1000
    o3@units  = "ppb"
    o3@description ="o3"   
  u10     = f->U10                   ; (Time, south_north, west_east)
  v10     = f->V10                    

  times   = chartostring(f->Times)   ; convert to type string [plot]
  ntim    = dimsizes(times)          ; # time steps



  ;************************************************
; create plots: create colormap using named colors
;************************************************
  wks = gsn_open_wks("pdf" ,"WRF_lc")           ; ps,pdf,x11,ncgm,eps

  colors = (/"white","black"          \        ; {fore/back}ground
            ,"white","azure"          \
            ,"green","palegreen","yellowgreen", "greenyellow" \
            ,"yellow","goldenrod","orange","orangered"        \
            ,"red","deeppinK", "violet","darkviolet"          \
            ,"blueviolet","blue"                              /)
  gsn_define_colormap(wks, colors)  

  res                       = True             ; plot mods desired
  res@gsnMaximize           = True             ; maximize size
  res@gsnSpreadColors       = True             ; use full range of colormap
  res@gsnScalarContour      = True               ; contours desired
  res@gsnLeftString         = "Wind Vectors (m/s)"
  res@gsnRightString        = "so2  ppbv"

  res@cnFillOn              = True             ; color plot desired
  res@cnLinesOn             = False            ; turn off contour lines
  res@cnLineLabelsOn        = False            ; turn off contour labels
  res@cnFillMode            = "RasterFill"     ; raster
  res@cnLevelSelectionMode  = "ExplicitLevels" ; explicit [unequal] cn levels
  res@cnLevels              = (/0,0.1,1,2.5,5,7.5,10,15,20,25,37.5,50,75,100,125,150/)

  res@vcGlyphStyle          = "WindBarb"
  res@vcRefLengthF          = 0.025            ; ref vec length
  res@vcMinDistanceF        = 0.025            ; larger means sparser
  res@vcWindBarbTickLengthF = 0.4              ; default 0.3
  res@vcRefAnnoOn           = False

  res@mpGeophysicalLineThicknessF = 2.0
  res@mpUSStateLineThicknessF     = 2.0
;************************************************
; Use WRF_contributed procedure to set map resources
;************************************************
  WRF_map_c(f, res, 0)                   ; reads info from file

;************************************************
; set True for native (direct) mapping (faster plotting)
; set False for non-native mappings
;************************************************
  res@tfDoNDCOverlay       = True

;************************************************
; associate the 2-dimensional coordinates to the variable for plotting
; only if not a native projection [  res@tfDoNDCOverlay=False ]
;************************************************
  if (.not.res@tfDoNDCOverlay) then
      lat2d   = f->XLAT(0,:,:)     
      lon2d   = f->XLONG(0,:,:)      

      u10@lat2d = lat2d
      u10@lon2d = lon2d
      v10@lat2d = lat2d
      v10@lon2d = lon2d

      o3@lat2d = lat2d
      o3@lon2d = lon2d
  end if

;****************************************************************************
; Plot one time and level for demo
; .  create u and v on a common grid for visualization: nothing fancy
;****************************************************************************
  nt = 12
;;do nt=0,ntim-1                               ; uncomment to loop
     res@tiMainString             = times(nt)
     plot = gsn_csm_vector_scalar_map(wks,u10(nt,:,:,:),v10(nt,:,:,:),o3(nt,:,:,:),res)
;;end do

end



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

新浪微博达人勋

发表于 2014-3-26 20:01:10 | 显示全部楼层
o3 = f->o3   
是四维数组 ?????????
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2014-3-26 20:06:03 | 显示全部楼层
前面的两个warning可能是因为你的NCARG_ROOT这个环境变量设置不正确。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2014-3-26 20:07:43 | 显示全部楼层
freekiller 发表于 2014-3-26 20:01
o3 = f->o3   
是四维数组 ?????????

对滴。。。脚本是网上的!!!不会改了,,,求救啊
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2014-3-26 20:08:18 | 显示全部楼层
longlivehj 发表于 2014-3-26 20:06
前面的两个warning可能是因为你的NCARG_ROOT这个环境变量设置不正确。

能具体点吗???
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2014-3-26 20:10:33 | 显示全部楼层
那个错误显示是3维的变量,你用了4个下标去索引。但是,从你的代码里面,没有发现有4个下标的数组索引啊!
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2014-3-26 20:12:36 | 显示全部楼层
longlivehj 发表于 2014-3-26 20:10
那个错误显示是3维的变量,你用了4个下标去索引。但是,从你的代码里面,没有发现有4个下标的数组索引啊!

意思是脚本就有问题吧,我就想出个每小时,第一层,含经纬度的o3浓度图!求相关脚本做参考,谢了
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2014-3-26 20:13:22 | 显示全部楼层
腐朽的我Zero 发表于 2014-3-26 20:07
对滴。。。脚本是网上的!!!不会改了,,,求救啊

plot = gsn_csm_vector_scalar_map(wks,u10(nt,:,:),v10(nt,:,:),o3(nt,:,:),res)
那为什么o3只给了3个下标?
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2014-3-26 20:16:48 | 显示全部楼层
本帖最后由 longlivehj 于 2014-3-26 20:18 编辑
腐朽的我Zero 发表于 2014-3-26 20:12
意思是脚本就有问题吧,我就想出个每小时,第一层,含经纬度的o3浓度图!求相关脚本做参考,谢了

level一般是第二维吧,那么应该是这样:
plot = gsn_csm_vector_scalar_map(wks,u10(nt,:,:),v10(nt,:,:),o3(nt,0,:,:),res)
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2014-3-26 20:18:32 | 显示全部楼层

你在终端里面运行两个命令
echo $NCARG_ROOT
which ncl
把结果贴出来再看吧!
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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