Calculates a running correlation.
Available in version 5.2.0 and later.
load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/run_cor.ncl" function run_cor ( x [*] : numeric, y [*] : numeric, time [*] : numeric, wSize  : integer ) return_val [*] : numeric
A one-dimensional array of any numeric type.y
An array of any numeric type and the same size as x.time
A one-dimensional numeric array of the same size as x and y that represents the time coordinates of x and y. This array must have a "units" attribute recognized by ut_calendar.wSize
An integer representing the number of points to include in the running correlation.
A one-dimensional array dimensioned npts-wSize-1, where npts represents the length of x and y. The return type will be double if x or y are double, and float otherwise.
This function uses escorc to calculate a running correlation, given a window wSize.
The window size represents the number of elements to include in the running correlation (time width). Generally we use 11 year, 15 year, 21 year and so on.
Suppose the parameters are Xi and Yi, where i=1....n. The return values of run_cor for a wSize=11 is a one dimensional array of correlation values of each group of 11 years; i.e. the correlation coefficient for the parameters Xi and Yi corresponds to i=1 to 11, i=2 to 12, i=3 to 13, . . . i=(n-10) to n.
Similarly for wSize=15. The correlation value of each group of 15 years is calculated where Xi and Yi corresponds to i=1 to 15, i=2 to 16, i=3 to 17,. . . i=(n-14) to n.
For any time width, the correlation value corresponds to the middle year.
This script was contributed by:
Sabeerali C T
Climate and Global Modelling Division
Indian Institute of Tropical Meteorology
cor_11 = run_cor(x,y,time,11) cor_15 = run_cor(x,y,time,15) cor_21 = run_cor(x,y,time,21)