how to do averaging over land

Stegert stegert at IFM.UNI-HAMBURG.DE
Thu May 10 05:03:33 EDT 2007


Dear,

I don't know whether there is a 'direct' way within GrADS.
Anyway, I calculated average values at certain ocean areas.

I assume you have a certain grid of say 180x120 cells (i.e.
1'x1' per cell for your area).

1) You create a land-sea-mask within an ASCII-file
(landsea.dat) containing a 180x120 matrix of zeros and ones
representing land and sea, respectively.

2) open your grads-file and do a loop through the map (assumably
a 2d dataset!?)
var = 0
inc = 0
j   = 120
while (j>0)
  'set y 'j
  lsmask = read(landsea.dat)  * opens the dat-file
  lsline = sublin(lsmask,2)   * read line
  i = 1
  while (i<181)
    'set x 'i
    lsval = subwrd(lsline,i)  * read value
    if (lsval = 1)            * only when on land
      'd parameter'           * read value from grads
      var = var + subwrd(result,4)
      inc = inc + 1
    endif
    i = i+1
  endwhile
  j = j-1
endwhile
st = close(landsea.dat)

With 'var' you have the total amount over land.
With 'var/inc' you'll get the average over land.
Mind: In the .dat the 10°N/100°E is in the last
line (that's why to count j from 120 to 0).

You can also put this within a temporal loop to
read different time steps as well as you can define
different areas (defined by 0,1,2,...) and with
elseif (lsval = 2) var2 = var2+subwrd(result,4); inc2 = inc2+1; endif
elseif (lsval = 3) var3 = var3+subwrd(result,4); inc3 = inc3+1; endif
etc.

Hope, this helps.
Christoph

praise praise wrote:
>
> Dear frineds,
>
> My problem is to construct a time series representing an area average of
> a parameter, say temperature, over the area say (100-130E, 10-30N).  But
> I am only interested in the average over land.
>
> Thus, do anyone know how to define the variable representing an areal
> average over land only?
>
> Thanks
>
> MC


--
Christoph Stegert
Institute for Oceanography - Ecological Modelling group
University of Hamburg, GER - (ZMK/ZMAW alliance member)
Bundesstr.53 20146 Hamburg - +49-40/42838-7486 Room 348



More information about the gradsusr mailing list