Sometimes the best debugger is a print statement.
When you have problems, try printing, it helps debugging.
NCL likes to help but we can not debug user codes on a regular
basis. Your code has no comments and is not indented. This
makes following the code time consuming.
--- In the following x(i) is a constant and you are setting all values of (say) data(0,:) to that value *each iteration*! The : is NCL array syntax. > do i=0,11 > data(0,:) = x1(i) > data(1,:) = x2(i) > data(2,:) = x3(i) > plot(i) = gsn_csm_xy(wks,time,data,res) ; plot correlation > end do *Maybe* what you want is to eliminate the do loop. data(0,:) = x1 data(1,:) = x2 data(2,:) = x3 On 5/25/10 5:11 AM, Ibo Ze wrote: > Hi Dennis, > > It turned out to work OK but now plotting same single xy curve in all > panel plot. > I tried to loop data arrays but then it gives straight lines. Please > help to rectify it. > Thanks.Ibo > The data array loop code segment: > > do i=0,11 > data(0,:) = x1(i) > data(1,:) = x2(i) > data(2,:) = x3(i) > > plot(i) = gsn_csm_xy(wks,time,data,res) ; plot correlation > end do > gsn_panel(wks,plot,(/4,3/),resP) > > > ------------------------------------------------------------------------ > *From:* Dennis Shea <shea@ucar.edu> > *To:* Ibo Ze <ibo85@ymail.com> > *Cc:* Rick Brownrigg <brownrig@ucar.edu>; Ncl Talk <ncl-talk@ucar.edu> > *Sent:* Mon, May 24, 2010 8:14:59 AM > *Subject:* Re: [ncl-talk] Panel plot errors > > Please look at your code. > > You have > > > res@gsnDraw = False > > res@gsnFrame = False > > Then you use the 'res' variable in your call to gsn_panel > > > gsn_panel(wks,plot,(/4,3/),res) ; plot correlation > > Thus, there will bo no Draw or Frame. If you look at the > panel URL, you will see that a differently used varaible > is used for panel resources. > > http://www.ncl.ucar.edu/Applications/panel.shtml > > ;************************************************ > ; create panel > ;************************************************ > resP = True ; modify the panel plot > resP@txString = "A common title" > resP@gsnMaximize= True ; make ps,pdf,eps large > gsn_panel(wks,plot,(/4,3/),resP) ; now draw as one plot > > > On 5/24/10 6:47 AM, Ibo Ze wrote: > > Hi Rick, > > > > Thankyou for your suggestions. I've changed the script and now it > > terminates without any error and output. Please suggest to avoid > > termination and to generate output panel plot. > > Thanks. Ibo > > > > The code is as follows: > > > > 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,11 > > filename1 = "6104_pk_"+sprinti("%0.2i",i+1)+"_avg.nc <http://_avg.nc>" > > print(filename1) > > filename2 = "6104_ind_"+sprinti("%0.2i",i+1)+"_avg.nc" > > print(filename2) > > filename3 = "6104_sec_"+sprinti("%0.2i",i+1)+"_avg.nc" > > print(filename3) > > f1 = addfile(filename1,"r") > > f2 = addfile(filename2,"r") > > f3 = addfile(filename3,"r") > > if (i.eq.0) then > > a1=f1->a > > a2=f2->a > > a3=f3->a > > dim1=dimsizes(a1) > > dim2=dimsizes(a2) > > dim3=dimsizes(a3) > > p=new((/12,dim1/),"float") > > a=new((/12,dim2/),"float") > > c=new((/12,dim3/),"float") > > end if > > p(i,:)=f1->a > > a(i,:)=f2->a > > c(i,:)=f3->a > > delete(f1) > > delete(f2) > > delete(f3) > > end do > > x1 = dim_standardize_Wrap(a1,1) > > x2 = dim_standardize_Wrap(a2,1) > > x3 = dim_standardize_Wrap(a3,1) > > dimx1 = dimsizes(x1) > > dimx2 = dimsizes(x2) > > dimx3 = dimsizes(x3) > > dimmx = max((/dimx1,dimx2,dimx3/)) > > time = ispan(1961,2004,1) > > data = new((/3,dimmx/),"float") > > wks = gsn_open_wks("x11","stanom_pic_06") ; open a ps plot > > plot = new(12,graphic) > > res = True ; make plot mods > > res@gsnDraw = False > > res@gsnFrame = False > > res@xyLineThicknesses = (/2.,2.,2./) > > res@xyLineColors = (/"red","blue","orange"/) > > res@xyDashPatterns = (/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 = 1960 > > res@trXMaxF = 2004 > > res@gsnYRefLine = 0. ; reference line > > res@tiXAxisString = "Time(years)" ; x-axis label > > res@tiYAxisString = "Standardized Anomaly" ; x-axis label > > do i=0,11 > > data(0,:) = x1 > > data(1,:) = x2 > > data(2,:) = x3 > > plot(i) = gsn_csm_xy(wks,time,data,res) ; plot correlation > > end do > > gsn_panel(wks,plot,(/4,3/),res) ; plot correlation > > ;end > > > > > > ------------------------------------------------------------------------ > > *From:* Rick Brownrigg <brownrig@ucar.edu <mailto:brownrig@ucar.edu>> > > *To:* Ibo Ze <ibo85@ymail.com <mailto:ibo85@ymail.com>>; Ncl Talk > <ncl-talk@ucar.edu <mailto:ncl-talk@ucar.edu>> > > *Sent:* Mon, May 24, 2010 6:21:16 AM > > *Subject:* Re: [ncl-talk] Panel plot errors > > > > Hi, > > > > There are at least two problems that I see: > > > > 1. NCL's array indexing is zero-based. Your do_loop indexing is 1-based, > > ranging from 1-12, indexing into > > the arrays "p", "d", "c". You either want something like "do i=0,11" or > > "p(i-1,:)=f1->a", etc. > > > > 2. On the line that reads "data = new((/3,dim/),"float")", the variable > > "dim" has never been created. You have variables "dim1", "dim2", "dim3"; > > perhaps one of those was intended? > > > > Its possible that fixing these two issues will clear up the remaining > > errors (?) Hope that helps... > > Rick > > > > > > On Sun, 23 May 2010 01:53:10 -0700 (PDT) > > Ibo Ze <ibo85@ymail.com <mailto:ibo85@ymail.com> > <mailto:ibo85@ymail.com <mailto:ibo85@ymail.com>>> wrote: > > > Hi, > > > > > > I want to plot standardized anomaly for all months for three > > different regions in a panel plot. Getting following error: > > > > > > fatal:Subscript out of range, error in subscript #0 > > > fatal:Execute: Error occurred at or near line 45 in file > stnd_anomaly.ncl > > > fatal:Variable (dim) is undefined > > > fatal:Execute: Error occurred at or near line 59 in file > stnd_anomaly.ncl > > > warning:dim_standardize: 1 rightmost sections of the input array > > contained all missing values > > > fatal:Assignment type mismatch, right hand side can't be coerced to > > type of left hand side > > > fatal:Execute: Error occurred at or near line 64 in file > stnd_anomaly.ncl > > > warning:dim_standardize: 1 rightmost sections of the input array > > contained all missing values > > > fatal:Assignment type mismatch, right hand side can't be coerced to > > type of left hand side > > > fatal:Execute: Error occurred at or near line 65 in file > stnd_anomaly.ncl > > > warning:dim_standardize: 1 rightmost sections of the input array > > contained all missing values > > > fatal:Assignment type mismatch, right hand side can't be coerced to > > type of left hand side > > > fatal:Execute: Error occurred at or near line 66 in file > stnd_anomaly.ncl > > > fatal:Undefined identifier: (data) is undefined, can't continue > > > fatal:Execute: Error occurred at or near line 88 in file > stnd_anomaly.ncl > > > (0) Error: gsn_panel: all of the plots passed to gsn_panel appear to > > be invalid > > > > > > ******************************************************************* > > > > > > Please help to rectify this error. > > > Thanks. Ibo > > > The script i am using is as follows: > > > > > > 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=1,12 >> > filename1 = "6104_pk_"+sprinti("%0.2i",i)+"_avg.nc <http://_avg.nc>" > > > print(filename1) > > > filename2 = "6104_ind_"+sprinti("%0.2i",i)+"_avg.nc" > > > print(filename2) > > > filename3 = "6104_sec_"+sprinti("%0.2i",i)+"_avg.nc" > > > print(filename3) > > > f1 = addfile(filename1,"r") > > > f2 = addfile(filename2,"r") > > > f3 = addfile(filename3,"r") > > > if (i.eq.1) then > > > a1 = f1->a > > > a2 = f2->a > > > a3 = f3->a > > > dim1 = dimsizes(a1) > > > dim2 = dimsizes(a2) > > > dim3 = dimsizes(a3) > > > p=new((/12,dim1/),"float") > > > d=new((/12,dim2/),"float") > > > c=new((/12,dim3/),"float") > > > end if > > > p(i,:)=f1->a > > > d(i,:)=f2->a > > > c(i,:)=f3->a > > > delete(f1) > > > delete(f2) > > > delete(f3) > > > end do > > > time = ispan(1961,2004,1) > > > > > > data = new((/3,dim/),"float") > > > f1 = dim_standardize_Wrap(p(:,:),1) > > > f2 = dim_standardize_Wrap(d(:,:),1) > > > f3 = dim_standardize_Wrap(c(:,:),1) > > > > > > wks = gsn_open_wks("x11","stanom_pic_06") ; open a ps plot > > > plot = new(12,graphic) > > > res = True ; make plot mods > > > res@gsnDraw = False > > > res@gsnFrame = False > > > res@xyLineThicknesses = (/2.,2.,2./) > > > res@xyLineColors = (/"red","blue","orange"/) > > > res@xyDashPatterns = (/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 = 1960 > > > res@trXMaxF = 2004 > > > res@gsnYRefLine = 0. ; reference line > > > res@tiXAxisString = "Time(years)" ; x-axis label > > > res@tiYAxisString = "Standardized Anomaly" ; x-axis label > > > do i=0,11 > > > data(0,:)=f1(i,:) > > > data(1,:)=f2(i,:) > > > data(2,:)=f3(i,:) > > > > > > plot(i) = gsn_csm_xy(wks,time,data,res) ; plot correlation > > > end do > > > gsn_panel(wks,plot,(/4,3/),res) ; plot correlation > > > > > > end > > > > > > > > > > > > > > > > > > > > > > _______________________________________________ > > ncl-talk mailing list > > List instructions, subscriber options, unsubscribe: >> http://mailman.ucar.edu/mailman/listinfo/ncl-talk > _______________________________________________ ncl-talk mailing list List instructions, subscriber options, unsubscribe: http://mailman.ucar.edu/mailman/listinfo/ncl-talkReceived on Tue May 25 09:56:00 2010
This archive was generated by hypermail 2.1.8 : Wed May 26 2010 - 10:39:13 MDT