Merge pull request #937 from PyPSA/h2-myopic-plot

Fix plotting of retrofitted hydrogen pipelines with pathway optimisat…
This commit is contained in:
Fabian Neumann 2024-02-16 16:42:21 +01:00 committed by GitHub
commit a3c0ffac44
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 11 deletions

View File

@ -19,6 +19,8 @@ Upcoming Release
today to tomorrow's energy consumption is set with the ``industry:
sector_ratios_fraction_future:`` parameter.
* Fix plotting of retrofitted hydrogen pipelines with pathway optimisation.
* Bugfix: Correct units of subtracted chlorine and methanol demand in
:mod:`build_industry_sector_ratios`.

View File

@ -24,6 +24,7 @@ def group_pipes(df, drop_direction=False):
"""
Group pipes which connect same buses and return overall capacity.
"""
df = df.copy()
if drop_direction:
positive_order = df.bus0 < df.bus1
df_p = df[positive_order]
@ -32,12 +33,13 @@ def group_pipes(df, drop_direction=False):
df = pd.concat([df_p, df_n])
# there are pipes for each investment period rename to AC buses name for plotting
df["index_orig"] = df.index
df.index = df.apply(
lambda x: f"H2 pipeline {x.bus0.replace(' H2', '')} -> {x.bus1.replace(' H2', '')}",
axis=1,
)
return df.groupby(level=0).agg(
{"p_nom_opt": "sum", "bus0": "first", "bus1": "first"}
{"p_nom_opt": "sum", "bus0": "first", "bus1": "first", "index_orig": "first"}
)
@ -95,6 +97,7 @@ def plot_h2_map(n, regions):
)
if not h2_retro.empty:
if snakemake.params.foresight != "myopic":
positive_order = h2_retro.bus0 < h2_retro.bus1
h2_retro_p = h2_retro[positive_order]
swap_buses = {"bus0": "bus1", "bus1": "bus0"}