Runs forecasts for renewable generation sites, currently just uses PVnet based models but this may change in the future, saves results to a DB.
The ML models are from PVnet and uses ocf_data_sampler for the data processing We use NWP data such as ECMWF's IFS forecast and live generation values as input, to predict up to 48 hours into the future.
We are currently running a Netherlands solar model. The configuration is stored here
We are also running an India sites solar model.
A post-processing adjustment method is used to correct systemic biases in the forecast see the adjuster for more detail.
The following environment variables are required to run the app:
DB_URL
: The database connection string to connect to the databaseNWP_ECMWF_ZARR_PATH
: The path to the ECWMF NWP zarr file, this can be a local path or a remote pathNWP_MO_GLOBAL_ZARR_PATH
: The path to the Met Office NWP zarr file, this can be a local path or a remote pathSATELLITE_ZARR_PATH
: The path to the satellite zarr file, this can be a local path or a remote pathSAVE_BATCHES_DIR
: The directory to save the batches to, this is required to save the batches of data that are processed by the app-SAVE_BATCHES_DIR
: The directory to save the batches to, this is required to save the batches of data that are processed by the appHUGGINGFACE_TOKEN
: Token used for private modelsCOUNTRY
: Can benl
for Netherlands, orindia
for India.CLIENT_NAME
: The name of the client, this is used to the sites that should be runSATELLITE_SCALE_FACTOR
: The scale factor for the satellite data. Defaults to 1023SATELLITE_BACKUP_ZARR_PATH
: Back up satellite data source. Defaults to None
Here are some temporary ones
MO_GLOBAL_SCALE_CLOUDS
: The scale factor for the Met Office global clouds, this is used to scale the clouds in the Met Office NWP dataMO_GLOBAL_ZERO_TOTAL_CLOUD_COVER
: Whether to set the total cloud cover to zero in the Met Office global NWP data, this is used to set the total cloud cover to zero in the Met Office global NWP data
Lint with:
make lint
Format code with:
make format
make test
Replace {DB_URL}
with a postgres DB connection string (see below for setting up a ephemeral local DB)
If testing on a local DB, you may use the following script to seed the the DB with a dummy user, site and site_group.
DB_URL={DB_URL} poetry run seeder
This example runs the application and writes the results to stdout
DB_URL={DB_URL} NWP_ZARR_PATH={NWP_ZARR_PATH} poetry run app
To save batches, you need to set the SAVE_BATCHES_DIR
environment variable to directory.
### Starting a local database using docker
```bash
docker run \
-it --rm \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=postgres \
-p 54545:5432 postgres:14-alpine \
postgres
The corresponding DB_URL
will be
postgresql://postgres:postgres@localhost:54545/postgres
Building and running in Docker
Build the Docker image
make docker.build
Create a container from the image. This example runs the application and writes the results to stdout.
Replace {DB_URL}
with a postgres DB connection string.
N.B if the database host is localhost
on the host machine, replace localhost
with host.docker.internal
so that docker can access the database from within the container
docker run -it --rm -e DB_URL={DB_URL} -e NWP_ZARR_PATH={NWP_ZARR_PATH} ocf/india-forecast-app
This repo makes use of PyTorch (torch
and torchvision
packages) CPU-only version. In order to support installing PyTorch via poetry for various environments, we specify the exact wheels for each environment in the pyproject.toml file. Some background reading on why this is required can be found here: https://santiagovelez.substack.com/p/how-to-install-torch-cpu-in-poetry?utm_campaign=post&utm_medium=web&triedRedirect=true
Problem: Container can't connect to local database with "connection refused" error
Solution: If using localhost in your DB_URL, replace it with host.docker.internal
when running in Docker
Problem: Database authentication failures
Solution: Verify your DB_URL format is correct: postgresql://username:password@hostname:port/database
Problem: Out of memory errors when loading models Solution: Ensure your system has sufficient RAM, or consider using a smaller model variant.