Skip to content

Commit f2d2440

Browse files
committed
plot resources: biomass potentials
1 parent 7a1c84b commit f2d2440

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed

rules/plot.smk

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,15 @@ rule plot_salt_caverns_clustered:
112112
script:
113113
"../scripts/plot_salt_caverns_clustered.py"
114114

115+
116+
rule plot_biomass_potentials:
117+
input:
118+
biomass=RESOURCES + "biomass_potentials_s_{clusters}.csv",
119+
regions_onshore=RESOURCES + "regions_onshore_elec_s_{clusters}.geojson",
120+
rc="matplotlibrc",
121+
output:
122+
solid_biomass=multiext(RESOURCES + "graphics/biomass-potentials-{clusters}-solid_biomass", ".png", ".pdf"),
123+
not_included=multiext(RESOURCES + "graphics/biomass-potentials-{clusters}-not_included", ".png", ".pdf"),
124+
biogas=multiext(RESOURCES + "graphics/biomass-potentials-{clusters}-biogas", ".png", ".pdf"),
125+
script:
126+
"../scripts/plot_biomass_potentials.py"

scripts/plot_biomass_potentials.py

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# -*- coding: utf-8 -*-
2+
# SPDX-FileCopyrightText: : 2023- Fabian Neumann
3+
#
4+
# SPDX-License-Identifier: MIT
5+
"""
6+
Plot unclustered salt caverns.
7+
"""
8+
9+
import pandas as pd
10+
import geopandas as gpd
11+
import matplotlib.pyplot as plt
12+
import cartopy.crs as ccrs
13+
import cartopy
14+
15+
16+
def plot_biomass_potentials(bio, regions, kind):
17+
18+
crs = ccrs.EqualEarth()
19+
regions = regions.to_crs(crs.proj4_init)
20+
21+
fig, ax = plt.subplots(figsize=(7, 7), subplot_kw={"projection": crs})
22+
23+
ax.add_feature(cartopy.feature.COASTLINE.with_scale("50m"), linewidth=0.5, zorder=2)
24+
ax.add_feature(cartopy.feature.BORDERS.with_scale("50m"), linewidth=0.5, zorder=2)
25+
26+
nkind = "disregarded biomass" if kind == "not included" else kind
27+
label = f"{nkind} potentials [TWh/a]"
28+
29+
regions.plot(
30+
ax=ax,
31+
column=bio[kind],
32+
cmap="Greens",
33+
legend=True,
34+
linewidth=0.5,
35+
edgecolor='grey',
36+
legend_kwds={
37+
"label": label,
38+
"shrink": 0.7,
39+
"extend": "max",
40+
},
41+
)
42+
43+
total = bio[kind].sum()
44+
45+
ax.text(-0.8e6, 7.4e6, f"{total:.0f} TWh/a", color="#343434")
46+
47+
plt.xlim(-1e6, 2.6e6)
48+
plt.ylim(4.3e6, 7.8e6)
49+
50+
ax.axis("off")
51+
52+
for fn in snakemake.output[kind.replace(" ", "_")]:
53+
plt.savefig(fn)
54+
55+
56+
if __name__ == "__main__":
57+
if "snakemake" not in globals():
58+
from _helpers import mock_snakemake
59+
60+
snakemake = mock_snakemake(
61+
"plot_biomass_potentials",
62+
clusters=128,
63+
configfiles=["../../config/config.test.yaml"]
64+
)
65+
66+
plt.style.use(snakemake.input.rc)
67+
68+
bio = pd.read_csv(snakemake.input.biomass, index_col=0).div(1e6) # TWh/a
69+
70+
regions = gpd.read_file(
71+
snakemake.input.regions_onshore
72+
).set_index("name")
73+
74+
75+
plot_biomass_potentials(bio, regions, kind="not included")
76+
plot_biomass_potentials(bio, regions, kind="biogas")
77+
plot_biomass_potentials(bio, regions, kind="solid biomass")
78+

0 commit comments

Comments
 (0)