Skip to content

Commit

Permalink
v0.4
Browse files Browse the repository at this point in the history
Updated to use PV_Forecast API v4
  • Loading branch information
JamieTaylor-TUOS committed Aug 1, 2022
1 parent c1da791 commit ec1e076
Show file tree
Hide file tree
Showing 22 changed files with 327 additions and 200 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# PV_Forecast-API
A Python implementation of the PV_Forecast web API. See [www.solar.sheffield.ac.uk/pvforecast/](https://www.solar.sheffield.ac.uk/pvforecast/) and [api.solar.sheffield.ac.uk](https://api.solar.sheffield.ac.uk/)

**Latest Version: 0.3**
**Latest Version: 0.4**

**New! Updated 2021-02-23 to use PV_Forecast API v3.**
**New! Updated 2022-08-01 to use PV_Forecast API v4.**

## About this repository

Expand Down Expand Up @@ -55,7 +55,7 @@ pvf = PVForecast(user_id="", api_key="") # Enter your user_id and api_key here!
|-------|----|------|
|Get the latest nationally aggregated GB PV outturn forecast|`pvf.latest()`|`[[0, '2021-02-23T10:00:00Z', '2021-02-23T10:30:00Z', 2600.0], ..., [0, '2021-02-23T10:00:00Z', '2021-02-26T10:00:00Z', 5230.0]]`|
|Get the latest aggregated outturn forecast for **PES** region **23** (Yorkshire) as a DataFrame|`pvf.latest(entity_id=23, dataframe=True)`|![Screenshot of output](/misc/code_example_output1.png?raw=true)
|Get the latest aggregated outturn forecast for **GSP** ID **120** (INDQ1 or "Indian Queens")|`pvf.latest(entity_type="gsp", entity_id=120, dataframe=True)`|![Screenshot of output](/misc/code_example_output2.png?raw=true)
|Get the latest aggregated outturn forecast for **GSP** ID **152** (INDQ1 or "Indian Queens")|`pvf.latest(entity_type="gsp", entity_id=152, dataframe=True)`|![Screenshot of output](/misc/code_example_output2.png?raw=true)
|Get the nationally aggregated GB PV outturn forecast with forecast base `2021-02-23T07:00:00Z` as a DataFrame|`pvf.get_forecast(datetime(2021, 2, 23, 7, 0, tzinfo=pytz.utc), dataframe=True))`|![Screenshot of output](/misc/code_example_output3.png?raw=true)|
|Get all 07:00 nationally aggregated GB PV outturn forecasts between `2021-02-23T01:00:00Z` and `2021-02-23T07:00:00Z`, as a DataFrame|`pvf.get_forecasts(datetime(2021, 2, 23, 1, 0, tzinfo=pytz.utc), datetime(2021, 2, 23, 7, 0, tzinfo=pytz.utc), forecast_base_times=["07:00"], dataframe=True))`|![Screenshot of output](/misc/code_example_output4.png?raw=true)|

Expand Down
32 changes: 16 additions & 16 deletions Tests/test_pvforecast_api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Unit tests for the pvforecast library.
Author: JamieTalor
Author: Jamie Taylor
First Authored: 2021-02-02
"""

Expand Down Expand Up @@ -114,52 +114,52 @@ def test_latest(self):

def test_get_forecasts(self):
"""Test the get_forecasts function."""
data = self.api.get_forecasts(start=datetime(2021, 2, 2, 1, 0, tzinfo=pytz.utc),
end=datetime(2021, 2, 2, 12, 0, tzinfo=pytz.utc),
data = self.api.get_forecasts(start=datetime(2022, 7, 19, 1, 0, tzinfo=pytz.utc),
end=datetime(2022, 7, 20, 12, 0, tzinfo=pytz.utc),
entity_type="pes", entity_id=0)
self.check_list(data)
self.check_pes_list_dtypes(data)
data = self.api.get_forecasts(start=datetime(2021, 2, 2, 1, 0, tzinfo=pytz.utc),
end=datetime(2021, 2, 2, 12, 0, tzinfo=pytz.utc),
data = self.api.get_forecasts(start=datetime(2022, 7, 19, 1, 0, tzinfo=pytz.utc),
end=datetime(2022, 7, 19, 12, 0, tzinfo=pytz.utc),
entity_type="pes", entity_id=0, dataframe=True)
self.check_df_columns(data)
self.check_df_dtypes(data)
data = self.api.get_forecasts(start=datetime(2021, 2, 2, 1, 0, tzinfo=pytz.utc),
end=datetime(2021, 2, 2, 12, 0, tzinfo=pytz.utc),
data = self.api.get_forecasts(start=datetime(2022, 7, 19, 1, 0, tzinfo=pytz.utc),
end=datetime(2022, 7, 19, 12, 0, tzinfo=pytz.utc),
entity_type="pes", entity_id=0,
extra_fields="installedcapacity_mwp", dataframe=True)
self.check_df_dtypes(data)
data = self.api.get_forecasts(start=datetime(2021, 2, 1, 7, 0, tzinfo=pytz.utc),
end=datetime(2021, 2, 2, 7, 0, tzinfo=pytz.utc),
data = self.api.get_forecasts(start=datetime(2022, 7, 19, 7, 0, tzinfo=pytz.utc),
end=datetime(2022, 7, 20, 7, 0, tzinfo=pytz.utc),
entity_type="gsp", entity_id=26)
self.check_list(data)
self.check_gsp_list_dtypes(data)
data = self.api.get_forecasts(start=datetime(2021, 2, 1, 7, 0, tzinfo=pytz.utc),
end=datetime(2021, 2, 2, 7, 0, tzinfo=pytz.utc),
data = self.api.get_forecasts(start=datetime(2022, 7, 19, 7, 0, tzinfo=pytz.utc),
end=datetime(2022, 7, 20, 7, 0, tzinfo=pytz.utc),
entity_type="gsp", entity_id=26, dataframe=True)
self.check_df_columns(data)
self.check_df_dtypes(data)
return

def test_get_forecast(self):
"""Test the get_forecast function."""
data = self.api.get_forecast(forecast_base_gmt=datetime(2021, 2, 2, 7, 0, tzinfo=pytz.utc),
data = self.api.get_forecast(forecast_base_gmt=datetime(2022, 7, 19, 7, 0, tzinfo=pytz.utc),
entity_type="pes", entity_id=0)
self.check_list(data)
self.check_pes_list_dtypes(data)
data = self.api.get_forecast(forecast_base_gmt=datetime(2021, 2, 2, 7, 0, tzinfo=pytz.utc),
data = self.api.get_forecast(forecast_base_gmt=datetime(2022, 7, 19, 7, 0, tzinfo=pytz.utc),
entity_type="pes", entity_id=0, dataframe=True)
self.check_df_columns(data)
self.check_df_dtypes(data)
data = self.api.get_forecast(forecast_base_gmt=datetime(2021, 2, 2, 7, 0, tzinfo=pytz.utc),
data = self.api.get_forecast(forecast_base_gmt=datetime(2022, 7, 19, 7, 0, tzinfo=pytz.utc),
entity_type="pes", entity_id=0,
extra_fields="installedcapacity_mwp", dataframe=True)
self.check_df_dtypes(data)
data = self.api.get_forecast(forecast_base_gmt=datetime(2021, 2, 2, 7, 0, tzinfo=pytz.utc),
data = self.api.get_forecast(forecast_base_gmt=datetime(2022, 7, 19, 7, 0, tzinfo=pytz.utc),
entity_type="gsp", entity_id=26)
self.check_list(data)
self.check_gsp_list_dtypes(data)
data = self.api.get_forecast(forecast_base_gmt=datetime(2021, 2, 2, 7, 0, tzinfo=pytz.utc),
data = self.api.get_forecast(forecast_base_gmt=datetime(2022, 7, 19, 7, 0, tzinfo=pytz.utc),
entity_type="gsp", entity_id=26, dataframe=True)
self.check_df_columns(data)
self.check_df_dtypes(data)
Expand Down
Binary file modified docs/build/doctrees/environment.pickle
Binary file not shown.
Binary file modified docs/build/doctrees/index.doctree
Binary file not shown.
Binary file modified docs/build/doctrees/modules.doctree
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/build/html/.buildinfo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 5c3c1c98b780bdb703f436ed2d941f15
config: 22b47d1b12a8c3ac47dfa55c58d5834f
tags: 645f666f9bcd5a90fca523b33c5a78b7
14 changes: 7 additions & 7 deletions docs/build/html/_modules/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Overview: module code &#8212; PV_Forecast-API 0.3 documentation</title>
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../_static/classic.css" type="text/css" />
<title>Overview: module code &#8212; PV_Forecast-API 0.4 documentation</title>
<link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="../_static/classic.css" />

<script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
<script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
Expand All @@ -26,7 +26,7 @@ <h3>Navigation</h3>
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">PV_Forecast-API 0.3 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="../index.html">PV_Forecast-API 0.4 documentation</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Overview: module code</a></li>
</ul>
</div>
Expand Down Expand Up @@ -69,13 +69,13 @@ <h3>Navigation</h3>
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="nav-item nav-item-0"><a href="../index.html">PV_Forecast-API 0.3 documentation</a> &#187;</li>
<li class="nav-item nav-item-0"><a href="../index.html">PV_Forecast-API 0.4 documentation</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">Overview: module code</a></li>
</ul>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2018, Jamie Taylor.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.5.1.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.0.1.
</div>
</body>
</html>
Loading

0 comments on commit ec1e076

Please sign in to comment.