This repository contains the code and analysis for the Ember Flexibility Study, conducted in collaboration with Ember and Open Energy Transition (OET). The study investigates clean flexibility options for Europe's energy system, building on the PyPSA-Eur framework. All results are computed from raw data and code to ensure full reproducibility.
This repository is a soft-fork of OET-PyPSA-Eur and contains the entire project Clean Flexibility for Europe's Energy System supported by Open Energy Transition (OET)*, including code and report. The philosophy behind this repository is that no intermediary results are included, but all results are computed from raw data and code.
This repository is maintained using OET's soft-fork strategy. OET's primary aim is to contribute as much as possible to the open source (OS) upstream repositories. For long-term changes that cannot be directly merged upstream, the strategy organizes and maintains OET forks, ensuring they remain up-to-date and compatible with upstream, while also supporting future contributions back to the OS repositories.
benchmarks
: will storesnakemake
benchmarks (does not exist initially)config
: configurations used in the studycutouts
: will store raw weather data cutouts fromatlite
(does not exist initially)data
: includes input data that is not produced by anysnakemake
ruledoc
: includes all files necessary to build thereadthedocs
documentation of PyPSA-Eurenvs
: includes all themamba
environment specifications to run the workflowlogs
: will store log files (does not exist initially)notebooks
: includes all thenotebooks
used for ad-hoc analysisreport
: contains all files necessary to build the report; plots and result files are generated automaticallyrules
: includes all thesnakemake
rules loaded in theSnakefile
resources
: will store intermediate results of the workflow which can be picked up again by subsequent rules (does not exist initially)results
: will store the solved PyPSA network data, summary files and plots (does not exist initially)scripts
: includes all the Python scripts executed by thesnakemake
rules to build the model
First fork the repository Ember-Flexibility-Study on GitHub to your own account. Please make sure to check the box Copy the master branch only
. Then, clone your fork locally:
git clone https://github.com/<your-username>/Ember-Flexibility-Study.git
Once you have cloned your fork, you should add the following upstream remotes to keep your repository up to date with the main projects:
-
Add the main Ember-Flexibility-Study repository as
upstream
:git remote add upstream https://github.com/open-energy-transition/Ember-Flexibility-Study.git
-
Add the main OET soft-fork of PyPSA-Eur as
upstream_pypsa_eur_oet
:git remote add upstream_pypsa_eur_oet https://github.com/open-energy-transition/pypsa-eur.git
This setup allows you to fetch and integrate changes from both the main study repository and the OET soft-fork of PyPSA-Eur.
To keep your fork up to date, you can merge changes from the master branch of either upstream_pypsa_eur_oet
or upstream
as follows:
-
To merge changes from the OET soft-fork of PyPSA-Eur:
git fetch upstream_pypsa_eur_oet git merge upstream_pypsa_eur_oet/master
-
To merge changes from the main Ember-Flexibility-Study repository:
git fetch upstream git merge upstream/master
Resolve any conflicts if they arise, then push the updates to your fork if needed.
Clone the repository:
git clone https://github.com/open-energy-transition/{{repository}}
You need mamba to run the analysis. Users may also prefer to use micromamba or conda. Using mamba
, you can create an environment from within you can run it:
mamba env create -f environment.yaml
Activate the newly created {{project_short_name}}
environment:
mamba activate {{project_short_name}}
snakemake -call
This will run all analysis steps to reproduce results and build the report.
To generate a PDF of the dependency graph of all steps resources/dag.pdf
run:
snakemake -c1 dag
Snakemake is a workflow management system that enables reproducible and scalable data analyses. It allows you to define complex pipelines in a readable Python-based language, automatically handling dependencies, job execution, and resource management. Snakemake is widely used in scientific computing for automating data processing, analysis, and reporting.
Snakemake workflows are built from modular units called rules. Each rule specifies how to create output files from input files, using scripts or shell commands. Rules define the steps of your workflow and their dependencies, making it easy to manage complex pipelines.
Here are some of the most important command-line options (keys) to control the workflow:
-j
,--jobs [N]
: Set the maximum number of jobs to run in parallel (e.g.,-j 4
).-c
,--cores [N]
: Specify the number of CPU cores to use (e.g.,-c 1
).-n
,--dryrun
: Show what would be executed without actually running the workflow.-s
,--snakefile [FILE]
: Specify a custom Snakefile (default isSnakefile
).-R
,--rerun-incomplete
: Re-run jobs with incomplete output files.--unlock
: Unlock the working directory if a previous run was interrupted.--dag
: Print the directed acyclic graph (DAG) of jobs in the workflow.--forceall
: Force the execution of all rules, regardless of output file timestamps.-k
,--keep-going
: Continue as much as possible after an error.--config [KEY=VALUE,...]
: Override config file values from the command line.
For a full list of options, see the Snakemake documentation or run snakemake --help
.
In PyPSA-Eur, some of the most important rules that structure the workflow include:
- retrieve: Downloads and prepares all required input data.
- build_network: Constructs the base energy system network from input data.
- prepare_sector: Prepares sector-coupling data (e.g., heating, transport).
- solve_network: Runs the optimization to solve the energy system model.
- postprocess: Processes and analyzes the results after solving.
- plot_network: Generates plots and visualizations from the results.
- report: Builds the final report or documentation from the results.
These rules are typically defined in separate .smk
files (e.g., rules/retrieve.smk
, rules/build_electricity.smk
) and are orchestrated by the main Snakefile
.
We strongly welcome anyone interested in contributing to this project. If you have any ideas, suggestions or encounter problems, feel invited to file issues or make pull requests on GitHub.
To issue a pull request to the master
branch of the upstream repository Ember-Flexibility-Study, please follow the instructions and follow the instructions from the pull request template.
For issues, bugs and feature requests, please use the GitHub Issues page.
The code in this repository is released as free software under the MIT License, see doc/licenses.rst
. However, different licenses and terms of use may apply to the various input data, see doc/data_sources.rst
.