diff --git a/envs/environment.yaml b/envs/environment.yaml index 4aefcb9a..90b710c9 100644 --- a/envs/environment.yaml +++ b/envs/environment.yaml @@ -10,7 +10,6 @@ dependencies: - python>=3.8 - pip - - pypsa>=0.19.1 - atlite>=0.2.6 - dask @@ -55,5 +54,6 @@ dependencies: - tabula-py - pip: + - git+https://github.com/pypsa/pypsa.git#egg=pypsa - vresutils>=0.3.1 - tsam>=1.1.0 diff --git a/scripts/cluster_network.py b/scripts/cluster_network.py index bd412b7f..bb35decb 100644 --- a/scripts/cluster_network.py +++ b/scripts/cluster_network.py @@ -138,7 +138,8 @@ import seaborn as sns from functools import reduce from pypsa.networkclustering import (busmap_by_kmeans, busmap_by_spectral_clustering, - busmap_by_hac, _make_consense, get_clustering_from_busmap) + busmap_by_hac, busmap_by_greedy_modularity, + _make_consense, get_clustering_from_busmap) import warnings warnings.filterwarnings(action='ignore', category=UserWarning) @@ -326,6 +327,8 @@ def busmap_for_n_clusters(n, n_clusters, solver_name, focus_weights=None, algori return prefix + busmap_by_louvain(reduce_network(n, x), n_clusters[x.name], **algorithm_kwds) elif algorithm == "hac": return prefix + busmap_by_hac(n, n_clusters[x.name], buses_i=x.index, feature=feature.loc[x.index]) + elif algorithm == "modularity": + return prefix + busmap_by_greedy_modularity(n, n_clusters[x.name], buses_i=x.index) else: raise ValueError(f"`algorithm` must be one of 'kmeans', 'hac', 'spectral' or 'louvain'. Is {algorithm}.")