load "/usr/share/ncarg/nclscripts/csm/gsn_code.ncl" load "/usr/share/ncarg/nclscripts/csm/gsn_csm.ncl" load "/home/isakhar/Desktop/fixscript/hodo_cartesian.ncl" ; ****************************************************************** ; ******* THERE IS NO SUPPORT FOR THE HODOGRAPH FUNCTION ********* ; ****************************************************************** undef("hodograph") function hodograph (wks[1]: graphic, wspd[*]:numeric, wdir[*]:numeric, hRes[1]:logical) ; Nomenclature ; wspd - wind speed (any units) ; wdir - wind direction (degrees) ; meteorological: dir from which the wind blows ; eg: 90 deg means blowing from the east ; hRes - resources which affect plot appearance ; begin debug = False if (hRes) then opts = hRes ; if True over ride local/defaults with input end if nW = dimsizes(wspd) ; total number of elements rad = 4.*atan(1.0)/180. ; degress to radians ; compute wind components u = -wspd*sin(wdir*rad) ; u component (zonal) v = -wspd*cos(wdir*rad) ; v component (meridional) ;uAve = avg(u) ;vAve = avg(v) ;wAve = avg(wspd) ;wDir = atan2(uAve,vAve)/rad +180. ; average wind direction [0,360] ;wStd = stddev(wspd) ;wNum = num(.not.ismissing(wspd) ) ; total number of non-msg values ;nCalm = num( wspd.eq.0.)*1.0 ; total calm reports (float) wMin = 0.0 wMax = max( wspd ) maxLev = 5 if (opts .and. isatt(opts,"hodo_maxLev")) then maxLev = opts@hodo_maxLev end if maxAxis = wMax if (opts .and. isatt(opts,"hodo_maxAxis")) then maxAxis = opts@maxAxis end if mnmxintw = nice_mnmxintvl( wMin, maxAxis, maxLev, True) ;print(mnmxintw) res = True res@gsnDraw = False res@gsnFrame = False res@gsnMaximize = True BorderLineColor = 28 ; light gray for default if (opts .and. isatt(opts,"hodo_borderColor")) then BorderLineColor = opts@hodo_borderColor end if res@tmBorderLineColor = BorderLineColor res@tmXBOn = True res@tmXBBorderOn = True ; True is the default res@tmXBLabelsOn = True ; True is the default res@tmXBLabelFontColor= BorderLineColor res@tmXBMajorLineColor= BorderLineColor res@tmXBMinorLineColor= BorderLineColor res@tmYLOn = True res@tmYLBorderOn = True ; True is the default res@tmYLLabelsOn = True ; True is the default res@tmYLLabelFontColor= BorderLineColor res@tmYLMajorLineColor= BorderLineColor res@tmYLMinorLineColor= BorderLineColor res@tmYROn = True res@tmYRBorderOn = True ; True is the default res@tmXTOn = True ; turn off tick marks on each side res@tmXTBorderOn = True ; True is the default ; are perim border wanted if (opts .and. isatt(opts,"hodo_perim") .and. .not.opts@hodo_perim) then res@tmXBOn = False res@tmXBBorderOn = False res@tmXTOn = False res@tmXTBorderOn = False res@tmYLOn = False res@tmYLBorderOn = False res@tmYROn = False res@tmYRBorderOn = False end if spaceAxis = 0.0 ; arbitrary 'extra' space spaceAxis = mnmxintw(2)*0.50 ; arbitrary 'extra' space res@trXMinF = -mnmxintw(1) - spaceAxis res@trXMaxF = mnmxintw(1) + spaceAxis res@trYMinF = -mnmxintw(1) - spaceAxis res@trYMaxF = mnmxintw(1) + spaceAxis res@tiMainFontColor = 1 ; default is 1 res@tiYAxisString = "V-Wind" res@tiXAxisString = "U-Wind" res@tiXAxisFontColor = BorderLineColor res@tiYAxisFontColor = BorderLineColor if (opts .and. isatt(opts,"hodo_axisTitle") .and. .not.opts@hodo_axisTitle) then delete(res@tiXAxisString) delete(res@tiYAxisString) end if if (opts .and. isatt(opts,"tiMainString") ) then res@tiMainString = opts@tiMainString end if if (opts .and. isatt(opts,"gsnLeftString") ) then res@gsnLeftString = opts@gsnLeftString end if if (opts .and. isatt(opts,"gsnCenterString") ) then res@gsnCenterString = opts@gsnCenterString end if if (opts .and. isatt(opts,"gsnRightString") ) then res@gsnRightString = opts@gsnRightString end if nCirc = 361 ; do this once nCircles = toint(mnmxintw(1)/mnmxintw(2)) xCirc = new ( nCirc, "float") yCirc = xCirc xCirc = 0.0 yCirc = 0.0 plot = gsn_csm_xy(wks, xCirc, yCirc, res) ; blank gsRes = True gsRes@gsLineColor = BorderLineColor ; light gray gsRes@gsLineThicknessF = 0.5 ; default = 1.0 txRes = True ; set text resources txRes@txFontColor = BorderLineColor txRes@txFontHeightF = 0.0150 ;txPos = 145 ; (math) degrees ;txShiftx = 0.90 ;txShifty = 0.90 txPos = 270 ; (math) degrees txShiftx = 0.00 txShifty = 0.00 txRes@txAngleF = 0 xcos = cos(fspan(0, 360, nCirc)*rad) xsin = sin(fspan(0, 360, nCirc)*rad) do n=1,nCircles ; plot coordinates for circles xCirc = n*mnmxintw(2)*xcos yCirc = n*mnmxintw(2)*xsin plot@$unique_string("dum")$ = gsn_add_polyline(wks,plot,xCirc,yCirc,gsRes) if (opts) then if(.not.isatt(opts,"hodo_labelCircle") .or. \ isatt(opts,"hodo_labelCircle") .and. opts@hodo_labelCircle) then labelCirc = ""+(n*mnmxintw(2)) ;print("labelCirc="+labelCirc) plot@$unique_string("dum")$ = \ gsn_add_text(wks,plot,labelCirc \ ,xCirc(txPos)-txShiftx \ ,yCirc(txPos)+txShifty,txRes) end if end if end do gsRes = True gsRes@gsMarkerSizeF = 0.0075 if (opts .and. isatt(opts,"hodo_markerSize")) then gsRes@gsMarkerSizeF = opts@hodo_markerSize end if gsRes@gsMarkerIndex = 16 ; solid circle if (opts .and. isatt(opts,"hodo_markerIndex")) then gsRes@gsMarkerSizeF = opts@hodo_markerIndex end if plot@$unique_string("dum")$ = gsn_add_polymarker(wks,plot, u , v ,gsRes) gsRes@gsMarkerSizeF = 0.02 gsRes@gsMarkerIndex = 2 ; "+" gsRes@gsMarkerColor = "blue" plot@$unique_string("dum")$ = gsn_add_polymarker(wks,plot, 0.0 , 0.0 ,gsRes) resuv = True plot@$unique_string("dum")$ = gsn_add_polyline(wks,plot,u,v,resuv) ; Attach some text strings next to the markers. txres = True txres@txJust = "TopLeft" txres@txFontHeightF = 0.0150 if (opts .and. isatt(opts,"hodo_txFontHeightF")) then txres@txFontHeightF = opts@hodo_hodo_txFontHeightF end if labels = " " + ispan(0,nW-1,1) nStride = 1 if (opts .and. isatt(opts,"hodo_txLabelStride")) then nStride = opts@hodo_txLabelStride end if txid = gsn_add_text(wks,plot,labels(::nStride),u(::nStride),v(::nStride),txres) if (isatt(hRes,"gsnDraw")) then if (hRes@gsnDraw) then draw(plot) end if else draw(plot) end if if (isatt(hRes,"gsnFrame")) then if (hRes@gsnFrame) then frame (wks) end if else frame (wks) end if return (plot) end