Re: to calculate the average of variables only on land or for only a continet

From: Dennis Shea (shea AT XXXXXX)
Date: Wed Feb 06 2002 - 15:37:19 MST


>Thanks for your answer. I have that thought. But which function should I use?
>wgt_areaave? It needs two arrays. But I think the mask for the land and ocean
>isn't even. It can't be defined by two 1-dim arrays. Is there a function to
>calculate the weighted average using a 2-dim array(mask)? I can't find such a
>function. Thanks.

As is often the case, you must combine one or more functions
to do what you want. Here you want to use two functions:
mask and wgt_areaave. This is the art of programming :-)

The actual mask documentation is at:

    http://ngwww.ucar.edu/ngdoc/ng/ref/ncl/functions/mask.html

Some examples of "mask" are at:

    http://www.cgd.ucar.edu/csm/support/CSM_Graphics/mask.shtml
    
Please look at them.

Note: you must have some array that is used by the mask operator.
      below the array is denoted as "lsmask"

-------
Let "x" be the data

  land_only = x ; trick to maintain meta data
  ocean_only = x

  land_only = mask(x, lsmask, 1)
  ocean_only = mask(x, lsmask, 0)
  

----

Now please read the documentation on wgt_areaave http://ngwww.ucar.edu/ngdoc/ng/ref/ncl/functions/wareaave.html Yes, wgt_areaave has 2 1D wgt arrays but

(1) if you have gaussian weights (say, gw) you could use

xAreaAve = wgt_areaave (x, gw, 1.0, 0)

(2) if you want cosine weighting. I'll assume "lat" is 1D (units=degrees), then

cwgt = cos(lat*0.0174532) ; array syntax xAreaAVE = wgt_areaave (x, cwgt, 1.0, 0)

Regards, Dennis Shea



This archive was generated by hypermail 2b29 : Tue Feb 19 2002 - 08:48:13 MST