Skip to content

Commit fb2c381

Browse files
committed
merge master
1 parent ba44b81 commit fb2c381

File tree

3 files changed

+47
-32
lines changed

3 files changed

+47
-32
lines changed

Snakefile

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ BENCHMARKS = "benchmarks/" + RDIR
3333
RESOURCES = "resources/" + RDIR if not run.get("shared_resources") else "resources/"
3434
RESULTS = "results/" + RDIR
3535

36-
3736
localrules:
3837
purge,
3938

rules/plot.smk

+2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ rule plot_renewable_potential_unclustered:
5252
output:
5353
wind=multiext(RESOURCES + "graphics/wind-energy-density", ".png", ".pdf"),
5454
solar=multiext(RESOURCES + "graphics/solar-energy-density", ".png", ".pdf"),
55+
wind_cf=multiext(RESOURCES + "graphics/wind-capacity-factor", ".png", ".pdf"),
56+
solar_cf=multiext(RESOURCES + "graphics/solar-capacity-factor", ".png", ".pdf"),
5557
script:
5658
"../scripts/plot_renewable_potential_unclustered.py"
5759

scripts/plot_renewable_potential_unclustered.py

+45-31
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,29 @@
1313
import pandas as pd
1414
import xarray as xr
1515

16+
def plot_map(regions, color, cmap, label, vmin=None, vmax=None):
17+
18+
proj = ccrs.EqualEarth()
19+
regions = regions.to_crs(proj.proj4_init)
20+
fig, ax = plt.subplots(figsize=(7, 7), subplot_kw={"projection": proj})
21+
regions.plot(
22+
ax=ax,
23+
column=color,
24+
cmap=cmap,
25+
linewidths=0,
26+
legend=True,
27+
vmin=vmin,
28+
vmax=vmax,
29+
legend_kwds={"label": label, "shrink": 0.8},
30+
)
31+
ax.add_feature(cartopy.feature.COASTLINE.with_scale("50m"), linewidth=0.5, zorder=4)
32+
ax.add_feature(cartopy.feature.BORDERS.with_scale("50m"), linewidth=0.5, zorder=2)
33+
ax.gridlines(linestyle=":")
34+
ax.axis("off")
35+
36+
return fig, ax
37+
38+
1639
if __name__ == "__main__":
1740
if "snakemake" not in globals():
1841
from _helpers import mock_snakemake
@@ -41,49 +64,40 @@
4164
wind = wind.groupby(level=0).sum().reindex(regions.index, fill_value=0)
4265
wind_per_skm = wind / regions.Area / 1e3 # GWh
4366

44-
proj = ccrs.EqualEarth()
45-
regions = regions.to_crs(proj.proj4_init)
46-
fig, ax = plt.subplots(figsize=(7, 7), subplot_kw={"projection": proj})
47-
regions.plot(
48-
ax=ax,
49-
column=wind_per_skm,
50-
cmap="Blues",
51-
linewidths=0,
52-
legend=True,
53-
legend_kwds={"label": r"Wind Energy Potential [GWh/a/km$^2$]", "shrink": 0.8},
54-
)
55-
ax.add_feature(cartopy.feature.COASTLINE.with_scale("50m"), linewidth=0.5, zorder=4)
56-
ax.add_feature(cartopy.feature.BORDERS.with_scale("50m"), linewidth=0.5, zorder=2)
57-
ax.gridlines(linestyle=":")
58-
ax.axis("off")
67+
fig, ax = plot_map(regions, wind_per_skm, "Blues", r"Wind Energy Potential [GWh/a/km$^2$]")
5968

6069
for fn in snakemake.output["wind"]:
6170
plt.savefig(fn)
6271

72+
cf = pd.Series()
73+
for profile in ["onwind", "offwind-ac", "offwind-dc"]:
74+
ds = xr.open_dataset(snakemake.input[f"profile_{profile}"])
75+
cf = pd.concat([cf, (ds.profile.mean("time") * 100).to_pandas()])
76+
cf = cf.groupby(level=0).mean().reindex(regions.index, fill_value=0.)
77+
78+
fig, ax = plot_map(regions, cf, "Blues", r"Wind Capacity Factor [%]", vmin=0, vmax=60)
79+
80+
for fn in snakemake.output["wind_cf"]:
81+
plt.savefig(fn)
82+
6383
onregions = gpd.read_file(snakemake.input.regions_onshore).set_index("name")
6484
onregions["Area"] = onregions.to_crs(epsg=3035).area.div(1e6)
6585

6686
ds = xr.open_dataset(snakemake.input.profile_solar)
6787
solar = (ds.p_nom_max * ds.profile.sum("time")).to_pandas()
6888

69-
solar = solar.groupby(level=0).sum().reindex(onregions.index, fill_value=0)
89+
solar = solar.groupby(level=0).sum().reindex(onregions.index, fill_value=0.)
7090
solar_per_skm = solar / onregions.Area / 1e3 # GWh
7191

72-
proj = ccrs.EqualEarth()
73-
onregions = onregions.to_crs(proj.proj4_init)
74-
fig, ax = plt.subplots(figsize=(7, 7), subplot_kw={"projection": proj})
75-
onregions.plot(
76-
ax=ax,
77-
column=solar_per_skm,
78-
cmap="Reds",
79-
linewidths=0,
80-
legend=True,
81-
legend_kwds={"label": r"Solar Energy Potential [GWh/a/km$^2$]", "shrink": 0.8},
82-
)
83-
ax.add_feature(cartopy.feature.COASTLINE.with_scale("50m"), linewidth=0.5, zorder=2)
84-
ax.add_feature(cartopy.feature.BORDERS.with_scale("50m"), linewidth=0.5, zorder=2)
85-
ax.gridlines(linestyle=":")
86-
ax.axis("off")
92+
fig, ax = plot_map(onregions, solar_per_skm, "Reds", r"Solar Energy Potential [GWh/a/km$^2$]")
8793

8894
for fn in snakemake.output["solar"]:
8995
plt.savefig(fn)
96+
97+
cf = (ds.profile.mean("time") * 100).to_pandas()
98+
cf = cf.groupby(level=0).mean().reindex(onregions.index, fill_value=0.)
99+
100+
fig, ax = plot_map(onregions, cf, "Reds", r"Solar Capacity Factor [%]", vmin=6, vmax=20)
101+
102+
for fn in snakemake.output["solar_cf"]:
103+
plt.savefig(fn)

0 commit comments

Comments
 (0)