pypsa.clustering.ClusteringAccessor.cluster_spatially_by_kmeans

pypsa.clustering.ClusteringAccessor.cluster_spatially_by_kmeans#

ClusteringAccessor.cluster_spatially_by_kmeans(bus_weightings: pd.Series, n_clusters: int, line_length_factor: float = 1.0, **kwargs: Any) Clustering#

Cluster the network according to k-means clustering of the buses.

Buses can be weighted by an integer in the series bus_weightings.

Note that this clustering method completely ignores the branches of the network.

Parameters:
  • n (pypsa.Network) – The buses must have coordinates x, y.

  • bus_weightings (pandas.Series) – Series of integer weights for buses, indexed by bus names.

  • n_clusters (int) – Final number of clusters desired.

  • line_length_factor (float) – Factor to multiply the spherical distance between new buses in order to get new line lengths.

  • kwargs – Any remaining arguments to be passed to KMeans (e.g. n_init, n_jobs)

Returns:

Clustering – A named tuple containing network, busmap and linemap

Return type:

named tuple