Home

Awesome

Quartz Solar Forecast

<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->

All Contributors

<!-- ALL-CONTRIBUTORS-BADGE:END -->

image tags badge pypi badge ease of contribution: easy Python package tests

The aim of the project is to build an open source PV forecast that is free and easy to use. The forecast provides the expected generation in kw for 0 to 48 hours for a single PV site.

Open Climate Fix also provides a commercial PV forecast, please get in touch at quartz.support@openclimatefix.org

Want to learn more about the project? We've presented Quartz Solar Forecast at two open source conferences:

The current model uses GFS or ICON NWPs to predict the solar generation at a site

from quartz_solar_forecast.forecast import run_forecast
from quartz_solar_forecast.pydantic_models import PVSite
from datetime import datetime

# make a pv site object
site = PVSite(latitude=51.75, longitude=-1.25, capacity_kwp=1.25)

# run model for today, using ICON NWP data
predictions_df = run_forecast(site=site, ts=datetime.today(), nwp_source="icon")

which should result in a time series similar to this one:

https://github.com/openclimatefix/Open-Source-Quartz-Solar-Forecast/blob/main/predictions.png?raw=true

A colab notebook providing some examples can be found here.

Generating Forecasts

To generate solar forecasts and save them into a CSV file, follow these steps:

python scripts/forecast_csv.py

Replace the --init_time_freq, --start_datetime, --end_datetime, and --site_name with your desired forecast initialization frequency (in hours), start datetime, end datetime, and the name of the forecast or site, respectively.

Output

The script will generate solar forecasts at the specified intervals between the start and end datetimes. The results will be combined into a CSV file named using the site name, start and end datetimes, and the frequency of forecasts. This file will be saved in the scripts/csv_forecasts directory.

Installation

The source code is currently hosted on GitHub at: https://github.com/openclimatefix/Open-Source-Quartz-Solar-Forecast

Binary installers for the latest released version are available at the Python Package Index (PyPI)

pip install quartz-solar-forecast

You might need to install the following packages first

conda install -c conda-forge pyresample

This can solve the bug: ___kmpc_for_static_fini.

Model

Two models are currently available to make predictions.

Gradient Boosting Model (default)

The model uses GFS or ICON NWPs to predict the solar generation at a site. It is a gradient boosted tree model and uses 9 NWP variables. It is trained on 25,000 PV sites with over 5 years of PV history, which is available here. The training of this model is handled in pv-site-prediction TODO - we need to benchmark this forecast.

The 9 NWP variables, from Open-Meteo documentation, are mentioned above with their appropariate units.

  1. Visibility (km), or vis: Distance at which objects can be clearly seen. Can affect the amount of sunlight reaching solar panels.
  2. Wind Speed at 10 meters (km/h), or si10 : Wind speed measured at a height of 10 meters above ground level. Important for understanding weather conditions and potential impacts on solar panels.
  3. Temperature at 2 meters (°C), or t : Air temperature measure at 2 meters above the ground. Can affect the efficiency of PV systems.
  4. Precipitation (mm), or prate : Precipitation (rain, snow, sleet, etc.). Helps to predict cloud cover and potentiel reductions in solar irradiance.
  5. Shortwave Radiation (W/m²), or dswrf: Solar radiation in the shortwave spectrum reaching the Earth's surface. Measure of the potential solar energy available for PV systems.
  6. Direct Radiation (W/m²) or dlwrf: Longwave (infrared) radiation emitted by the Earth back into the atmosphere. confirm it is correct
  7. Cloud Cover low (%), or lcc: Percentage of the sky covered by clouds at low altitudes. Impacts the amount of solar radiation reachign the ground, and similarly the PV system.
  8. Cloud Cover mid (%), or mcc : Percentage of the sky covered by clouds at mid altitudes.
  9. Cloud Cover high (%), or lcc : Percentage of the sky covered by clouds at high altitude We also use the following features

XGBoost

The second option is an XGBoost model and uses the following Numerical Weather Predictions (NWP) input features achieved from open-meteo variables. Different types of data is provided by open-meteo. To train this model hourly forecast data of the historical weather API was used. The time period is restricted by the availabilty of the target solar enegery data of the panels and covers the time between 2018 and 2021. Additional information about the time, location and specifics about the panel are used. The weather features used are listed below, with the description given by open-meteo.

To use this model specify model="xgb" in run_forecast(site=site, model="xgb", ts=datetime.today()).

Model Comparisons

The following plot shows example predictions of both models for the same time period. Additionally for the Gradient Boosting model (default) the results from the two different data sources are shown.

model comparison Predictions using the two different models and different data sources.

Known restrictions

Evaluation

Gradient Boosting Model (default)

To evaluate the model we use the UK PV dataset and the ICON NWP dataset. All the data is publicly available and the evaluation script can be run with the following command

python scripts/run_evaluation.py

The test dataset we used is defined in quartz_solar_forecast/dataset/testset.csv. This contains 50 PV sites, which 50 unique timestamps. The data is from 2021.

The results of the evaluation are as follows The MAE is 0.1906 kw across all horizons.

HorizonsMAE [kw]MAE [%]
00.202 +- 0.036.2
10.211 +- 0.036.4
20.216 +- 0.036.5
3 - 40.211 +- 0.026.3
5 - 80.191 +- 0.016
9 - 160.161 +- 0.015
17 - 240.173 +- 0.015.3
24 - 480.201 +- 0.016.1

If we exclude nighttime, then the average MAE [%] from 0 to 36 forecast hours is 13.0%.

Notes:

XGBoost

The model was trained and evaluated on 1147 solar panels and tested on 37 independent locations. An intensive hyperparameter tuning was performed. The model provides a feature importance list. Different metrics were calculated and analyzed. Finally the model was evaluated using the Mean Absolute Error (MAE). The MAE over the entire test data is $0.12$ kW, when the night times are excluded the MAE is $0.21$ kW. A plot with the MAE for each panel in the test set is shown in the figure below.

MAE Mean absolute error for the panels in the test set.

Notes:

Abbreviations

FOSDEM

FOSDEM is a free event for software developers to meet, share ideas and collaborate. Every year, thousands of developers of free and open source software from all over the world gather at the event in Brussels. OCF presented Quartz Solar Forecast project at FOSDEM 2024. The link to the original FOSDEM video is availble at Quartz Solar OS: Building an open source AI solar forecast for everyone. It is also available on YouTube

Running the dashboard locally

Start the API first (port 8000): cd api python main.py

Start the frontend (port 5137): cd dashboards/dashboard_1 npm install npm run dev

There is also a steamlit dashboard in dashboards/dashboard_2 that can be used.

Contribution

We welcome other models.

Contributors ✨

Thanks goes to these wonderful people (emoji key):

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --> <!-- prettier-ignore-start --> <!-- markdownlint-disable --> <table> <tbody> <tr> <td align="center" valign="top" width="14.28%"><a href="https://github.com/peterdudfield"><img src="https://avatars.githubusercontent.com/u/34686298?v=4?s=100" width="100px;" alt="Peter Dudfield"/><br /><sub><b>Peter Dudfield</b></sub></a><br /><a href="https://github.com/openclimatefix/open-source-quartz-solar-forecast/commits?author=peterdudfield" title="Code">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/zakwatts"><img src="https://avatars.githubusercontent.com/u/47150349?v=4?s=100" width="100px;" alt="Megawattz"/><br /><sub><b>Megawattz</b></sub></a><br /><a href="#ideas-zakwatts" title="Ideas, Planning, & Feedback">🤔</a> <a href="#talk-zakwatts" title="Talks">📢</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/EdFage"><img src="https://avatars.githubusercontent.com/u/87755165?v=4?s=100" width="100px;" alt="EdFage"/><br /><sub><b>EdFage</b></sub></a><br /><a href="https://github.com/openclimatefix/open-source-quartz-solar-forecast/commits?author=EdFage" title="Documentation">📖</a> <a href="https://github.com/openclimatefix/open-source-quartz-solar-forecast/commits?author=EdFage" title="Code">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/chloepilonv"><img src="https://avatars.githubusercontent.com/u/136987461?v=4?s=100" width="100px;" alt="Chloe Pilon Vaillancourt"/><br /><sub><b>Chloe Pilon Vaillancourt</b></sub></a><br /><a href="https://github.com/openclimatefix/open-source-quartz-solar-forecast/commits?author=chloepilonv" title="Documentation">📖</a></td> <td align="center" valign="top" width="14.28%"><a href="http://racheltipton.dev"><img src="https://avatars.githubusercontent.com/u/86949265?v=4?s=100" width="100px;" alt="rachel tipton"/><br /><sub><b>rachel tipton</b></sub></a><br /><a href="#talk-rachel-labri-tipton" title="Talks">📢</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/armenbod"><img src="https://avatars.githubusercontent.com/u/84937223?v=4?s=100" width="100px;" alt="armenbod"/><br /><sub><b>armenbod</b></sub></a><br /><a href="#content-armenbod" title="Content">🖋</a> <a href="https://github.com/openclimatefix/open-source-quartz-solar-forecast/commits?author=armenbod" title="Code">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/shreyasudaya"><img src="https://avatars.githubusercontent.com/u/94735680?v=4?s=100" width="100px;" alt="Shreyas Udaya"/><br /><sub><b>Shreyas Udaya</b></sub></a><br /><a href="https://github.com/openclimatefix/open-source-quartz-solar-forecast/commits?author=shreyasudaya" title="Documentation">📖</a></td> </tr> <tr> <td align="center" valign="top" width="14.28%"><a href="http://github.com/aryanbhosale"><img src="https://avatars.githubusercontent.com/u/36108149?v=4?s=100" width="100px;" alt="Aryan Bhosale"/><br /><sub><b>Aryan Bhosale</b></sub></a><br /><a href="https://github.com/openclimatefix/open-source-quartz-solar-forecast/commits?author=aryanbhosale" title="Documentation">📖</a> <a href="https://github.com/openclimatefix/open-source-quartz-solar-forecast/commits?author=aryanbhosale" title="Code">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/0xFrama"><img src="https://avatars.githubusercontent.com/u/30957828?v=4?s=100" width="100px;" alt="Francesco"/><br /><sub><b>Francesco</b></sub></a><br /><a href="https://github.com/openclimatefix/open-source-quartz-solar-forecast/commits?author=0xFrama" title="Code">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/roshnaeem"><img src="https://avatars.githubusercontent.com/u/47316899?v=4?s=100" width="100px;" alt="Rosheen Naeem"/><br /><sub><b>Rosheen Naeem</b></sub></a><br /><a href="https://github.com/openclimatefix/open-source-quartz-solar-forecast/commits?author=roshnaeem" title="Documentation">📖</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/bikramb98"><img src="https://avatars.githubusercontent.com/u/24806286?v=4?s=100" width="100px;" alt="Bikram Baruah"/><br /><sub><b>Bikram Baruah</b></sub></a><br /><a href="https://github.com/openclimatefix/open-source-quartz-solar-forecast/commits?author=bikramb98" title="Code">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/Hapyr"><img src="https://avatars.githubusercontent.com/u/23398802?v=4?s=100" width="100px;" alt="Jakob Gebler"/><br /><sub><b>Jakob Gebler</b></sub></a><br /><a href="https://github.com/openclimatefix/open-source-quartz-solar-forecast/issues?q=author%3AHapyr" title="Bug reports">🐛</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/ombhojane"><img src="https://avatars.githubusercontent.com/u/82753658?v=4?s=100" width="100px;" alt="Om Bhojane"/><br /><sub><b>Om Bhojane</b></sub></a><br /><a href="https://github.com/openclimatefix/open-source-quartz-solar-forecast/commits?author=ombhojane" title="Code">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="http://chrisadams.me.uk"><img src="https://avatars.githubusercontent.com/u/17906?v=4?s=100" width="100px;" alt="Chris Adams"/><br /><sub><b>Chris Adams</b></sub></a><br /><a href="#ideas-mrchrisadams" title="Ideas, Planning, & Feedback">🤔</a></td> </tr> <tr> <td align="center" valign="top" width="14.28%"><a href="https://github.com/mudrap17"><img src="https://avatars.githubusercontent.com/u/76879120?v=4?s=100" width="100px;" alt="Mudra Patel"/><br /><sub><b>Mudra Patel</b></sub></a><br /><a href="https://github.com/openclimatefix/open-source-quartz-solar-forecast/commits?author=mudrap17" title="Documentation">📖</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/diegomarvid"><img src="https://avatars.githubusercontent.com/u/33181424?v=4?s=100" width="100px;" alt="Diego Marvid"/><br /><sub><b>Diego Marvid</b></sub></a><br /><a href="https://github.com/openclimatefix/open-source-quartz-solar-forecast/commits?author=diegomarvid" title="Documentation">📖</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/froukje"><img src="https://avatars.githubusercontent.com/u/10419258?v=4?s=100" width="100px;" alt="Frauke Albrecht"/><br /><sub><b>Frauke Albrecht</b></sub></a><br /><a href="https://github.com/openclimatefix/open-source-quartz-solar-forecast/commits?author=froukje" title="Code">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/Ludecan"><img src="https://avatars.githubusercontent.com/u/17169248?v=4?s=100" width="100px;" alt="Pablo Alfaro"/><br /><sub><b>Pablo Alfaro</b></sub></a><br /><a href="https://github.com/openclimatefix/open-source-quartz-solar-forecast/pulls?q=is%3Apr+reviewed-by%3ALudecan" title="Reviewed Pull Requests">👀</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/KelRem"><img src="https://avatars.githubusercontent.com/u/175075550?v=4?s=100" width="100px;" alt="KelRem"/><br /><sub><b>KelRem</b></sub></a><br /><a href="#question-KelRem" title="Answering Questions">💬</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/sicunchen"><img src="https://avatars.githubusercontent.com/u/14258987?v=4?s=100" width="100px;" alt="Lia Chen"/><br /><sub><b>Lia Chen</b></sub></a><br /><a href="https://github.com/openclimatefix/open-source-quartz-solar-forecast/commits?author=sicunchen" title="Code">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="https://clementlumumba.netlify.app/"><img src="https://avatars.githubusercontent.com/u/43673340?v=4?s=100" width="100px;" alt="Clement Lumumba"/><br /><sub><b>Clement Lumumba</b></sub></a><br /><a href="https://github.com/openclimatefix/open-source-quartz-solar-forecast/commits?author=Clemo97" title="Code">💻</a></td> </tr> <tr> <td align="center" valign="top" width="14.28%"><a href="https://github.com/aayushyatiwari"><img src="https://avatars.githubusercontent.com/u/169576527?v=4?s=100" width="100px;" alt="aayush"/><br /><sub><b>aayush</b></sub></a><br /><a href="https://github.com/openclimatefix/open-source-quartz-solar-forecast/commits?author=aayushyatiwari" title="Documentation">📖</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/Brohan7524"><img src="https://avatars.githubusercontent.com/u/85754035?v=4?s=100" width="100px;" alt="Rohan Singh"/><br /><sub><b>Rohan Singh</b></sub></a><br /><a href="https://github.com/openclimatefix/open-source-quartz-solar-forecast/commits?author=Brohan7524" title="Code">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/sumana-2705"><img src="https://avatars.githubusercontent.com/u/110307215?v=4?s=100" width="100px;" alt="Sumana Sree Angajala"/><br /><sub><b>Sumana Sree Angajala</b></sub></a><br /><a href="https://github.com/openclimatefix/open-source-quartz-solar-forecast/commits?author=sumana-2705" title="Code">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/EmilyIsCoding"><img src="https://avatars.githubusercontent.com/u/98443131?v=4?s=100" width="100px;" alt="Emily"/><br /><sub><b>Emily</b></sub></a><br /><a href="https://github.com/openclimatefix/open-source-quartz-solar-forecast/commits?author=EmilyIsCoding" title="Tests">⚠️</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/sergejlazuk"><img src="https://avatars.githubusercontent.com/u/33606741?v=4?s=100" width="100px;" alt="sergejla"/><br /><sub><b>sergejla</b></sub></a><br /><a href="#question-sergejlazuk" title="Answering Questions">💬</a></td> </tr> </tbody> </table> <!-- markdownlint-restore --> <!-- prettier-ignore-end --> <!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the all-contributors specification. Contributions of any kind welcome!