From 03b51cac18da1de89003325d4adf119edfc9c2f5 Mon Sep 17 00:00:00 2001 From: Fabian Neumann Date: Wed, 14 Aug 2019 17:15:07 +0200 Subject: [PATCH] add rulegraphs --- doc/conf.py | 1 + doc/plotting.rst | 151 ++++++++++++++++++- doc/preparation.rst | 1 - doc/preparation/add_electricity.rst | 46 ++++++ doc/preparation/base_network.rst | 43 ++++++ doc/preparation/build_bus_regions.rst | 40 +++++ doc/preparation/build_country_flh.rst | 6 - doc/preparation/build_cutout.rst | 31 ++++ doc/preparation/build_hydro_profile.rst | 34 +++++ doc/preparation/build_natura_raster.rst | 28 ++++ doc/preparation/build_powerplants.rst | 31 ++++ doc/preparation/build_renewable_profiles.rst | 43 ++++++ doc/preparation/build_shapes.rst | 40 +++++ doc/preparation/prepare_links_p_nom.rst | 28 ++++ doc/simplification/cluster_network.rst | 32 ++++ doc/simplification/prepare_network.rst | 31 ++++ doc/simplification/simplify_network.rst | 34 +++++ doc/solving/solve_network.rst | 28 ++++ doc/solving/solve_operations_network.rst | 31 ++++ doc/solving/trace_solve_network.rst | 28 ++++ scripts/build_country_flh.py | 4 +- 21 files changed, 694 insertions(+), 17 deletions(-) delete mode 100644 doc/preparation/build_country_flh.rst diff --git a/doc/conf.py b/doc/conf.py index 9f060636..867b9f53 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -36,6 +36,7 @@ extensions = [ 'sphinx.ext.todo', 'sphinx.ext.mathjax', 'sphinx.ext.napoleon', + 'sphinx.ext.graphviz', #'sphinx.ext.pngmath', #'sphinxcontrib.tikz', #'rinoh.frontend.sphinx', diff --git a/doc/plotting.rst b/doc/plotting.rst index be030a75..9f1076bf 100644 --- a/doc/plotting.rst +++ b/doc/plotting.rst @@ -4,31 +4,166 @@ Plotting and Summary .. warning:: The corresponding code is currently under revision and has only minimal documentation. +.. _flh: + +Rule :mod:`build_country_flh` +============================= + +.. graphviz:: + :align: center + + digraph snakemake_dag { + graph [bgcolor=white, + margin=0, + size="8,5" + ]; + node [fontname=sans, + fontsize=10, + penwidth=2, + shape=box, + style=rounded + ]; + edge [color=grey, + penwidth=2 + ]; + 0 [color="0.31 0.6 0.85", + fillcolor=gray, + label=build_country_flh, + style=filled]; + 1 [color="0.06 0.6 0.85", + label=base_network]; + 1 -> 0; + 2 [color="0.42 0.6 0.85", + label=build_natura_raster]; + 2 -> 0; + 3 [color="0.58 0.6 0.85", + label=build_shapes]; + 3 -> 0; + 4 [color="0.14 0.6 0.85", + label=build_cutout]; + 4 -> 0; + } + +| + +.. automodule:: build_country_flh + .. _plot_potentials: -Plot Potentials -=============== +Rule :mod:`plot_p_nom_max` +========================== + +.. graphviz:: + :align: center + + digraph snakemake_dag { + graph [bgcolor=white, + margin=0, + size="8,5" + ]; + node [fontname=sans, + fontsize=10, + penwidth=2, + shape=box, + style=rounded + ]; + edge [color=grey, + penwidth=2 + ]; + 0 [color="0.42 0.6 0.85", + fillcolor=gray, + label=plot_p_nom_max, + style=filled]; + 1 [color="0.58 0.6 0.85", + label=cluster_network]; + 1 -> 0; + } + +| .. automodule:: plot_p_nom_max .. _summary: -Make Summary -============ +Rule :mod:`make_summary` +======================== + +.. graphviz:: + :align: center + + digraph snakemake_dag { + graph [bgcolor=white, + margin=0, + size="8,5" + ]; + node [fontname=sans, + fontsize=10, + penwidth=2, + shape=box, + style=rounded + ]; + edge [color=grey, + penwidth=2 + ]; + 0 [color="0.47 0.6 0.85", + fillcolor=gray, + label=make_summary, + style=filled]; + 1 [color="0.11 0.6 0.85", + label=solve_network]; + 1 -> 0; + } + +| .. automodule:: make_summary .. _summary_plot: -Plot Summary -============ +Rule :mod:`plot_summary` +======================== + +.. graphviz:: + :align: center + + + +| .. automodule:: plot_summary .. _map_plot: -Plot Network -============ +Rule :mod:`plot_network` +======================== + +.. graphviz:: + :align: center + + digraph snakemake_dag { + graph [bgcolor=white, + margin=0, + size="8,5" + ]; + node [fontname=sans, + fontsize=10, + penwidth=2, + shape=box, + style=rounded + ]; + edge [color=grey, + penwidth=2 + ]; + 0 [color="0.00 0.6 0.85", + fillcolor=gray, + label=plot_network, + style=filled]; + 1 [color="0.50 0.6 0.85", + label=solve_network]; + 1 -> 0; + } + +| .. automodule:: plot_network diff --git a/doc/preparation.rst b/doc/preparation.rst index 30d88439..5fb891dc 100644 --- a/doc/preparation.rst +++ b/doc/preparation.rst @@ -32,7 +32,6 @@ together into a detailed PyPSA network stored in ``networks/elec.nc``. preparation/base_network preparation/build_bus_regions preparation/build_natura_raster - preparation/build_country_flh preparation/build_powerplants preparation/build_renewable_profiles preparation/build_hydro_profile diff --git a/doc/preparation/add_electricity.rst b/doc/preparation/add_electricity.rst index fad502a5..6e5b4c2a 100644 --- a/doc/preparation/add_electricity.rst +++ b/doc/preparation/add_electricity.rst @@ -3,4 +3,50 @@ Rule :mod:`add_electricity` ============================= +.. graphviz:: + :align: center + + digraph snakemake_dag { + graph [bgcolor=white, + margin=0, + size="8,5" + ]; + node [fontname=sans, + fontsize=10, + penwidth=2, + shape=box, + style=rounded + ]; + edge [color=grey, + penwidth=2 + ]; + 3 [color="0.25 0.6 0.85", + label=simplify_network]; + 4 [color="0.50 0.6 0.85", + fillcolor=gray, + label=add_electricity, + style=filled]; + 4 -> 3; + 5 [color="0.36 0.6 0.85", + label=build_bus_regions]; + 5 -> 4; + 6 [color="0.58 0.6 0.85", + label=base_network]; + 6 -> 4; + 7 [color="0.31 0.6 0.85", + label=build_powerplants]; + 7 -> 4; + 8 [color="0.28 0.6 0.85", + label=build_shapes]; + 8 -> 4; + 9 [color="0.22 0.6 0.85", + label=build_renewable_profiles]; + 9 -> 4; + 10 [color="0.44 0.6 0.85", + label=build_hydro_profile]; + 10 -> 4; + } + +| + .. automodule:: add_electricity diff --git a/doc/preparation/base_network.rst b/doc/preparation/base_network.rst index cb29093d..743bbe10 100644 --- a/doc/preparation/base_network.rst +++ b/doc/preparation/base_network.rst @@ -3,4 +3,47 @@ Rule :mod:`base_network` ============================= +.. graphviz:: + :align: center + + digraph snakemake_dag { + graph [bgcolor=white, + margin=0, + size="8,5" + ]; + node [fontname=sans, + fontsize=10, + penwidth=2, + shape=box, + style=rounded + ]; + edge [color=grey, + penwidth=2 + ]; + 4 [color="0.50 0.6 0.85", + label=add_electricity]; + 5 [color="0.36 0.6 0.85", + label=build_bus_regions]; + 6 [color="0.58 0.6 0.85", + fillcolor=gray, + label=base_network, + style=filled]; + 6 -> 4; + 6 -> 5; + 7 [color="0.31 0.6 0.85", + label=build_powerplants]; + 6 -> 7; + 9 [color="0.22 0.6 0.85", + label=build_renewable_profiles]; + 6 -> 9; + 8 [color="0.28 0.6 0.85", + label=build_shapes]; + 8 -> 6; + 11 [color="0.03 0.6 0.85", + label=prepare_links_p_nom]; + 11 -> 6; + } + +| + .. automodule:: base_network \ No newline at end of file diff --git a/doc/preparation/build_bus_regions.rst b/doc/preparation/build_bus_regions.rst index 96063104..3c827f51 100644 --- a/doc/preparation/build_bus_regions.rst +++ b/doc/preparation/build_bus_regions.rst @@ -3,4 +3,44 @@ Rule :mod:`build_bus_regions` ============================= +.. graphviz:: + :align: center + + digraph snakemake_dag { + graph [bgcolor=white, + margin=0, + size="8,5" + ]; + node [fontname=sans, + fontsize=10, + penwidth=2, + shape=box, + style=rounded + ]; + edge [color=grey, + penwidth=2 + ]; + 3 [color="0.25 0.6 0.85", + label=simplify_network]; + 4 [color="0.50 0.6 0.85", + label=add_electricity]; + 5 [color="0.36 0.6 0.85", + fillcolor=gray, + label=build_bus_regions, + style=filled]; + 5 -> 3; + 5 -> 4; + 9 [color="0.22 0.6 0.85", + label=build_renewable_profiles]; + 5 -> 9; + 6 [color="0.58 0.6 0.85", + label=base_network]; + 6 -> 5; + 8 [color="0.28 0.6 0.85", + label=build_shapes]; + 8 -> 5; + } + +| + .. automodule:: build_bus_regions \ No newline at end of file diff --git a/doc/preparation/build_country_flh.rst b/doc/preparation/build_country_flh.rst deleted file mode 100644 index 5c7f053d..00000000 --- a/doc/preparation/build_country_flh.rst +++ /dev/null @@ -1,6 +0,0 @@ -.. _flh: - -Rule :mod:`build_country_flh` -============================= - -.. automodule:: build_country_flh \ No newline at end of file diff --git a/doc/preparation/build_cutout.rst b/doc/preparation/build_cutout.rst index e6d4516a..c2acd665 100644 --- a/doc/preparation/build_cutout.rst +++ b/doc/preparation/build_cutout.rst @@ -3,4 +3,35 @@ Rule :mod:`build_cutout` ============================= +.. graphviz:: + :align: center + + digraph snakemake_dag { + graph [bgcolor=white, + margin=0, + size="8,5" + ]; + node [fontname=sans, + fontsize=10, + penwidth=2, + shape=box, + style=rounded + ]; + edge [color=grey, + penwidth=2 + ]; + 9 [color="0.22 0.6 0.85", + label=build_renewable_profiles]; + 10 [color="0.44 0.6 0.85", + label=build_hydro_profile]; + 13 [color="0.17 0.6 0.85", + fillcolor=gray, + label=build_cutout, + style=filled]; + 13 -> 9; + 13 -> 10; + } + +| + .. automodule:: build_cutout \ No newline at end of file diff --git a/doc/preparation/build_hydro_profile.rst b/doc/preparation/build_hydro_profile.rst index ae3de14a..a3d83987 100644 --- a/doc/preparation/build_hydro_profile.rst +++ b/doc/preparation/build_hydro_profile.rst @@ -3,4 +3,38 @@ Rule :mod:`build_hydro_profile` =============================== +.. graphviz:: + :align: center + + digraph snakemake_dag { + graph [bgcolor=white, + margin=0, + size="8,5" + ]; + node [fontname=sans, + fontsize=10, + penwidth=2, + shape=box, + style=rounded + ]; + edge [color=grey, + penwidth=2 + ]; + 4 [color="0.61 0.6 0.85", + label=add_electricity]; + 8 [color="0.00 0.6 0.85", + label=build_shapes]; + 10 [color="0.11 0.6 0.85", + fillcolor=gray, + label=build_hydro_profile, + style=filled]; + 8 -> 10; + 10 -> 4; + 13 [color="0.56 0.6 0.85", + label=build_cutout]; + 13 -> 10; + } + +| + .. automodule:: build_hydro_profile diff --git a/doc/preparation/build_natura_raster.rst b/doc/preparation/build_natura_raster.rst index 1efc22fe..6638e0f6 100644 --- a/doc/preparation/build_natura_raster.rst +++ b/doc/preparation/build_natura_raster.rst @@ -3,4 +3,32 @@ Rule :mod:`build_natura_raster` =============================== +.. graphviz:: + :align: center + + digraph snakemake_dag { + graph [bgcolor=white, + margin=0, + size="8,5" + ]; + node [fontname=sans, + fontsize=10, + penwidth=2, + shape=box, + style=rounded + ]; + edge [color=grey, + penwidth=2 + ]; + 9 [color="0.22 0.6 0.85", + label=build_renewable_profiles]; + 12 [color="0.31 0.6 0.85", + fillcolor=gray, + label=build_natura_raster, + style=filled]; + 12 -> 9; + } + +| + .. automodule:: build_natura_raster diff --git a/doc/preparation/build_powerplants.rst b/doc/preparation/build_powerplants.rst index 14c529b2..e22c1dce 100644 --- a/doc/preparation/build_powerplants.rst +++ b/doc/preparation/build_powerplants.rst @@ -3,4 +3,35 @@ Rule :mod:`build_powerplants` ============================= +.. graphviz:: + :align: center + + digraph snakemake_dag { + graph [bgcolor=white, + margin=0, + size="8,5" + ]; + node [fontname=sans, + fontsize=10, + penwidth=2, + shape=box, + style=rounded + ]; + edge [color=grey, + penwidth=2 + ]; + 4 [color="0.61 0.6 0.85", + label=add_electricity]; + 6 [color="0.17 0.6 0.85", + label=base_network]; + 7 [color="0.58 0.6 0.85", + fillcolor=gray, + label=build_powerplants, + style=filled]; + 6 -> 7; + 7 -> 4; + } + +| + .. automodule:: build_powerplants diff --git a/doc/preparation/build_renewable_profiles.rst b/doc/preparation/build_renewable_profiles.rst index a8252d0b..a52f5134 100644 --- a/doc/preparation/build_renewable_profiles.rst +++ b/doc/preparation/build_renewable_profiles.rst @@ -3,4 +3,47 @@ Rule :mod:`build_renewable_profiles` ==================================== +.. graphviz:: + :align: center + + digraph snakemake_dag { + graph [bgcolor=white, + margin=0, + size="8,5" + ]; + node [fontname=sans, + fontsize=10, + penwidth=2, + shape=box, + style=rounded + ]; + edge [color=grey, + penwidth=2 + ]; + 4 [color="0.61 0.6 0.85", + label=add_electricity]; + 5 [color="0.19 0.6 0.85", + label=build_bus_regions]; + 9 [color="0.22 0.6 0.85", + fillcolor=gray, + label=build_renewable_profiles, + style=filled]; + 5 -> 9; + 9 -> 4; + 6 [color="0.17 0.6 0.85", + label=base_network]; + 6 -> 9; + 8 [color="0.00 0.6 0.85", + label=build_shapes]; + 8 -> 9; + 12 [color="0.31 0.6 0.85", + label=build_natura_raster]; + 12 -> 9; + 13 [color="0.56 0.6 0.85", + label=build_cutout]; + 13 -> 9; + } + +| + .. automodule:: build_renewable_profiles diff --git a/doc/preparation/build_shapes.rst b/doc/preparation/build_shapes.rst index e78ada6d..f03500f9 100644 --- a/doc/preparation/build_shapes.rst +++ b/doc/preparation/build_shapes.rst @@ -3,4 +3,44 @@ Rule :mod:`build_shapes` ============================= +.. graphviz:: + :align: center + + digraph snakemake_dag { + graph [bgcolor=white, + margin=0, + size="8,5" + ]; + node [fontname=sans, + fontsize=10, + penwidth=2, + shape=box, + style=rounded + ]; + edge [color=grey, + penwidth=2 + ]; + 4 [color="0.61 0.6 0.85", + label=add_electricity]; + 5 [color="0.19 0.6 0.85", + label=build_bus_regions]; + 6 [color="0.17 0.6 0.85", + label=base_network]; + 8 [color="0.00 0.6 0.85", + fillcolor=gray, + label=build_shapes, + style=filled]; + 8 -> 4; + 8 -> 5; + 8 -> 6; + 9 [color="0.22 0.6 0.85", + label=build_renewable_profiles]; + 8 -> 9; + 10 [color="0.11 0.6 0.85", + label=build_hydro_profile]; + 8 -> 10; + } + +| + .. automodule:: build_shapes diff --git a/doc/preparation/prepare_links_p_nom.rst b/doc/preparation/prepare_links_p_nom.rst index 23272254..ae7aa4d0 100644 --- a/doc/preparation/prepare_links_p_nom.rst +++ b/doc/preparation/prepare_links_p_nom.rst @@ -3,4 +3,32 @@ Rule :mod:`prepare_links_p_nom` =============================== +.. graphviz:: + :align: center + + digraph snakemake_dag { + graph [bgcolor=white, + margin=0, + size="8,5" + ]; + node [fontname=sans, + fontsize=10, + penwidth=2, + shape=box, + style=rounded + ]; + edge [color=grey, + penwidth=2 + ]; + 6 [color="0.17 0.6 0.85", + label=base_network]; + 11 [color="0.39 0.6 0.85", + fillcolor=gray, + label=prepare_links_p_nom, + style=filled]; + 11 -> 6; + } + +| + .. automodule:: prepare_links_p_nom diff --git a/doc/simplification/cluster_network.rst b/doc/simplification/cluster_network.rst index 866c73f5..5975a5d5 100644 --- a/doc/simplification/cluster_network.rst +++ b/doc/simplification/cluster_network.rst @@ -3,4 +3,36 @@ Rule :mod:`cluster_network` =========================== +.. graphviz:: + :align: center + + digraph snakemake_dag { + graph [bgcolor=white, + margin=0, + size="8,5" + ]; + node [fontname=sans, + fontsize=10, + penwidth=2, + shape=box, + style=rounded + ]; + edge [color=grey, + penwidth=2 + ]; + 1 [color="0.50 0.6 0.85", + label=prepare_network]; + 2 [color="0.36 0.6 0.85", + fillcolor=gray, + label=cluster_network, + style=filled]; + 2 -> 1; + 3 [color="0.14 0.6 0.85", + label=simplify_network]; + 3 -> 2; + } + + +| + .. automodule:: cluster_network diff --git a/doc/simplification/prepare_network.rst b/doc/simplification/prepare_network.rst index 19ec177f..42308f1e 100644 --- a/doc/simplification/prepare_network.rst +++ b/doc/simplification/prepare_network.rst @@ -3,4 +3,35 @@ Rule :mod:`prepare_network` =========================== +.. graphviz:: + :align: center + + digraph snakemake_dag { + graph [bgcolor=white, + margin=0, + size="8,5" + ]; + node [fontname=sans, + fontsize=10, + penwidth=2, + shape=box, + style=rounded + ]; + edge [color=grey, + penwidth=2 + ]; + 0 [color="0.53 0.6 0.85", + label=solve_network]; + 1 [color="0.50 0.6 0.85", + fillcolor=gray, + label=prepare_network, + style=filled]; + 1 -> 0; + 2 [color="0.36 0.6 0.85", + label=cluster_network]; + 2 -> 1; + } + +| + .. automodule:: prepare_network diff --git a/doc/simplification/simplify_network.rst b/doc/simplification/simplify_network.rst index b2c96321..7551d96b 100644 --- a/doc/simplification/simplify_network.rst +++ b/doc/simplification/simplify_network.rst @@ -3,4 +3,38 @@ Rule :mod:`simplify_network` ============================ +.. graphviz:: + :align: center + + digraph snakemake_dag { + graph [bgcolor=white, + margin=0, + size="8,5" + ]; + node [fontname=sans, + fontsize=10, + penwidth=2, + shape=box, + style=rounded + ]; + edge [color=grey, + penwidth=2 + ]; + 2 [color="0.36 0.6 0.85", + label=cluster_network]; + 3 [color="0.14 0.6 0.85", + fillcolor=gray, + label=simplify_network, + style=filled]; + 3 -> 2; + 4 [color="0.61 0.6 0.85", + label=add_electricity]; + 4 -> 3; + 5 [color="0.19 0.6 0.85", + label=build_bus_regions]; + 5 -> 3; + } + +| + .. automodule:: simplify_network diff --git a/doc/solving/solve_network.rst b/doc/solving/solve_network.rst index 12edd2ee..4479c4e8 100644 --- a/doc/solving/solve_network.rst +++ b/doc/solving/solve_network.rst @@ -3,4 +3,32 @@ Rule :mod:`solve_network` ========================= +.. graphviz:: + :align: center + + digraph snakemake_dag { + graph [bgcolor=white, + margin=0, + size="3,3" + ]; + node [fontname=sans, + fontsize=10, + penwidth=2, + shape=box, + style=rounded + ]; + edge [color=grey, + penwidth=2 + ]; + 0 [color="0.64 0.6 0.85", + fillcolor=gray, + label=solve_network, + style=filled]; + 1 [color="0.33 0.6 0.85", + label=prepare_network]; + 1 -> 0; + } + +| + .. automodule:: solve_network diff --git a/doc/solving/solve_operations_network.rst b/doc/solving/solve_operations_network.rst index aaf2e7c4..343790bf 100644 --- a/doc/solving/solve_operations_network.rst +++ b/doc/solving/solve_operations_network.rst @@ -3,4 +3,35 @@ Rule :mod:`solve_operations_network` ==================================== +.. graphviz:: + :align: center + + digraph snakemake_dag { + graph [bgcolor=white, + margin=0, + size="8,5" + ]; + node [fontname=sans, + fontsize=10, + penwidth=2, + shape=box, + style=rounded + ]; + edge [color=grey, + penwidth=2 + ]; + 0 [color="0.06 0.6 0.85", + fillcolor=gray, + label=solve_operations_network, + style=filled]; + 1 [color="0.00 0.6 0.85", + label=cluster_network]; + 1 -> 0; + 2 [color="0.19 0.6 0.85", + label=solve_network]; + 2 -> 0; + } + +| + .. automodule:: solve_operations_network diff --git a/doc/solving/trace_solve_network.rst b/doc/solving/trace_solve_network.rst index 22f34325..2e4ac920 100644 --- a/doc/solving/trace_solve_network.rst +++ b/doc/solving/trace_solve_network.rst @@ -3,4 +3,32 @@ Rule :mod:`trace_solve_network` =============================== +.. graphviz:: + :align: center + + digraph snakemake_dag { + graph [bgcolor=white, + margin=0, + size="8,5" + ]; + node [fontname=sans, + fontsize=10, + penwidth=2, + shape=box, + style=rounded + ]; + edge [color=grey, + penwidth=2 + ]; + 0 [color="0.17 0.6 0.85", + fillcolor=gray, + label=trace_solve_network, + style=filled]; + 1 [color="0.58 0.6 0.85", + label=prepare_network]; + 1 -> 0; + } + +| + .. automodule:: trace_solve_network diff --git a/scripts/build_country_flh.py b/scripts/build_country_flh.py index fc32fbf6..ceae4848 100644 --- a/scripts/build_country_flh.py +++ b/scripts/build_country_flh.py @@ -24,12 +24,12 @@ Inputs - ``data/bundle/corine/g250_clc06_V18_5.tif``: `CORINE Land Cover (CLC) `_ inventory on `44 classes `_ of land use (e.g. forests, arable land, industrial, urban areas). - .. image:: ../img/corine.png + .. image:: img/corine.png :scale: 33 % - ``data/bundle/GEBCO_2014_2D.nc``: A `bathymetric `_ data set with a global terrain model for ocean and land at 15 arc-second intervals by the `General Bathymetric Chart of the Oceans (GEBCO) `_. - .. image:: ../img/gebco_2019_grid_image.jpg + .. image:: img/gebco_2019_grid_image.jpg :scale: 50 % **Source:** `GEBCO `_