Skip to content

Commit

Permalink
Fix an error in simplify_network when to_substations simplification f…
Browse files Browse the repository at this point in the history
…lag is on (#708)

* Fix a used column name in a buses df

* Fix for an empty list

* Revise a column name

* Remove multi-index subsetting
  • Loading branch information
ekatef committed May 9, 2023
1 parent 5cc92a7 commit 1989668
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions scripts/simplify_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,8 @@ def aggregate_to_substations(n, aggregation_strategies=dict(), buses_i=None):
dist.loc[incarrier_b, ~incarrier_b] = np.inf

busmap = n.buses.index.to_series()
busmap.loc[buses_i] = dist.idxmin(1)
if not dist.empty:
busmap.loc[buses_i] = dist.idxmin(1)

bus_strategies, generator_strategies = get_aggregation_strategies(
aggregation_strategies
Expand Down Expand Up @@ -658,7 +659,11 @@ def merge_isolated_nodes(n, threshold, aggregation_strategies=dict()):

# all the nodes to be merged should be mapped into a single node
map_isolated_node_by_country = (
n.buses.loc[i_suffic_load].groupby("country")["bus_id"].first().to_dict()
n.buses.assign(bus_id=n.buses.index)
.loc[i_suffic_load]
.groupby("country")["bus_id"]
.first()
.to_dict()
)
isolated_buses_mapping = n.buses.loc[i_suffic_load, "country"].replace(
map_isolated_node_by_country
Expand Down

0 comments on commit 1989668

Please sign in to comment.