# specx_anal

Calculates 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 specx_anal(
x    : float,
iopt : integer,
jave : integer,
pct  : float
)
```

## Arguments

x
A 1-dimensional array of length N containing the data. 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

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

• spcx - 1-dimensional array 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.

• 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.

## Example 1

Perform a spectral analysis on series x:
```   iopt = 0    ; remove series mean
jave = 0    ; no smoothing; return periodogram estimates
pct  = 0.1  ; taper 10% of the data
dof  = specx_anal (x,iopt,jave,pct)
```

## Example 2

Perform a spectral analysis on series x but assume x has dimensions nyrs x nmos where nyrs represents the number of years and nmos the number of months. Use NCL function ndtooned:
```   iopt = 0    ; remove series mean
jave = 3    ; Average 3 periodogram estimates using modified Daniel
pct  = 0.1  ; taper 10% of the data
dof  = specx_anal (ndtooned(x),iopt,jave,pct)
```

## Example 3

Perform a spectral analysis on series x but assume x has dimensions time x lev x lat x lon and named dimensions "time", "lev", "lat", "lon". Let's assume we want the spectral analysis across time at a specific point lev=kl, lat=nl, lon=ml. Then, using NCL's dimension reordering:
```   iopt = 1    ; remove least squares linear trend in x
; prior to tapering and computing spectra.
jave = 5    ; Average 5 periodogram estimates using modified Daniel
pct  = 0.1  ; taper 10% of the data
dof  = specx_anal (x(lev|kl:kl,lat|nl:nl,lon|ml:ml,time:),iopt,jave,pct)
```

### Reference Manual Control Panel

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