Skip to content

Commit

Permalink
Remove duplicate entries from calc_dispatch per carrier and avoid war…
Browse files Browse the repository at this point in the history
…nings

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
  • Loading branch information
ClaraBuettner committed Aug 15, 2024
1 parent 3e50624 commit 85ac40c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions etrago/analyze/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 85ac40c

Please sign in to comment.