Adding a independent point to an xyplot.

From: Justin Traiteur <jtraite2_at_nyahnyahspammersnyahnyah>
Date: Wed Sep 01 2010 - 18:45:50 MDT

Hey all,

I was wondering if anyone knew how to add a point (arbitrary place) to
an xy plot. The point will be used to determine how far the ensemble
models (temperature profile) are from the true value at one height.

Thanks,
Justin

The code is below.

>> 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"
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRF_contributed.ncl" ;
>> WRF_Times2Udunits_c
>> begin
>> i = 1
>> do while (i .le. 6)
>> date = "_06041300"
>> diri = "./"
>> ens = i
>> fili = "wrfout_ens"
>> nc = ".nc"
>> f = addfile (diri+fili+ens+date+nc,
>> "r") ; Load file
>> pltType = "x11" ;
>> Use x11 for plotting
>> wks = gsn_open_wks(pltType,"overlay") ; Open
>> workstation
>> res = True
>> res@MainTitle = "SCM WRF"
>> pltres = True
>> mpres = True
>> times = wrf_user_list_times(f)
>> it = 1
>> res@TimeLabel = times(it)
>> eta_i = ispan(1,40,1)
>> plot = new (1,"graphic") ;
>> Plot 2 maps
>> theta = wrf_user_getvar(f,"theta",it)
>> thetan1 = theta(eta_i,0,0)
>> thetan2 = theta(eta_i,0,1)
>> thetan3 = theta(eta_i,1,0)
>> thetan4 = theta(eta_i,1,1)
>> thetan5 = (thetan1 + thetan2)/2 ;
>> Calculate average Theta between U points
>> thetan6 = (thetan3 + thetan4)/2 ;
>> Calculate average Theta between V poitns
>> thetan7 = (thetan5 + thetan6)/2
>> z = wrf_user_getvar(f,"z",it) ;
>> Model height
>> zn = z(eta_i,0,0) ;
>> Only first 40 levs
>> u1 = f->U(it,eta_i,0,1)
>> u2 = f->U(it,eta_i,1,1)
>> v1 = f->V(it,eta_i,1,0)
>> v2 = f->V(it,eta_i,1,1)
>> u3 = (u1 + u2)/2 ;
>> Calculate average between U grid points
>> v3 = (v1 + v2)/2 ;
>> Calculate average between V grid points
>> spd = sqrt(u3*u3+v3*v3) ;
>> Calculate wind speed
>> res = True ;
>> plot mods desired
>> res@tiMainString = "WRF SCM THETA" ;
>> title
>> res@tiYAxisString = "Height (m)" ;
>> y axis title
>> res@tiXAxisString = "Potential Temperature (K)" ;
>> x axis title
>> res@trXMaxF = 302.44
>> gsnDraw = False
>> gsnFrame = False
>> colors =
>> (/"black","red","blue","green","brown","orange"/)
>> res@xyLineThicknesses = 3.0 ;
>> line thicknesses
>> res@TimeLabel = times(it)
>> opts = res
>> opts@cnLineColor = "Red"
>> FramePlot = False
>> gsnDraw = False
>> gsnFrame = False
>> if(i .eq. 1) then
>> theta1 = thetan7
>> z1 = zn
>> end if
>> if(i .eq. 2) then
>> theta2 = thetan7
>> z2 = zn
>> end if
>> if(i .eq. 3) then
>> theta3 = thetan7
>> z3 = zn
>> end if
>> if(i .eq. 4) then
>> theta4 = thetan7
>> z4 = zn
>> end if
>> if(i .eq. 5) then
>> theta5 = thetan7
>> z5 = zn
>> end if
>> if(i .eq. 6) then
>> theta6 = thetan7
>> z6 = zn
>> end if
>> if(i .eq. 7) then
>> theta7 = thetan7
>> z7 = zn
>> end if
>> if(i .eq. 8) then
>> theta8 = thetan7
>> z8 = zn
>> end if
>> if(i .eq. 9) then
>> theta9 = thetan7
>> z9 = zn
>> end if
>> if(i .eq. 10) then
>> theta10 = thetan7
>> z10 = zn
>> end if
>> if(i .eq. 11) then
>> theta11 = thetan7
>> z11 = zn
>> end if
>> i = i+1
>> end do
>> plot1 = gsn_csm_xy(wks,theta1,z1,res)
>> res@xyLineColor = colors(1)
>> plot2 = gsn_csm_xy(wks,theta2,z2,res)
>> res@xyLineColor = colors(2)
>> plot3 = gsn_csm_xy(wks,theta3,z3,res)
>> res@xyLineColor = colors(3)
>> plot4 = gsn_csm_xy(wks,theta4,z4,res)
>> res@xyLineColor = colors(4)
>> plot5 = gsn_csm_xy(wks,theta5,z5,res)
>> res@xyLineColor = colors(5)
>> plot6 = gsn_csm_xy(wks,theta6,z6,res)
>> ; res@xyLineColor = colors(6)
>> ; plot7 = gsn_csm_xy(wks,theta7,z7,res)
>> ; plot8 = gsn_csm_xy(wks,theta8,z8,res)
>> ; plot9 = gsn_csm_xy(wks,theta9,z9,res)
>> ; plot10 = gsn_csm_xy(wks,theta10,z10,res)
>> ; plot11 = gsn_csm_xy(wks,theta11,z11,res)
>> overlay(plot1,plot2)
>> overlay(plot1,plot3)
>> overlay(plot1,plot4)
>> overlay(plot1,plot5)
>> overlay(plot1,plot6)
>> number = (/1., 2., 3., 4., 5., 6./)
>> lgres = True
>> lgres@lgLineColors = colors
>> lgres@lgItemType = "Lines"
>> lgres@lgLabelFontHeightF = .08
>> lgres@vpWidthF = 0.18
>> lgres@vpHeightF = 0.16
>> lgres@perimThicknessF = 2.0
>> lgres@lgMonoDashIndex= True
>> lgres@lgDashIndex = 0
>> labels = " Ensemble "+number
>> legend = gsn_create_legend (wks,6,labels,lgres)
>> amres = True
>> amres@amJust = "TopRight"
>> amres@amParallelPosF = 0.4
>> amres@amOrthogonalPosF = -0.4
>> annoid = gsn_add_annotation(plot1,legend,amres)
>> ; overlay(plot1,plot7)
>> ; overlay(plot1,plot8)
>> ; overlay(plot1,plot9)
>> ; overlay(plot1,plot10)
>> ; overlay(plot1,plot11)
>> draw(plot1)
>> frame(wks)
>> end
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Sep 1 18:45:48 2010

This archive was generated by hypermail 2.1.8 : Thu Sep 09 2010 - 05:56:39 MDT