From e61da8618e7ed5adfc4efc468dc7bac7de92fa63 Mon Sep 17 00:00:00 2001 From: Irieo Date: Fri, 3 Nov 2023 12:36:40 +0100 Subject: [PATCH] bug fix: add_electricity breaks in specific cases --- scripts/add_electricity.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/add_electricity.py b/scripts/add_electricity.py index 79b54974..b1e9a6aa 100755 --- a/scripts/add_electricity.py +++ b/scripts/add_electricity.py @@ -759,7 +759,10 @@ def estimate_renewable_capacities(n, year, tech_map, expansion_limit, countries) for ppm_technology, techs in tech_map.items(): tech_i = n.generators.query("carrier in @techs").index - stats = capacities.loc[ppm_technology].reindex(countries, fill_value=0.0) + if ppm_technology in capacities.index.get_level_values("Technology"): + stats = capacities.loc[ppm_technology].reindex(countries, fill_value=0.0) + else: + stats = pd.Series(0.0, index=countries) country = n.generators.bus[tech_i].map(n.buses.country) existent = n.generators.p_nom[tech_i].groupby(country).sum() missing = stats - existent