Skip to content

Commit 63a5236

Browse files
lachlan-solcastLachlan
andauthored
Add historic advanced pv power (#38)
* Add historic advanced pv power * Bump version to 1.2.5 --------- Co-authored-by: Lachlan <lachlan@solcast.com.au>
1 parent 6cb4eea commit 63a5236

7 files changed

Lines changed: 75 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## [1.2.5] - 2024-07-05
4+
5+
- Add advanced_pv_power to the historic module
6+
37
## [1.2.4] - 2024-04-19
48

59
- Add pv_power_sites to package \_\_init\_\_

docs/historic.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22

33
Historical irradiance, weather and power data, from 2007 to 7 days ago at 1-2km and 5 minutes resolution.
44
For more information see the [API Docs](https://docs.solcast.com.au/#36bffd5d-d2b5-4bc3-b757-855624432375).
5-
The `Historic` module has 2 methods:
5+
The `Historic` module has 3 methods:
66

77
| Endpoint | API Docs |
88
|-------------------------|---------------------------------------------------------------------------------------------------------|
99
| `radiation_and_weather` | [list of API parameters](https://docs.solcast.com.au/#9de907e7-a52f-4993-a0f0-5cffee78ad10){.md-button} |
1010
| `rooftop_pv_power` | [list of API parameters](https://docs.solcast.com.au/#504e6e52-992f-4ac2-a4dc-d7ab312f992a){.md-button} |
11+
| `advanced_pv_power` | [list of API parameters](https://docs.solcast.com.au/#1db1132e-8d49-4f25-939f-34883e5336c4){.md-button} |
1112

1213
### Example
1314

solcast/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "1.2.4"
1+
__version__ = "1.2.5"
22

33
from . import (
44
api,

solcast/historic.py

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
from .api import Client, PandafiableResponse
2-
from .urls import base_url, historic_radiation_and_weather, historic_rooftop_pv_power
2+
from .urls import (
3+
base_url,
4+
historic_radiation_and_weather,
5+
historic_rooftop_pv_power,
6+
historic_advanced_pv_power,
7+
)
38

49

510
def radiation_and_weather(
@@ -99,3 +104,46 @@ def rooftop_pv_power(
99104
params["duration"] = duration
100105

101106
return client.get(params)
107+
108+
109+
def advanced_pv_power(
110+
resource_id: int, start: str, end: str = None, duration: str = None, **kwargs
111+
) -> PandafiableResponse:
112+
"""
113+
Get historical high spec PV power estimated actuals for the requested site,
114+
derived from satellite (clouds and irradiance over non-polar continental areas)
115+
and numerical weather models (other data).
116+
117+
Args:
118+
resource_id: a Solcast resource id
119+
start: datetime-like, first day of the requested period
120+
end: optional, datetime-like, last day of the requested period
121+
duration: optional, ISO_8601 compliant duration for the historic data.
122+
Must be within 31 days of the start_date.
123+
**kwargs: additional keyword arguments to be passed through as URL parameters to the Solcast API
124+
125+
See https://docs.solcast.com.au/ for full list of parameters.
126+
"""
127+
client = Client(
128+
base_url=base_url,
129+
endpoint=historic_advanced_pv_power,
130+
response_type=PandafiableResponse,
131+
)
132+
133+
assert (end is None and duration is not None) | (
134+
duration is None and end is not None
135+
), "only one of duration or end"
136+
137+
params = {
138+
"resource_id": resource_id,
139+
"start": start,
140+
"format": "json",
141+
**kwargs,
142+
}
143+
144+
if end is not None:
145+
params["end"] = end
146+
if duration is not None:
147+
params["duration"] = duration
148+
149+
return client.get(params)

solcast/live.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def radiation_and_weather(
4646
def rooftop_pv_power(
4747
latitude: float, longitude: float, **kwargs
4848
) -> PandafiableResponse:
49-
"""Get basic rooftop PV power forecasts from the present time up to 14 days ahead
49+
"""Get basic rooftop PV power estimated actuals from the present time up to 14 days ahead
5050
for the requested location, derived from satellite (clouds and irradiance over
5151
non-polar continental areas, nowcasted for approx. four hours ahead) and numerical
5252
weather models (other data and longer horizons).
@@ -71,7 +71,7 @@ def rooftop_pv_power(
7171

7272
def advanced_pv_power(resource_id: int, **kwargs) -> PandafiableResponse:
7373
"""
74-
Get high spec PV power forecasts from the present time up to 14 days ahead for
74+
Get high spec PV power estimated actuals from the present time up to 14 days ahead for
7575
the requested site, derived from satellite (clouds and irradiance
7676
over non-polar continental areas, nowcasted for approx. four hours ahead)
7777
and numerical weather models (other data and longer horizons).

solcast/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
live_advanced_pv_power = "data/live/advanced_pv_power"
55
historic_radiation_and_weather = "data/historic/radiation_and_weather"
66
historic_rooftop_pv_power = "data/historic/rooftop_pv_power"
7+
historic_advanced_pv_power = "data/historic/advanced_pv_power"
78
forecast_radiation_and_weather = "data/forecast/radiation_and_weather"
89
forecast_rooftop_pv_power = "data/forecast/rooftop_pv_power"
910
forecast_advanced_pv_power = "data/forecast/advanced_pv_power"

tests/test_historic.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import pytest
22

33
from solcast import historic
4-
from solcast.unmetered_locations import load_test_locations_coordinates
4+
from solcast.unmetered_locations import (
5+
load_test_locations_coordinates,
6+
UNMETERED_LOCATIONS,
7+
)
58
import pandas as pd
69

710

@@ -38,3 +41,15 @@ def test_rooftop_pv_power():
3841
assert res.success is True
3942
assert len(res.to_dict()["estimated_actuals"]) == 3 * 48 + 1
4043
assert ~res.to_pandas().isna().any().all()
44+
45+
46+
def test_advanced_pv_power():
47+
res = historic.advanced_pv_power(
48+
resource_id=UNMETERED_LOCATIONS["Sydney Opera House"]["resource_id"],
49+
start="2022-10-25T14:45:00.00Z",
50+
duration="P3D",
51+
)
52+
53+
assert res.success is True
54+
assert len(res.to_dict()["estimated_actuals"]) == 3 * 48 + 1
55+
assert ~res.to_pandas().isna().any().all()

0 commit comments

Comments
 (0)