Dear NCL users,
I'm korean and my name is Kam Eun-A. I don't know English.
I will draw contour and polyline on the one frame.
Input data are WRF output.
I want create contour plot and polyline on the same frame.
But, It created on two frame. first frame is contour plot, and second frame was overlay polyline on contour plot.
here is my code:
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"
begin; Open WRF files. a = addfile("../wrfout_d01_2008-10-10_00:00:00.nc", "r") b = addfile("../wrfout_d02_2007-01-01_12:00:00.nc", "r")
; Read first (and only) timestep of data to contour at = wrf_user_getvar(a,"HGT",0) bt = wrf_user_getvar(b,"HGT",0)
; Read lat/lon coordinates for eack dataset. atlat = a->XLAT(0,:,:) atlon = a->XLONG(0,:,:) btlat = b->XLAT(0,:,:) btlon = b->XLONG(0,:,:)
wks = gsn_open_wks("x11","hgt_test") ; Open X11 file.
setvalues wks "wkBackgroundColor" : "white" "wkForegroundColor" : "black" end setvalues
gsn_define_colormap(wks,"gui_default")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Set some contouring resources.
opts = True opts_at_InitTime = False opts_at_Footer = False
cnres = opts; cnres_at_gsnDraw = True; cnres_at_gsnFrame = True cnres_at_gsnMaximize = True
cnres_at_cnInfoLabelOn = False
; Set contour resources cnres_at_cnFillOn = True; cnres_at_ContourParameters = (/0, 6000, 100/)
res = cnres
dims = dimsizes(at) r = dimsizes(dims) r1 = dims(r-1) r2 = dims(r-2)
at_at_lat2d = atlat at_at_lon2d = atlon
contour1= wrf_contour(a,wks,at,res)
pltres = True mpres = True mpres_at_mpGeophysicalLineColor = "Black" mpres_at_mpGridLineColor = "Black"
plot = wrf_map_overlays(a,wks,(/contour1/),pltres,mpres)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
res2 = cnres res2_at_lbLabelBarOn = False res2_at_gsnMaximize = False
bt_at_lat2d = btlat bt_at_lon2d = btlon
; Overlay 2nd contour plots on original map/contour plot overlay(plot,contour1)
draw(plot)
; Set some polyline resources. lnres = True lnres_at_gsLineThicknessF = 1.5
; Add some boxes to the map, showing the two finer-resolution amp areas. dims = dimsizes(bt) r2 = dimsizes(dims) r21 = dims(r2-1) r22 = dims(r2-2)
xbox = (/btlon(0,0), btlon(0,r21-1),btlon(r22-1,r21-1),\ btlon(r22-1,0),btlon(0,0)/) ybox = (/btlat(0,0), btlat(0,r21-1), btlat(r22-1,r21-1),\ btlat(r22-1,0), btlat(0,0)/)
x_out = new(dimsizes(xbox),typeof(xbox)) y_out = new(dimsizes(ybox),typeof(ybox))
; Can't use gsn_polyline here, because will get curved box lines. datatondc(plot, xbox, ybox, x_out, y_out) gsn_polyline_ndc(wks, x_out, y_out, lnres)
; Now advance the frame frame(wks)
end
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Aug 19 2009 - 02:38:10 MDT
This archive was generated by hypermail 2.2.0 : Mon Aug 24 2009 - 11:15:23 MDT