[ncl-talk] Error: Subscript out of range error in subscript #1

Ipshita Majhi ipmajhi at alaska.edu
Thu Nov 6 12:17:04 MST 2014


Thank you very much. Yes it was the same line with the sce_week(i,52) which
was giving an error. I will specify line number too next t

Best Regards
Ipshita

On Thu, Nov 6, 2014 at 12:46 PM, Michael Notaro <mnotaro at wisc.edu> wrote:

> It's a good idea to specify which line # is giving the error message.
>
>
> sce_week has dimensions of 47,52.
>
> Therefore, sce_week(i,52) is out of range.
> The 2nd dimension is 0:51, so 52 is too large.
>
>
>
>
> Michael
>
>
> On 11/06/14, Ipshita Majhi  wrote:
> > Hi All,
> >
> >
> > I wrote a code to calculate the weekly long term mean for snow covered
> area.
> >
> > First I wanted to create a matrix which had each years week and then
> finally calculate it. while trying to create such a matrix I get the above
> mentioned error. If anyone can help it would be great.
> >
> > Here is the code
> >
> > ;*******************************************
> > 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"
> > ;*******************************************
> > ;Reading in the data
> >
> > a=addfile("~/Documents/Snow_cover_IMS/nhsce_v01r01_19661004_20140602.nc(
> http://nhsce_v01r01_19661004_20140602.nc)","r")
> >
> > sce=a->snow_cover_extent
> > time_sce=a->time
> >
> >
> > ;Now converting the time from georgian to ut_calender
> > ;Doing an area average for sce
> >
> > sce_area=wgt_areaave_Wrap(sce,1.0,1.0, 0)
> >
> > ut_sce=cd_calendar(time_sce,0)
> >
> >
> > ;Extracting just the year information from the time series
> >
> > xyears=ut_sce(:,0)
> >
> > ;This part of code is to create a matrix with each years weekly data
> > ;The years go from 1967 to 2013 i.e 47 years with 52 weeks for each year
> >
> > sce_week=new((/47,52/),"float")
> >
> >
> > do i=1,47
> >
> > years=ispan(1967,2013,1)
> >
> > yind=years(i)
> >
> > time_ind= ind(xyears.eq.yind) ; We are extracting each year one by one
> >
> > z=dimsizes(time_ind)
> >
> > sce_ind=sce_area(time_ind); extracting the array of sce which matches
> the indices
> >
> > sce_year=sce_ind(1:52); This is to take only 52 weeks from the indices
> for each year
> >
> > sce_reshape=reshape(sce_year,(/1,52/)); This is putting the output with
> one row and 52 columns
> >
> > sce_week(i,52)=sce_reshape; This is putting the array in the new array
> >
> > if (z.gt.52) then ; This is for years which have more then 52 weeks
> > i=i+1
> > end if
> >
> > end do
> >
> ;*****************************************************************************
> >
> >
> > Thank You
> > Best Regards
> > Ipshita
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20141106/994fa3d7/attachment.html 


More information about the ncl-talk mailing list