Re: gsn_add_polyline

From: Adam Phillips <asphilli_at_nyahnyahspammersnyahnyah>
Date: Wed, 30 Jan 2008 16:59:55 -0700

Hi Jimmy,

Instead of this:

dum = new(4,graphic)
xp = (/-100.4,-100.5,-97.,-97.,-100.4/)
yp = (/42.14,44.30,44.35,42.19,42.14/)
do r=0,3
    dum(r) = gsn_add_polyline(wks,plts(3),xp(r:r+1),yp(r:r+1),resp)
end do

try this:

dum = new((/4,4/),graphic)
xp = (/-100.4,-100.5,-97.,-97.,-100.4/)
yp = (/42.14,44.30,44.35,42.19,42.14/)
do q=0,3 ; # of plots
    do r=0,3 ; # of lines
       dum(q,r) = gsn_add_polyline(wks,plts(q),xp(r:r+1),yp(r:r+1),resp)
    end do
end do

Adam

jimmyc_at_iastate.edu wrote:
> NCLers-
> See script below which attempts to add a box using gsn_add_polyline. The
> method below only yields a box in the 4th panel.
> I tried adding the code for that loop after each plot but it seg
> faulted. Is there a better way of doing this?
>
> ;*************************************************
> ; WRF: panel three different variables at the same time step
> ;************************************************
> 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/WRF_contributed.ncl"
>
> begin
> ;************************************************
> ; open file and read in data
> ;************************************************
> f = addfile("myj_noah.nc", "r")
> g = addfile("ysu_noah.nc", "r")
> h = addfile("mrf_noah.nc", "r")
> i = addfile("prec.nc", "r")
> ;************************************************
> ; Read character variable Times; Convert to string for plots
> ; Read vertical coordinate for plot labels
> ;************************************************
> times = chartostring(f->Times) ; built-in function
>
> ; znu = f->ZNU(0,:) ; (Time, bottom_top)
> ;************************************************
> ; Read perturbation geopotential, pressure, water vapor ; at all times
> and levels
> ;************************************************
> rainc1 = f->RAINC
> rainnc1 = f->RAINNC
> rain1 = rainc1(96,:,:)+rainnc1(96,:,:)
> rainc2 = g->RAINC
> rainnc2 = g->RAINNC
> rain2 = rainc2(96,:,:)+rainnc2(96,:,:)
> rainc3 = h->RAINC
> rainnc3 = h->RAINNC
> rain3 = rainc3(96,:,:)+rainnc3(96,:,:)
> precip = i->APCP
>
> pr =
> precip(0,:,:)+precip(1,:,:)+precip(2,:,:)+precip(3,:,:)+precip(4,:,:)+precip(5,:,:)+precip(6,:,:)+precip(7,:,:)+precip(8,:,:)+precip(10,:,:)+precip(11,:,:)+precip(12,:,:)+precip(13,:,:)+precip(14,:,:)+precip(15,:,:)+precip(16,:,:)+precip(17,:,:)+precip(18,:,:)+precip(19,:,:)+precip(20,:,:)+precip(21,:,:)+precip(22,:,:)+precip(23,:,:)+precip(9,:,:)
>
>
> ;************************************************
> ; create plots ;************************************************
> wks = gsn_open_wks("ps" ,"precip") ; ps,pdf,x11,ncgm,eps
> gsn_define_colormap(wks ,"BlAqGrYeOrReVi200"); choose colormap
>
> res = True ; plot mods desired
> res_at_gsnMaximize = True ; uncomment to maximize size
> res_at_gsnSpreadColors = True ; use full range of colormap
> res_at_cnFillOn = True ; color plot desired
> res_at_cnLinesOn = False ; turn off contour lines
> res_at_cnLineLabelsOn = False ; turn off contour labels
> res_at_lbLabelAutoStride = True ; let NCL figure lb stride
> res_at_cnLevelSelectionMode = "ExplicitLevels" ; explicit [unequal] cn
> levels
> res_at_cnLevels =
> (/0,.254,1,4,8,16,24,32,40,48,56,64,72,80,88,96,128,256/)
>
> ;************************************************
> ; Use WRF_contributed procedure to set map resources
> ;************************************************
> WRF_map_c(f,res,0) ; set map resources
> ;************************************************
> ; set True for native mapping (faster plotting)
> ; set to False othewise ;************************************************
> res_at_tfDoNDCOverlay = True
>
> ;************************************************
> ; associate the 2-dimensional coordinates to variables for plotting
> ; only if res_at_tfDoNDCOverlay=False
> ;************************************************
> if (.not.res_at_tfDoNDCOverlay) then
> lat2d = f->XLAT(0,:,:) ; need for map limits
> lon2d = f->XLONG(0,:,:)
>
> p_at_lat2d = lat2d
> p_at_lon2d = lon2d
> ph_at_lat2d = lat2d
> ph_at_lon2d = lon2d
> q2_at_lat2d = lat2d
> q2_at_lon2d = lon2d
> end if
>
> ;************************************************
> ; allocate array for 3 plots
> ;************************************************
> plts = new (4,"graphic")
> ;************************************************
> ; Specify (arbitrarily chosen) subscripts ; This could also be done in a
> do loop or explicitly specified
> ;************************************************
> nt = 96 ; last time step
> kl = 3
> ;************************************************
> ; Tell NCL not to draw or advance frame for individual plots
> ;************************************************
> res_at_gsnDraw = False ; (a) do not draw
> res_at_gsnFrame = False ; (b) do not advance 'frame'
>
> res_at_gsnLeftString ="Stage IV precipitation"
>
> plts(0) = gsn_csm_contour_map(wks,pr,res)
>
> ; res_at_gsnLeftString = ph_at_description+": znu="+znu(kl)
> res_at_gsnLeftString ="MYJ"
> plts(1) = gsn_csm_contour_map(wks,rain1(:,:),res)
>
> ; res_at_gsnLeftString = p_at_description+": znu="+znu(kl)
> res_at_gsnLeftString ="YSU"
> plts(2) = gsn_csm_contour_map(wks,rain2(:,:),res)
>
> ; delete(res_at_gsnLeftString)
> res_at_gsnLeftString ="MRF"
> plts(3) = gsn_csm_contour_map(wks,rain3(:,:),res)
>
> do q=0,3
> tres = True
> tres_at_txFontHeightF = 0.02
> ;need lat lon
> txt = gsn_add_text(wks,plts(q),"OAX",-96.33,41.25,tres)
> txta = gsn_add_text(wks,plts(q),"ABR",-98.43,45.45,tres)
>
> ;add polymarker for OAX and ABR
> polyres = True
> polyres_at_gsMarkerIndex = (/6,8/); 16
> polyres_at_gsMarkerSizeF = 5.
> gl = (/-96.33,-98.43/)
> gn = (/41.25,45.45/)
> dm = gsn_add_polymarker(wks,plts(q),gn(:),gl(:),polyres)
>
> resp = True
> resp_at_gsLineColor = "black"
> resp_at_gsLineThicknessF = 2.0
> resp_at_gsLineLabelString = "CI"
> dum = new(4,graphic)
> ;x and y points
> xp = (/-100.4,-100.5,-97.,-97.,-100.4/)
> yp = (/42.14,44.30,44.35,42.19,42.14/)
> do r=0,3
> dum(r) = gsn_add_polyline(wks,plts(3),xp(r:r+1),yp(r:r+1),resp)
> end do
>
> end do
> ; draw(plot)
> ; frame(wks)
>
>
> ;************************************************
> ; create panel: panel plots have their own set of resources
> ;************************************************
> resP = True ; modify the panel plot
> resP_at_txString = f_at_TITLE+": "+times(nt)
> resP_at_gsnMaximize = True ; maximize panel area
> resP_at_vpHeightF = 0.345614
> resP_at_vpWidthF = 0.413117
> ; resa_at_vpKeepAspect = True
> resP_at_gsnPanelRowSpec = True ; specify 1 top, 2
> lower level
> ; resP_at_gsnPanelDebug = True
> gsn_panel(wks,plts,(/2,2/),resP) ; now draw as one plot
>
> end
>

-- 
--------------------------------------------------------------
Adam Phillips			             asphilli_at_ucar.edu
National Center for Atmospheric Research   tel: (303) 497-1726
ESSL/CGD/CAS                               fax: (303) 497-1333
P.O. Box 3000				
Boulder, CO 80307-3000	  http://www.cgd.ucar.edu/cas/asphilli
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Jan 30 2008 - 16:59:55 MST

This archive was generated by hypermail 2.2.0 : Thu Jan 31 2008 - 22:46:00 MST