Skip to content

Install

This page sets up DemandCast on your computer: the code, its Python environment, the API keys of the data sources, and the folder where the data goes. It takes about 10 minutes.

Only need the forecasts?

The trained model and hourly forecasts for 184 countries and 135 subdivisions from 2000 to 2025 are on Zenodo. You do not need to install anything to use them.

What you need

  • Git, to download the code.
  • uv, a fast Python package manager. It installs the right Python version (3.12 or later) and all the dependencies for you.
  • Disk space. The code is small. The data is not: weather grids and the electricity demand of many sources can take tens of gigabytes.

You can also use Docker instead of uv. The Docker image has everything installed.

1. Get the code

git clone https://github.com/open-energy-transition/demandcast.git
cd demandcast/demandcast

The repository has a demandcast/ folder inside it. Run every command from this inner demandcast/ folder: the scripts import their modules from there.

2. Install the dependencies

uv sync

uv reads pyproject.toml, creates a virtual environment in .venv/, and installs the exact versions listed in uv.lock.

The LSTM model is optional and needs PyTorch, a large dependency. Install it only if you plan to use that model:

uv sync --extra lstm

Check that everything works by printing the help of a script:

uv run retrieve.py --help

Not using uv?

You can install the dependencies of pyproject.toml with another tool, such as conda or pip. Then replace uv run <script>.py with python <script>.py in all the commands of this documentation.

To use Jupyter notebooks with the same environment:

uv run --with jupyter jupyter lab

3. Add your API keys

Some data sources require you to register and use a personal key. DemandCast reads the keys from a file named .env in the demandcast/ folder. Create it and add only the keys you need, one per line, without quotes:

CDS_API_KEY=<your_key>
EMBER_API_KEY=<your_key>
ENTSOE_API_KEY=<your_key>
EIA_API_KEY=<your_key>
EPIAS_USERNAME=<your_username>
EPIAS_PASSWORD=<your_password>
ISONE_USERNAME=<your_username>
ISONE_PASSWORD=<your_password>
ZENODO_API_KEY=<your_key>
SANDBOX_ZENODO_API_KEY=<your_key>

Put any comment on its own line, starting with #: Docker's --env-file would read a comment after a value as part of the key.

Key Needed for Where to get it
CDS_API_KEY Gridded weather and temperature (not for past years with reanalysis_source: arco) Register on the Climate Data Store and accept the licences of the ERA5 and CMIP6 datasets
EMBER_API_KEY Annual electricity demand per capita Ember API (free)
ENTSOE_API_KEY The entsoe data source Register on the ENTSO-E Transparency Platform and request API access
EIA_API_KEY The eia data source EIA Open Data (free)
EPIAS_USERNAME, EPIAS_PASSWORD The epias data source A free account on EPİAŞ Transparency
ISONE_USERNAME, ISONE_PASSWORD The isone data source A free ISO Express account
ZENODO_API_KEY, SANDBOX_ZENODO_API_KEY Publishing a release Your Zenodo account settings

A script that needs a missing key stops with an error that names the variable. Keys already set in your shell take priority over the .env file.

Warning

Never commit .env: it holds your personal credentials. The repository's .gitignore already excludes it.

4. Choose where the data goes

Everything the scripts write (downloads, datasets, models, results and logs) goes in the data folder, demandcast/data/ by default. To keep it somewhere else, such as on a larger disk, set the environment variable DEMANDCAST_DATA_FOLDER in your shell:

export DEMANDCAST_DATA_FOLDER=/path/to/large/disk/demandcast-data

Warning

Set DEMANDCAST_DATA_FOLDER in your shell (for example in ~/.bashrc), not in .env. The .env file is read only when a script first needs an API key, so a data folder set there would apply only to part of a run.

The Data folder page describes everything inside it.

Next step

Follow Your first forecast to retrieve data, train a model and forecast a year of hourly demand.