;*********************************************** 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/csm/contributed.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl" ;*********************************************** begin ymin = 2300. ; min height to be plotted ymax = 5500. ; max height to be plotted ncol = 7 ; number of columns of data in each ascii file wbcrit = 100. fils = systemfunc("ls *.txt") nfiles = dimsizes(fils) wks = gsn_open_wks("ps","test") gsn_define_colormap(wks,"WhBlGrYeRe") do gg = 0,nfiles-1 t = asciiread(fils(gg) ,(/-1/), "float") nlvl = dimsizes(t)/ncol ; figure out number of levels in the ascii file delete(t) TestData = asciiread(fils(gg) ,(/nlvl,ncol/), "float") z = TestData (:,2) wspd = TestData (:,6) wdir = TestData (:,5) delete(TestData) rad = 4.0*atan(1.0)/180. u = -wspd*sin(rad*wdir) v = -wspd*cos(rad*wdir) if (gg.eq.0) then res = True res@gsnDraw = False res@gsnFrame = False res@vpWidthF = 0.8 res@vpHeightF = 0.5 res@vpXF = 0.1 res@vpYF = 0.9 res@trYMinF = ymin res@trYMaxF = ymax xc = (/-1,nfiles,nfiles,-1,-1/) yc = (/ymin,ymin,ymax,ymax,ymin/) plot = gsn_csm_xy(wks,xc,yc,res) ; draw blank xy plot by outlining min/max of X/Y axes contours = ispan(5,65,5)*1. ; set contours used to define barb color colors = (/20,30,40,45,50,55,60,65,70,75,80,85,90,95/) ; set colors end if wmsetp ("wdf", 1) ; meteorological dir wmsetp("wbs",0.025) do hh = 0,dimsizes(z)-1 wmsetp("col", GetFillColorIndex(contours,colors,wspd(hh))) if (z(hh).lt.ymax) then if (hh.eq.0) then ; always draw the first wind barb wmbarb(wks, gg*1., z(hh), u(hh), v(hh)) iFlag = True ; print("1: hh = "+hh) else if (z(hh)-zsave.ge.wbcrit) then ; if the current height is beyond wbcrit from wmbarb(wks, gg*1., z(hh), u(hh), v(hh)) ; previous barb height, draw barb iFlag = True ; print("2: hh = "+hh+", z = "+z(hh)) else if (.not.iFlag) then ; if the previous barb wasn't drawn, draw this barb wmbarb(wks, gg*1., z(hh), u(hh), v(hh)) ; regardless of wbcrit iFlag = True ; print("3: hh = "+hh+", z = "+z(hh)) else iFlag = False ; set iFlag to False, denoting the barb wasn't drawn ; print("4: hh = "+hh+", z = "+z(hh)) end if end if end if zsave = z(hh) else iFlag = False end if end do delete([/z,wspd,wdir,u,v/]) end do ;-------------------------------------------------------------------------- ; Draw Labelbar ;-------------------------------------------------------------------------- lbres = True lbres@lbPerimOn = False ; no label bar box lbres@lbOrientation = "Horizontal" ; orientation lbres@vpWidthF = 0.5 ; size lbres@vpHeightF = 0.075 lbres@lbLabelFontHeightF = 0.015 ; label font height lbres@lbLabelAlignment = "InteriorEdges" ; where to label lbres@lbMonoFillPattern = True ; fill sold lbres@lbFillColors = colors gsn_labelbar_ndc (wks,dimsizes(contours)+1,sprintf("%3.0f",contours),0.25,0.32,lbres) draw(plot) ; draw the plot frame(wks) ; advance the frame end