problems with aave
Diane Stokes
Diane.Stokes at NOAA.GOV
Fri Feb 23 13:24:14 EST 2007
I see two (maybe three) contributing factors to the difference:
First, the result from aave is latitude weighted. From the documentation:
"The aave function assumes that the world coordinates are longitude in
the X dimension and latitude in the Y dimension, and does weighting in
the latitude dimension by the difference between the sines of the
latitude at the northern and southern edges of the grid box. For areal
averaging without latitude weighting, use the amean function."
The impact of using aave vs amean depends on the latitude range of your
region.
Second, in your fortran code, the denominator is too small when you
divide mh(i) by the number of gridsquares. You have:
mh(i)=mh(i)/((35-26)*(50-43))
Try:
mh(i)=mh(i)/((35-26+1)*(50-43+1))
A third (possible) factor is that you have missing value(s) that would
get excluded from the aave (or amean) calculation but are not excluded
in the code. The impact from that would depend on the value you use for
"missing".
Diane
sansaad wrote:
> Hi everybody
>
> I'd done some calculations using both GRADS and Fortran, and I realised
> that the spatial average using GRADS (aave) differs by a ratio of
> approximately 0.787 from the spatial average using Fortran. By this I
> mean that if I multiply the Fortran's values by 0.787, they ALWAYS match
> with the GRADS' values (with small errors).
>
> Can anyone explain the reason for this "magic number" (0.787)?
>
> A part of the program using GRADS and Fortran respectively are given
> bellow.
>
> I would appreciate any kind of commentaries.
>
> Sandra Saad
>
>
> ### Spatial Average using GRADS ########
>
> set t 1 last
> d aave(h,x=26,x=35,y=43,y=50)
>
>
> ### Spatial Average using Fortran (90) ########
>
> do i=1,it
> do ny=43,50
> do nx=26,35
> mh(i)=mh(i)+h(i,nx,ny)
> enddo
> enddo
> mh(i)=mh(i)/((35-26)*(50-43))
> enddo
>
> do i=1,it
> write(3,*)i,mh(i)
> enddo
>
More information about the gradsusr
mailing list