爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 5381|回复: 4

[作图] NCL一页多图总有error提示没定义变量

[复制链接]
发表于 2017-11-20 00:01:54 | 显示全部楼层 |阅读模式

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

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

x
各位大神,NCL刚入门,想画个多图,总提示我没定义这个变量,可是脚本根本没这个变量
begin
  diri  = "/home/zhangs/"
  files = systemfunc("ls " + diri + "*monthly.nc")
  f = addfiles(files,"r")


  wks = gsn_open_wks("png","CT2016")     
  gsn_define_colormap(wks,"BlueRed")

;;;;;;;;;2013;;;;;;;;;;
  it_s=201301
  it_e=201312

  time = f[:]->time
  YYYYMM = cd_calendar(time,-1)
  rec_s = ind(it_s.eq.YYYYMM)
  rec_e = ind(it_e.eq.YYYYMM)
  biofuel = f[:]->bio_flux_opt(rec_s:rec_e,:,:)

  aa = dim_sum_n_Wrap(biofuel,0)
  bb = aa*31536000
  a2013 = bb*12                      ; 1mol=12gC
  copy_VarMeta(aa,a2013)

;;;;;;;;;;2014;;;;;;;;;;;;
  it_s=201401
  it_e=201412

  time = f[:]->time
  YYYYMM = cd_calendar(time,-1)
  rec_s = ind(it_s.eq.YYYYMM)
  rec_e = ind(it_e.eq.YYYYMM)
  biofuel = f[:]->bio_flux_opt(rec_s:rec_e,:,:)

  aa = dim_sum_n_Wrap(biofuel,0)
  bb = aa*31536000
  a2014 = bb*12                      ; 1mol=12gC
  copy_VarMeta(aa,a2014)

;;;;;;;;;;;;;2015;;;;;;;;;;;;;;;;;;
  it_s=201501
  it_e=201512

  time = f[:]->time   
  YYYYMM = cd_calendar(time,-1)
  rec_s = ind(it_s.eq.YYYYMM)
  rec_e = ind(it_e.eq.YYYYMM)
  biofuel = f[:]->bio_flux_opt(rec_s:rec_e,:,:)

  aa = dim_sum_n_Wrap(biofuel,0)
  bb = aa*31536000
  a2015 = bb*12                      ; 1mol=12gC
  copy_VarMeta(aa,a2015)

  plot = new(3,"graphic")

  cmap  = read_colormap_file("gui_default")
  ncmap = dimsizes(cmap(:,0))
  res                 = True                                      
  res@gsnRightString  = "g/m2/yr"                 
  res@gsnCenterString = "2013"
  res@gsnCenterStringFontHeightF = 0.03  

  res@gsnDraw             = False            ; don't draw
  res@gsnFrame            = False            ; don't advance frame
  res@cnInfoLabelOn       = False            ; turn off cn info label
  res@lbLabelBarOn        = False            ; turn off individual cb's  

  res@cnLevelSelectionMode = "ExplicitLevels"
  res@cnLevels  =  (/-50,-40,-30,-20,-10,0,10,20,30,40,50/)
  res@cnFillColors = (/2,7,18,25,43,56,123,145,171,189,207,238/)

  plot(0) = gsn_csm_contour_map(wks,a2013,res)
  plot(1) = gsn_csm_contour_map(wks,a2014,res)
  plot(2) = gsn_csm_contour_map(wks,a2015,res)

;************************************************
; create panel
;************************************************
  resP                  = True                   ; modify the panel plot
  resP@gsnFrame         = False                  ; don't advance panel plot
  resP@gsnPanelLabelBar = True                   ; add common colorbar
  resP@gsnPanelMainString = "CT2016"     ; new way of setting main title (as of NCL V6.4.0)
; resP@txString           = "A common title"     ; old way of setting main title
  resP@gsnPanelBottom   = 0.05                   ; add space at bottom
  resP@gsnPanelFigureStrings= (/"2013)","2014)","2015)"/) ; add strings to panel
  resP@amJust   = "TopLeft"
  gsn_panel(wks,plot,(/3,1/),resP)               ; now draw as one plot


end


QQ图片20171121223043.png
密码修改失败请联系微信:mofangbao
发表于 2017-11-20 11:02:47 | 显示全部楼层
本帖最后由 刘勇的下铺 于 2017-11-20 11:03 编辑

楼主把gsn_panel(wks,plot,(/3,1/),resP)这个改成gsn_panel(wks,plot(0,2),(/3,1/)resP)试试
密码修改失败请联系微信:mofangbao
发表于 2017-11-20 11:03:33 | 显示全部楼层
楼主把gsn_panel(wks,plot,(/3,1/),resP)这个改成gsn_panel(wks,plot(0,2),(/3,1/)resP)试试
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2017-11-20 16:31:22 | 显示全部楼层
还是不行呢,大神
fatal:syntax error: line 89 in file sum.ncl before or near resP
  gsn_panel(wks,plot(0,2),(/3,1/)resP
------------------------------------^

fatal:error in statement
fatal:Syntax Error in block, block not executed
fatal:error at line 90 in file sum.ncl
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2017-11-20 20:49:23 | 显示全部楼层
啊... 把脚本让同学给运行,结果就好了,但是只能是黑白的图...  不能彩色,可是明明设置过color的
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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