% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/Spectrum.R
\name{Spectrum}
\alias{Spectrum}
\title{Estimate frequency spectrum}
\usage{
Spectrum(data, time_dim = "ftime", ncores = NULL)
}
\arguments{
\item{data}{A vector or numeric array of which the frequency spectrum is 
required. If it's a vector, it should be a time series. If it's an array,
the  dimensions must have at least 'time_dim'. The data is assumed to be  
evenly spaced in time.}

\item{time_dim}{A character string indicating the dimension along which to 
compute the frequency spectrum. The default value is 'ftime'.}

\item{ncores}{An integer indicating the number of cores to use for parallel 
computation. The default value is NULL.}
}
\value{
A numeric array of the frequency spectrum with dimensions 
 c(<time_dim> = number of frequencies, stats = 4, the rest of the 
 dimensions of 'data'). The 'stats' dimension contains the frequency values,
 the power, the 95\% significance level and the 99\% one.
}
\description{
Estimate the frequency spectrum of the data array together with its 95\% and
99\% significance level. The output is provided as an array with dimensions 
power, the 95\% significance level and the 99\% one.\cr
The spectrum estimation relies on a R built-in function \code{spectrum()} 
and the significance levels are estimated by a Monte-Carlo method.
}
\examples{
# Load sample data as in Load() example:
example(Load)

ensmod <- MeanDims(sampleData$mod, c(1, 2))
spectrum <- Spectrum(ensmod)
for (jsdate in 1:dim(spectrum)['sdate']) {
 for (jlen in 1:dim(spectrum)['ftime']) {
   if (spectrum[jlen, 2, jsdate] > spectrum[jlen, 4, jsdate]) {
     ensmod[jsdate, ] <- Filter(ensmod[jsdate, ],  
                                   spectrum[jlen, 1, jsdate])
   }
 }
}
 \donttest{
PlotAno(InsertDim(ensmod, 2, 1), sdates = startDates)
 }

}
