[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
This commit is contained in:
pre-commit-ci[bot] 2024-01-25 19:50:03 +00:00
parent a2cd042472
commit 5fcfafe971
2 changed files with 18 additions and 17 deletions

View File

@ -14,7 +14,8 @@ if config["foresight"] != "perfect":
plotting=config["plotting"],
input:
network=RESOURCES + "networks/elec_s{simpl}_{clusters}.nc",
regions_onshore=RESOURCES + "regions_onshore_elec_s{simpl}_{clusters}.geojson",
regions_onshore=RESOURCES
+ "regions_onshore_elec_s{simpl}_{clusters}.geojson",
rc="matplotlibrc",
output:
map=RESULTS + "maps/power-network-{clusters}.pdf",
@ -28,7 +29,6 @@ if config["foresight"] != "perfect":
script:
"../scripts/plot_power_network_clustered.py"
rule plot_power_network:
params:
plotting=config["plotting"],

View File

@ -6,15 +6,13 @@
Plot clustered electricity transmission network.
"""
import pypsa
import cartopy.crs as ccrs
import geopandas as gpd
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import pypsa
from matplotlib.lines import Line2D
from pypsa.plot import add_legend_lines
from plot_power_network import load_projection
from pypsa.plot import add_legend_lines
if __name__ == "__main__":
if "snakemake" not in globals():
@ -23,7 +21,7 @@ if __name__ == "__main__":
snakemake = mock_snakemake(
"plot_power_network_clustered",
clusters=128,
configfiles=["../../config/config.test.yaml"]
configfiles=["../../config/config.test.yaml"],
)
plt.style.use(snakemake.input.rc)
@ -32,16 +30,13 @@ if __name__ == "__main__":
n = pypsa.Network(snakemake.input.network)
regions = gpd.read_file(snakemake.input.regions_onshore).set_index('name')
regions = gpd.read_file(snakemake.input.regions_onshore).set_index("name")
proj = load_projection(snakemake.params.plotting)
fig, ax = plt.subplots(figsize=(8,8), subplot_kw={"projection": proj})
fig, ax = plt.subplots(figsize=(8, 8), subplot_kw={"projection": proj})
regions.to_crs(proj.proj4_init).plot(
ax=ax,
facecolor='none',
edgecolor='lightgray',
linewidth=0.75
ax=ax, facecolor="none", edgecolor="lightgray", linewidth=0.75
)
n.plot(
ax=ax,
@ -50,7 +45,7 @@ if __name__ == "__main__":
link_colors=n.links.p_nom.apply(
lambda x: "darkseagreen" if x > 0 else "skyblue"
),
link_widths=2.,
link_widths=2.0,
)
sizes = [10, 20]
@ -74,6 +69,12 @@ if __name__ == "__main__":
Line2D([0], [0], color="darkseagreen", lw=2),
Line2D([0], [0], color="skyblue", lw=2),
]
plt.legend(handles, ["HVDC existing", "HVDC planned"], frameon=False, loc=[0., 0.9], fontsize=13)
plt.legend(
handles,
["HVDC existing", "HVDC planned"],
frameon=False,
loc=[0.0, 0.9],
fontsize=13,
)
plt.savefig(snakemake.output.map, bbox_inches='tight')
plt.savefig(snakemake.output.map, bbox_inches="tight")