<div dir="ltr"><div>Hi<br><br></div>Here is the input file. I will follow the advice you gave, thanks so much for the help. I will update once I am able to able to make it work <br><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jan 23, 2016 at 2:30 PM, Adv <span dir="ltr">&lt;<a href="mailto:advita6@gmail.com" target="_blank">advita6@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div>Hi ,<br></div>Can you please attach a input file? Is that three dimensional array. If so<br><br></div>a(time:,lat:,lon:)<br></div>a(0:end:7,:,:) This would give you a weekly data from daily and then calculate average to get a weekly average.<br><br></div>Cheers..<br><div><div><div><br></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div>On Sat, Jan 23, 2016 at 5:01 PM, Ipshita Majhi <span dir="ltr">&lt;<a href="mailto:ipmajhi@alaska.edu" target="_blank">ipmajhi@alaska.edu</a>&gt;</span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><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" target="_blank">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" target="_blank">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>
<br></div></div>_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br><br clear="all"><br>-- <br><div><div dir="ltr"><div><div><div><div>Ipshita Majhi<br></div>PhD Candidate<br></div>University of Alaska , Fairbanks<br></div>Atmospheric Science Department<br></div><a href="tel:%28907%29978-4220" value="+19079784220" target="_blank">(907)978-4220</a> <a href="mailto:ipmajhi@alaska.edu" target="_blank">ipmajhi@alaska.edu</a><br></div></div>
</div></div>