-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds module to fetch from the aggregations endpoint.
- Loading branch information
1 parent
63a5236
commit 348eebe
Showing
7 changed files
with
115 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Aggregations | ||
More information in the [API Docs](https://docs.solcast.com.au/?#c1726d91-8a67-4803-89f4-02ecb5f03c05). | ||
|
||
The module `aggregations` has 2 available methods: | ||
|
||
| Endpoint | API Docs | | ||
|---------------------|---------------------------------------------------------------------------------------------------------| | ||
| `live` | [details](https://docs.solcast.com.au/#d1fc6dfa-a2f6-40db-a2b4-545030e33197){.md-button} | | ||
| `forecast` | [details](https://docs.solcast.com.au/#bda5d3ea-34fb-4f36-b0ca-d0a2d7c00629){.md-button} | | ||
|
||
### Example | ||
|
||
```python | ||
from solcast import aggregations | ||
|
||
res = aggregations.forecast( | ||
collection_id="country_total", | ||
aggregation_id="it_total", | ||
output_parameters=['percentage', 'pv_estimate'] | ||
) | ||
|
||
res.to_pandas().head() | ||
``` | ||
|
||
| period_end | percentage | pv_estimate | | ||
|:--------------------------|-------------:|--------------:| | ||
| 2024-06-13 04:30:00+00:00 | 1 | 333.499 | | ||
| 2024-06-13 05:00:00+00:00 | 3.6 | 1157.39 | | ||
| 2024-06-13 05:30:00+00:00 | 7 | 2268.41 | | ||
| 2024-06-13 06:00:00+00:00 | 10.4 | 3361.17 | | ||
| 2024-06-13 06:30:00+00:00 | 14.4 | 4630.91 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
from typing import Optional | ||
|
||
from .api import Client, PandafiableResponse | ||
from .urls import ( | ||
base_url, | ||
forecast_grid_aggregations, | ||
live_grid_aggregations, | ||
) | ||
|
||
|
||
def live( | ||
collection_id: str, aggregation_id: Optional[str], **kwargs | ||
) -> PandafiableResponse: | ||
""" | ||
Get live aggregation data for up to 7 days of data at a time for a requested collection or aggregation. | ||
Args: | ||
collection_id: a unique identifier for your collection. | ||
aggregation_id: a unique identifier that belongs to the requested collection. | ||
**kwargs: additional keyword arguments to be passed through as URL parameters to the Solcast API | ||
See https://docs.solcast.com.au/ for full list of parameters. | ||
""" | ||
client = Client( | ||
base_url=base_url, | ||
endpoint=live_grid_aggregations, | ||
response_type=PandafiableResponse, | ||
) | ||
|
||
return client.get( | ||
{ | ||
"collection_id": collection_id, | ||
"aggregation_id": aggregation_id, | ||
"format": "json", | ||
**kwargs, | ||
} | ||
) | ||
|
||
|
||
def forecast( | ||
collection_id: str, aggregation_id: Optional[str], **kwargs | ||
) -> PandafiableResponse: | ||
""" | ||
Get forecast aggregation data for up to 7 days of data at a time for a requested collection or aggregation. | ||
Args: | ||
collection_id: a unique identifier for your collection. | ||
aggregation_id: a unique identifier that belongs to the requested collection. | ||
**kwargs: additional keyword arguments to be passed through as URL parameters to the Solcast API | ||
See https://docs.solcast.com.au/ for full list of parameters. | ||
""" | ||
client = Client( | ||
base_url=base_url, | ||
endpoint=forecast_grid_aggregations, | ||
response_type=PandafiableResponse, | ||
) | ||
|
||
return client.get( | ||
{ | ||
"collection_id": collection_id, | ||
"aggregation_id": aggregation_id, | ||
"format": "json", | ||
**kwargs, | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters