爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
123
返回列表 发新帖
楼主: tianmeng

ncl 画WRF结果的风速风向

[复制链接]
 楼主| 发表于 2014-9-16 21:59:53 | 显示全部楼层
longlivehj 发表于 2014-9-16 21:41
再仔细看看呢!
要不把全部代码贴出来瞅瞅?

好的,我还有问题呢,因为9km分辨率经常出现zero field,我不知道是为什么
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2014-9-16 22:02:35 | 显示全部楼层
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"

begin
;---Open WRF output file and read data
  dir      = "./"
  filename = "wrfreckm912_20131211.nc"
  a = addfile(dir + filename,"r")
  wks = gsn_open_wks("png","wrf9_latlonoverlay")
  res = True
  times  = wrf_user_getvar(a,"times",-1)  ; get times in the file
  ntimes = dimsizes(times)         ; number of times in the file

;---Just look at first time step.
  do it = 0,ntimes-1,1
  print("Working on time: " + times(it) )

;---Read temperature and terrain height off file
  tc2    = wrf_user_getvar(a,"T2",it)
  tc2    = tc2-273.16   ; T in C
slp = wrf_user_getvar(a,"slp",it)    ; slp
  wrf_smooth_2d( slp, 3 )            ; smooth slp
  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

  lat2d = wrf_user_getvar(a,"XLAT",it)   ; latitude
  lon2d = wrf_user_getvar(a,"XLONG",it)  ; longitude
  dims = dimsizes(tc2)
  tc2@description ="Surface Temperature"
  tc2@units = "C"
  u10@units = "m/s"
  v10@units = "m/s"

  ; Plotting options for T
    opts = res
    opts@cnFillOn = True
    gsn_define_colormap(wks,"BlWhRe")
    res@gsnSpreadColors=True
    opts@ContourParameters = (/ -15., 15., 1./)
    opts@gsnSpreadColorEnd = -3  ; End third from the last color in color map
    opts@sfXArray = lon2d
opts@sfYArray = lat2d
    contour = wrf_contour(a,wks,tc2,opts)
    delete(opts)


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

; Plotting options for Wind Vectors
      opts = res
      res@gsnDraw  = True    ; Forces the plot to be drawn
                                                                  
res@gsnFrame = True    ; Frame advance
      opts@FieldTitle = "Wind"       ; overwrite Field Title
      opts@vcGlyphStyle ="WindBarb"
      opts@vfXArray=lon2d
      opts@vfYArray=lat2d
      vector = wrf_vector(a,wks,u10,v10,opts)
      delete(opts)

;---Set some basic plot options
  opts = True
  opts@MainTitle                   = "REAL-TIME WRF"
  pltres = True
  mpres  = True

  opts@TimeLabel = times(it)   ; Set valid time to use on plots
;----------------------------------------------------------------------
; Plot partial domain.
;----------------------------------------------------------------------
;---Set special resource to indicate we are using XLAT/XLONG coordinates.
  pltres@LatLonOverlay = True

;---Zoom in on map, which we can do because we're using lat/lon coordinates.
  mpres@mpLeftCornerLatF  =  34.
  mpres@mpRightCornerLatF =  39.
  mpres@mpLeftCornerLonF  = 114.
  mpres@mpRightCornerLonF = 124.
  mpres@mpDataBaseVersion="MediumRes"
  mpres@mpDataSetName="Earth..4"
  mpres@mpGeophysicalLineColor = "Black"
  mpres@mpGridLineColor        = "Black"
  mpres@mpLimbLineColor        = "Black"
  mpres@mpPerimLineColor       = "Black"
  mpres@mpUSStateLineThicknessF     = 2
  mpres@mpUSStateLineColor="Black"
  mpres@mpOutlineSpecifiers="China:states"
mpres@mpNationalLineColor    = "Black"
  mpres@mpNationalLineThicknessF    = 2
  plot = wrf_map_overlays(a,wks,(/contour,contour_psl,vector/),pltres,mpres)
end do
end
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2014-9-16 22:02:56 | 显示全部楼层
longlivehj 发表于 2014-9-16 21:41
再仔细看看呢!
要不把全部代码贴出来瞅瞅?

我贴在下面了
密码修改失败请联系微信:mofangbao
发表于 2014-9-17 15:34:14 | 显示全部楼层
数据格式是什么呢?
密码修改失败请联系微信:mofangbao
发表于 2014-9-17 15:40:53 | 显示全部楼层
tianmeng 发表于 2014-9-16 22:02
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf ...

代码貌似没啥问题。zero field是tc2还是slp,这个需要你自己查一下。
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2014-9-17 20:44:14 | 显示全部楼层
kongfeng0824 发表于 2014-9-17 15:34
数据格式是什么呢?

nc格式,WRF转出来的结果
密码修改失败请联系微信:mofangbao
 楼主| 发表于 2014-9-17 20:45:02 | 显示全部楼层
longlivehj 发表于 2014-9-17 15:40
代码貌似没啥问题。zero field是tc2还是slp,这个需要你自己查一下。

现在OK了,不过貌似区域选择得太小了,边界的数据问题很大
密码修改失败请联系微信:mofangbao
发表于 2014-9-23 09:07:13 | 显示全部楼层
过段时间也要用ncl画WRF的结果了。。。。。。。。。
密码修改失败请联系微信:mofangbao
发表于 2015-8-24 21:12:37 | 显示全部楼层
楼主,你会画这个图么?有没有相关脚本?
QQ截图20150824103519.png
密码修改失败请联系微信:mofangbao
发表于 2017-1-19 22:17:49 | 显示全部楼层
ncl初学者,一头雾水
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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