爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 1218|回复: 1

[作图] overlay_dom.ncl脚本交流分享

[复制链接]

新浪微博达人勋

发表于 2018-5-14 22:33:31 | 显示全部楼层 |阅读模式

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

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

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

begin

  wks = gsn_open_wks("eps", "wrf_overlay_doms")  ; Open graphics file

  d1 =addfile("e:/2013IOP6/bdy/2013071912/wpsprd/met_em.d01.2013-07-19_12:00:00.nc","r")   ; Open a file
  ;d2 = addfile("../met_em.d02.2012-01-27_00:00:00.nc", "r")


  var1 = wrf_user_getvar(d1,"HGT_M",0)
  lat1 = wrf_user_getvar(d1,"XLAT",0)
  lon1 = wrf_user_getvar(d1,"XLONG",0)
  ; var2 = wrf_user_getvar(d2,"HGT_M",0)
  ; lat2 = wrf_user_getvar(d2,"XLAT",0)
  ; lon2 = wrf_user_getvar(d2,"XLONG",0)

  var1@lat2d = lat1
  var1@lon2d = lon1
  ; var2@lat2d = lat2
  ; var2@lon2d = lon2

  dom_dims = dimsizes(var1)
  dom_rank = dimsizes(dom_dims)
  nx1 = dom_dims(dom_rank - 1) - 1
  ny1 = dom_dims(dom_rank - 2) - 1
  ; dom_dims = dimsizes(var2)
  ; dom_rank = dimsizes(dom_dims)
  ; nx2 = dom_dims(dom_rank - 1) - 1
  ; ny2 = dom_dims(dom_rank - 2) - 1


  res                 = True

; Set some contouring resources.
  res@cnFillOn        = True
  res@cnLinesOn       = False
  res@cnLineLabelsOn  = False
  res@cnInfoLabelOn   = False
  res@gsnSpreadColors = True
  res@cnLevelSelectionMode = "ExplicitLevels"
  res@cnLevels             = (/0, 10, 25, 50, 75, 125, 200, 350, 500, 750,1000, 1250, 1500, 1750, 2000, 2250, 3000/)
  res@gsnLeftString = ""
  res@gsnRightString = ""

  res@gsnDraw         = False
  res@gsnFrame        = False

  res2 = res

; Add map resources
  res@mpDataBaseVersion     = "MediumRes"          ; Default is LowRes
  res@mpOutlineDrawOrder    = "PostDraw"           ; Draw map outlines last
  res@mpGridAndLimbOn       = False                ; Turn off lat/lon lines
  res@pmTickMarkDisplayMode = "Always"             ; Turn on map tickmarks
  res = set_mp_wrf_map_resources(d1,res)
  res@mpLimitMode        = "Corners"               ; Portion of map to zoom
  res@mpLeftCornerLatF   = lat1(0,0)
  res@mpLeftCornerLonF   = lon1(0,0)
  res@mpRightCornerLatF  = lat1(ny1,nx1)
  res@mpRightCornerLonF  = lon1(ny1,nx1)

; Add label bar resources
  res@lbLabelAutoStride = True
  res@gsnMaximize     = True    ; Maximize plot in frame


  res2@lbLabelBarOn = False  ; Labelbar already created in 1st plot
  res2@gsnMaximize  = False  ; Use maximization from original plot

; we need these to later draw boxes for the location of the nest domain
  xbox_out = new(5,float)
  ybox_out = new(5,float)
  lnres = True
  lnres@gsLineThicknessF  = 1.5

; make images
  map = gsn_csm_contour_map(wks, var1, res)
  ;plot = gsn_csm_contour(wks, var2, res2)


; let's make 3 plots
; 1 - the mother domain only
; 2 - the mother and nest domains
; 3 - same as 2, but add a box around domain 2


; PLOT 1
  draw(map)
  frame(wks)

; PLOT 2
  ;overlay (map, plot)
  ;draw(map)
  ;frame(wks)

; PLOT 3
  ;draw(map)   ; domain 2 already overlaid here - so just draw again
  ;xbox = (/lon2(0,0),lon2(0,nx2),lon2(ny2,nx2),lon2(ny2,0),lon2(0,0)/)
  ;ybox = (/lat2(0,0),lat2(0,nx2),lat2(ny2,nx2),lat2(ny2,0),lat2(0,0)/)
  ;datatondc(map, xbox, ybox, xbox_out, ybox_out)
  ;gsn_polyline_ndc(wks, xbox_out, ybox_out, lnres)
  ;frame(wks)

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

新浪微博达人勋

发表于 2018-5-14 23:20:08 | 显示全部楼层
可以给个示意图
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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