From c8bc7174cd53f60d26a62bd882ba5fb4f999e7ce Mon Sep 17 00:00:00 2001 From: ClaraBuettner Date: Mon, 30 Oct 2023 15:47:31 +0100 Subject: [PATCH 1/3] Include only selected store carriers in legend --- etrago/tools/plot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etrago/tools/plot.py b/etrago/tools/plot.py index 0bacc770..292dafa5 100644 --- a/etrago/tools/plot.py +++ b/etrago/tools/plot.py @@ -2591,7 +2591,7 @@ def plot_grid( ) bus_scaling = bus_sizes bus_sizes = bus_scaling * calc_storage_expansion_per_bus(network) - for store_carrier in ["H2", "heat", "battery"]: + for store_carrier in scaling_store_expansion.keys(): bus_sizes[ bus_sizes.index.get_level_values("carrier").str.contains( store_carrier From 6c97eaad800eb21ab35eeeceee18a2f2d3196be7 Mon Sep 17 00:00:00 2001 From: ClaraBuettner Date: Mon, 30 Oct 2023 15:55:00 +0100 Subject: [PATCH 2/3] Allow user-defind geographical boundaries --- etrago/tools/plot.py | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/etrago/tools/plot.py b/etrago/tools/plot.py index 292dafa5..d68479e6 100644 --- a/etrago/tools/plot.py +++ b/etrago/tools/plot.py @@ -1750,7 +1750,7 @@ def calc_network_expansion(network, method="abs", ext_min=0.1): return network, extension_lines, extension_links -def plot_background_grid(network, ax): +def plot_background_grid(network, ax, geographical_boundaries): """Plots grid topology in background of other network.plot Parameters @@ -1759,6 +1759,8 @@ def plot_background_grid(network, ax): Overall container of PyPSA ax : matplotlib.axes._subplots.AxesSubplot axes of plot + geographical_boundaries : list + Set georaphical boundaries for the plots Returns ------- @@ -1779,7 +1781,7 @@ def plot_background_grid(network, ax): geomap=True, projection=ccrs.PlateCarree(), color_geomap=True, - boundaries=[-2.5, 16, 46.8, 58], + boundaries=geographical_boundaries, ) else: network.plot( @@ -2323,6 +2325,7 @@ def plot_grid( "heat": 0.1, "battery": 10, }, + geographical_boundaries=[-2.5, 16, 46.8, 58], ): """Function that plots etrago.network and results for lines and buses @@ -2384,6 +2387,9 @@ def plot_grid( Set scaling values to be used per technology for the plots storage_expansion and h2_battery_storage_expansion. The default is {"H2": 50, "heat": 0.1, "battery": 10} + geographical_boundaries : list, optional + Set georaphical boundaries for the plots The default is + [-2.5, 16, 46.8, 58] Returns ------- @@ -2438,7 +2444,7 @@ def plot_grid( link_widths = link_colors.apply(lambda x: 10 if x != 0 else 0) line_widths = 10 label = "line loading in p.u." - plot_background_grid(network, ax) + plot_background_grid(network, ax, geographical_boundaries) # Only active flow direction is displayed! flow = pd.Series(1, index=network.branches().index, dtype="float64") flow.iloc[flow.index.get_level_values("component") == "Line"] = ( @@ -2477,14 +2483,14 @@ def plot_grid( label = "v_nom in kV" line_colors = network.lines.v_nom link_colors = pd.Series(data=0, index=network.links.index) - plot_background_grid(network, ax) + plot_background_grid(network, ax, geographical_boundaries) elif line_colors == "expansion_abs": title = "Network expansion" label = "network expansion in GVA" all_network, line_colors, link_colors = calc_network_expansion( network, method="abs", ext_min=ext_min ) - plot_background_grid(all_network, ax) + plot_background_grid(all_network, ax, geographical_boundaries) if ext_width is not False: line_widths = line_colors / ext_width @@ -2506,7 +2512,7 @@ def plot_grid( all_network, line_colors, link_colors = calc_network_expansion( network, method="rel", ext_min=ext_min ) - plot_background_grid(all_network, ax) + plot_background_grid(all_network, ax, geographical_boundaries) if ext_width is not False: line_widths = 0.5 + (line_colors / ext_width) link_widths = link_colors.apply( @@ -2526,11 +2532,11 @@ def plot_grid( if ext_width is not False: line_widths = 0.5 + (line_colors / ext_width) link_colors = pd.Series(data=0, index=network.links.index) - plot_background_grid(network, ax) + plot_background_grid(network, ax, geographical_boundaries) elif line_colors == "dlr": title = "Dynamic line rating" label = "TWh above nominal capacity" - plot_background_grid(network, ax) + plot_background_grid(network, ax, geographical_boundaries) # calc min capacity per line in the given period: Since lines with # different original voltage level could be aggregated during the @@ -2563,7 +2569,7 @@ def plot_grid( label = "" line_colors = "grey" link_colors = "grey" - plot_background_grid(network, ax) + plot_background_grid(network, ax, geographical_boundaries) link_widths = 0 line_widths = 0 @@ -2714,7 +2720,7 @@ def plot_grid( geomap=False, projection=ccrs.PlateCarree(), color_geomap=True, - boundaries=[-2.5, 16, 46.8, 58], + boundaries=geographical_boundaries, ) else: ll = network.plot( @@ -2729,7 +2735,7 @@ def plot_grid( flow=flow, title=title, geomap=False, - boundaries=[-2.5, 16, 46.8, 58], + boundaries=geographical_boundaries, ) l3 = None From 75e285b2d7a0d0c56a8ab1c6cceda73da5e0beb2 Mon Sep 17 00:00:00 2001 From: ClaraBuettner Date: Mon, 30 Oct 2023 16:26:44 +0100 Subject: [PATCH 3/3] Set default value of scaling_store_expansion to False This parameter shpuld be only used when plotting storage expansion as bus_colors. It leads to errors whem this parameter is used for other bus_colors, e.g. "gen-dist". To use it easier, this parameter is set to False by default. --- etrago/tools/plot.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/etrago/tools/plot.py b/etrago/tools/plot.py index d68479e6..11bee6b3 100644 --- a/etrago/tools/plot.py +++ b/etrago/tools/plot.py @@ -2320,11 +2320,7 @@ def plot_grid( ext_min=0.1, ext_width=False, legend_entries="all", - scaling_store_expansion={ - "H2": 50, - "heat": 0.1, - "battery": 10, - }, + scaling_store_expansion=False, geographical_boundaries=[-2.5, 16, 46.8, 58], ): """Function that plots etrago.network and results for lines and buses @@ -2386,6 +2382,7 @@ def plot_grid( scaling_store_expansion : dict, optional Set scaling values to be used per technology for the plots storage_expansion and h2_battery_storage_expansion. The default is + False, it could be assinged like this: {"H2": 50, "heat": 0.1, "battery": 10} geographical_boundaries : list, optional Set georaphical boundaries for the plots The default is