new spatial clustering method: modularity
This commit is contained in:
parent
44e8fbd5aa
commit
387271b03b
@ -10,7 +10,6 @@ dependencies:
|
|||||||
- python>=3.8
|
- python>=3.8
|
||||||
- pip
|
- pip
|
||||||
|
|
||||||
- pypsa>=0.19.1
|
|
||||||
- atlite>=0.2.6
|
- atlite>=0.2.6
|
||||||
- dask
|
- dask
|
||||||
|
|
||||||
@ -55,5 +54,6 @@ dependencies:
|
|||||||
- tabula-py
|
- tabula-py
|
||||||
|
|
||||||
- pip:
|
- pip:
|
||||||
|
- git+https://github.com/pypsa/pypsa.git#egg=pypsa
|
||||||
- vresutils>=0.3.1
|
- vresutils>=0.3.1
|
||||||
- tsam>=1.1.0
|
- tsam>=1.1.0
|
||||||
|
@ -138,7 +138,8 @@ import seaborn as sns
|
|||||||
from functools import reduce
|
from functools import reduce
|
||||||
|
|
||||||
from pypsa.networkclustering import (busmap_by_kmeans, busmap_by_spectral_clustering,
|
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
|
import warnings
|
||||||
warnings.filterwarnings(action='ignore', category=UserWarning)
|
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)
|
return prefix + busmap_by_louvain(reduce_network(n, x), n_clusters[x.name], **algorithm_kwds)
|
||||||
elif algorithm == "hac":
|
elif algorithm == "hac":
|
||||||
return prefix + busmap_by_hac(n, n_clusters[x.name], buses_i=x.index, feature=feature.loc[x.index])
|
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:
|
else:
|
||||||
raise ValueError(f"`algorithm` must be one of 'kmeans', 'hac', 'spectral' or 'louvain'. Is {algorithm}.")
|
raise ValueError(f"`algorithm` must be one of 'kmeans', 'hac', 'spectral' or 'louvain'. Is {algorithm}.")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user