# specxy_anal

Calculates cross spectra quantities of a series.

Note: This function is only available in version 4.1.1 of NCL. If your site is licensed for version 4.1, then you can get version 4.1.1 for free. To get version 4.1.1 of NCAR Graphics software, please contact your site representative. If you don't know who your site representative is, then send email to ncarginf@ucar.edu or call (303) 497-1201.

## Synopsis

```    function specxy_anal(
x    : float,
y    : float,
iopt : integer,
jave : integer,
pct  : float
)
```

## Arguments

x, y
1-dimensional arrays of length N containing the data. x and y must be the same length. Missing values are not allowed.
iopt
detrending option. iopt = 0 => remove series mean, iopt = 1 => remove the series mean and least squares linear trend.
jave
smoothing to be performed on the periodiogram estimates. This should be an odd number (>= 3). If not, the routine will force it to the next largest odd number.

```  jave=0 : do no smoothing
spcx contains raw spectra estimates (periodogram)
jave>0 : average jave periodogram estimates together
utilizing modified daniell smoothing (good
stability but may lead to large bias ).
all weights are 1/jave except wgt(1) and wgt(jave)
which are 1/(2*jave). this is the recommended option.
It is this number which has the most impact on the
degrees of freedom.
```
pct
percent of the series to be tapered (0.0 <= pct <= 1.0). If pct =0.0, no tapering will be done. If pct = 1.0, the whole series is effected. A pct of 0.10 is common (tapering should always be done).

## Description

specxy_anal returns the degrees of freedom as a float scalar. It also returns the following attributes:

• spcx,spcy - 1-dimensional arrays of length N/2
spcx(0) - spectral estimate at frq = (1/N) [N=dimsizes(x)]
spcx(N/2-1)- spectral estimate at frq = 0.5

These spectra have been normalized so that SUM{spcx(n)*df}= variance of the detrended series where df=frequency spacing. The units are variance/(unit frequency interval).

• frq - frequency (cycles/time). A 1-dimensional array of length N/2.

• cospc - cospectrum. A 1-dimensional array of length N/2. This is the real part of the cross spectrum. It measures the extent to which there are oscillations with the same phase in the two series (or with opposite sign, i.e., with a phase shift of half a cycle). In other words, it measures the contribution of different frequencies to the total cross-covariance at zero lag.

• quspc - quadrature spectrum. A 1-dimensional array of length N/2. This is the imaginary part of the cross spectrum. it measures the extent to which there are oscillations with a phase difference of a quarter cycle in either direction. i.e., It measures the contribution of different frequencies to the total cross-covariance of the series when all harmonics of one series are delayed a quarter cycle relative to the other relative to the other series.

• coher - coherence squared. A 1-dimensional array of length N/2. This is analogous to the square of the correlation coef except that the coherence squared is a function of frequency.

• phase - phase (in degrees). A 1-dimensioinal array of length N/2. A positive phase indicates that x leads y.

• bw - spectral band width (scalar, float)

• xavei - average of the x series on input (scalar, float)

• xvari - variance of the x series on input (scalar, float)

• xvaro - variance of the x series after detrending (scalar, float)

• xlag1 - lag one auto correlation of the x series after detrending (scalar, float)

• xslope - least squares slope per time interval of linear trend (if iopt = 1) of the x series.

• yavei - average of the y series on input (scalar, float)

• yvari - variance of the y series on input (scalar, float)

• yvaro - variance of the y series after detrending (scalar, float)

• ylag1 - lag one auto correlation of the y series after detrending (scalar, float)

• yslope - least squares slope per time interval of linear trend (if iopt = 1) of the y series.

## Example 1

Perform cross-spectral analysis on series x and y:

```   iopt = 1    ; remove least squares linear trends from each
; series prior to tapering and computing spectra.
jave = 7    ; Average 7 periodogram estimates using modified Daniel
pct  = 0.1  ; taper 10% of the data
dof = specxy_anal (x,y,iopt,jave,pct)
```

### Reference Manual Control Panel

\$Revision: 1.5 \$ \$Date: 1999/03/31 17:41:30 \$