\name{EuroAtlanticTC}
\alias{EuroAtlanticTC}
\title{
EuroAtlantic Teleconnection indices using REOF.
}
\description{
Performs a Rotated EOF over the EuroAtlantic region (20N-80N, 90W-60E) and returns the first 4 modes of variability (patterns and indices). 
The EOF rotation uses varimax rotation and is area-weighted.
}
\usage{
EuroAtlanticTC(ano, lon, lat, ntrunc = 30)
}
\arguments{
  \item{ano}{
Array of anomalies with dimensions (number of timesteps, number of latitudes,
number of longitudes).
  }
  \item{lon}{
Vector of longitudes of \code{ano}.
  }
  \item{lat}{
Vector of latitudes of \code{ano}.
  }
  \item{ntrunc}{
Number of EOF modes to be kept before doing varimax rotation. Default = 30.
  }
}
\value{
  \item{patterns}{
An array of teleconnection patterns normalized to 1 (unitless) and then divided by area weights, with dimensions (4, 
number of latitudes, number of longitues). 
  }
  \item{indices}{
An array of teleconnection indices with the units of the original field to the 
power of 2, with dimensions (number of time steps, 4). \code{indices} 
contains already the percentage of explained variance (i.e. it is not normalized).
  }
  \item{var}{
Percentage of variance fraction of total variance explained by each mode
(number of modes).
  }
  \item{wght}{
Weights with dimensions (number of latitudes, number of longitudes).
  }
}
\examples{
#----------------------------    
# Usage example
#----------------------------    
## Load data
data <-  Load(var = "psl", exp = NULL, obs = list(list(path=rean)),paste0(year.start:year.end,'1201'), storefreq = 'monthly', leadtimemin = 1, leadtimemax = 3,output = 'lonlat', latmin = 0, latmax = 90)

## Compute seasonal average
seasonal <- Mean1Dim(pslFull$obs,4)

## Compute anomalies
clim <- Mean1Dim(seasonal,3)
anom <- sweep(seasonal, c(1,2,4,5), clim, FUN="-")

## Get the TCs
EAT <- EuroAtlantic_TC(anom, data$lon, data$lat)
-
## Get correlation patterns:
cor.map <- CorrPatterns(ano = anom, lon = data$lon, lat = data$lat, PCs = EAT$indices, nPCs = 4, show = TRUE, var = EAT$var)


  \dontshow{
startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101')
sampleData <- s2dverification:::.LoadSampleData('tos', c('experiment'),
                                                c('observation'), startDates,
                                                leadtimemin = 1,
                                                leadtimemax = 4,
                                                output = 'lonlat',
                                                latmin = 27, latmax = 48,
                                                lonmin = -12, lonmax = 40)



  \dontrun{
data_path <- system.file('sample_data', package = 's2dverification')
expA <- list(name = 'experiment', path = file.path(data_path, 
             'model/$EXP_NAME$/$STORE_FREQ$_mean/$VAR_NAME$_3hourly',
             '$VAR_NAME$_$START_DATE$.nc'))
obsX <- list(name = 'observation', path = file.path(data_path, 
             '$OBS_NAME$/$STORE_FREQ$_mean/$VAR_NAME$',
             '$VAR_NAME$_$YEAR$$MONTH$.nc'))

# Now we are ready to use Load().
startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101')
sampleData <- Load('tos', list(expA), list(obsX), startDates,
                   leadtimemin = 1, leadtimemax = 4, output = 'lonlat',
                   latmin = 0, latmax = 90, lonmin = -100, lonmax = 100)
  }
  \dontshow{
startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101')
sampleData <- s2dverification:::.LoadSampleData('tos', c('experiment'),
                                                c('observation'), startDates,
                                                leadtimemin = 1,
                                                leadtimemax = 4,
                                                output = 'lonlat',
                                                latmin = 27, latmax = 48,
                                                lonmin = -12, lonmax = 40)
# No example data is available over EAtl region, so in this example we will 
# tweak the available data. In a real use case, one can Load() the data over 
# EAtl region directly.
sampleData$lon[] <- c(100, 250, 340)
sampleData$lat[] <- c(0, 90)
  }
# This example computes the EATCs 
ano <- Ano_CrossValid(sampleData$mod, sampleData$obs)
EATC <- EuroAtlanticTC(ano$ano_obs, sampleData$lon, sampleData$lat, ntrunc = 30)
}
\author{
History:\cr
0.1  -  2018-05  (N. Cortesi and Ll. Lledó, \email{nicola.cortesi at bsc.es})  -  Original code
1.0  -  2018-05  (N. Manubens, \email{nicolau.manubens at bsc.es})  -  Formatting to R CRAN
}
\seealso{ProjectField, NAO, PlotBoxWhisker}
\keyword{datagen}
