\name{SeaIceModes}
\alias{SeaIceModes}
\title{
  Computes sea ice variability modes or clusters.
}
\description{
  This function computes sea ice variability modes based on the K-means clustering
  method applied to sea ice variable such as area, extent, volume or thickness averages 
  over the selected regions with sea ice in the Northern or Southern Hemisphere.
}
\usage{
  SeaIceModes(var, exp, obs, sdates, seasoninf, seasonsup, nclusters=NULL, nleadtime=NULL, nmember=NULL, leadtimemin=1, leadtimemax=NULL, storefreq="monthly", sampleperiod=1, pldgr=0, listregs=NULL, weights=NULL, listindx=NULL)
}
\arguments{
  \item{var}{
    For example: sia, sie, sit, .. (sea ice area, extent, thickness, ..)
    exp, obs, sdates, nleadtime, leadtimemin, leadtimemax, storefreq and sampleperiod
      are the same as in Load: only var, exp, obs and sdates are mandatory, and only
      1 experiment or only 1 observational dataset can be loaded.  
  }
  \item{nmember}{ 
    Selected ensemble member or mean between selected ensemble members, e.g. c(1,3)
    (default is NULL which produce ensemble mean of all available ensemble members).
  }
  \item{seasoninf}{
    Month of the year when to start computing the extended seasonal means: 1 to 12.
  }
  \item{seasonsup}{
    Month of the year when to stop computing the extended seasonal means: 1 to 12. 
    The extended seasonal means can overlap the 31s December: e.g., DJF average.
    For monthly means put the same vales for saesoninf and seasonsup.
  }
  \item{nclusters}{
    K number of clusters to be computed, or K initial cluster centers (default is NULL
    and then Clusters.R  will determine the optimal number of clusters and their centers).
  }
  \item{pldgr}{
    pldgr<0 for using the full values, 0 for removing the long-term mean, and 0<pldgr for
    using residulas after removing polynomial fit of the pldgr order/degree (deafult is 0).
  }
  \item{listregs}{
    List of sea ice regions/zones/points used must be specified (it is expected that 
    Load configuration file has entries that support experiments and/or observations
    with variable names in the form of var_listregs[1], var_listregs[2], ..).
  }
  \item{weights}{
    Area weights of the selected regions in listsregs (default NULL means that var is
    being area weighted before loading, e.g. average sit, so this puts all values to 1).
  }
  \item{listindx}{
    List of validity indices (from NbClust package plus 'first') used to determine optimal 
    K if it is not specified via positive integer bigger than 1 or initial/seed cluster 
    centers in nclusters (NULL is deafult which leads to application of: 'kl', 'ch', 
    'duda', 'ratkowsky', 'ball', 'ptbiserial', 'gap', 'mcclain', 'tau', and 'sdindex').
  }
}
\value{
  \item{$clusters}{ 
    A vector (time series) of integers indicating the occurrence of a cluster, i.e., when
    certain data member in time is allocated to a specific cluster (e.g, 2 1 3 1 1 1 ..).
  }
  \item{$centers}{
    A matrix of cluster centres or centroids (e.g. [1:K, 1:spatial degrees of freedom]).
  }
  \item{$totss}{
    The total sum of squares. 
  }
  \item{$withinss}{
    A vector of within-cluster sum of squares, one component per cluster. 
  }
  \item{$tot.withinss}{
    Total within-cluster sum of squares, i.e., sum(withinss). 
  }
  \item{$betweenss}{
    The between-cluster sum of squares, i.e. totss-tot.withinss. 
  }
  \item{$size}{
    The number of points in each cluster. 
  }
}
\examples{

}
\author{
  History:
  1.0  #  2014-10  (N.S. Fuckar, neven.fuckar@ic3.cat)  #  Original code
}
\keyword{datagen}
