爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 5720|回复: 3

用ncl画图时出图全是单张的,并且乱码。求问大神为什么。。

[复制链接]

新浪微博达人勋

发表于 2020-6-25 12:39:37 | 显示全部楼层 |阅读模式

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

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

x
别人的脚本我用了,他能够画出来,我就改了下路径,但是图画出来完全一张一张的。之前下载官网的脚本也是这样,到现在没找到原因,求大神解答!!!

这个是我的脚本:

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"

begin


a = addfile("./wrfout_d01_2017-07-01_00:00:00.nc","r")
  type = "eps"
  type@wkPaperWidthF = 8.3
  type@wkPaperHeightF = 11.7
  wks = gsn_open_wks(type,"wind_shade")
; wks = gsn_open_wks(type,"outputd02")


; Set some Basic Plot options
  res = True
  res@MainTitle = "REAL-TIME WRF"
  res@vpWidthF = 0.7
  res@vpHeightF = 0.4

  pltres = True
  mpres = True
  mpres0 = True
  mpres0@mpGeophysicalLineColor = "Black"
  mpres0@mpNationalLineColor    = "Black"
  mpres0@mpUSStateLineColor     = "Black"


;@mpGeophysicalLineColor      = "Black"  ; Overwrite basic map settings
  mpres@mpGridLineColor             = "Black"
  mpres@mpLimbLineColor             = "Black"
  mpres@mpNationalLineColor         = "Black"
  mpres@mpPerimLineColor            = "Black"
  mpres@mpUSStateLineColor          = "Black"
  mpres@mpDataSetName          = "Earth..4"   ; This new database contains
                                           ; divisions for other countries.
  mpres@mpDataBaseVersion      = "MediumRes"  ; Medium resolution database
  mpres@mpOutlineOn            = True         ; Turn on map outlines
  mpres@mpOutlineSpecifiers    = (/"China:states","Taiwan"/)       ;China:states
;;;;;;;;;;;;
;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

; What levels and how many are in the data set?
  pressure_levels = (/ 850., 700., 500., 300., 100./)   ; pressure levels to plot
  nlevels         = dimsizes(pressure_levels)           ; number of pressure levels


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  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        
    z  = wrf_user_getvar(a, "z",it)        ; grid point height
    u  = wrf_user_getvar(a,"ua",it)        ; u averaged to mass points
    v  = wrf_user_getvar(a,"va",it)        ; v averaged to mass points
    p  = wrf_user_getvar(a, "pressure",it) ; pressure is our vertical coordinate
    z  = wrf_user_getvar(a, "z",it)        ; grid point height
      spd = (u*u + v*v)^(0.5)             ; speed in m/sec
      spd@description = "Wind Speed"
      spd@units = "m/s"
      u = u*1.94386                       ; winds now in kts
      v = v*1.94386                       ; winds now in kts
      u@units = "kts"
      v@units = "kts"

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
do level = 0,nlevels-1                 ; LOOP OVER LEVELS

      pressure = pressure_levels(level)
      z_plane  = wrf_user_intrp3d( z,p,"h",pressure,0.,False)   
      u_plane  = wrf_user_intrp3d( u,p,"h",pressure,0.,False)
      v_plane  = wrf_user_intrp3d( v,p,"h",pressure,0.,False)

      u_plane = u_plane*1.94386     ; kts
      v_plane = v_plane*1.94386     ; kts
      u_plane@units = "kts"
      v_plane@units = "kts"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

      ; Add some level info to the plot
        res@PlotLevelID = pressure + " hPa"


     ; Wind Vectors and Speed
       opts = res
       opts@ContourParameters = (/1., 25., 3. /)
       opts@cnFillOn          = True
       opts@cnFillColors= (/"White","White","White", "White","Chartreuse","ForestGreen", "Yellow","Orange","Red","Violet"/)
       contour = wrf_contour(a,wks,spd(level,:,:),opts)
       delete(opts)

       opts = res
       opts@FieldTitle        = "Wind"       ; Overwrite Field Title
       opts@NumVectors        = 47           ; wind barb density
       vector =  wrf_vector(a,wks,u(level,:,:),v(level,:,:),opts)
       delete(opts)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;


      plot = wrf_map_overlays(a,wks,(/contour,vector/),pltres,mpres)


     end do      ; END OF LEVEL LOOP

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

  end do        ; END OF TIME LOOP

end





1 (2).png
2 (2).png
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2020-6-25 21:07:18 | 显示全部楼层
type = "eps"

eps的话会自动覆盖之前的图内容和文件名称

如果修改为png格式,命名时文件会自动重命名,出来就是一张张的图了
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

 楼主| 发表于 2020-6-26 14:46:16 | 显示全部楼层
小其其格 发表于 2020-6-25 21:07
type = "eps"

eps的话会自动覆盖之前的图内容和文件名称

我改成过eps的,但是还是一张一张的。而且图上还是乱码的,排列没对= =
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

发表于 2020-7-1 10:22:24 | 显示全部楼层
先设置一下gsnMaximize为True,
然后gsnFrame和gsnDraw设置为False,每次循环之后draw(plot),然后再frame(wks)
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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