;---------------------------------------------------------------------- ; This script demonstrates the use of data striding to remove ; clutter, especially from vector plots. ; ; This graphic is NOT used in the Graphics workshop lecture slides. It ; is basically vector1d.ncl and vector1e.ncl paneled on one page. ; (These two scripts ARE used in the Graphics lecture.) ;---------------------------------------------------------------------- begin ;---Read data off netCDF file a = addfile("$NCARG_ROOT/lib/ncarg/data/cdf/uv300.nc","r") u = a->U(1,:,:) v = a->V(1,:,:) speed = sqrt(u^2+v^2) copy_VarCoords(u,speed) ; Copy coordinate variables to speed nstep = 4 ; Stride for vector and contour data ;---Start graphics wks = gsn_open_wks("png","overlay_subset") ; open a png file ;---Contour resource list cnres = True cnres@gsnDraw = False ; don't draw cnres@gsnFrame = False ; don't advance frame cnres@cnFillOn = True ; turn on color cnres@cnFillPalette = "gui_default" cnres@cnLinesOn = False ; no contour lines cnres@mpFillOn = False ; no map fill cnres@gsnLeftString = "Speed" ; change left string cnres@gsnRightString = u@units ; assign right string ;---Vector resource list vcres = True ; vector only resources vcres@gsnDraw = False ; don't draw vcres@gsnFrame = False ; don't advance frame vcres@vcGlyphStyle = "CurlyVector" ; curly vectors vcres@vcRefMagnitudeF = 20 ; define vector ref mag vcres@vcRefLengthF = 0.045 ; define length of vec ref vcres@vcRefAnnoOrthogonalPosF = -.535 ; move ref vector into plot vcres@gsnRightString = " " ; turn off right string vcres@gsnLeftString = " " ; turn off left string vcres@tiXAxisString = " " ; turn off axis label ;---Create graphic array to hold two sets of plots. plot = new(2,graphic) ;---Overlay speed vector plot on contour/map plot plot(0) = gsn_csm_contour_map_ce(wks,speed(::nstep,::nstep),cnres) vplot1 = gsn_csm_vector(wks,u(::nstep,::nstep),v(::nstep,::nstep),vcres) overlay(plot(0),vplot1) ;---Overlay wind vector plot on contour/map plot cnres@gsnLeftString = "Wind" ; change left string plot(1) = gsn_csm_contour_map_ce(wks,u(::nstep,::nstep),cnres) vplot2 = gsn_csm_vector(wks,u(::nstep,::nstep),v(::nstep,::nstep),vcres) overlay(plot(1),vplot2) ;---Panel both plots resP = True ; panel only resources resP@gsnMaximize = True ; maximize plots resP@gsnPanelMainString = "Vectors and contours strided every " + \ nstep + "th step" gsn_panel(wks,plot,(/2,1/),resP) ; now draw as one plot end