|
| 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