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.
This commit is contained in:
Koen van Greevenbroek 2023-05-24 11:13:37 +02:00
parent 0c95b5a840
commit 312dd81f21

View File

@ -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