\name{Clim}
\alias{Clim}
\title{Computes Per-pair/Kharin/FALSEuckar Climatologies}
\description{
This function computes climatologies from the experimental and observational matrices output from \code{Load()} using one of the following methods:\cr
  1) per-pair method (Garcia-Serrano and Doblas-Reyes, CD, 2012)\cr
  2) Kharin method (Karin et al, GRL, 2012)\cr
  3) Fuckar mathod (Fuckar et al, GRL, 2014)\cr
Clim function computes climatologies using the startdates covered by the whole experiments/observational data sets. The startdates not available for all the data (model and obs) are excluded when computing the climatologies.
}
\usage{
Clim(var_exp, var_obs, memb = TRUE, kharin = FALSE, NDV = FALSE)
}
\arguments{
  \item{var_exp}{
Model data:\cr
  c(nmod/nexp, nmemb/nparam, nsdates, nltime) up to\cr
  c(nmod/nexp, nmemb/nparam, nsdates, nltime, nlevel, nlat, nlon)
  }
  \item{var_obs}{
Observational data: \cr
  c(nobs, nmemb, nsdates, nltime) up to\cr
  c(nobs, nmemb, nsdates, nltime, nlevel, nlat, nlon)
  }
  \item{memb}{
memb: TRUE/FALSE (1 climatology for each member). Default = TRUE.
  }
  \item{kharin}{
TRUE/FALSE (if Kharin method is applied or not). Default = FALSE.
  }
  \item{NDV}{
TRUE/FALSE (if Fuckar method is applied or not). Default = FALSE. 
  }
}
\value{
  \item{clim_exp}{Matrix with same dimensions as var_exp}
  \item{clim_obs}{Matrix with same dimensions as var_obs}
}
\examples{
# See examples on Load() to understand the first lines in this example
  \dontrun{
configfile <- system.file('config/sample.conf', package = 's2dverification')
file_conn <- file(configfile)
text <- gsub("!!!PATH_TO_REPLACE!!!", system.file('sample_data', 
             package = 's2dverification'), readLines(file_conn))
writeLines(text, file_conn)
close(file_conn)
# Now we are ready to use Load().
startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101')
sampleData <- Load('tos', c('experiment'), c('observation'), startDates, 
                   output = 'areave', latmin = 27, latmax = 48, lonmin = -12,
                   lonmax = 40, configfile = configfile)
  }
  \dontshow{
startDates <- c('19851101', '19901101', '19951101', '20001101', '20051101')
sampleData <- s2dverification:::.LoadSampleData('tos', c('experiment'), 
                                                c('observation'), startDates,
                                                output = 'areave', 
                                                latmin = 27, latmax = 48, 
                                                lonmin = -12, lonmax = 40) 
  }
clim <- Clim(sampleData$mod, sampleData$obs)
PlotClim(clim$clim_exp, clim$clim_obs, 
         toptitle = paste('sea surface temperature climatologies'), 
         ytitle = 'K', monini = 11, listexp = c('CMIP5 IC3'), 
         listobs = c('ERSST'), biglab = FALSE, fileout = 'tos_clim.eps')
}
\author{
History:\cr
0.9  -  2011-03  (V. Guemas, \email{virginie.guemas@ic3.cat})  -  Original code\cr
1.0  -  2013-09  (N. Manubens, \email{nicolau.manubens@ic3.cat})  -  Formatting to R CRAN
}
\keyword{datagen}
