Forecasting the grid emission factor for the Netherlands

A workflow to produce emission factor forecasts for the electricity mix of the Netherlands, up to 7 days ahead.

2
contributors
22 commitsLast commit ≈ 2 weeks ago0 stars0 forks

What Forecasting the grid emission factor for the Netherlands can do for you

Forecasting grid emission factor for the Netherlands

This repository contains a workflow to produce emission factor forecasts for the electricity mix of the Netherlands, up to 7 days ahead.

Model training

Model training is performed with AutoGluon, using the time series forcasting module.

As training data the total energy production and the energy mix's emission factor are used, sourced from the Nationaal Energie Dashboard with the produced solar and wind energy as "known covariates".

Model training result, validation on unseen data

The NED also provides forecasts for the solar and wind production. These are used in forecasting of the emission factor.

Example forecast, for 2025-01-28 - 2025-02-04

Reproducing results

The Dockerfile contained in this reposity describes all steps you need to go through to train a model and to produce a forecast.

The container image allows easy production of forecasts. Docker engine is freely available on Linux.

To run the container image do:

docker run \
    -e NED_API_KEY \
    --volume /local/path/to/output/dir:/data \
    ghcr.io/esi-far/emissionfactor-forecast:0.1.0

The /data directory is the location where the prediction file should end up. The container will also write the run-up data used in the prediction, as well as NED's forecast for available wind and solar energy.

The environmental variable NED_API_KEY should be your ned.nl API key. Set this with:

export NED_API_KEY=enter-your-key-here

More information on the NED API is available here.

Note that the container's ouput files will be written as root. To avoid this you can set the user ID, e.g.:

docker run \
    -e NED_API_KEY \
    --volume /local/path/to/output/dir:/data \
    --user 1000:1000 \
    ghcr.io/esi-far/emissionfactor-forecast:0.1.0

If your user ID is 1000.

Building the container image

Note that for model training, historical NED data is required, but this is removed from the container image due to licensing restrictions. The required files are;

  • wind, zeewind, zon, electriciteitsmix .csv files
  • years 2021, 2022, 2023, 2024

These files are available from ned.nl after registering.

Local installation, training and prediction

Instead of the containerized model, you can also work in a local environment.

  • Download the data from NED.nl, see the previous section for which files you need
  • Clone this repository, change working directory into the repository
  • In a Python environment (3.10/3.11) do:
pip install autogluon.timeseries --extra-index-url https://download.pytorch.org/whl/cpu
pip install -e .[dev]
  • Set the following environmental variables:
    • MODEL_PATH should refer to a directory where the trained model should be stored
    • TRAINING_DATA should refer to the directory with the training data .csv files
    • NED_API_KEY should be your API key from NED.nl (available after registration)
    • OUTPUT_PATH should be the path where you want the output .csv files to be written to
  • Now you can run python src/emissionfactor_nl/train_model.py to train the model
  • With python src/emissionfactor_nl/predict.py you can generate a forecast based on the currently available forecast data from NED.nl
Keywords
Programming languages
  • Python 90%
  • Dockerfile 10%
License
</>Source code
Packages
github.com

Participating organisations

Netherlands eScience Center
PowerChainger

Contributors

Bart Schilperoort
Research Software Engineer
Netherlands eScience Center
Thijs Vroegh
Research Software Engineer
Netherlands eScience Center

Related projects

TeSoPs

Technologically and socially feasible transition pathways for local energy system integration

Updated 2 months ago
In progress