<div dir="ltr"><div><div>Dear NCL,<br><br></div>I have written a code to convert daily to weekly data and it does not match the data set I have, the code I have written works. I was wondering where I went wrong. If you could guide me on that it would be very helpful.<br><br></div>Here is the code<br>***********************************************************************<br>;This is to convert daily to weekly for precipitation data<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>a= addfile(&quot;~/Documents/Snow_cover_IMS/NCL_codes/<a href="http://precp_daily_krishna.nc">precp_daily_krishna.nc</a>&quot;,&quot;r&quot;)<br>precp=a-&gt;p<br>t=a-&gt;time<br><br><br>time_cd=cd_calendar(t,0)<br><br>;Since we are reading data from 1967-2013, we have 46 years<br>year_52=ispan(1901,2010,1)<br><br><br>;Writing a loop to process the xday information<br><br>xday=new((/110,365/),&quot;float&quot;)<br>time_year=time_cd(:,0)<br><br>do i=0,109<br><br>matching=ind(year_52(i).eq.time_year) <br><br><br><br>day_size=(dimsizes(matching))<br><br>if (day_size.gt.365) then<br><br>d=matching(1:365)<br><br>else<br>d=matching<br>end if <br>precp_daily=precp(d)<br>xday(i,:)= precp_daily<br><br>delete(matching)<br>delete(precp_daily)<br><br>end do<br>print(xday)<br><br><br>; Now converting daily to weekly<br><br>;Now we want to convert the 365 days to weekly for each year<br><br>;Now just doing it for one year and checking the result<br><br>;pweek=new((/110,52/),&quot;float&quot;)<br>x364=xday(:,0:363); This is to get 52 weeks <br>;print(x364)<br><br>printVarSummary(x364)<br>pweek=new((/110,52/),&quot;float&quot;)<br> <br>  <br>do i=0,109<br>do j=0,357,7<br>pweek(i,j/7)=avg(x364(i,j:j+6))<br>if(any(ismissing(pweek))) then<br>pweek@_FillValue =-9999.0  ; sets _FillValue to -9999.0   <br>  end if<br>end do<br>end do<br><br><br>pweek = where(<a href="http://pweek.gt">pweek.gt</a>. 1e25, pweek@_FillValue, pweek)<br><br>printMinMax(pweek, 0)<br><br>opt = True<br>opt@fout = &quot;weekly_mean_AIR_precp.txt&quot;<br>write_matrix(pweek, &quot;52f9.1&quot;, opt) <br><br>******************************************************************************<br clear="all"><div><div><div><div><br></div></div></div></div></div>