[ncl-talk] Error: Subscript out of range error in subscript #1
Ipshita Majhi
ipmajhi at alaska.edu
Thu Nov 6 11:41:53 MST 2014
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
","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/6af4fbe1/attachment.html
More information about the ncl-talk
mailing list