Skip to content

Commit 00a5227

Browse files
GF-D6wholmgren-dnv
andauthored
Add soiling notebooks to docs (#51)
* Base_url should not appear in url params when provided * Add response type hint to live soiling hsu method * Add HSU notebook example to docs * Add Kimber notebook example to docs * unused import * pyproject cleanup * soiling notebook updates * fix precip accum norm bug * dict | bug * no pip install in notebooks, use [all], clarify pandas dep * fix response docs, add jupyter notebook downloads * forgot to add new files to previous commit * move dust soiling notebooks from 2. to 1. * fix soiling notebook titles * Rerun notebooks to update output cells --------- Co-authored-by: Will Holmgren <William.Holmgren@dnv.com>
1 parent 6d0229d commit 00a5227

21 files changed

+1857
-172
lines changed

README.md

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,33 @@ cd solcast-api-python-sdk
2424
pip install .
2525
```
2626

27-
The vanilla version doesn't have any dependency. For full functionality,
28-
for example for getting the data into `DataFrames`, and for development, use the `[all]` tag:
27+
The base solcast sdk install requires only the python standard library.
28+
Pandas is the only optional dependency that adds functionality to the package.
2929

3030
```commandline
31-
pip install .[all] for the dev libs
31+
pip install solcast pandas
3232
```
3333

34+
The example notebooks use a variety of optional dependencies to showcase different
35+
ways in which the Solcast API may be used. To install these dependencies run
36+
37+
```commandline
38+
pip install solcast[all]
39+
```
40+
41+
3442
## Basic Usage
3543

3644
```python
3745
from solcast import live
3846

39-
df = live.radiation_and_weather(
47+
res = live.radiation_and_weather(
4048
latitude=-33.856784,
4149
longitude=151.215297,
4250
output_parameters=['air_temp', 'dni', 'ghi']
43-
).to_pandas()
51+
)
52+
res.to_dict()
53+
res.to_pandas() # requires optional pandas installation
4454
```
4555

4656
Don't forget to set your [account Api Key](https://toolkit.solcast.com.au/register) with:
@@ -57,6 +67,15 @@ They are executed on `unmetered locations` and as such won't consume your reques
5767
pytest tests
5868
```
5969

70+
## Docs
71+
72+
From the directory run
73+
```bash
74+
mkdocs build
75+
mkdocs serve
76+
```
77+
In a browser navigate to `localhost:8000` to see the documentation.
78+
6079
### Formatters and Linters
6180

6281
| Language | Formatter/Linter |

docs/api/pandafiableresponse.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
::: solcast.api.PandafiableResponse

docs/index.md

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,28 @@
11
# Welcome to Solcast
2-
A simple Python SDK that wraps [Solcast's API](https://docs.solcast.com.au/).
2+
A simple Python SDK that wraps [Solcast's API](https://docs.solcast.com.au/).
33

44
## Install
55
From the directory run the following command:
6-
```bash
6+
```bash
77
pip install --user solcast
88
```
99
!!! tip
1010

11-
for full functionality install **all**: `pip install --user solcast[all]`
11+
for full functionality install **pandas**: `pip install --user solcast pandas`
12+
13+
The example notebooks use a variety of optional dependencies to showcase different
14+
ways in which the Solcast API may be used. To install these dependencies run
15+
16+
```commandline
17+
pip install --user solcast[all]
18+
```
1219

1320
## Usage
14-
!!! warning
21+
!!! warning
1522

1623
To access Solcast data you will need a [commercial API key](https://toolkit.solcast.com.au/register). If you have the API key already,
1724
you can use it with this library either as an environment variable called SOLCAST_API_KEY,
18-
or you can pass it as an argument `api_key` when you call one of the library's methods.
25+
or you can pass it as an argument `api_key` when you call one of the library's methods.
1926

2027
Fetching live radiation and weather data:
2128

@@ -40,7 +47,7 @@ from solcast.unmetered_locations import UNMETERED_LOCATIONS
4047
sydney = UNMETERED_LOCATIONS['Sydney Opera House']
4148

4249
res = forecast.rooftop_pv_power(
43-
latitude=sydney['latitude'],
50+
latitude=sydney['latitude'],
4451
longitude=sydney['longitude'],
4552
period='PT5M',
4653
capacity=5, # 5KW
@@ -49,22 +56,22 @@ res = forecast.rooftop_pv_power(
4956
)
5057
```
5158

52-
53-
Where the data returned is a timeseries, the response can be converted to a Pandas DataFrame as follows. This is available for all the modules apart from `pv_power_sites`.
59+
All response data can be extracted in Python dictionary format.
5460

5561
```python
56-
df = res.to_pandas()
62+
d = res.to_dict()
5763
```
58-
!!! info
59-
Pandas is not installed by default to keep the environment light. It is installed with the [all] tag
6064

61-
For all the modules, data can be extracted in Python dictionary format.
65+
If pandas is installed, timeseries responses can be converted to a Pandas DataFrame using the ``.to_pandas()`` method.
66+
6267
```python
63-
df = res.to_dict()
68+
df = res.to_pandas()
6469
```
70+
!!! info
71+
Pandas is not installed by default to keep the environment light.
6572

6673

67-
Available modules are
74+
Available modules are
6875

6976
| Module | API Docs |
7077
|------------------|------------------------------------------|
@@ -76,14 +83,6 @@ Available modules are
7683
| `aggregations` | [solcast.aggregations](aggregations.md) |
7784

7885

79-
## Docs
80-
from the directory run
81-
```bash
82-
mkdocs build
83-
mkdocs serve
84-
```
85-
In a browser navigate to `localhost:8000` to see the documentation.
86-
8786
## Contributing & License
8887
Any type of suggestion and code contribution is welcome as PRs and/or Issues.
8988
This repository is licensed under MIT (see LICENSE).

docs/notebooks/1.3 Getting Data - Make Concurrent Requests.ipynb

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,6 @@
99
"It is important to note that it is possible to exceed your rate limit as you increase the number of parallel downloads, which may cause some requests to fail!"
1010
]
1111
},
12-
{
13-
"cell_type": "code",
14-
"execution_count": 1,
15-
"metadata": {},
16-
"outputs": [],
17-
"source": [
18-
"# ! pip install pandas matplotlib"
19-
]
20-
},
2112
{
2213
"cell_type": "code",
2314
"execution_count": 1,
@@ -82,7 +73,7 @@
8273
},
8374
{
8475
"cell_type": "code",
85-
"execution_count": 4,
76+
"execution_count": null,
8677
"metadata": {},
8778
"outputs": [
8879
{
@@ -223,8 +214,8 @@
223214
" df.append(res.to_pandas())\n",
224215
" else:\n",
225216
" # NOTE for production purposes you will need to deal with API failures, e.g. due rate-limiting!\n",
226-
" pass \n",
227-
" \n",
217+
" pass\n",
218+
"\n",
228219
"df = pd.concat(df)\n",
229220
"df"
230221
]

0 commit comments

Comments
 (0)