Computing pentad averages!

Charles Seman Charles.Seman at NOAA.GOV
Fri May 4 18:16:44 EDT 2007


Abbas Mofidi,

I'm not sure if this is what you want to do, but here is a
possibility... Note, it is assumed that each netCDF dataset has the same
grid coordinates... Please note, the following code has not been tested,
so use with caution...

'sdfopen ncdata\hour\uwind200mb-1apr-31oct1994-daily.nc'
'sdfopen ncdata\hour\vwind200mb-1apr-30sep1994-daily.nc'
'sdfopen ncdata\hour\hgt200mb-1apr-30sep1994-daily.nc'
*
*  define pentad averages (centered running means) for all time levels
between t=64 to t=151 (ie 62-66, 63-67, ... ,149-153)
*
'set lat 10 50'
'set lon 20 110'
'set z 1'
'set t 64 151'
'set dfile 1'
'define u5 = ave(uwnd,t-2,t+2)'
'set dfile 2'
'define v5 = ave(vwnd,t-2,t+2)'
'set dfile 3'
'define z5 = ave(hgt,t-2,t+2)'
*
*  plot desired time levels (every 5th time level) between t=64 to t=151
(ie 62-66, 67-71, ... ,149-153)...
*
     ti = 64
while ti <= 151
    'clear'
*
*  assuming "u5", "v5", and "z5" are on the same grid...
*
    'set t ' ti
    'set lat 10 50'
    'set lon 20 110'
    'set z 1'
*
*  plot vorticity (assuming "u5" and "v5" are on the same grid)
*
    'set dfile 1'
    'set gxout shaded'
    'set csmooth on'
    'set grid off'
    'set cint 0.00001'
    'set black -1e-06 1e-06'
    'set font 2'
    'set xlopts 1 5 0.14'
    'set ylopts 1 5 0.14'
    'display hcurl(u5,v5)/0.00001'
    'run cbarn'
*
*  overlay heights
*
    'set dfile 3'
    'set gxout contour'
    'set csmooth on'
    'set grid off'
    'set cint 25'
    'set clskip 2'
    'set font 2'
    'set cthick 6'
    'set xlopts 1 5 0.14'
    'set ylopts 1 5 0.14'
    'set ccolor 1'
    'set map 1'
    'display z5'
    'draw title Vorticity 700hPa and Geop.Height 200hPa-' ti''
  'printim Vort&Hgt200mb' ti '.gif gif x1200 y1000 white'
    ti = ti + 5
ENDWHILE
say

I hope this helps,
Chuck

abbas mofidi wrote:
> Dear Grads users,
> I am new to Grads and I have a question related to getting time
> average. I have written a sript to compute the pentad averages of
> variables. I don't know what's wrong with it which instead of pentad
> averages(for example in the following script: the pentad for 62-66,
> 67-71,72-76,......) it is displaying just for the first day of each
> pentad(62th,67th,72th,...)?
> Thank you very much for your assistance
> A. Mofidi
> * script For Computing pentad Vorticity and Hgt 200hpa-JJA
>      ti = 62
> while ti <= 153
> 'sdfopen ncdata\hour\uwind200mb-1apr-31oct1994-daily.nc'
> 'sdfopen ncdata\hour\vwind200mb-1apr-30sep1994-daily.nc'
> 'sdfopen ncdata\hour\hgt200mb-1apr-30sep1994-daily.nc'
>     'clear'
>     'set dfile 1'
>     'set t ' ti
>     'set lat 10 50'
>     'set lon 20 110'
>     'set z 1'
>     'set ave(z 1,ti=62,ti=153)'
>     'u=uwnd'
>     'set dfile 2'
>     'set t ' ti
>     'set z 1'
>     'set ave(z 1,ti=62,ti=153)'
>     'v=vwnd'
>     'set gxout shaded'
>     'set csmooth on'
>     'set grid off'
>     'set cint 0.00001'
>     'set black -1e-06 1e-06'
>     'set font 2'
>     'set xlopts 1 5 0.14'
>     'set ylopts 1 5 0.14'
>     'display hcurl(u,v)/0.00001'
>     'run cbarn'
>     'set dfile 3'
>     'set t ' ti
>     'set lat 10 50'
>     'set lon 20 110'
>     'set z 1'
>     'set ave(z 1,ti=62,ti=153)'
>     'set gxout contour'
>     'set csmooth on'
>     'set grid off'
>     'set cint 25'
>     'set clskip 2'
>     'set font 2'
>     'set cthick 6'
>     'set xlopts 1 5 0.14'
>     'set ylopts 1 5 0.14'
>     'set ccolor 1'
>     'set map 1'
>     'display hgt'
>     'draw title Vorticity 700hPa and Geop.Height 200hPa-' ti''
>   'printim Vort&Hgt200mb' ti '.gif gif x1200 y1000 white'
>     ti = ti + 5
> ENDWHILE
> say
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>

--

Please note that Charles.Seman at noaa.gov should be considered my NOAA
email address, not cjs at gfdl.noaa.gov.

********************************************************************
 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  08540-6649            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