#'Correlation of Weighted Multi-Models based on Best OLS Combination Method 
#'
#'@description This function calculates the correlation of weighted multi-models based on Best OLS Combination Method
#'
#'@param anom 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,
#'abind
#'@examples
#'mod <- 1 : (4 * 13 * 14 * 15 * 16 * 17)
#'dim(mod) <- c(dataset = 4, member = 13, sdate = 14, ftime = 15, lat = 16, lon = 17)
#'obs <- 1 : (1 * 1 * 14 * 15 * 16 * 17)
#'dim(obs) <- c(dataset = 1, member = 1, sdate = 14, ftime = 15, lat = 16, lon = 17)
#'dat <- list(mod = mod, obs = obs)
#'b <- CorrWMMBOCM(anom = dat)
#'str(b)
#'@export
CorrWMMBOCM <- function(anom) {
  # seasonal average of anomalies per model
  AvgExp <- MeanListDim(anom$mod, narm = T, c(2, 4))
  AvgObs <- MeanListDim(anom$obs, narm = T, c(2, 4))
  
  # rearrange
  Data_WMM <- aperm(abind(AvgExp, AvgObs, along = 1), c(2,1,3,4))
  
  # predictions based on BOCM
  #source("YOUR_PATH/bocm/bocm_cv.R")
  bocmPred <- apply(Data_WMM, c(3,4), function(x) bocm_cv(x[,5],x[,1:4]))
  
  # weighted multi model correlation - BOCM
  corr_WMM_bocm <- Corr(var_exp = InsertDim(bocmPred, 1, 1),
                        var_obs = AvgObs,
                        posloop = 1, poscor = 2)
  return(list(bocmPred, corr_WMM_bocm))
}