[ncl-talk] weighted averages

Amanda Frigola afrigola at marum.de
Fri Oct 27 07:44:47 MDT 2017


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( lat )

  rad    = 4.0*atan(1.0)/180.0
  re     = 6371220.0
  rr     = re*rad

  dlon   = abs(lon(2)-lon(1))*rr
  dx     = dlon*cos(lat*rad)

  dy     = new ( jlat, typeof(dx))
                                                            
  dy(0)  = abs(lat(2)-lat(1))*rr
  dy(1:jlat-2)  = abs(lat(2:jlat-1)-lat(0:jlat-3))*rr*0.5   
  dy(jlat-1)    = abs(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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20171027/8f4f8772/attachment.html>


More information about the ncl-talk mailing list