Re: help with tickmarks on gsn_csm_y plots

From: Adam Phillips <asphilli_at_nyahnyahspammersnyahnyah>
Date: Fri Jun 22 2012 - 13:46:46 MDT

Hi Kerrie,
I would try using str_get_cols to isolate the day from the MMDD string,
then use ind to identify all instances where day = 1.
day_int = stringtoint(str_get_cols(timeMMDD_str,2,3))
day_1_ind = ind(day_int.eq.1)
res@tmXBMode="Explicit"
res@tmXBValues=day_1_ind(1:) ; (1:) as you do not wish to
include Mar 1st)
res@tmXBLabels=timeMMDD_str(day_1_ind(1:))

http://www.ncl.ucar.edu/Document/Functions/Built-in/str_get_cols.shtml

Hope that helps... Adam

On 06/22/2012 01:33 PM, Kerrie Geil wrote:
> Currently, the code snippet below produces a panel plot of 22
> gsn_csm_y plots showing average daily precipitation over a certain
> time period, for a certain location, for various climate models. On
> each gsn_csm_y plot, the bottom x-axis has a tickmark and a MMDD time
> label for each day from Mar 1 to Jul 31. I'm having trouble figuring
> out how to get the x-axis tickmarks the way I want. What I want to do
> is only have a tickmark at Apr 1, May 1, Jun 1, and Jul 1. I'll
> remove the time labels and add the appropriate months as text between
> the tick marks below the axis. Can anyone help me with which
> resources to use in order to only show these few tickmarks?
>
> Thanks in advance,
> Kerrie
>
> ...
> wks=gsn_open_wks(type,"plots/PR_TIMEAVG_"+box(ibox))
> plot(nmodels)=gsn_csm_y(wks,pr_timeavgdata,res)
>
> delete([/res,timeMMDD_str/])
>
> startyear=toint(str_get_cols(timerange,0,3))
> endyear=toint(str_get_cols(timerange,5,8))
> nyears=toint(endyear)-toint(startyear)+1
>
> do imodel=0,nmodels-1
> print("MODEL= "+models(imodel))
> ndays =
> numAsciiCol("pr_textfiles/"+models(imodel)+"_YYYYMMDDtime_"+timerange)
> model_time=asciiread("pr_textfiles/"+models(imodel)+"_YYYYMMDDtime_"+timerange,(/nyears,ndays/),"integer")
> model_time_str=tostring(model_time)
> indices=ind( (toint(str_get_cols(model_time_str(0,:),4,5)).ge.3)
> .and. (toint(str_get_cols(model_time_str(0,:),4,5)).le.7) )
>
> pr_avgbox1=asciiread("pr_textfiles/"+box(ibox)+"_"+models(imodel)+"_Daily_"+timerange,(/nyears,ndays/),"float")
> pr_avgbox2=pr_avgbox1(:,indices)
> pr_timeavgmodel=dim_avg_n_Wrap(pr_avgbox2,0)
> timeMMDD_str=str_get_cols(model_time_str(0,indices),4,7)
>
> res=True
> res@gsnMaximize=True
> res@gsnDraw=False
> res@gsnFrame=False
> res@tmXBMode="Explicit"
> res@tmXBValues=ispan(0,dimsizes(timeMMDD_str)-1,1)
> res@tmXBLabels=timeMMDD_str
> res@tmXBLabelAngleF=270.
> res@tmXBLabelFontHeightF=0.01
> res@tmBorderThicknessF=1.5
> res@tmXTOn=False
> res@trXMinF = 0.0
> res@trXMaxF = max(res@tmXBValues)
> res@trYMinF = 0.0
> res@trYMaxF = 6.0
> res@gsnYRefLine=threshold
> res@gsnYRefLineDashPattern=2
> res@gsnYRefLineThicknessF=1.25
> res@gsnCenterString=models(imodel)
>
> plot(imodel)=gsn_csm_y(wks,pr_timeavgmodel,res)
>
> delete([/model_time,model_time_str,indices,pr_avgbox1,pr_avgbox2,pr_timeavgmodel,timeMMDD_str,res/])
> end do ;### model loop
>
> print("creating panel plot")
> pres=True
> pres@gsnPanelRowSpec = True
> pres@gsnMaximize=True
>
> gsn_panel(wks,plot,(/4,4,4,4,4,2/),pres)
> ...
>
>
> --
> Kerrie Geil
> Master's Student
> Department of Atmospheric Sciences
> University of Arizona
> PAS Building Rm 526
> 1118 E 4th Street
> Tucson, AZ 85721
>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

-- 
______________________________________________________________
Adam Phillips                                asphilli@ucar.edu
NCAR/Climate and Global Dynamics Division       (303) 497-1726
P.O. Box 3000				
Boulder, CO 80307-3000    http://www.cgd.ucar.edu/cas/asphilli

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Jun 22 13:46:56 2012

This archive was generated by hypermail 2.1.8 : Mon Jun 25 2012 - 09:57:23 MDT