Weather regimes can be calculated using the k-means clustering algorithm, typically applied to the EOFs of anomalies from selected variables, after smoothing and detrending.
The work flow will be something like:
Load()
.Ano()
.Smooth()
.Trend()
.EOF()
.Cluster()
.Composite()
.PlotEquiMap()
.Some steps may be omitted/altered, for example, the user may wish to use are averages instead of the EOFs, or even apply clustering directly to the spatial data (after detrending and calculating the anomalies) although this may be computationall expensive.
North Atlantic Weather Regimes“> ——————
Below is a simple example of calculating the weather regimes for the North Atlantic from JRA55 SLP for January.
```r
library(s2dverification)
library(reshape2)
JRA55 <- '/esnas/recon/jma/jra55/$STORE_FREQ$_mean/$VAR_NAME$_f6h/$VAR_NAME$_$YEAR$$MONTH$.nc'
psl <- "psl"
year.start <- 1981
year.end <- 2016
#Euro-Atlantic region
lat.max <- 81
lat.min <- 27
lon.max <- 45
lon.min <- 274.5
firstmonth <- 1
leadmonth <- 0
psl <- Load(var = psl, exp = NULL, obs = list(list(path=JRA55)), paste0(year.start:year.end,'0101'), storefreq = 'daily', leadtimemax = 366, output = 'lonlat', latmin = lat.min, latmax = lat.max, lonmin = lon.min, lonmax = lon.max, nprocs=8)
lon <- psl$lon
lat <- psl$lat
psl <- Trend(psl$obs, posTR = 3)$detrended
psl <- psl[1, 1, , , , ] # Drop the dataset and members dimensions
psl <- Subset(psl, 2, 1 : 31) # Select the month of January
psl_ano <- psl - InsertDim(Mean1Dim(psl, 1), 1, 36)
names(dim(psl_ano)) <- c("ftime", "sdate", "lon", "lat")
WR <- WeatherRegime(psl_ano, lon = lon, lat = lat, ncenters = 4)
PlotEquiMap(WR$test[1,,], lon = lon, lat = lat) #Plot the 1st regime
```