[ncl-talk] weighted averages
Dennis Shea
shea at ucar.edu
Fri Oct 27 13:44:28 MDT 2017
Some references that ma/may-not be of help:
https://en.wikipedia.org/wiki/Gaussian_grid
http://journals.ametsoc.org/doi/pdf/10.1175/1520-0493%
281999%29127%3C1872%3ASAMDF%3E2.0.CO%3B2
*Question 1: *Is it appropriate to apply the gaussian weights method to my
grid?
Yes. T42 (64 lat x 128 lon) is a gaussian grid where a spectral Triangular
truncation has been applied.
The gaussian weights should be on the file [likely named: *gwt*].
In short, use the gaussian weights.
---
If grid point weights (gaussian or, say, cos(lat)) are not provided you
must calculate them:
(a) Gaussian Weights: https://www.ncl.ucar.edu/Document/Functions/
Contributed/latGauWgt.shtml
This uses a fortran code that that yields gaussian weights such that
global integrals will be exact.
The output matches what the models use.
(b) Latitudinal weighting: https://www.ncl.ucar.edu/Document/Functions/
Contributed/latRegWgt.shtml
*Question 2: *What is not clear to me is why do we write dy(0) =
abs(lat(2)-lat(1))*rr?
Why do we not write dy(0) = abs(lat(1)-lat(0))*rr instead?
---
Well if they are equally spaced it does not make any difference.
Likely, when I wrote this documentation I was mentally using fortran
subscripting/indexing (1-based) rather the C- which uses 0-based
subscripting.
On Fri, Oct 27, 2017 at 7:44 AM, Amanda Frigola <afrigola at marum.de> wrote:
> Dear all,
>
> I was trying to calculate a weighted average with a gaussian grid (CAM
> model, T42).
>
> I found this link:
> http://www.ncl.ucar.edu/Document/Functions/Built-in/wgt_areaave.shtml
>
> The first example described in there suggests three possible different
> methods:
> 1. cell area method
> 2. gaussian weights method
> 3. cos(lat) method.
>
> I would like to use either the first or the second methods.
> I would have two questions.
>
> *Question one*: Is it appropriate to apply the gaussian weights method to
> my grid? The appropriateness of this method is based on the assumption that
> the gaussian weights are proportional to the cell areas. What are the
> gaussian weights? How are they calculated? And why are they proportional to
> the cell areas?
>
> *Question two*: The code provided in the link above to calculate the
> weighted average using the cell area method is as follows:
>
> lat = f->lat
> lon = f->lon
>
> jlat = *dimsizes* <http://www.ncl.ucar.edu/Document/Functions/Built-in/dimsizes.shtml>( lat )
>
> rad = 4.0**atan* <http://www.ncl.ucar.edu/Document/Functions/Built-in/atan.shtml>(1.0)/180.0
> re = 6371220.0
> rr = re*rad
>
> dlon = *abs* <http://www.ncl.ucar.edu/Document/Functions/Built-in/abs.shtml>(lon(2)-lon(1))*rr
> dx = dlon**cos* <http://www.ncl.ucar.edu/Document/Functions/Built-in/cos.shtml>(lat*rad)
>
> dy = *new* <http://www.ncl.ucar.edu/Document/Functions/Built-in/new.shtml> ( jlat, *typeof* <http://www.ncl.ucar.edu/Document/Functions/Built-in/typeof.shtml>(dx))
>
> dy(0) = *abs* <http://www.ncl.ucar.edu/Document/Functions/Built-in/abs.shtml>(lat(2)-lat(1))*rr
> dy(1:jlat-2) = *abs* <http://www.ncl.ucar.edu/Document/Functions/Built-in/abs.shtml>(lat(2:jlat-1)-lat(0:jlat-3))*rr*0.5
> dy(jlat-1) = *abs* <http://www.ncl.ucar.edu/Document/Functions/Built-in/abs.shtml>(lat(jlat-1)-lat(jlat-2))*rr
>
> area = dx*dy
>
> uAve_area = *wgt_areaave*(u, area, 1.0, 1)
>
>
> My question regards the way dy is calculated.
>
> I understand that dy(0) and dy(jlat-1) need to be calculated in a different way, because the general expression dy(j)= abs(lat(j+1)-lat(j-1))*rr*0.5, is not defined for j=0 and j=(jlat-1), since the subscript of the
>
> function lat would go out of range. What is not clear to me is why do we write dy(0) = abs(lat(2)-lat(1))*rr?
>
> Why do we not write dy(0) = abs(lat(1)-lat(0))*rr instead?
>
> Hope you can help,
>
> Amanda
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20171027/cedb0371/attachment.html>
More information about the ncl-talk
mailing list