From e367f8ae11380050f4e0265afa1228c39fc5fe62 Mon Sep 17 00:00:00 2001 From: Leon <5868911+leonsn@users.noreply.github.com> Date: Mon, 24 May 2021 22:11:24 +0200 Subject: [PATCH] Fix error when running without the industry sector (#96) Fixing that the code stops with an error if running without the industry sector, e.g. only including electricity and heat. When the industry sector is not included, balances_df.index.levels[0] does not include "process emissions". Using the XOR operator "^" does then add it instead of removing it when compared to the co2_carriers list. The XOR operator does only work as intended, i.e. excluding the three emission-related strings, when these strings are already in the original list. The proposed change fixes the issue. --- scripts/plot_summary.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/plot_summary.py b/scripts/plot_summary.py index bc852e70..9b3a81e1 100644 --- a/scripts/plot_summary.py +++ b/scripts/plot_summary.py @@ -177,7 +177,7 @@ def plot_balances(): balances_df = pd.read_csv(snakemake.input.balances,index_col=list(range(3)),header=list(range(n_header))) balances = {i.replace(" ","_") : [i] for i in balances_df.index.levels[0]} - balances["energy"] = balances_df.index.levels[0].symmetric_difference(co2_carriers) + balances["energy"] = [i for i in balances_df.index.levels[0] if i not in co2_carriers] for k,v in balances.items(): @@ -401,4 +401,4 @@ if __name__ == "__main__": opts=sector_opts.split('-') for o in opts: if "cb" in o: - plot_carbon_budget_distribution() \ No newline at end of file + plot_carbon_budget_distribution()