;**************************************************** ; xy_28.ncl ; ; Concepts illustrated: ; - Drawing a hodograph plot ; - Reading data from an ASCII file ; - Drawing XY plot curves with both lines and markers ; - Putting labels on an XY plot ; ;**************************************************** ; ; This script was contributed by Haoming Chen from ; LASG/IAP in Beijing, China. ; ; A hodograph plot is a suitable approach in ; describing diurnal variations in the wind vector ; at a given point. ; 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/csm/shea_util.ncl" begin ; Read data of an ASCII file fin = "hodo1832.dat" ;nlvl = 40 nlvl = 24 ncol = 3 dat = asciiread(fin,(/nlvl,ncol/),"float") nhr = 25 badv = -999.0 alt = dat(:,0) u = dat(:,1)*1.94 v = dat(:,2)*1.94 ;u = dat(:,1) ;v = dat(:,2) ul = (u(:)^2+v(:)^2)^.5 print(ul) do i=0,nlvl-2 dis = (abs((u(i)-u(i+1)))^2+abs((v(i)-v(i+1))^2))^.5 ul = ul + dis print(dis) print(i) end do ;==================================================== ; wks = gen_open_wks("eps","hodograph_test") wks = gsn_open_wks ("png",fin+"hodograph") res = True res@gsnMaximize = True ; Maximize plot in window. res@gsnDraw = False ; Don't draw plot res@gsnFrame = False ; Don't advance frame ; res@gsnPaperOrientation = "portrait" res@gsnLeftString = "" res@gsnRightString = "" res@xyMarkLineMode = "MarkLines" ; markers and lines res@xyMarkers = 16 ; filled dot res@xyMarkerSizeF = 0.0135 res@xyMarkerThicknessF = 0.6 res@tiMainString = fin+"U = "+ul+"knots" res@tiYAxisString = "V-Wind" res@tiXAxisString = "U-Wind" res@trXMinF = -50 res@trXMaxF = 50 res@trYMinF = -50 res@trYMaxF = 50 plot = gsn_csm_xy (wks,u,v,res) ; Create plot, but don't draw it ; Attach some text strings next to the markers. txres = True txres@txFontHeightF = 0.0275 txres@txJust = "TopLeft" ; labels = " " + ispan(2000,30000,2000) labels = " " + alt(:) labels(0:nlvl-1:2) = "" ; Don't do the last one. txid = gsn_add_text(wks,plot,labels,u,v,txres) draw(plot) ; Drawing the plot will also cause text strings to frame(wks) ; Advance the frame. end