diff --git a/doc/release_notes.rst b/doc/release_notes.rst index e2636ecad..1f9267494 100644 --- a/doc/release_notes.rst +++ b/doc/release_notes.rst @@ -16,6 +16,8 @@ E.g. if a new rule becomes available describe how to use it `snakemake -j1 run_t * Improve network simplification routine to account for representation HVDC as Line component `PR #743 `__ +* Remove deprecated pypsa.networkclustering approach and replace by pypsa.clustering.spatial `PR #786 `__ + PyPSA-Earth 0.2.2 ================= diff --git a/envs/environment.yaml b/envs/environment.yaml index d0795f374..0fe0751c0 100644 --- a/envs/environment.yaml +++ b/envs/environment.yaml @@ -12,7 +12,7 @@ dependencies: - pip - mamba # esp for windows build -- pypsa>=0.21.3 +- pypsa>=0.23, <0.25 # - atlite>=0.2.4 # until https://github.com/PyPSA/atlite/issues/244 is not merged - dask - powerplantmatching>=0.5.7 diff --git a/scripts/_helpers.py b/scripts/_helpers.py index 3a1047f65..328382e58 100644 --- a/scripts/_helpers.py +++ b/scripts/_helpers.py @@ -340,7 +340,7 @@ def get_aggregation_strategies(aggregation_strategies): from pypsa.clustering.spatial import _make_consense except Exception: # TODO: remove after new release and update minimum pypsa version - from pypsa.networkclustering import _make_consense + from pypsa.clustering.spatial import _make_consense bus_strategies = dict(country=_make_consense("Bus", "country")) bus_strategies.update(aggregation_strategies.get("buses", {})) diff --git a/scripts/cluster_network.py b/scripts/cluster_network.py index 86c16aac1..3e66534d6 100644 --- a/scripts/cluster_network.py +++ b/scripts/cluster_network.py @@ -88,7 +88,7 @@ **Is it possible to run the model without the** ``simplify_network`` **rule?** No, the network clustering methods in the PyPSA module - `pypsa.networkclustering `_ + `pypsa.clustering.spatial `_ do not work reliably with multiple voltage levels and transformers. .. tip:: @@ -141,7 +141,7 @@ ) from add_electricity import load_costs from build_shapes import add_gdp_data, add_population_data, get_GADM_layer -from pypsa.networkclustering import ( +from pypsa.clustering.spatial import ( busmap_by_greedy_modularity, busmap_by_hac, busmap_by_kmeans, @@ -694,7 +694,7 @@ def cluster_regions(busmaps, inputs, output): # Fast-path if no clustering is necessary busmap = n.buses.index.to_series() linemap = n.lines.index.to_series() - clustering = pypsa.networkclustering.Clustering( + clustering = pypsa.clustering.spatial.Clustering( n, busmap, linemap, linemap, pd.Series(dtype="O") ) elif len(n.buses) < n_clusters: diff --git a/scripts/simplify_network.py b/scripts/simplify_network.py index 11e59b5d2..d529d798d 100644 --- a/scripts/simplify_network.py +++ b/scripts/simplify_network.py @@ -96,13 +96,13 @@ from _helpers import configure_logging, get_aggregation_strategies, update_p_nom_max from add_electricity import load_costs from cluster_network import cluster_regions, clustering_for_n_clusters -from pypsa.io import import_components_from_dataframe, import_series_from_dataframe -from pypsa.networkclustering import ( +from pypsa.clustering.spatial import ( aggregategenerators, aggregateoneport, busmap_by_stubs, get_clustering_from_busmap, ) +from pypsa.io import import_components_from_dataframe, import_series_from_dataframe from scipy.sparse.csgraph import connected_components, dijkstra sys.settrace