From 85ac40cc7063c580fd93a0384cf53ec28cd4264a Mon Sep 17 00:00:00 2001 From: ClaraBuettner Date: Thu, 15 Aug 2024 09:27:02 +0200 Subject: [PATCH 1/3] Remove duplicate entries from calc_dispatch per carrier and avoid warnings There were entries for each generator (assuming that there is only one generator for each bus and carrier). But when redispatch is eplicitly considered, there are up to three generators for each combination. To avoid duplicate entries, only unique combinations are used as an index for the series --- etrago/analyze/plot.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/etrago/analyze/plot.py b/etrago/analyze/plot.py index 07dd75d6..d8616acc 100644 --- a/etrago/analyze/plot.py +++ b/etrago/analyze/plot.py @@ -841,16 +841,18 @@ def calc_dispatch_per_carrier(network, timesteps, dispatch_type="total"): ] dist = pd.Series( - index=pd.MultiIndex.from_tuples(index, names=["bus", "carrier"]), + index=pd.MultiIndex.from_tuples( + index, names=["bus", "carrier"] + ).unique(), dtype=float, - ) + ).sort_index() for i in dist.index: gens = network.generators[ (network.generators.bus == i[0]) & (network.generators.carrier == i[1]) ].index - dist[i] = ( + dist.loc[i] = ( ( network.generators_t.p[gens].transpose()[ network.snapshots[timesteps] From bfb932d86d19fdb9bcaf1ac39f5783619c33d9f5 Mon Sep 17 00:00:00 2001 From: ClaraBuettner Date: Thu, 15 Aug 2024 09:36:30 +0200 Subject: [PATCH 2/3] Avoid deprecation warning when initializing the busmap --- etrago/cluster/spatial.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etrago/cluster/spatial.py b/etrago/cluster/spatial.py index 9f782c1d..30d7779e 100755 --- a/etrago/cluster/spatial.py +++ b/etrago/cluster/spatial.py @@ -759,7 +759,7 @@ def kmedoids_dijkstra_clustering( kmeans.fit(points) busmap = pd.Series( - data=kmeans.predict(buses.loc[buses_i, ["x", "y"]]), + data=kmeans.predict(buses.loc[buses_i, ["x", "y"]].values), index=buses_i, dtype=object, ) From e432de95f866d01f8606e2d36679fce294b50d33 Mon Sep 17 00:00:00 2001 From: ClaraBuettner Date: Thu, 15 Aug 2024 11:28:48 +0200 Subject: [PATCH 3/3] Delete print statement --- etrago/execute/market_optimization.py | 1 - 1 file changed, 1 deletion(-) diff --git a/etrago/execute/market_optimization.py b/etrago/execute/market_optimization.py index e175ed44..6d8eb5b1 100644 --- a/etrago/execute/market_optimization.py +++ b/etrago/execute/market_optimization.py @@ -209,7 +209,6 @@ def optimize_with_rolling_horizon( n.storage_units.state_of_charge_initial = ( n.storage_units_t.state_of_charge.loc[snapshots[start - 1]] ) - print(i) # Make sure that state of charge of batteries and pumped hydro # plants are cyclic over the year by using the state_of_charges # from the pre_market_model