feedback code review (opts argument and unpacking)

This commit is contained in:
Seth 2022-03-28 13:42:55 +02:00
parent e45c7a65ff
commit c37171b01d

View File

@ -74,7 +74,7 @@ def set_plot_style():
}]) }])
def plot_map(n, ax=None, attribute='p_nom', opts={}): def plot_map(n, opts, ax=None, attribute='p_nom'):
if ax is None: if ax is None:
ax = plt.gca() ax = plt.gca()
@ -263,20 +263,20 @@ if __name__ == "__main__":
map_figsize = config["plotting"]['map']['figsize'] map_figsize = config["plotting"]['map']['figsize']
map_boundaries = config["plotting"]['map']['boundaries'] map_boundaries = config["plotting"]['map']['boundaries']
n = load_network_for_plots(paths.network, paths.tech_costs, config) n = load_network_for_plots(snakemake.input.network, snakemake.input.tech_costs, config)
scenario_opts = wildcards.opts.split('-') scenario_opts = wildcards.opts.split('-')
fig, ax = plt.subplots(figsize=map_figsize, subplot_kw={"projection": ccrs.PlateCarree()}) fig, ax = plt.subplots(figsize=map_figsize, subplot_kw={"projection": ccrs.PlateCarree()})
plot_map(n, ax, wildcards.attr, config["plotting"]) plot_map(n, config["plotting"], ax=ax, attribute=wildcards.attr)
fig.savefig(out.only_map, dpi=150, bbox_inches='tight') fig.savefig(snakemake.output.only_map, dpi=150, bbox_inches='tight')
ax1 = fig.add_axes([-0.115, 0.625, 0.2, 0.2]) ax1 = fig.add_axes([-0.115, 0.625, 0.2, 0.2])
plot_total_energy_pie(n, ax1, config["plotting"]) plot_total_energy_pie(n, config["plotting"], ax=ax1)
ax2 = fig.add_axes([-0.075, 0.1, 0.1, 0.45]) ax2 = fig.add_axes([-0.075, 0.1, 0.1, 0.45])
plot_total_cost_bar(n, ax2, config["plotting"]) plot_total_cost_bar(n, config["plotting"], ax=ax2)
ll = wildcards.ll ll = wildcards.ll
ll_type = ll[0] ll_type = ll[0]
@ -286,4 +286,4 @@ if __name__ == "__main__":
fig.suptitle('Expansion to {amount} {label} at {clusters} clusters' fig.suptitle('Expansion to {amount} {label} at {clusters} clusters'
.format(amount=amnt, label=lbl, clusters=wildcards.clusters)) .format(amount=amnt, label=lbl, clusters=wildcards.clusters))
fig.savefig(out.ext, transparent=True, bbox_inches='tight') fig.savefig(snakemake.output.ext, transparent=True, bbox_inches='tight')