[gradsusr] calculating monthly from daily averages

kombo kai kaikombo at yahoo.com
Mon Jun 29 05:47:14 EDT 2015


Hi grad users I want to calculate the monthly averages from the daily average data I have found a script in the grads users blog.I tried to correct the script based on my data, but when I run the script it gives me the .nc file with constant number and with only one time step, the length of my daily data is from t=1 (st January 1998) to t=5632(May 2013) days?Is their any one can help to see where is the problem 
Here is the the script? 
 'reinit'mday = '31 28 31 30 31 30 31 31 30 31 30 31'month = 'jan feb mar apr may jun jul aug sep oct nov dec'
 'sdfopen  C:/Users/laptop/Documents/Work/datatrim/data_trim.nc' 'set x 1 136 ' 'set y 1 144' 'set t 1 5630'* 'set z 1'   yr1 = 1998  yr2 = 2012
 yr = yr1 while(yr<=yr2)  leap = 0  if(math_mod(yr,400) = 0 | math_mod(yr,4) = 0 & math_mod(yr,100) != 0)   leap = 1* say yr' is a leap year.'  endif  imon = 1  while(imon <= 12)   md = subwrd(mday,imon)   mc = subwrd(month,imon)   if(imon = 2); md = md + leap; endif;   time1 = '01'mc''yr   time2 = md''mc''yr*   say time1' 'time2   'define aveprecip= ave(precipitation,time='time1',time='time2')'*   'set gxout sdfwrite'   'set sdfwrite  C:/Users/laptop/Documents/Work/datatrim/monthly_trim.nc'  'sdfwrite aveprecip'   imon = imon + 1   endwhile  yr = yr + 1 endwhile'c'regaedskaikombo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20150629/6541b435/attachment.html 


More information about the gradsusr mailing list