Skip to content

Commit

Permalink
Example run of forecast in a notebook with a plot (#39)
Browse files Browse the repository at this point in the history
* example run of forecast in a notebook with a plot

* add a static plot to example notebook to render in Github

* small format change

* small punctuation change

* remove cell outputs
  • Loading branch information
zakwatts authored Jan 31, 2024
1 parent 62d9ac0 commit 34ef9d1
Showing 1 changed file with 101 additions and 0 deletions.
101 changes: 101 additions & 0 deletions examples/example_notebook.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Example Notebook to show how to predict solar power generation"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Make sure to have installed the quart_solar_forecast package: \n",
"```\n",
"pip install quartz_solar_forecast\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# 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",
"\n",
"# Import matplotlib and plotly for plotting.\n",
"import plotly.express as px\n",
"import matplotlib.pyplot as plt"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Create a PVSite object with the site's latitude, longitude and capacity.\n",
"site = PVSite(latitude=51.75, longitude=-1.25, capacity_kwp=1.25)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"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)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Create an interactive plot of the forecast using plotly.\n",
"fig = px.line(predictions_df)\n",
"fig.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Create a static plot of the forecast using matplotlib.\n",
"predictions_df.plot()\n",
"plt.show()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "quartz_open",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.0"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

0 comments on commit 34ef9d1

Please sign in to comment.