Skip to content

Commit

Permalink
Update readme and examples (#113)
Browse files Browse the repository at this point in the history
* Update README.md

* Update README.md

* Update example.py

change the example to a dynamic timestamp

* change the examples to use dynamic timestamps.

---------

Co-authored-by: Jakob Gebler <[email protected]>
  • Loading branch information
Hapyr and Jakob Gebler authored Apr 23, 2024
1 parent c77b56b commit fb9328c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@ The current model uses GFS or ICON NWPs to predict the solar generation at a sit
```python
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, uses ICON NWP data by default
predictions_df = run_forecast(site=site, ts='2023-11-01')
# run model for today, using ICON NWP data
predictions_df = run_forecast(site=site, ts=datetime.today(), nwp_source="icon")
```

Which gives the following prediction
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](https://github.com/openclimatefix/Open-Source-Quartz-Solar-Forecast/blob/main/predictions.png?raw=true)

Expand Down Expand Up @@ -91,7 +92,7 @@ The model also uses the following variables, which are currently all set to nan
## Known restrictions
- The model is trained on [UK MetOffice](https://www.metoffice.gov.uk/services/data/met-office-weather-datahub) NWPs, but when running inference we use [GFS](https://www.ncei.noaa.gov/products/weather-climate-models/global-forecast) data from [Open-meteo](https://open-meteo.com/). The differences between GFS and UK MetOffice could led to some odd behaviours.
- It looks like the GFS data on Open-Meteo is only available for free for the last 3 months.
- Depending, whether the timestamp for the prediction lays more than 90 days in the past or not, different data sources for the NWP are used. If we predict within the last 90 days, we can use ICON or GFS from the open-meteo Weather Forecast API. Since ICON doesn't provide visibility, this parameter is queried from GFS in any case. If the date for the prediction is further back in time, a reanalysis model of historical data is used (open-meteo | Historical Weather API). The historical weather API doesn't't provide visibility at all, that's why it's set to a maximum of 24000 meter in this case. This can lead to some loss of precision.

## Evaluation

Expand Down
8 changes: 4 additions & 4 deletions examples/example.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
""" Example code to run the forecast"""
from quartz_solar_forecast.forecast import run_forecast
from quartz_solar_forecast.pydantic_models import PVSite

from datetime import datetime, timedelta

def main():
# make input data
site = PVSite(latitude=51.75, longitude=-1.25, capacity_kwp=1.25)

# run model
predictions_df = run_forecast(site=site, ts="2023-10-30")
ts = datetime.today() - timedelta(weeks=1)
predictions_df = run_forecast(site=site, ts=ts, nwp_source="icon")

print(predictions_df)
print(f"Max: {predictions_df['power_wh'].max()}")
Expand Down
9 changes: 5 additions & 4 deletions examples/example_notebook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"# Import forecast script and PVSite class.\n",
"from quartz_solar_forecast.forecast import run_forecast\n",
"from quartz_solar_forecast.pydantic_models import PVSite\n",
"from datetime import datetime, timedelta\n",
"\n",
"# Import matplotlib and plotly for plotting.\n",
"import plotly.express as px\n",
Expand All @@ -49,9 +50,9 @@
"outputs": [],
"source": [
"# Run the forecast for a specific initial timestamp.\n",
"# This generates a forecast at 15 minute intervals for the following 48 hours.\n",
"predictions_df = run_forecast(site=site, ts='2023-11-01')\n",
"print(predictions_df)"
"# This generates a forecast at 15 minute intervals for 48 hours.\n",
"ts = datetime.today() - timedelta(weeks=1)\n",
"predictions_df = run_forecast(site=site, ts=ts, nwp_source=\"icon\")"
]
},
{
Expand Down Expand Up @@ -93,7 +94,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.0"
"version": "3.10.12"
}
},
"nbformat": 4,
Expand Down

0 comments on commit fb9328c

Please sign in to comment.