Skip to content

Commit

Permalink
Merge pull request #1270 from daniel-rdt/myopic_hydrogen_network_plot…
Browse files Browse the repository at this point in the history
…ting

fix plotting of hydrogen network with myopic foresight.
  • Loading branch information
lisazeyen authored Sep 10, 2024
2 parents 8a0b6ba + a7c3775 commit 05634e8
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions scripts/plot_hydrogen_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ def plot_h2_map(n, regions):

retro_wo_new_i = h2_retro.index.difference(h2_new.index)
h2_retro_wo_new = h2_retro.loc[retro_wo_new_i]
h2_retro_wo_new.index = h2_retro_wo_new.index_orig
h2_retro_wo_new.index = h2_retro_wo_new.index_orig.apply(
lambda x: x.split("-2")[0]
)

to_concat = [h2_new, h2_retro_w_new, h2_retro_wo_new]
h2_total = pd.concat(to_concat).p_nom_opt.groupby(level=0).sum()
Expand All @@ -126,7 +128,12 @@ def plot_h2_map(n, regions):
link_widths_total = h2_total / linewidth_factor

n.links.rename(index=lambda x: x.split("-2")[0], inplace=True)
n.links = n.links.groupby(level=0).first()
# group links by summing up p_nom values and taking the first value of the rest of the columns
other_cols = dict.fromkeys(n.links.columns.drop(["p_nom_opt", "p_nom"]), "first")
n.links = n.links.groupby(level=0).agg(
{"p_nom_opt": "sum", "p_nom": "sum", **other_cols}
)

link_widths_total = link_widths_total.reindex(n.links.index).fillna(0.0)
link_widths_total[n.links.p_nom_opt < line_lower_threshold] = 0.0

Expand Down

0 comments on commit 05634e8

Please sign in to comment.