Skip to content

Commit 97a42ca

Browse files
authored
pypowsybl-jupyter demo notebook (#23)
* adds a new notebook to demonstrate the pypowsybl-jupyter widget * adds to the README a Binder badge/link * adds requirements file Signed-off-by: Christian Biasuzzi <christian.biasuzzi@soft.it>
1 parent a4084ee commit 97a42ca

File tree

3 files changed

+159
-0
lines changed

3 files changed

+159
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@
88
- Operator strategy notebook: [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/powsybl/pypowsybl-notebooks/main?labpath=operator_strategy.ipynb)
99
- Computation using Dynaflow : [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/powsybl/pypowsybl-notebooks/main?labpath=dynaflow/pypowsybl_dynaflow.ipynb)
1010
- Sensitivity analysis and PTDF calculation [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/powsybl/pypowsybl-notebooks/main?labpath=sensitivity_analysis.ipynb)
11+
- Pypowsybl-Jupyter widgets notebook : [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/powsybl/pypowsybl-notebooks/main?labpath=pypowsybl_jupyter_widgets_demo.ipynb)
12+

pypowsybl_jupyter_widgets_demo.ipynb

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "474d58ab-cc5a-4396-8db1-4221abbdd2dc",
6+
"metadata": {
7+
"editable": true,
8+
"slideshow": {
9+
"slide_type": ""
10+
},
11+
"tags": []
12+
},
13+
"source": [
14+
"# Pypowsybl-jupyter widgets demo: network explorer"
15+
]
16+
},
17+
{
18+
"cell_type": "markdown",
19+
"id": "49d2aab9-ef3f-4b57-a023-ab1c72608eaf",
20+
"metadata": {
21+
"editable": true,
22+
"slideshow": {
23+
"slide_type": ""
24+
},
25+
"tags": []
26+
},
27+
"source": [
28+
"Pypowsybl-jupyter provides a set of interactive widgets for PyPowSyBl in Jupyter.\n",
29+
"This notebook demonstrates the network explorer."
30+
]
31+
},
32+
{
33+
"cell_type": "code",
34+
"execution_count": null,
35+
"id": "ab21fcb8-d724-48f6-aa53-63e81a863e7a",
36+
"metadata": {},
37+
"outputs": [],
38+
"source": [
39+
"%pip install pypowsybl"
40+
]
41+
},
42+
{
43+
"cell_type": "code",
44+
"execution_count": null,
45+
"id": "2624eba1",
46+
"metadata": {},
47+
"outputs": [],
48+
"source": [
49+
"%pip install pypowsybl_jupyter"
50+
]
51+
},
52+
{
53+
"cell_type": "code",
54+
"execution_count": null,
55+
"id": "33e76b81-4788-4fd6-af5d-390cb6230c34",
56+
"metadata": {},
57+
"outputs": [],
58+
"source": [
59+
"import pypowsybl as pp\n",
60+
"from pypowsybl_jupyter import network_explorer"
61+
]
62+
},
63+
{
64+
"cell_type": "markdown",
65+
"id": "3dc5dc34-2c28-411f-b281-c3cc2fd53ad4",
66+
"metadata": {},
67+
"source": [
68+
"Create a network."
69+
]
70+
},
71+
{
72+
"cell_type": "code",
73+
"execution_count": null,
74+
"id": "ff9bf071-2f25-43a5-8db1-838dc781bd69",
75+
"metadata": {},
76+
"outputs": [],
77+
"source": [
78+
"n = pp.network.create_ieee14()"
79+
]
80+
},
81+
{
82+
"cell_type": "markdown",
83+
"id": "e550558b-452d-424f-b484-79ae60ec35bc",
84+
"metadata": {
85+
"editable": true,
86+
"slideshow": {
87+
"slide_type": ""
88+
},
89+
"tags": []
90+
},
91+
"source": [
92+
"Display the network explorer widget. \n",
93+
"* Click on a voltage level from the list to display its NAD and SLD in the two \"Network Area\" and \"Single Line\" tabs. \n",
94+
"* Both diagrams can be panned and zoomed.\n",
95+
"* The NAD is centered on the currently selected voltage level. A 'depth' slider controls the size of the sub-network."
96+
]
97+
},
98+
{
99+
"cell_type": "code",
100+
"execution_count": null,
101+
"id": "4e7dd648-eef9-4a33-b7c8-3925fbca7395",
102+
"metadata": {},
103+
"outputs": [],
104+
"source": [
105+
"network_explorer(n)"
106+
]
107+
},
108+
{
109+
"cell_type": "markdown",
110+
"id": "c3132815-c0d1-4884-aae9-186abe655baf",
111+
"metadata": {
112+
"editable": true,
113+
"slideshow": {
114+
"slide_type": ""
115+
},
116+
"tags": []
117+
},
118+
"source": [
119+
"It is possible to pre-select the VL to display and the depth using the optional parameters 'vl_id' and 'depth'."
120+
]
121+
},
122+
{
123+
"cell_type": "code",
124+
"execution_count": null,
125+
"id": "5966caae-c700-4904-ba19-2c2400ba46e9",
126+
"metadata": {},
127+
"outputs": [],
128+
"source": [
129+
"network_explorer(n, vl_id='VL14', depth=4)"
130+
]
131+
}
132+
],
133+
"metadata": {
134+
"kernelspec": {
135+
"display_name": "Python 3 (ipykernel)",
136+
"language": "python",
137+
"name": "python3"
138+
},
139+
"language_info": {
140+
"codemirror_mode": {
141+
"name": "ipython",
142+
"version": 3
143+
},
144+
"file_extension": ".py",
145+
"mimetype": "text/x-python",
146+
"name": "python",
147+
"nbconvert_exporter": "python",
148+
"pygments_lexer": "ipython3",
149+
"version": "3.12.3"
150+
}
151+
},
152+
"nbformat": 4,
153+
"nbformat_minor": 5
154+
}

requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# needed by pypowsybl-jupyter, for Binder
2+
anywidget
3+

0 commit comments

Comments
 (0)