From eb3435672204ff2cd7a0f91baca202e7f333e060 Mon Sep 17 00:00:00 2001 From: Tom Brown Date: Wed, 13 May 2020 13:25:32 +0200 Subject: [PATCH] make_summary: Remove erroneous power outputs for non-multi links This bug in PyPSA was fixed in: https://github.com/PyPSA/PyPSA/commit/f484adc87603b16ef1a49cd8b4520bdd1eaceae1 --- scripts/make_summary.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/make_summary.py b/scripts/make_summary.py index a11e4b76..da37d0a1 100644 --- a/scripts/make_summary.py +++ b/scripts/make_summary.py @@ -250,7 +250,11 @@ def calculate_energy(n,label,energy): else: c_energies = pd.Series(0.,c.df.carrier.unique()) for port in [col[3:] for col in c.df.columns if col[:3] == "bus"]: - c_energies -= c.pnl["p"+port].multiply(n.snapshot_weightings,axis=0).sum().groupby(c.df.carrier).sum() + totals = c.pnl["p"+port].multiply(n.snapshot_weightings,axis=0).sum() + #remove values where bus is missing (bug in nomopyomo) + no_bus = c.df.index[c.df["bus"+port] == ""] + totals.loc[no_bus] = n.component_attrs[c.name].loc["p"+port,"default"] + c_energies -= totals.groupby(c.df.carrier).sum() c_energies = pd.concat([c_energies], keys=[c.list_name])