爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 5865|回复: 4

新手求指导,NCL画图

[复制链接]
发表于 2017-5-8 17:38:44 | 显示全部楼层 |阅读模式

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

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

x
初学NCL,在官网上下了一个脚本运行试试,由于服务器装不了高版本的NCL,所以NCL的版本是5.1.0.
运行后提示错误如下:
" to ColorMapngToCmap:Unable to convert string "BlueWhiteOrangeRed
warning:Error retrieving resource wkColorMap from DB - Using default value
fatal:Either file (nc_file) isn't defined or variable (times) is not a variable in the file
fatal:Execute: Error occurred at or near line 1339 in file $NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl

fatal:Execute: Error occurred at or near line 62


换了脚本,还是提示这个错误,为什么呢?,求大神指导。

脚本如下:

;   Example script to produce plots for a WRF real-data run,
;   with the ARW coordinate dynamics option.

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
;
; The WRF ARW input file.  
; This needs to have a ".nc" appended, so just do it.
a=addfile("./wrfout_d01_2015-05-14_06_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_Surface1")

; Set some basic resources
  res = True
  res@MainTitle                   = "REAL-TIME WRF"

  pltres = True
  mpres = True


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

; 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

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

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

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


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

    slp = wrf_user_getvar(a,"slp",it)    ; slp
      wrf_smooth_2d( slp, 3 )            ; smooth slp
    tc = wrf_user_getvar(a,"tc",it)      ; 3D tc
    td = wrf_user_getvar(a,"td",it)      ; 3D td
    u  = wrf_user_getvar(a,"u",it)      ; 3D U at mass points
    v  = wrf_user_getvar(a,"v",it)      ; 3D V at mass points
    td2 =  wrf_user_getvar(a,"td2",it)   ; Td2 in C
    tc2 = wrf_user_getvar(a,"T2",it)     ; T2 in Kelvin
       tc2 = tc2-273.16                  ; T2 in C
    u10 = wrf_user_getvar(a,"U10",it)    ; u at 10 m, mass point
    v10 = wrf_user_getvar(a,"V10",it)    ; v at 10 m, mass point

    tf2 = 1.8*tc2+32.                    ; Turn temperature into Fahrenheit
      tf2@description = "Surface Temperature"
      tf2@units = "F"
    td_f = 1.8*td2+32.                   ; Turn temperature into Fahrenheit
      td_f@description = "Surface Dew Point Temp"
      td_f@units = "F"
    u10 = u10*1.94386                    ; Turn wind into knots
    v10 = v10*1.94386
      u10@units = "kts"
      v10@units = "kts"

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

    ; Plotting options for T               
      opts = res                        
      opts@cnFillOn = True  
      opts@ContourParameters = (/ -20., 90., 5./)
      opts@gsnSpreadColorEnd = -3  ; End third from the last color in color map
      contour_tc = wrf_contour(a,wks,x11,opts)
      delete(opts)


    ; Plotting options for Td
      opts = res         
      opts@cnFillOn = True
      opts@cnLinesOn = True
      opts@cnLineLabelsOn = True
      opts@ContourParameters = (/ -20., 90., 5./)
      opts@cnLineLabelBackgroundColor = -1
      opts@gsnSpreadColorEnd = -3  ; End third from the last color in color map
      contour_td = wrf_contour(a,wks,td_f,opts)
      delete(opts)


    ; Plotting options for SLP                     
      opts = res         
      opts@cnLineColor = "Blue"
      opts@cnHighLabelsOn = True
      opts@cnLowLabelsOn = True
      opts@ContourParameters = (/ 900., 1100., 4. /)
      opts@cnLineLabelBackgroundColor = -1
      opts@gsnContourLineThicknessesScale = 2.0
      contour_psl = wrf_contour(a,wks,slp,opts)
      delete(opts)

    ; Plotting options for Wind Vectors                 
      opts = res         
      opts@FieldTitle = "Wind"       ; overwrite Field Title
      opts@NumVectors = 47           ; density of wind barbs
      vector = wrf_vector(a,wks,u10,v10,opts)
      delete(opts)


    ; MAKE PLOTS                                       
      plot = wrf_map_overlays(a,wks,(/contour_tc,contour_psl,vector/),pltres,mpres)
      plot = wrf_map_overlays(a,wks,(/contour_td,vector/),pltres,mpres)

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

  end do        ; END OF TIME LOOP

end


file:///C:\Users\lenovo\AppData\Roaming\Tencent\Users\496014988\QQ\WinTemp\RichOle\RN@2143R_]JG1T66(N@{E{M.png

密码修改失败请联系微信:mofangbao
发表于 2017-5-8 17:45:42 | 显示全部楼层
type = "x11"
这个x11改成png试试
密码修改失败请联系微信:mofangbao
发表于 2017-5-8 17:46:37 | 显示全部楼层
本帖最后由 Soaring 于 2017-5-8 17:48 编辑

估计主要是版本原因吧,很多功能老版本不能实现(比如第一个提示色标不可用,还有缺少wrfuser这个库)还有,你有对应的WRF数据吗?
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2017-5-9 09:31:56 | 显示全部楼层
Soaring 发表于 2017-5-8 17:46
估计主要是版本原因吧,很多功能老版本不能实现(比如第一个提示色标不可用,还有缺少wrfuser这个库)还有 ...

我有对应的数据,我查了下库里面没有BlueWhiteOrangeRed.rgb这个文件,我估计是版本问题,那是不是老版本就不能用了啊~
密码修改失败请联系微信:mofangbao
发表于 2017-5-9 13:33:06 | 显示全部楼层
呼小喵喵 发表于 2017-5-9 09:31
我有对应的数据,我查了下库里面没有BlueWhiteOrangeRed.rgb这个文件,我估计是版本问题,那是不是老版本 ...

可以用,只是很多功能受限制,一般6.2.1以上版本功能基本都能用
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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