Solar Consumer
This code can be used to download solar forecasts and save them to a PostgreSQL database by retrieving solar generation estimates for embedded solar farms and preparing the data for analysis.
https://github.com/openclimatefix/solar-consumer
Category: Renewable Energy
Sub Category: Photovoltaics and Solar Energy
Keywords from Contributors
nowcasting eumetsat dbml pvsite pvoutput solar forecasting-models graph-neural-networks weather gan
Last synced: about 17 hours ago
JSON representation
Repository metadata
Pull and save solar generation and forecasts
- Host: GitHub
- URL: https://github.com/openclimatefix/solar-consumer
- Owner: openclimatefix
- License: mit
- Created: 2024-11-28T16:12:39.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2026-01-22T13:58:49.000Z (17 days ago)
- Last Synced: 2026-01-22T21:51:07.856Z (17 days ago)
- Language: Python
- Homepage:
- Size: 519 KB
- Stars: 7
- Watchers: 2
- Forks: 27
- Open Issues: 14
- Releases: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
README.md
Solar Consumer
This code can be used to download solar forecasts and save them to a PostgreSQL database. It fetches solar generation estimates for embedded solar farms and processes the data for analysis.
We currently collect
- UK: Forecast can be retreived from NESO. Generation Data can be retrevied from PVLive.
- NL: Generation values from Ned NL, both national and region. National Forecast values from Ned NL too.
- DE: Generation values from ENTSOE for several TSOs.
- BE: Solar PV forecast data (national and regional) from Elia Open Data API.
- India (Rajasthan): Real-time solar and wind generation data from RUVNL (Rajasthan Urja Vikas Nigam Limited).
India – RUVNL (Rajasthan)
The solar consumer supports RUVNL (Rajasthan, India) real-time generation data.
- Both solar and wind generation are supported
- Data is fetched via
solar-consumer - Generation data can be saved directly to the site_database
- Separate sites are created for solar and wind generation
- No separate
ruvnl-consumerservice is required
Here are the different sources of data, and which methods can be used to save the results
| Source | Country | CSV | Data Platform | DB (Legacy) | Site DB (Legacy) |
|---|---|---|---|---|---|
| PVLive | 🇬🇧 | ✅ | ✅ | ||
| NESO forecast | 🇬🇧 | ✅ | ✅ | ||
| Ned-nl | 🇳🇱 | ✅ | ✅ | ||
| Ned-nl forecast | 🇳🇱 | ✅ | ✅ | ||
| Germany (ENTSOE) | 🇩🇪 | ✅ | ✅ | ||
| Elia Open Data | 🇧🇪 | ✅ | |||
| RUVNL (Rajasthan SLDC) | 🇮🇳 | ✅ | ✅ |
Requirements
- Docker
- Docker Compose
Installation & Running
- Clone the repository:
git clone https://github.com/openclimatefix/neso-solar-consumer.git
cd neso-solar-consumer
- Copy the example environment file:
cp .example.env .env
- Start the application:
docker compose up -d
The above command will:
- Start a PostgreSQL database container
- Build and start the NESO Solar Consumer application
- Configure all necessary networking between containers
To stop the application:
docker compose down
To view logs:
docker compose logs -f
Note: The PostgreSQL data is persisted in a Docker volume. To completely reset the database, use:
docker compose down -v
Documentation
The package provides three main functionalities:
- Data Fetching: Retrieves solar forecast data from the NESO API
- Data Formatting: Processes the data into standardized forecast objects
- Data Storage: Saves the formatted forecasts to a PostgreSQL database
Key Components:
fetch_data.py: Handles API data retrievalformat_forecast.py: Converts raw data into forecast objectssave_forecast.py: Manages database operationsapp.py: Orchestrates the entire pipeline
Environment Variables: (Can be found in the .example.env / .env file)
DB_URL=postgresql://postgres:postgres@localhost:5432/neso_solar: Database ConfigurationCOUNTRY="gb": Country code for fetching data. Currently, other options are ["be", "ind_rajasthan", "nl"]SAVE_METHOD: Ways to store the data. Options are ["db", "csv", "site-db"].
site-dbis supported for NL, DE, and India (RUVNL).CSV_DIR=None: Directory to save CSV files ifSAVE_METHOD="csv".UK_PVLIVE_REGIME=in-day: For UK PVLive, the regime. Can be "in-day" or "day-after"UK_PVLIVE_N_GSPS=342: For UK PVLive, the amount of gsps we pull data for.UK_PVLIVE_BACKFILL_HOURS=2: For UK PVLive, the amount of backfill hours we pull, when regime="in-day"
Adding a New Country
This guide explains how to add a new country data source to Solar Consumer.
Overview
Adding a country typically involves:
- Identifying a reliable data source or API
- Implementing a country-specific fetch function
- Adding tests
- Saving data locally (CSV) and/or to the data platform
Step 1: Find a Data Source / API
Identify a reliable data source for the country:
- Prefer official grid operators or government-backed APIs
- Ensure timestamps, units, and generation values are clearly defined
If the API requires credentials:
- Add the variable to
.example.env - Document the required environment variable name
Step 2: Create a Fetch Function
Add a new country-specific fetch module inside the solar_consumer package.
Example naming convention:
solar_consumer/data/fetch_<country>.py
Next Steps
After adding the fetch function:
- Register the country in the main fetch dispatcher
- Add unit and integration tests under
tests/ - Verify the data runs locally and can be saved to CSV
- If supported, ensure data can be saved to the data platform
- Open a pull request for review
Saving Data to the Data Platform
If the country supports saving data to the data platform:
- Clone the data platform repository:
git clone https://github.com/openclimatefix/data-platform.git - Follow the data-platform README to start it locally (Docker-based setup).
- Configure Solar Consumer to point to the local data-platform instance.
- Run the consumer and verify data is ingested successfully.
Development
- Set up the development environment:
pip install ".[dev]"
- Run tests:
pytest
- Format code:
black .
- Run linter:
ruff check .
Running the Test Suite
The test suite includes unit tests and integration tests:
# Run all tests
pytest
# Run specific test file
pytest tests/test_fetch_data.py
# Run with coverage
pytest --cov=neso_solar_consumer
Continuous Integration (CI)
This reposistory has 2 main CI workflows - branch-ci and merged-ci.
branch-ciis triggered on all pushes to any branch exceptmain, and on any pull request that is opened, reopened or updated. It runs the tests suite, lints the project, and builds and pushes a dev image.merged-ciis triggered on any pull request merged intomain. It bumps the git tag, and builds and pushes a container with that tag.
FAQ
Q: What format is the data stored in?
A: The data is stored in PostgreSQL using SQLAlchemy models, with timestamps in UTC and power values in megawatts.
Q: How often should I run the consumer?
A: This depends on your use case and the NESO API update frequency. The consumer can be scheduled using cron jobs or other scheduling tools.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing and community
- PR's are welcome! See the Organisation Profile for details on contributing
- Find out about our other projects in the OCF Meta Repo
- Check out the OCF blog for updates
- Follow OCF on LinkedIn
Contributors
Part of the Open Climate Fix community.
Owner metadata
- Name: Open Climate Fix
- Login: openclimatefix
- Email: info@openclimatefix.org
- Kind: organization
- Description: Using open science to mitigate climate change
- Website: openclimatefix.org
- Location: London
- Twitter: openclimatefix
- Company:
- Icon url: https://avatars.githubusercontent.com/u/48357542?v=4
- Repositories: 88
- Last ynced at: 2024-04-15T07:32:15.529Z
- Profile URL: https://github.com/openclimatefix
GitHub Events
Total
- Delete event: 23
- Pull request event: 51
- Fork event: 4
- Issues event: 25
- Watch event: 3
- Issue comment event: 63
- Push event: 114
- Pull request review comment event: 75
- Pull request review event: 78
- Create event: 43
Last Year
- Delete event: 23
- Pull request event: 51
- Fork event: 4
- Issues event: 25
- Watch event: 3
- Issue comment event: 63
- Push event: 114
- Pull request review comment event: 75
- Pull request review event: 78
- Create event: 43
Committers metadata
Last synced: 5 days ago
Total Commits: 335
Total Committers: 27
Avg Commits per committer: 12.407
Development Distribution Score (DDS): 0.663
Commits in past year: 262
Committers in past year: 22
Avg Commits per committer in past year: 11.909
Development Distribution Score (DDS) in past year: 0.603
| Name | Commits | |
|---|---|---|
| Peter Dudfield | p****d@h****m | 113 |
| allcontributors[bot] | 4****] | 38 |
| BumpVersion Action | b****n@g****s | 27 |
| Siddharth | s****9@g****m | 26 |
| katyalmohit | 1****t | 16 |
| Reem-Albadwy | 1****y | 12 |
| Rahul Ahuja | r****a@l****m | 11 |
| alirashidAR | a****8@y****m | 11 |
| aca23si | s****3@s****k | 11 |
| Vishal | v****1@g****m | 10 |
| Pavan | p****9@g****m | 9 |
| ram-from-tvl | r****l@g****m | 8 |
| devsjc | 4****c | 7 |
| anxkhn | a****8@g****m | 6 |
| Pavan | p****n@P****l | 5 |
| Rahul-JOON | r****6@g****m | 4 |
| Alexandra Udaltsova | 4****a | 3 |
| Peter Ireland | p****d@w****m | 3 |
| michael-gendy | 6****y | 3 |
| Satyam Agrawal | l****m@g****m | 3 |
| Prafful Vyas | p****7@g****m | 2 |
| rahul | v****3@g****m | 2 |
| Conor O'Callaghan | 4****n | 1 |
| James Fulton | d****n@y****k | 1 |
| ManzoorAhmedShaikh | m****4@g****m | 1 |
| Niaha lalwani | n****i@N****l | 1 |
| Sagarpillai | S****i@i****m | 1 |
Committer domains:
- yahoo.co.uk: 1
- windesco.com: 1
- sheffield.ac.uk: 1
Issue and Pull Request metadata
Last synced: 1 day ago
Total issues: 16
Total pull requests: 69
Average time to close issues: 20 days
Average time to close pull requests: 6 days
Total issue authors: 3
Total pull request authors: 17
Average comments per issue: 2.25
Average comments per pull request: 1.29
Merged pull request: 52
Bot issues: 0
Bot pull requests: 11
Past year issues: 15
Past year pull requests: 62
Past year average time to close issues: 13 days
Past year average time to close pull requests: 6 days
Past year issue authors: 3
Past year pull request authors: 14
Past year average comments per issue: 2.07
Past year average comments per pull request: 1.23
Past year merged pull request: 45
Past year bot issues: 0
Past year bot pull requests: 9
Top Issue Authors
- peterdudfield (14)
- rahul-ahuja (1)
- Shohail-Ismail (1)
Top Pull Request Authors
- peterdudfield (22)
- allcontributors[bot] (11)
- rahul-ahuja (7)
- Shohail-Ismail (6)
- michael-gendy (4)
- CodeVishal-17 (3)
- alirashidAR (2)
- Prafful-Vyas (2)
- ADIMANV (2)
- Rahul-JOON (2)
- lambaaryan011 (2)
- ManzoorAhmedShaikh (1)
- vashisthrahul13 (1)
- katyalmohit (1)
- pavankulkarni007 (1)
Top Issue Labels
- contributions-welcome (9)
- good first issue (3)
- ocf-internal (2)
- bug (1)
- enhancement (1)
- documentation (1)
Top Pull Request Labels
Score: 6.340359303727752
