Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
quartz-solar-forecast
Advanced tools
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:
FOSDEM 2024 (Free and Open source Software Developers' European Meeting): How we built Open Quartz, our motivation behind it and its impact on aiding organizations in resource optimization Watch the talk
LF Energy 2024: Exploring Open Quartz's developments - new models, inverter APIs, and our Open Source journey at Open Climate Fix Watch the talk
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:
A colab notebook providing some examples can be found here.
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.
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.
The package logs when run_forecast
is used. This is useful for OCF to determine how the package is being used
and how we can make improvements in the future.
Note that any latitudes and longitudes are rounded to 2 decimals places in order to anonymize the data.
If you would like to disable this logging, you can do so by setting the environment variable QUARTZ_SOLAR_FORECAST_LOGGING
to False
.
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.
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())
.
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.
Predictions using the two different models and different data sources.
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.
Horizons | MAE [kw] | MAE [%] |
---|---|---|
0 | 0.202 +- 0.03 | 6.2 |
1 | 0.211 +- 0.03 | 6.4 |
2 | 0.216 +- 0.03 | 6.5 |
3 - 4 | 0.211 +- 0.02 | 6.3 |
5 - 8 | 0.191 +- 0.01 | 6 |
9 - 16 | 0.161 +- 0.01 | 5 |
17 - 24 | 0.173 +- 0.01 | 5.3 |
24 - 48 | 0.201 +- 0.01 | 6.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.
Mean absolute error for the panels in the test set.
Notes:
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
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.
We welcome other models.
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!
FAQs
Open Source Solar Forecasting for a Site
We found that quartz-solar-forecast demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.