爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 748|回复: 3

[作图] 利用ncl脚本画wrfout总降雨图像出错

[复制链接]

新浪微博达人勋

发表于 2019-4-3 18:22:02 | 显示全部楼层 |阅读模式

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

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

x
我在使用wrf_Precip_multi_files.ncl脚本画wrfout总降雨图像的时候出现的这样的问题:
1212.png
实在是不知道哪里出问题了,求帮看~!以下是wrf_Precip_multi_files.ncl脚本内容:

;   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/wrf/WRFUserARW.ncl"
;load "./WRFUserARW.ncl"

begin
;
; Make a list of all files we are interested in
  DATADir = "/public/home/czhang/app/WRF/3.8.1/WRFV3-MPI/run/"
  FILES = systemfunc (" ls -1 " + DATADir + "wrfout* ")
  numFILES = dimsizes(FILES)
  print("numFILES = " + numFILES)
  type = "png"
; type = "pdf"
; type = "ps"
; type = "ncgm"
; Set some basic resources
  a = addfiles(FILES+".nc","r")
  slp = wrf_user_getvar(a,"slp",-1)  ; slp
    wrf_smooth_2d( slp, 3 )            ; smooth slp

  rain_con_tend = rain_con
  rain_tot_tend = rain_tot
  ; We know our data is available every 3 hours, so setting tend_int to 1 gives
  ; Plotting options for Sea Level Pressure

    opts_r@cnLevelSelectionMode = "ExplicitLevels"
                                    "Chartreuse3","Green","ForestGreen", \
    opts_r@cnConstFLabelOn      = False
    opts_r@cnFillOn             = True


  ; Total Precipitation (color fill)
    contour_tot = wrf_contour(a[it],wks, rain_tot(it,:,:), opts_r)

  ; Precipitation Tendencies
    opts_r@SubFieldTitle = "from " + times(it-tend_int) + " to " + times(it)

    contour_tend = wrf_contour(a[it],wks, rain_tot_tend(it,:,:),opts_r) ; total (color)
    contour_res = wrf_contour(a[it],wks,rain_exp_tend(it,:,:),opts_r)   ; exp (color)
    opts_r@cnFillOn = False
    opts_r@cnLineColor = "Red4"
    contour_prm = wrf_contour(a[it],wks,rain_con_tend(it,:,:),opts_r)   ; con (red lines)
    delete(opts_r)



  ; MAKE PLOTS

    ; Total Precipitation
      plot = wrf_map_overlays(a[it],wks,contour_tot,pltres,mpres)

    ; Total Precipitation Tendency + SLP
      plot = wrf_map_overlays(a[it],wks,(/contour_tend,contour_psl/),pltres,mpres)

    ; Non-Convective and Convective Precipiation Tendencies
      plot = wrf_map_overlays(a[it],wks,(/contour_res,contour_prm/),pltres,mpres)


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

  end do        ; END OF TIME LOOP

end

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

新浪微博达人勋

发表于 2019-4-3 19:14:35 | 显示全部楼层
89行是什么
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

 楼主| 发表于 2019-4-3 19:37:40 | 显示全部楼层

发现脚本没有上传完全是这个(89行加粗):
;   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/wrf/WRFUserARW.ncl"
;load "./WRFUserARW.ncl"

begin
;
; Make a list of all files we are interested in
  DATADir = "/kiaat2/bruyerec/WRF/WRFV3_4861/test/em_real/split_files/"
  FILES = systemfunc (" ls -1 " + DATADir + "wrfout* ")
  numFILES = dimsizes(FILES)
  print("numFILES = " + numFILES)
  print(FILES)
  print (" ")

; We generate plots, but what kind do we prefer?
  type = "x11"
; type = "pdf"
; type = "ps"
; type = "ncgm"
  wks = gsn_open_wks(type,"plt_Precip_multi_files")


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

  pltres = True
  mpres = True
  mpres@mpGeophysicalLineColor = "Black"
  mpres@mpNationalLineColor    = "Black"
  mpres@mpUSStateLineColor     = "Black"
  mpres@mpGridLineColor        = "Black"
  mpres@mpLimbLineColor        = "Black"
  mpres@mpPerimLineColor       = "Black"

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  a = addfiles(FILES+".nc","r")

  times = wrf_user_getvar(a,"times",-1)  ; get all times in the file
  ntimes = dimsizes(times)         ; number of times in the file

  slp = wrf_user_getvar(a,"slp",-1)  ; slp
    wrf_smooth_2d( slp, 3 )            ; smooth slp

  ; Get non-convective, convective and total precipitation
  rain_exp = wrf_user_getvar(a,"RAINNC",-1)
  rain_con = wrf_user_getvar(a,"RAINC",-1)
  rain_tot = rain_exp + rain_con
  rain_tot@description = "Total Precipitation"

  ; just creating new arrays here
  rain_exp_tend = rain_exp
  rain_con_tend = rain_con
  rain_tot_tend = rain_tot
  rain_exp_tend = 0.0
  rain_con_tend = 0.0
  rain_tot_tend = 0.0
  rain_exp_tend@description = "Explicit Precipitation Tendency"
  rain_con_tend@description = "Param  Precipitation Tendency"
  rain_tot_tend@description = "Precipitation Tendency"

  ; Calculate tendency values
  ; We know our data is available every 3 hours, so setting tend_int to 1 gives
  ; tendencies for 3 hours, setting it to 2, gives 6hourly tendencies                              
  tend_int = 2
  rain_exp_tend(tend_int:ntimes-1:tend_int,:,:) = rain_exp(tend_int:ntimes-1:tend_int,:,:) - rain_exp(0:ntimes-2:tend_int,:,:)
  rain_con_tend(tend_int:ntimes-1:tend_int,:,:) = rain_con(tend_int:ntimes-1:tend_int,:,:) - rain_con(0:ntimes-2:tend_int,:,:)
  rain_tot_tend(tend_int:ntimes-1:tend_int,:,:) = rain_tot(tend_int:ntimes-1:tend_int,:,:) - rain_tot(0:ntimes-2:tend_int,:,:)

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

  do it = tend_int,ntimes-1,tend_int    ; Let's skip the first time as rain is 0 here

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


; Plotting options for Sea Level Pressure
    opts_psl = res         
    opts_psl@ContourParameters = (/ 900., 1100., 2. /)
    opts_psl@cnLineColor       = "Blue"
    opts_psl@cnInfoLabelOn     = False
    opts_psl@cnLineLabelFontHeightF = 0.01
    opts_psl@cnLineLabelPerimOn = False
    opts_psl@gsnContourLineThicknessesScale = 1.5
    contour_psl = wrf_contour(a[it],wks,slp(it,:,:),opts_psl)
    delete(opts_psl)
   

  ; Plotting options for Precipitation
    opts_r = res                        
    opts_r@UnitLabel            = "mm"
    opts_r@cnLevelSelectionMode = "ExplicitLevels"
    opts_r@cnLevels             = (/ .1, .2, .4, .8, 1.6, 3.2, 6.4, \
                                    12.8, 25.6, 51.2, 102.4/)
    opts_r@cnFillColors         = (/"White","White","DarkOliveGreen1", \
                                "DarkOliveGreen3","Chartreuse", \
                                    "Chartreuse3","Green","ForestGreen", \
                                    "Yellow","Orange","Red","Violet"/)
    opts_r@cnInfoLabelOn        = False
    opts_r@cnConstFLabelOn      = False
    opts_r@cnFillOn             = True
   

  ; Total Precipitation (color fill)
    contour_tot = wrf_contour(a[it],wks, rain_tot(it,:,:), opts_r)

  ; Precipitation Tendencies
    opts_r@SubFieldTitle = "from " + times(it-tend_int) + " to " + times(it)

    contour_tend = wrf_contour(a[it],wks, rain_tot_tend(it,:,:),opts_r) ; total (color)
    contour_res = wrf_contour(a[it],wks,rain_exp_tend(it,:,:),opts_r)   ; exp (color)
    opts_r@cnFillOn = False
    opts_r@cnLineColor = "Red4"
    contour_prm = wrf_contour(a[it],wks,rain_con_tend(it,:,:),opts_r)   ; con (red lines)
    delete(opts_r)



  ; MAKE PLOTS                                       

    ; Total Precipitation
      plot = wrf_map_overlays(a[it],wks,contour_tot,pltres,mpres)

    ; Total Precipitation Tendency + SLP
      plot = wrf_map_overlays(a[it],wks,(/contour_tend,contour_psl/),pltres,mpres)

    ; Non-Convective and Convective Precipiation Tendencies
      plot = wrf_map_overlays(a[it],wks,(/contour_res,contour_prm/),pltres,mpres)


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

  end do        ; END OF TIME LOOP

end
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

发表于 2019-4-4 08:43:25 | 显示全部楼层
有list的下标越界了,检查一下89行附近的循环和引用。
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

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