adjust h2_plot function to work with myopic, since build year is now in links.index

This commit is contained in:
lisazeyen 2022-01-07 16:59:48 +01:00
parent 9f8b54a3ce
commit c40904a727

View File

@ -235,7 +235,7 @@ def plot_h2_map(network):
bus_size_factor = 1e5 bus_size_factor = 1e5
linewidth_factor = 1e4 linewidth_factor = 1e4
# MW below which not drawn # MW below which not drawn
line_lower_threshold = 1e3 line_lower_threshold = 1e2
# Drop non-electric buses so they don't clutter the plot # Drop non-electric buses so they don't clutter the plot
n.buses.drop(n.buses.index[n.buses.carrier != "AC"], inplace=True) n.buses.drop(n.buses.index[n.buses.carrier != "AC"], inplace=True)
@ -249,7 +249,7 @@ def plot_h2_map(network):
n.links.drop(n.links.index[~n.links.carrier.str.contains("H2 pipeline")], inplace=True) n.links.drop(n.links.index[~n.links.carrier.str.contains("H2 pipeline")], inplace=True)
h2_new = n.links.loc[n.links.carrier=="H2 pipeline", "p_nom_opt"] h2_new = n.links.loc[n.links.carrier=="H2 pipeline"]
h2_retro = n.links.loc[n.links.carrier=='H2 pipeline retrofitted'] h2_retro = n.links.loc[n.links.carrier=='H2 pipeline retrofitted']
@ -264,10 +264,18 @@ def plot_h2_map(network):
axis=1 axis=1
) )
h2_retro = h2_retro["p_nom_opt"] h2_new.index = h2_new.apply(
lambda x: f"H2 pipeline {x.bus0.replace(' H2', '')} -> {x.bus1.replace(' H2', '')}"
,axis=1)
h2_new = h2_new["p_nom_opt"].groupby(level=0).sum()
h2_retro = h2_retro["p_nom_opt"].groupby(level=0).sum()
h2_retro = h2_retro.groupby(level=0).sum().reindex(h2_new.index).fillna(0)
n.links.rename(index=lambda x: x.split("-2")[0], inplace=True)
n.links = n.links.groupby(level=0).first()
link_widths_total = (h2_new + h2_retro) / linewidth_factor link_widths_total = (h2_new + h2_retro) / linewidth_factor
link_widths_total = link_widths_total.groupby(level=0).sum().reindex(n.links.index).fillna(0.) link_widths_total = link_widths_total.reindex(n.links.index).fillna(0.)
link_widths_total[n.links.p_nom_opt < line_lower_threshold] = 0. link_widths_total[n.links.p_nom_opt < line_lower_threshold] = 0.
retro = n.links.p_nom_opt.where(n.links.carrier=='H2 pipeline retrofitted', other=0.) retro = n.links.p_nom_opt.where(n.links.carrier=='H2 pipeline retrofitted', other=0.)
@ -695,11 +703,11 @@ if __name__ == "__main__":
snakemake = mock_snakemake( snakemake = mock_snakemake(
'plot_network', 'plot_network',
simpl='', simpl='',
clusters=45, clusters="45",
lv=1.5, lv=1.0,
opts='', opts='',
sector_opts='Co2L0-168H-T-H-B-I-solar+p3-dist1', sector_opts='168H-T-H-B-I-A-solar+p3-dist1',
planning_horizons=2030, planning_horizons="2050",
) )
overrides = override_component_attrs(snakemake.input.overrides) overrides = override_component_attrs(snakemake.input.overrides)