From c68aa028ffff8d83a4ea3fa0dcefcf8e256aa58a Mon Sep 17 00:00:00 2001 From: Fabian Date: Fri, 10 Jun 2022 00:36:07 +0200 Subject: [PATCH] add_electricity: fix missing config key --- scripts/add_electricity.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/scripts/add_electricity.py b/scripts/add_electricity.py index 880dcaad..bd17dbe5 100755 --- a/scripts/add_electricity.py +++ b/scripts/add_electricity.py @@ -609,18 +609,22 @@ if __name__ == "__main__": conf.pop('carriers', []), **conf) if "estimate_renewable_capacities" not in snakemake.config['electricity']: - logger.warning("Missing key `estimate_renewable_capacities` under config entry `electricity`." - "In future versions, this will raise an error. ") - estimate_renewable_caps = {'enable': False} + logger.warning("Missing key `estimate_renewable_capacities` under config entry `electricity`. " + "In future versions, this will raise an error. " + "Falling back to whether ``estimate_renewable_capacities_from_capacity_stats`` is in the config.") + if "estimate_renewable_capacities_from_capacity_stats" in snakemake.config['electricity']: + estimate_renewable_caps = {'enable': True, **snakemake.config['electricity']["estimate_renewable_capacities_from_capacity_stats"]} + else: + estimate_renewable_caps = {'enable': False} if "enable" not in estimate_renewable_caps: - logger.warning("Missing key `enable` under config entry `estimate_renewable_capacities`." + logger.warning("Missing key `enable` under config entry `estimate_renewable_capacities`. " "In future versions, this will raise an error. Falling back to False.") estimate_renewable_caps = {'enable': False} if "from_opsd" not in estimate_renewable_caps: - logger.warning("Missing key `from_opsd` under config entry `estimate_renewable_capacities`." + logger.warning("Missing key `from_opsd` under config entry `estimate_renewable_capacities`. " "In future versions, this will raise an error. " "Falling back to whether `renewable_capacities_from_opsd` is non-empty.") - from_opsd = bool(snakemake.config["electricity"]["renewable_capacities_from_opsd"]) + from_opsd = bool(snakemake.config["electricity"].get("renewable_capacities_from_opsd", False)) estimate_renewable_caps['from_opsd'] = from_opsd