\name{EOF}
\alias{EOF}
\title{
Area-Weighted Empirical Orthogonal Function Analysis Using SVD
}
\description{
Performs an area-weighted EOF analysis using SVD based on a covariance matrix 
by default, based on a correlation matrix if \code{corr} argument is set to 
\code{TRUE}.
}
\usage{
EOF <- function(lon, lat, ano, neofs = 15, corr = FALSE)
}
\arguments{
  \item{lon}{
Vector of longitudes of \code{ano}.
  }
  \item{lat}{
Vector of latitudes of \code{ano}.
  }
  \item{ano}{
Array of anomalies with dimensions (number of timesteps, number of latitudes,
number of longitudes).
  }
  \item{neofs}{
Number of modes to be kept. Default = 15.
  }
  \item{corr}{
Whether to base on a correlation matrix (\code{TRUE}) or on a covariance 
matrix (default, \code{FALSE}).
}
\value{
  \item{EOFs}{
An array of EOF patterns normalized to 1 with dimensions (number of modes,
number of latitudes, number of longitues).
  }
  \item{PCs}{
An array of pincipal components with dimensions (number of time steps, number
of modes).
  }
  \item{var}{
Percentage (%) of variance fraction of total variance explained by each mode
(number of modes).
  }
  \item{mask}{
Mask with dimensions (number of latitudes, number of lonfitudes).
  }
  \item{wght}{
Weights with dimensions (number of latitudes, number of longitudes).
  }
}
\examples{

}
\author{
History:\cr
0.1  -  2012-10  (F. Lienert, \email{fabian.lienert at ic3.cat})  -  Original\cr
code, inspired by R. Benestad's EOF() in R package clim.pact.\cr
0.2  -  2014-03  (Lauriane Batte, \email{lauriane.batte at ic3.cat})  -  Bug-fixes:\cr
        1- Reversion of latitudes in the weights
        2- Correlation matrix was used instead of covariance
        3- Double use of the weights
0.3  -  2014-03  (Virginie Guemas, \email{virginie.guemas at bsc.es})  -  Bug-fixes:\cr
        1- Weight computation - division by sum of cos(lat)
        2- Shuffling of EOFs in EOF.2 intermediate vector
        3- Crash when neofs = 1 sorted out
        4- Crash when neofs > nt sorted out
0.4  -  2014-03  (Lauriane Batte, \email{lauriane.batte at ic3.cat})  -  Fixes:\cr
        1- BIG cleanup of code and clarification
        2- Reduction of the number of transpositions and associated bug-fixes
        4- Remove of the obsolete LINPACK options
0.5  -  2014-04  (Virginie Guemas, \email{virginie.guemas at bsc.es})  - Fixes:\cr
        1- Bug-fix in dimensions handling EOF composition restitutes now the 
original field in all cases
        2- Simplification of the convention transpose
        3- Options to use the correlation matrix rather than the 
covariance matrix
        4- Security checks 
        5- New normalization of PCs so that PC*EOF only reconstruct the 
original file 
        6- Weights = sqrt(cos(lat)) for ano so that covariance matrice 
weighted by cos(lat)
        7- Division of EOF by weights so that the reconstruction is simply 
EOF * PC
1.0  -  2016-03  (N. Manubens, \email{nicolau.manubens at bsc.es})  -  Formatting to R CRAN
}
\seealso{ProjectField, NAO, PlotBox}
\keyword{datagen}
