<div dir="ltr"><div><div><div><div><div><div>Hi,<br><br>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. <br></div>Error: Subscript out of range, error in subscript #0<br></div> Then when I average it, it gives me only one value instead of 52 and if I use<br></div>dim_avg_n then it gives other sets of concern.<br><br></div>Error : Invalid dimension sizes<br><br>;*******************************************<br>load &quot;$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl&quot;<br>load &quot;$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl&quot;<br>load &quot;$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl&quot;<br>;*******************************************<br><br>;Reading in the data<br><br>a=addfile(&quot;~/Documents/Snow_cover_IMS/<a href="http://nhsce_v01r01_19661004_20140602.nc">nhsce_v01r01_19661004_20140602.nc</a>&quot;,&quot;r&quot;)<br><br>sce=a-&gt;snow_cover_extent<br>time_sce=a-&gt;time<br><br><br>;Now converting the time from georgian to ut_calender<br>;Doing an area average for sce<br><br>sce_area=wgt_areaave_Wrap(sce,1.0,1.0, 0) <br><br>ut_sce=cd_calendar(time_sce,0)<br><br><br>;Extracting just the year information from the time series<br><br>xyears=ut_sce(:,0); Years from the SCE dataset<br><br>;This part of code is to create a matrix with each years weekly data<br>;The years go from 1967 to 2013 i.e 47 years with 52 weeks for each year<br><br>sce_week=new((/46,52/),&quot;float&quot;)<br>years=ispan(1967,2013,1)<br><br><br>do i=1,46<br><br><br>yind=years(i) <br><br><br>;Finding the index matching the year<br><br>time_ind=ind(xyears.eq.2012)<br><br>; Extracting that years snow cover extent <br><br>sce_year=sce_area(time_ind)<br>sce_52=sce_year(0:51)<br><br>;Now checking for years with 53 weeks<br>z=dimsizes(sce_year)<br><br>sce_week(i,0:51)=sce_52(i)<br><br> opt = True<br>opt@title  = &quot;sce_week_matrix.txt&quot;<br><br>;write_matrix(sce_week, &quot;52f1.10&quot;, opt)<br><br>end do<br><br>sce_week_avg=dim_avg_n_Wrap( sce_week, 2 ) <br><br></div>Thank YOu<br></div>Best Regards<br>Ipshita<br></div>