# [ncl-talk] Weekly avg with years of varying weeks

Wed Nov 12 09:43:47 MST 2014

```Hi,

I wrote a code to extract each year and then take a long term weekly
average i.e for 52 weeks. There are some years which have 53 years . I get
a matrix of 46 by 52 but it is not writing it out in a matrix.
Error: Subscript out of range, error in subscript #0
Then when I average it, it gives me only one value instead of 52 and if I
use
dim_avg_n then it gives other sets of concern.

Error : Invalid dimension sizes

;*******************************************
;*******************************************

","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); Years from the SCE dataset

;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((/46,52/),"float")
years=ispan(1967,2013,1)

do i=1,46

yind=years(i)

;Finding the index matching the year

time_ind=ind(xyears.eq.2012)

; Extracting that years snow cover extent

sce_year=sce_area(time_ind)
sce_52=sce_year(0:51)

;Now checking for years with 53 weeks
z=dimsizes(sce_year)

sce_week(i,0:51)=sce_52(i)

opt = True
opt at title  = "sce_week_matrix.txt"

;write_matrix(sce_week, "52f1.10", opt)

end do

sce_week_avg=dim_avg_n_Wrap( sce_week, 2 )

Thank YOu
Best Regards
Ipshita
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20141112/eccabe06/attachment.html
```