From 312dd81f216f2ab55ee2eb8b13c5a54532fe9e06 Mon Sep 17 00:00:00 2001 From: Koen van Greevenbroek Date: Wed, 24 May 2023 11:13:37 +0200 Subject: [PATCH] Fix bug with underground H2 storage creation For some small model regions, none of the H2 cavern types specified in the configuration might actually be available, in which case the line `h2_caverns = h2_caverns[cavern_types].sum(axis=1)` throws an error. --- scripts/prepare_sector_network.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index 012c9714..57deb5fd 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -1105,7 +1105,11 @@ def add_storage_and_grids(n, costs): cavern_types = snakemake.config["sector"]["hydrogen_underground_storage_locations"] h2_caverns = pd.read_csv(snakemake.input.h2_cavern, index_col=0) - if not h2_caverns.empty and options["hydrogen_underground_storage"]: + if ( + not h2_caverns.empty + and options["hydrogen_underground_storage"] + and set(cavern_types).intersection(h2_caverns.columns) + ): h2_caverns = h2_caverns[cavern_types].sum(axis=1) # only use sites with at least 2 TWh potential