\name{WeatherRegime}
\alias{WeatherRegime}
\title{
Function for Calculating the PCs and Kmeans Clusters
}
\description{
This function calculates the PCs of a dataset with dimensions c(year/month, month/day, lon, lat), then calculates the kmeans clusters from the PCs. The reconstructed field of EOFs * PCs is returned for each cluster, along with the cluster occurence time series and cluster centers. 
}
\usage{
WeatherRegime(data, EOFS = TRUE, explained_variance = 90, lon = NULL, lat = NULL, ncenters = NULL, method = "kmeans",
                          nstart = 30)
}
\arguments{
  \item{data}{
Array of data with dimensions c(year/month, month/day, lon, lat).
  }
  \item{EOFs}{
Should the kmeans be applied to the PCs of the data (EOFS = TRUE) or directly to the lon x lat data?
  }
  \item{explained_variance}{
Percentage of variance to be explained by the PCs. Only sufficient PCs to explain this much variance will be used in the kmeans.
  }
  \item{lon}{
Vector of longitudes.
  }
  \item{lat}{
Vector of latitudes.
  }
  \item{ncenters}{
Number of clusters to be calculated with the kmeans function.
  }
  \item{method}{
Currently only the kmeans method is supported.
  }
  \item{nstart}{
Parameter for the kmeans function determining how many random sets to choose.
  }
}
\value{
List with elements :\cr
field: the reconstructed field of PCs * EOFS \cr
EOFs: the EOFs \cr
center: the cluster centers \cr
cluster: timeseries of cluster occurence.
}
\examples{

}
\keyword{datagen}
