Skip to content

Commit

Permalink
rename networkclustering namespace (#786)
Browse files Browse the repository at this point in the history
* rename networkclustering namespace

* enforce higher pypsa version in env

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* add release notes

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* pypsa <0.24

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
pz-max and pre-commit-ci[bot] authored Jul 15, 2023
1 parent 186d2d2 commit ea30382
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
2 changes: 2 additions & 0 deletions doc/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/pypsa-meets-earth/pypsa-earth/pull/743>`__

* Remove deprecated pypsa.networkclustering approach and replace by pypsa.clustering.spatial `PR #786 <https://github.com/pypsa-meets-earth/pypsa-earth/pull/786>`__

PyPSA-Earth 0.2.2
=================

Expand Down
2 changes: 1 addition & 1 deletion envs/environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion scripts/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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", {}))
Expand Down
6 changes: 3 additions & 3 deletions scripts/cluster_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/PyPSA/PyPSA/blob/master/pypsa/networkclustering.py>`_
`pypsa.clustering.spatial <https://github.com/PyPSA/PyPSA/blob/master/pypsa/networkclustering.py>`_
do not work reliably with multiple voltage levels and transformers.
.. tip::
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions scripts/simplify_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ea30382

Please sign in to comment.