average in reanalysis data

Charles Seman Charles.Seman at NOAA.GOV
Fri Mar 18 18:22:46 EST 2005


Luis,

Perhaps you could try calculating an average of 30 years of averaged
precipitation data as follows:

ts = 1961
tf = 1990
nyear = tf-ts+1
*
*  initialize "pravgsum" for the first year...
*
tt=ts
*
*  define reanalysis file in terms of year index "tt"
*
reanalysis_file = ...  * must be defined
' open 'reanalysis_file
'query file'
say result
say ' '
rec5 = sublin(result,5) ; rec6 = sublin(result,6)
xsiz = subwrd(rec5,3) ; ysiz = subwrd(rec5,6) ; zsiz = subwrd(rec5,9) ;
tsiz = subwrd(rec5,12)
nvar = subwrd(rec6,5)
say '   nvar 'nvar
say '   xsiz 'xsiz
say '   ysiz 'ysiz
say '   zsiz 'zsiz
say '   tsiz 'tsiz
*
'set lon ...'   * must be defined
'set lat ...'   * must be defined
'set lev ...'   * must be defined
'set t 1'
'define pravg = ave('precip_variable',t=1,t='tsiz')'   * must be defined
*
*  start sum of yearly precip averages...
*
'pravgsum = pravg'
'undefine pravg'
*
* close reanalysis file for this year...
*
'close 1'
*
*  update "pravgsum" for each of the rest of the years...
*
tt=tt+1
while ( tt <= tf )
*
*  define reanalysis file in terms of year index "tt"
*
  reanalysis_file = ...  * must be defined
  'open 'reanalysis_file
  'set lon ...'    * must be defined
  'set lat ...'    * must be defined
  'set lev ...'    * must be defined
  'set t 1'
  'define pravg = ave('precip_variable',t=1,t='tsiz')'   * must be defined
*
*  update "pravgsum" using "pravg" for this year...
*
  'pravgsum = pravgsum + pravg'
  'undefine pravg'
*
* close reanalysis file for this year...
*
  'close 1'
  tt=tt+1
endwhile
*
*  calculate the average of the "nyear" yearly averages...
*
'define pravg = pravgsum/'nyear

'd pravg'

....

I hope this helps... Please let me know if you find any problems with
the above technique, OK?

Thanks,
Chuck


Luis Fernando Montana R. wrote:

> Hello all,
>
> I'm using data of the reanalysis for period 1961-1990. I have 30
> files, one per year and need to calculate the average of precipitation
> for that period.
>
> There is some simplified form to do it?
>
> Thanks in advance,
>
> Luis Fernando Montana Roa
> Posgrado de Meteorologia
> Universidad Nacional de Colombia
> Bogota - Colombia - South America
>

--

********************************************************************
 Charles Seman                                Charles.Seman at noaa.gov
 U.S. Department of Commerce / NOAA / OAR
 Geophysical Fluid Dynamics Laboratory         voice: (609) 452-6547
 201 Forrestal Road                              fax: (609) 987-5063
 Princeton, NJ  08542                 http://www.gfdl.noaa.gov/~cjs/
********************************************************************

"The contents of this message are mine personally and do not reflect
any position of the Government or NOAA."



More information about the gradsusr mailing list