\name{WeatherRegime}
\alias{WeatherRegime}
\title{
Function for Calculating the Cluster analysis
}
\description{
This function computes the weather regimes from a cluster analysis. It can be applied over the dataset with dimensions c(year/month, month/day, lon, lat), or over the PCs resulting from the application of the EOFs analysis to filter the dataset.  The cluster analysis can be performed with the traditional k-means or those methods included in the hclust (stats package). }
\usage{
WeatherRegime(data, EOFS = TRUE,  neofs=30, threshold = 90, lat_weights = lat_weights, lon = NULL, lat = NULL, ncenters = NULL, method = "kmeans",nstart = 30, listindex = NULL)
}
\arguments{
  \item{data}{
Array of data with dimensions c(year/month, month/day, lon, lat).
  }
  \item{EOFs}{
Whether to compute the EOFs over data confidence interv (default = 'TRUE') or not (FALSE).
  }
  \item{threshold}{
Value with the percentage of variance to be explained by the PCs . Only sufficient PCs to explain this much variance will be used in the clustering.
  }
  \item{lat_weights}{
Whether to apply latitude weighting (default = 'TRUE') or not (FALSE).
}
  \item{lon}{
Vector of longitudes.
  }
  \item{lat}{
Vector of latitudes.
  }
  \item{ncenters}{
Number of clusters to be calculated with the clustering function.
  }
  \item{method}{
Different options to estimate the clusters. The most traditional approach is the k-means analysis (default=’kmeans’) but the function also support the different methods included in the hclust . These methods are:  "ward.D", "ward.D2", "single", "complete", "average" (= UPGMA), "mcquitty" (= WPGMA), "median" (= WPGMC) or "centroid" (= UPGMC). For more details about these methods see the hclust function documentation included in the stats package.
  }
  \item{ncenters}{
Parameter for the cluster analysis determining how many random sets to choose.
  }
  \item{iter.max}
Parameter to select the maximum number of iterations allowed (see kmeans documentation for details)
  }
  \item{listindex}{
  }
  \item{ncores}{
  The number of multicore threads to use for parallel computation}
  }
\value{
List with elements :\cr
commposite:
pvalue: 
cluster:
center: the cluster centers 
cluster_lengths:
cluster_values:
persistence:
frequency:
}
\examples{

}
\author{
History:\cr
1.0  -  2018-05  (A. Hunter, \email{alasdair.hunter at bsc.es} and V.Torralba, \email{veronica.torralba at bsc.es} ) -  Original code
}

\keyword{datagen}

