#'Anomaly Correlation Coefficient (ACC) 
#'
#'@description This function calculates the correlation of individual models and multi-models mean
#'
#'@param data a list giving as output of Load function from S2dverification package.
#'
#'@return A list of 3:
#'\itemize{
#'\item\code{$ano} {A list of 2:
#'    \item\code{$ano_exp} {an array with the same dimensions as the \code{mod} label in the input \code{data}.}
#'    \item\code{$ano_exp} {an array with the same dimensions as the \code{obs} label in the input \code{data}.}
#'\item\code{$corr} {An array with the same dimensions as the \code{mod} label in the input \code{data} without the 'ftime' dimension containing the correlations coefficients.}
#'\item\code{$corr_MMM} {An array with the same dimensions as the \code{obs} label in the input \code{data} without the 'ftime' dimension containing the correlations coefficients of the multi-model mean.}
#'}
#'
#'@references 
#' \url{http://link.springer.com/10.1007/s00382-018-4404-z}
#' 
#'@import s2dverification
#'@examples
#'mod <- 1 : (2 * 3 * 4 * 5 * 6 * 7)
#'dim(mod) <- c(dataset = 2, member = 3, sdate = 4, ftime = 5, lat = 6, lon = 7)
#'obs <- 1 : (1 * 1 * 4 * 5 * 6 * 7)
#'dim(obs) <- c(dataset = 1, member = 1, sdate = 4, ftime = 5, lat = 6, lon = 7)
#'dat <- list(mod = mod, obs = obs)
#'a <- AnoCorr(dat)
#'str(a)
#'@export
AnoCorr <- function(data) {
  if (!is.list(data)) {
    stop("Parameter 'data' must be a list as output of Load function from s2dverification package.")
  }
  ano <- Ano_CrossValid(data$mod, data$obs)

  # seasonal average of anomalies per model
  AvgExp <- MeanListDim(ano$ano_exp, narm = T, c(2, 4))
  AvgObs <- MeanListDim(ano$ano_obs, narm = T, c(2, 4))
  # indv model correlation
  corr <- Corr(AvgExp, AvgObs, posloop = 1, poscor = 2)
  # seasonal avg of anomalies for multi-model
  AvgExp_MMM <- MeanListDim(AvgExp, narm = T, 1)
  AvgObs_MMM <- MeanListDim(AvgObs, narm = T, 1)
  # multi model correlation
  corr_MMM <- Corr(var_exp=InsertDim(AvgExp_MMM, 1, 1),
                   var_obs=InsertDim(AvgObs_MMM, 1, 1),
                   posloop = 1, poscor = 2)
  return(list(ano = ano, corr = corr, corr_MMM = corr_MMM))
}