Re: correlating two arrays

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Mon, 21 Jan 2008 17:59:14 -0700

Assuming you want a areal weighted pattern correlation, see Example 8
   http://www.ncl.ucar.edu/Document/Functions/Built-in/escorc.shtml

The "wgt" variable in this example is assumed to be the cos latitude

  lat(lat)
  rad = 4.*atan(1.)/180.
  wgt = cos(rad*lat)

Then proceed as in example 8
===============================
If the lat/lon arrays are 2D, say, XLAT, XLONG

   
            wgt = cos(rad*XLAT) ; wgt[*][*]
           

      xAvgArea = x*wgt/sum(wgt) ; weighted area average
      yAvgArea = y*wgt/sum(wgt) ** <http://www.ncl.ucar.edu/Document/Functions/Built-in/wgt_areaave.shtml>

      xAnom = x - xAvgArea ; anomalies
      yAnom = y - yAvgArea

      covxy = *sum* <http://www.ncl.ucar.edu/Document/Functions/Built-in/sum.shtml>(xAnom*yAnom*wgt) ; weighted anomaly covariance

      r = covxy/( *sqrt* <http://www.ncl.ucar.edu/Document/Functions/Built-in/sqrt.shtml>(*sum* <http://www.ncl.ucar.edu/Document/Functions/Built-in/sum.shtml>(wgt*xAnom^2)) **sqrt* <http://www.ncl.ucar.edu/Document/Functions/Built-in/sqrt.shtml>(*sum* <http://www.ncl.ucar.edu/Document/Functions/Built-in/sum.shtml>(wgt*yAnom^2)) )

Erik Noble wrote:
> Hi.
>
> I have two 2D arrays:
>
>>> whos Model1
>>>
> Name Size Bytes Class Attributes
>
> Model1 30x79 18960 double
>
>
>>> whos Obs
>>>
> Name Size Bytes Class Attributes
>
> Obs 30x79 18960 double
>
> I want to correlate these two arrays. Which set of NCL functions does this?
>

_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Jan 21 2008 - 17:59:14 MST

This archive was generated by hypermail 2.2.0 : Wed Jan 23 2008 - 14:19:33 MST