Skip to content

Commit 348eebe

Browse files
feature: adding aggregations (#39)
adds module to fetch from the aggregations endpoint.
1 parent 63a5236 commit 348eebe

File tree

7 files changed

+115
-7
lines changed

7 files changed

+115
-7
lines changed

CHANGELOG.md

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

3+
## [1.3.0] - 2024-07-10
4+
5+
- Add the `aggregations` module. No tests as we are yet to expose unmetered aggregations.
6+
7+
38
## [1.2.5] - 2024-07-05
49

510
- Add advanced_pv_power to the historic module

docs/aggregrations.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Aggregations
2+
More information in the [API Docs](https://docs.solcast.com.au/?#c1726d91-8a67-4803-89f4-02ecb5f03c05).
3+
4+
The module `aggregations` has 2 available methods:
5+
6+
| Endpoint | API Docs |
7+
|---------------------|---------------------------------------------------------------------------------------------------------|
8+
| `live` | [details](https://docs.solcast.com.au/#d1fc6dfa-a2f6-40db-a2b4-545030e33197){.md-button} |
9+
| `forecast` | [details](https://docs.solcast.com.au/#bda5d3ea-34fb-4f36-b0ca-d0a2d7c00629){.md-button} |
10+
11+
### Example
12+
13+
```python
14+
from solcast import aggregations
15+
16+
res = aggregations.forecast(
17+
collection_id="country_total",
18+
aggregation_id="it_total",
19+
output_parameters=['percentage', 'pv_estimate']
20+
)
21+
22+
res.to_pandas().head()
23+
```
24+
25+
| period_end | percentage | pv_estimate |
26+
|:--------------------------|-------------:|--------------:|
27+
| 2024-06-13 04:30:00+00:00 | 1 | 333.499 |
28+
| 2024-06-13 05:00:00+00:00 | 3.6 | 1157.39 |
29+
| 2024-06-13 05:30:00+00:00 | 7 | 2268.41 |
30+
| 2024-06-13 06:00:00+00:00 | 10.4 | 3361.17 |
31+
| 2024-06-13 06:30:00+00:00 | 14.4 | 4630.91 |

docs/index.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,14 @@ df = res.to_dict()
6666

6767
Available modules are
6868

69-
| Module | API Docs |
70-
|--------------|---------------------------------|
71-
| `live` | [solcast.live](live.md) |
72-
| `historic` | [solcast.historic](historic.md) |
73-
| `forecast` | [solcast.forecast](forecast.md) |
74-
| `tmy` | [solcast.tmy](tmy.md) |
69+
| Module | API Docs |
70+
|------------------|------------------------------------------|
71+
| `live` | [solcast.live](live.md) |
72+
| `historic` | [solcast.historic](historic.md) |
73+
| `forecast` | [solcast.forecast](forecast.md) |
74+
| `tmy` | [solcast.tmy](tmy.md) |
7575
| `pv_power_sites` | [solcast.pv_power_sites](pv_power_sites) |
76+
| `aggregations` | [solcast.aggregations](aggregations) |
7677

7778

7879
## Docs

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ nav:
1515
- Historic: historic.md
1616
- TMY: tmy.md
1717
- PV Power Sites: pv_power_sites.md
18+
- Aggregations: aggregations.md
1819
- Example Notebooks:
1920
- '1.1 Getting Data: Historic Solar Radiation': 'notebooks/1.1 Getting Data - Historic Solar Radiation.ipynb'
2021
- '1.2 Getting Data: TMY in your local timezone': 'notebooks/1.2 Getting Data - TMY in your local timezone.ipynb'

solcast/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
__version__ = "1.2.5"
1+
__version__ = "1.3.0"
22

33
from . import (
44
api,
55
forecast,
66
historic,
77
live,
88
tmy,
9+
aggregations,
910
unmetered_locations,
1011
urls,
1112
pv_power_sites,
1213
)
1314

1415
__all__ = [
16+
"aggregations",
1517
"forecast",
1618
"historic",
1719
"live",

solcast/aggregations.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
from typing import Optional
2+
3+
from .api import Client, PandafiableResponse
4+
from .urls import (
5+
base_url,
6+
forecast_grid_aggregations,
7+
live_grid_aggregations,
8+
)
9+
10+
11+
def live(
12+
collection_id: str, aggregation_id: Optional[str], **kwargs
13+
) -> PandafiableResponse:
14+
"""
15+
Get live aggregation data for up to 7 days of data at a time for a requested collection or aggregation.
16+
17+
Args:
18+
collection_id: a unique identifier for your collection.
19+
aggregation_id: a unique identifier that belongs to the requested collection.
20+
**kwargs: additional keyword arguments to be passed through as URL parameters to the Solcast API
21+
22+
See https://docs.solcast.com.au/ for full list of parameters.
23+
"""
24+
client = Client(
25+
base_url=base_url,
26+
endpoint=live_grid_aggregations,
27+
response_type=PandafiableResponse,
28+
)
29+
30+
return client.get(
31+
{
32+
"collection_id": collection_id,
33+
"aggregation_id": aggregation_id,
34+
"format": "json",
35+
**kwargs,
36+
}
37+
)
38+
39+
40+
def forecast(
41+
collection_id: str, aggregation_id: Optional[str], **kwargs
42+
) -> PandafiableResponse:
43+
"""
44+
Get forecast aggregation data for up to 7 days of data at a time for a requested collection or aggregation.
45+
46+
Args:
47+
collection_id: a unique identifier for your collection.
48+
aggregation_id: a unique identifier that belongs to the requested collection.
49+
**kwargs: additional keyword arguments to be passed through as URL parameters to the Solcast API
50+
51+
See https://docs.solcast.com.au/ for full list of parameters.
52+
"""
53+
client = Client(
54+
base_url=base_url,
55+
endpoint=forecast_grid_aggregations,
56+
response_type=PandafiableResponse,
57+
)
58+
59+
return client.get(
60+
{
61+
"collection_id": collection_id,
62+
"aggregation_id": aggregation_id,
63+
"format": "json",
64+
**kwargs,
65+
}
66+
)

solcast/urls.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
live_radiation_and_weather = "data/live/radiation_and_weather"
33
live_rooftop_pv_power = "data/live/rooftop_pv_power"
44
live_advanced_pv_power = "data/live/advanced_pv_power"
5+
live_grid_aggregations = "data/live/aggregations"
56
historic_radiation_and_weather = "data/historic/radiation_and_weather"
67
historic_rooftop_pv_power = "data/historic/rooftop_pv_power"
78
historic_advanced_pv_power = "data/historic/advanced_pv_power"
89
forecast_radiation_and_weather = "data/forecast/radiation_and_weather"
910
forecast_rooftop_pv_power = "data/forecast/rooftop_pv_power"
1011
forecast_advanced_pv_power = "data/forecast/advanced_pv_power"
12+
forecast_grid_aggregations = "data/forecast/aggregations"
1113
tmy_radiation_and_weather = "data/tmy/radiation_and_weather"
1214
tmy_rooftop_pv_power = "data/tmy/rooftop_pv_power"
1315
pv_power_site = "resources/pv_power_site"

0 commit comments

Comments
 (0)