Skip to content

Commit 69011c0

Browse files
thoginfneum
andauthored
fix: Update tutorial paths to match config directory structure (#1616)
* fix: Update tutorial paths to match config directory structure Fix directory path inconsistency between tutorial commands and actual file locations. The config sets `run.name: "test-elec"` and `run.shared_resources.policy: "test"`, which affects where files are stored. - Update all example commands to include correct paths (resources/test/...) - Fix analysis example to use correct results path (results/test-elec/...) - Add explanatory section about how config settings affect directory structure Fixes [#1614](#1614) * Update doc/tutorial.rst --------- Co-authored-by: Fabian Neumann <fabian.neumann@outlook.de>
1 parent b2b04a2 commit 69011c0

File tree

1 file changed

+28
-7
lines changed

1 file changed

+28
-7
lines changed

doc/tutorial.rst

+28-7
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,27 @@ Note, that ``config/test/config.electricity.yaml`` only includes changes relativ
9999
the default configuration. There are many more configuration options, which are
100100
documented at :ref:`config`.
101101

102+
Directory Structure and Configuration Settings
103+
----------------------------------------------
104+
105+
It's important to understand how certain configuration settings affect the directory structure in PyPSA-Eur:
106+
107+
- ``run.name`` determines the subdirectory within the ``results`` folder (e.g., ``results/test-elec/networks/...``)
108+
- ``run.shared_resources.policy`` determines the subdirectory within the ``resources`` folder (e.g., ``resources/test/networks/...``)
109+
110+
These settings work together to organize model runs:
111+
112+
- Final model outputs are always stored in ``results/[run.name]/...``
113+
- Intermediate files can be either:
114+
- Specific to a run: ``resources/[run.shared_resources.policy]/...`` (if policy is a string)
115+
- Shared between runs: ``resources/...`` (if policy is ``true``)
116+
- Not shared between runs: ``resources/[run.name]``(if policy is ``false``)
117+
- Partially shared: If policy is ``"base"``, some common files are shared while others remain run-specific
118+
119+
For this tutorial, with ``run.name: "test-elec"`` and ``run.shared_resources.policy: "test"``,
120+
intermediate resources are stored in ``resources/test/...`` while results are in ``results/test-elec/...``.
121+
122+
The implementation of this behavior can be found in ``scripts/_helpers.py``.
102123

103124
How to use ``snakemake`` rules?
104125
===================================
@@ -116,7 +137,7 @@ clustered down to 6 buses and every 24 hours aggregated to one snapshot. The com
116137
117138
$ snakemake results/test-elec/networks/base_s_6_elec_.nc --configfile config/test/config.electricity.yaml
118139
119-
orders ``snakemake`` to run the rule :mod:`solve_network` that produces the solved network and stores it in ``results/networks`` with the name ``base_s_6_elec_.nc``:
140+
orders ``snakemake`` to run the rule :mod:`solve_network` that produces the solved network and stores it in ``results/test-elec/networks`` with the name ``base_s_6_elec_.nc``:
120141

121142
.. literalinclude:: ../rules/solve_electricity.smk
122143
:start-at: rule solve_network:
@@ -347,10 +368,10 @@ You can produce any output file occurring in the ``Snakefile`` by running
347368
348369
For example, you can explore the evolution of the PyPSA networks by running
349370

350-
#. ``snakemake resources/networks/base.nc --configfile config/test/config.electricity.yaml``
351-
#. ``snakemake resources/networks/base_s.nc --configfile config/test/config.electricity.yaml``
352-
#. ``snakemake resources/networks/base_s_6.nc --configfile config/test/config.electricity.yaml``
353-
#. ``snakemake resources/networks/base_s_6_elec_.nc --configfile config/test/config.electricity.yaml``
371+
#. ``snakemake resources/test/networks/base.nc --configfile config/test/config.electricity.yaml``
372+
#. ``snakemake resources/test/networks/base_s.nc --configfile config/test/config.electricity.yaml``
373+
#. ``snakemake resources/test/networks/base_s_6.nc --configfile config/test/config.electricity.yaml``
374+
#. ``snakemake resources/test/networks/base_s_6_elec_.nc --configfile config/test/config.electricity.yaml``
354375

355376
To run all combinations of wildcard values provided in the ``config/config.yaml`` under ``scenario:``,
356377
you can use the collection rule ``solve_elec_networks``.
@@ -388,6 +409,6 @@ Jupyter Notebooks).
388409
389410
import pypsa
390411
391-
n = pypsa.Network("results/networks/base_s_6_elec_.nc")
412+
n = pypsa.Network("results/test-elec/networks/base_s_6_elec_.nc")
392413
393-
For inspiration, read the `examples section in the PyPSA documentation <https://pypsa.readthedocs.io/en/latest/examples-basic.html>`__.
414+
For inspiration, read the `examples section in the PyPSA documentation <https://pypsa.readthedocs.io/en/latest/examples-basic.html>`__.

0 commit comments

Comments
 (0)