Re: Index values panel plot

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Mon Dec 27 2010 - 14:13:08 MST

Often the best way to debug is to (a) look
at your code; (b) use print statements.

==

You have
    plot=new(2,graphic)

The you have a loop

> do j=0,3
> data(0,:)=f1(j,:)
> data(1,:)=f2(j,:)
> plot(j) = gsn_csm_xy(wks,time,data,res)
> end do
> gsn_panel(wks,plot,(/2,1/),False)

the j span 0->3 .... that is 4 elements. Hence,
    plot=new(4,graphic)

Then your gsn_panel might look

    gsn_panel(wks,plot,(/2,2/),False)

===
Note: Rather than

  f1 = dim_standardize_Wrap(p(:,:),1)

you should use

  f1 = dim_standardize_Wrap(p,1) ; p(:,:)

If using whole arrays, don't use (:,:) ... NCL operates differently on
this. A method of clearly indicating that p is 2D p(:,)
is to indcate that in a comment

On 12/27/2010 02:04 PM, Ibo Ze wrote:
> Hi Rick,
>
> Thanks for input. I now get following error at *plot* line which
> apparently isn't clear as to why happening:
>
> fatal:Subscript out of range, error in subscript #0
>
> Please suggest how to correct it.
>
> thanks!
>
> 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"
>
> begin
>
> do i=0,3
> j=i+6
> filename1="pkc."+sprinti("%2.2i",j)+".wa.nc"
> filename2="pks."+sprinti("%2.2i",j)+".wa.nc"
> f1=addfile(filename1,"r")
> f2=addfile(filename2,"r")
> if (i.eq.0) then
> a1=f1->pre
> a2=f2->pre
> dim=dimsizes(a1)
> dim=dimsizes(a2)
> p=new((/4,dim/),typeof(a1))
> d=new((/4,dim/),typeof(a2))
> end if
> p(i,:)=f1->pre
> d(i,:)=f2->pre
> delete(f1)
> delete(f2)
> end do
> time = ispan(1980,2000,1)
>
> data=new((/4,dim/),typeof(a1))
> f1 = dim_standardize_Wrap(p(:,:),1)
> f2 = dim_standardize_Wrap(d(:,:),1)
>
> ;************************************************
> ; Read data and fill missing values
> ;************************************************
> plot=new(2,graphic)
> wks = gsn_open_wks("x11","stanom.pkc.pks") ; open a ps plot
> res = True ; make plot mods
> res@gsnDraw= False
> res@gsnFrame= False
> res@xyLineThicknesses = (/1.,2.,1.,2./)
> res@xyDashPatterns = (/0.,0.,0.,0./) ; make all lines solid
> res@tmXTLabels = False
> res@tmLabelAutoStride = True
> res@trYMinF = -5.0 ; bring bars down to zero
> res@trYMaxF = 5.0 ; adds space on either end
> res@trXMinF= 1980
> res@trXMaxF= 2000
> res@gsnYRefLine = 0. ; reference line
> res@tiXAxisString = "Time(years)" ; x-axis label
> res@tiYAxisString = "Standardized Anomaly" ; x-axis label
>
> do j=0,3
> data(0,:)=f1(j,:)
> data(1,:)=f2(j,:)
> plot(j) = gsn_csm_xy(wks,time,data,res)
> end do
> gsn_panel(wks,plot,(/2,1/),False)
> end
>
>
> ------------------------------------------------------------------------
> *From:* "brownrig@ucar.edu" <brownrig@ucar.edu>
> *To:* Ibo Ze <ibo85@ymail.com>; Ncl Talk <ncl-talk@ucar.edu>
> *Sent:* Wed, December 22, 2010 10:39:21 PM
> *Subject:* Re: [ncl-talk] Index values panel plot
>
> Hi,
>
> The error messages are telling you what's wrong:
>
> 1. There is no variable named dimx. You have defined dimx1, dimx2,
> dimx3, dimx4, and dimmx; perhaps one of those was intended?
>
> 2. There is no array variable named "plots"; you need to define it as in
> your other script earlier today.
>
> Hope that helps...
> Rick
>
> On Wed, 22 Dec 2010 20:07:31 -0800 (PST)
> Ibo Ze <ibo85@ymail.com <mailto:ibo85@ymail.com>> wrote:
> > Hi All,
> >
> > I am trying to plot index values into 3 panels and getting following
> errors:
> >
> >
> > fatal:Undefined identifier: (dimx) is undefined, can't continue
> > fatal:Execute: Error occurred at or near line 63 in file t3.ncl
> >
> > fatal:Variable (plots) is undefined
> > fatal:Execute: Error occurred at or near line 75 in file t3.ncl
> >
> > fatal:syntax error: line 76 in file t3.ncl before or near end end
> > --^
> >
> > Below is my script. Please help to correct it. Thanks!
> >
> > 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"
> >
> > begin
> > wks = gsn_open_wks("x11","stanom") ; open a ps plot
> > res = True ; make plot mods
> > res@gsnDraw= False
> > res@gsnFrame= False
> > res@xyLineThicknesses = (/1.,2.,1.,2./)
> > ;res@xyLineColors = (/"pinkred","red","lightblue","blue"/)
> > res@xyDashPatterns = (/0.,0.,0.,0./) ; make all lines solid
> > res@trYMinF = -5.0 ; bring bars down to zero
> > res@trYMaxF = 5.0 ; adds space on either end
> > res@trXMinF = 1980
> > res@trXMaxF = 2000
> > res@gsnYRefLine = 0. ; reference line ;res@tiXAxisString =
> "Time(years)" ; x-axis label
> > ;res@tiYAxisString = "Standardized Anomaly" ; x-axis label
> >
> > do i=0,2
> > j=i+6
> > filename1 = "pkc."+sprinti("%0.2i",j)+".wa.nc <http://wa.nc>"
> > f1 = addfile("pkc.06.wa.nc <http://pkc.06.wa.nc>","r")
> > print(f1)
> > filename2 = "pks."+sprinti("%0.2i",j)+".wa.nc"
> > f2 = addfile("pks.06.wa.nc <http://pks.06.wa.nc>","r")
> > print(f2)
> > a1 = f1->pre
> > a2 = f2->pre
> > x1 = dim_standardize_Wrap(a1,1)
> > x2 = runave(x1,3,0)
> > x3 = dim_standardize_Wrap(a2,1)
> > x4 = runave(x3,3,0)
> > dimx1 = dimsizes(x1)
> > dimx2 = dimsizes(x2)
> > dimx3 = dimsizes(x3)
> > dimx4 = dimsizes(x4)
> > dimmx = max((/dimx1,dimx2,dimx3,dimx4/))
> > time = ispan(1980,2000,1)
> > data = new((/4,dimmx/),typeof(a1))
> > do k=0,3
> > data(k,:dimx(k+1)-1) = x(k+1)
> > ;data(0,:dimx1-1) = x1
> > ;data(1,:dimx2-1) = x2
> > ;data(2,:dimx3-1) = x3
> > ;data(3,:dimx4-1) = x4
> > plots(i) = gsn_csm_xy(wks,time,data(k),res) end do
> > end do
> >
> > pres = True
> > pres@gsnMaximize = True
> > gsn_panel(wks,plots,(/3,1/),pres)
> > end
> > exit
> >
> >
> >
> >
>
>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

-- 
======================================================
Dennis J. Shea                  tel: 303-497-1361    |
P.O. Box 3000                   fax: 303-497-1333    |
Climate Analysis Section                             |
Climate & Global Dynamics Div.                       |
National Center for Atmospheric Research             |
Boulder, CO  80307                                   |
USA                        email: shea 'at' ucar.edu |
======================================================
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Dec 27 14:13:15 2010

This archive was generated by hypermail 2.1.8 : Tue Jan 04 2011 - 09:16:52 MST