<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title></title><style type="text/css">.felamimail-body-blockquote {margin: 5px 10px 0 3px;padding-left: 10px;border-left: 2px solid #000088;} </style></head><body><font face="times new roman">Dear all,</font><div style=""><font face="times new roman"><br></font></div><div style=""><font face="times new roman">I was trying to calculate a weighted average with a gaussian grid (CAM model, T42). </font></div><div style=""><font face="times new roman"><br></font></div><div style=""><font face="times new roman">I found this link:</font></div><div style=""><font face="times new roman">http://www.ncl.ucar.edu/Document/Functions/Built-in/wgt_areaave.shtml</font></div><div style=""><font face="times new roman"><br></font></div><div style=""><font face="times new roman">The first example described in there suggests three possible different methods: </font></div><div style=""><font face="times new roman">1. cell area method</font></div><div style=""><font face="times new roman">2. gaussian weights method</font></div><div style=""><font face="times new roman">​3. cos(lat) method.</font></div><div style=""><font face="times new roman"><br></font></div><div style=""><font face="times new roman">I would like to use either the first or the second methods.</font></div><div style=""><font face="times new roman">I would have two questions.</font></div><div style=""><font face="times new roman"><br></font></div><div style=""><font face="times new roman"><b>Question one</b>: 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?</font></div><div style=""><font face="times new roman"><br></font></div><div style=""><font face="times new roman"><b>Question two</b>: The code provided in the link above </font><span style="font-family: "times new roman";">to calculate the weighted average using the cell area method</span><span style="font-family: "times new roman";"> is as follows:</span></div><div style=""><font face="times new roman"><br></font></div><div style=""><pre style="font-size: 13.3333px; line-height: 12pt; border-style: solid; border-width: 0px 0px 15px; border-color: transparent; background-color: rgb(255, 255, 255);"><font face="times new roman">  lat   = f->lat
  lon   = f->lon

  jlat  = <a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/dimsizes.shtml" style="margin: 0px; padding: 0px; text-decoration-line: none; color: rgb(133, 45, 133);"><strong style="margin: 0px; padding: 0px;">dimsizes</strong></a>( lat )

  rad    = 4.0*<a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/atan.shtml" style="margin: 0px; padding: 0px; text-decoration-line: none; color: rgb(133, 45, 133);"><strong style="margin: 0px; padding: 0px;">atan</strong></a>(1.0)/180.0
  re     = 6371220.0
  rr     = re*rad

  dlon   = <a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/abs.shtml" style="margin: 0px; padding: 0px; text-decoration-line: none; color: rgb(133, 45, 133);"><strong style="margin: 0px; padding: 0px;">abs</strong></a>(lon(2)-lon(1))*rr
  dx     = dlon*<a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/cos.shtml" style="margin: 0px; padding: 0px; text-decoration-line: none; color: rgb(133, 45, 133);"><strong style="margin: 0px; padding: 0px;">cos</strong></a>(lat*rad)

  dy     = <a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/new.shtml" style="margin: 0px; padding: 0px; text-decoration-line: none; color: rgb(133, 45, 133);"><strong style="margin: 0px; padding: 0px;">new</strong></a> ( jlat, <a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/typeof.shtml" style="margin: 0px; padding: 0px; text-decoration-line: none; color: rgb(133, 45, 133);"><strong style="margin: 0px; padding: 0px;">typeof</strong></a>(dx))
                                                            
  dy(0)  = <a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/abs.shtml" style="margin: 0px; padding: 0px; text-decoration-line: none; color: rgb(133, 45, 133);"><strong style="margin: 0px; padding: 0px;">abs</strong></a>(lat(2)-lat(1))*rr
  dy(1:jlat-2)  = <a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/abs.shtml" style="margin: 0px; padding: 0px; text-decoration-line: none; color: rgb(133, 45, 133);"><strong style="margin: 0px; padding: 0px;">abs</strong></a>(lat(2:jlat-1)-lat(0:jlat-3))*rr*0.5   
  dy(jlat-1)    = <a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/abs.shtml" style="margin: 0px; padding: 0px; text-decoration-line: none; color: rgb(133, 45, 133);"><strong style="margin: 0px; padding: 0px;">abs</strong></a>(lat(jlat-1)-lat(jlat-2))*rr

  area   = dx*dy        </font></pre><pre style="font-size: 13.3333px; line-height: 12pt; border-style: solid; border-width: 0px 0px 15px; border-color: transparent; background-color: rgb(255, 255, 255);"><font face="times new roman"> uAve_area = <strong style="font-size: 13.3333px; margin: 0px; padding: 0px;">wgt_areaave</strong><span style="font-size: 13.3333px;">(u, area, 1.0, 1)</span>                      </font></pre><pre style="font-size: 13.3333px; line-height: 12pt; border-style: solid; border-width: 0px 0px 15px; border-color: transparent; background-color: rgb(255, 255, 255);"><font face="times new roman"><br></font></pre><pre style="font-size: 13.3333px; line-height: 12pt; border-style: solid; border-width: 0px 0px 15px; border-color: transparent; background-color: rgb(255, 255, 255);"><font face="times new roman">My question regards the way dy is calculated.</font></pre><pre style="font-size: 13.3333px; line-height: 12pt; border-style: solid; border-width: 0px 0px 15px; border-color: transparent; background-color: rgb(255, 255, 255);"><font face="times new roman">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 </font></pre><pre style="font-size: 13.3333px; line-height: 12pt; border-style: solid; border-width: 0px 0px 15px; border-color: transparent; background-color: rgb(255, 255, 255);"><font face="times new roman">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? </font></pre><pre style="font-size: 13.3333px; line-height: 12pt; border-style: solid; border-width: 0px 0px 15px; border-color: transparent; background-color: rgb(255, 255, 255);"><font face="times new roman">Why do we not write dy(0) = abs(lat(1)-lat(0))*rr instead?</font></pre><pre style="font-size: 13.3333px; line-height: 12pt; border-style: solid; border-width: 0px 0px 15px; border-color: transparent; background-color: rgb(255, 255, 255);"><font face="times new roman">Hope you can help,</font></pre><pre style="font-size: 13.3333px; line-height: 12pt; border-style: solid; border-width: 0px 0px 15px; border-color: transparent; background-color: rgb(255, 255, 255);"><font face="times new roman">Amanda</font></pre></div></body></html>