爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 20261|回复: 39

ncl怎么进行批处理?

[复制链接]
发表于 2014-10-27 21:09:35 | 显示全部楼层 |阅读模式

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

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

x
我用ncl,打开n个文件,求其中变量的平均,最后的图怎么画,十分不明白?

密码修改失败请联系微信:mofangbao
 楼主| 发表于 2014-10-28 13:44:28 | 显示全部楼层
;   Example script to produce plots for a WRF real-data run,
;   with the ARW coordinate dynamics option.
;   Interpolating to specified height levels

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

begin
;
; The WRF ARW input file.
; This needs to have a ".nc" appended, so just do it.
  files = systemfunc("ls ./wrfreckm3*")
  f = addfiles(files,"r")
  ListSetType(f,"cat")
; We generate plots, but what kind do we prefer?
; type = "x11"
; type = "pdf"
; type = "ps"
; type = "ncgm"
  wks_type = "png"
  wks_type@wkWidth = 2500
  wks_type@wkHeight = 2500
  wks = gsn_open_wks(wks_type,"plt_HeightLevel")
  gsn_define_colormap(wks,"MPL_YlOrBr")

; Set some basic resources
  res = True
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


; What times and how many time steps are in the data set?
  times = wrf_user_getvar(f[:],"times",-1)  ; get all times in the file
  ntimes = dimsizes(times)         ; number of times in the file

; The specific height levels that we want the data interpolated to.
  height_levels = (/ 70./)   ; height levels to plot - in meter
  nlevels       = dimsizes(height_levels)     ; number of height levels

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

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; First get the variables we will need
sum_u  = wrf_user_getvar(f[:],"ua",0)        ; u averaged to mass points
   sum_v  = wrf_user_getvar(f[:],"va",0)        ; v averaged to mass points
   p  = wrf_user_getvar(f[:], "pressure",0)
   z  = wrf_user_getvar(f[:], "z",0)
   lon2d = wrf_user_getvar(f[:],"XLONG",0)
   lat2d = wrf_user_getvar(f[:],"XLAT",0)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
do it = 1,ntimes-1,1
    u  = wrf_user_getvar(f[:],"ua",it)        ; u averaged to mass points
    v  = wrf_user_getvar(f[:],"va",it)        ; v averaged to mass point
    sum_u=sum_u+u
    sum_v=sum_v+v
    delete(u)
    delete(v)
   end do
   avg_u=sum_u/ntimes
   avg_v=sum_v/ntimes

      height = height_levels
      result_u = wrf_user_intrp3d( avg_u,z,"h",height,0.,False)
      result_v = wrf_user_intrp3d( avg_v,z,"h",height,0.,False)
      result_uv = sqrt(result_u*result_u+result_v*result_v)
delete(avg_u)
      delete(avg_v)
      delete(sum_u)
      delete(sum_v)
      delete(result_u)
      delete(result_v)


      olon = fspan(114,123,144)
      olat = fspan(34,39,80)
  data1 = new((/144,80/),"float")
  olon!0          = "lon"
  olon@long_name  = "lon"
  olon@units      = "degrees-east"
  olon&lon        = olon
  olat!0          = "lat"
  olat@long_name  = "lat"
olat@units      = "degrees_north"
  olat&lat        = olat
  grid_uv = rcm2rgrid_Wrap(lat2d,lon2d,result_uv,olat,olon,0)
  grid_uv@long_name="avg of uv at 70m in December"

  ; Set some Basic Plot options
   res=True
   res@gsnAddCyclic = False
   res@gsnMaximize             = True
   ;res@gsnDraw                 = False
   ;res@gsnFrame                = False
   res@mpMinLatF               = 34.
   res@mpMaxLatF               = 39.
   res@mpMinLonF               = 114.
   res@mpMaxLonF               = 123.
   res@mpDataBaseVersion       = "MediumRes"
res@mpDataBaseVersion       = "MediumRes"
   res@mpDataSetName           = "Earth..4"
   res@mpOutlineOn           = True         ; Turn on map outlines
   res@mpOutlineSpecifiers   = (/"China","Taiwan"/)       ;China:states
   res@mpAreaMaskingOn = True   ;cover it
   res@mpMaskAreaSpecifiers = (/"China","Taiwan"/)   ;China:states
   res@mpLandFillColor         = "white"
   res@mpInlandWaterFillColor  = "white"
   res@mpOceanFillColor        = "white"
   res@mpOutlineBoundarySets   = "NoBoundaries"
   res@mpFillDrawOrder = "PostDraw"
   res@cnFillOn = True
   res@ContourParameters = (/ 0., 20., 2. /)

   plot = gsn_contour_map(wks,grid_uv,res)


end


没办法批量处理,fatal:_NclBuildConcatArray: Arrays of files are not yet supported
fatal:Execute: Error occurred at or near line 44 in file wrf_Height.ncl
密码修改失败请联系微信:mofangbao
回复 支持 1 反对 0

使用道具 举报

发表于 2014-10-27 21:50:01 | 显示全部楼层
addfiles
密码修改失败请联系微信:mofangbao
回复

使用道具 举报

 楼主| 发表于 2014-10-28 08:44:48 | 显示全部楼层
可是我计算完最后要画图,plot = wrf_map_overlays(a,wks,(/contour /),pltres,mpres),这个a是所有的文件还是什么?
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2014-10-28 14:18:33 | 显示全部楼层
急,跪求答案
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2014-10-28 14:22:57 | 显示全部楼层
急,跪求答案
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2014-10-28 14:23:09 | 显示全部楼层
急,跪求答案
密码修改失败请联系微信:mofangbao
发表于 2014-10-28 17:09:47 | 显示全部楼层
tianmeng 发表于 2014-10-28 13:44
;   Example script to produce plots for a WRF real-data run,
;   with the ARW coordinate dynamics o ...

rcm2rgrid插值后不能用plot = wrf_map_overlays(a,wks,(/contour /),pltres,mpres)这个语句画图了!用gsn_csm_contour_map!你后面报错也不知道具体是哪条语句?
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2014-10-28 17:16:06 | 显示全部楼层
风之牧语 发表于 2014-10-28 17:09
rcm2rgrid插值后不能用plot = wrf_map_overlays(a,wks,(/contour /),pltres,mpres)这个语句画图了!用gsn ...

就是最开始的批量文件读入不进去,
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2014-10-28 17:16:31 | 显示全部楼层
风之牧语 发表于 2014-10-28 17:09
rcm2rgrid插值后不能用plot = wrf_map_overlays(a,wks,(/contour /),pltres,mpres)这个语句画图了!用gsn ...

错误是:,fatal:_NclBuildConcatArray: Arrays of files are not yet supported
fatal:Execute: Error occurred at or near line 44 in file wrf_Height.ncl
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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