From 374eac07475456e35394a5dd0d2d4262fd639ff2 Mon Sep 17 00:00:00 2001 From: Tom Russell Date: Tue, 1 Sep 2020 11:05:07 +0100 Subject: [PATCH] Fix results aggregation, supply-demand interaction Aggregating according to a simplified list of heating technologies must sum up any grouped technologies. Fix is to test if entry exists in dict and create if missing, otherwise add values rather than overwriting. --- energy_demand/basic/demand_supply_interaction.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/energy_demand/basic/demand_supply_interaction.py b/energy_demand/basic/demand_supply_interaction.py index f6591764..1ede4433 100644 --- a/energy_demand/basic/demand_supply_interaction.py +++ b/energy_demand/basic/demand_supply_interaction.py @@ -64,13 +64,17 @@ def constrained_results( # ---------------------------------------- for submodel_nr, submodel in enumerate(submodels_names): for tech, fuel_tech in results_constrained.items(): - # Technological simplifications because of different technology definition and because not all technologies are used in supply model + # Technological simplifications because of different technology + # definition and because not all technologies are used in supply model tech_simplified = model_tech_simplification(tech) fueltype_str = technologies[tech_simplified].fueltype_str fueltype_int = technologies[tech_simplified].fueltype_int key_name = "{}_{}_{}".format(submodel, fueltype_str, tech_simplified) - supply_results[key_name] = fuel_tech[submodel_nr][:, fueltype_int, :] + if key_name not in supply_results: + supply_results[key_name] = fuel_tech[submodel_nr][:, fueltype_int, :] + else: + supply_results[key_name] += fuel_tech[submodel_nr][:, fueltype_int, :] assert not testing_functions.test_if_minus_value_in_array(results_unconstrained_no_heating)