Skip to content

Commit

Permalink
Replaces LayoutParameters with SldParameters (#11)
Browse files Browse the repository at this point in the history
* replaces LayoutParameters with SldParameters
* updates widgets examples to demonstrate SldParameters and NadParameters

Signed-off-by: Christian Biasuzzi <christian.biasuzzi@soft.it>
  • Loading branch information
CBiasuzzi authored Jun 7, 2024
1 parent 6ffb715 commit 28d400d
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 8 deletions.
17 changes: 14 additions & 3 deletions examples/demo_nad_simple.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"outputs": [],
"source": [
"import pypowsybl.network as pn\n",
"import pypowsybl.loadflow as lf\n",
"from pypowsybl_jupyter import display_nad"
]
},
Expand All @@ -30,7 +29,19 @@
"outputs": [],
"source": [
"vlid=network.get_voltage_levels().index[2]\n",
"display_nad(network.get_network_area_diagram(voltage_level_ids=vlid, depth=4))\n"
"display_nad(network.get_network_area_diagram(voltage_level_ids=vlid, depth=4))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4998ee29-21f3-45b0-9319-2a188185ad53",
"metadata": {},
"outputs": [],
"source": [
"#uses NadParameters to customize the NAD\n",
"pars=pn.NadParameters(edge_name_displayed=True, id_displayed=True, edge_info_along_edge=True, power_value_precision=1, angle_value_precision=0, current_value_precision=1, voltage_value_precision=0, bus_legend=False, substation_description_displayed=True)\n",
"display_nad(network.get_network_area_diagram(voltage_level_ids=vlid, depth=4, nad_parameters=pars))"
]
}
],
Expand All @@ -50,7 +61,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.2"
"version": "3.12.3"
}
},
"nbformat": 4,
Expand Down
12 changes: 11 additions & 1 deletion examples/demo_network_explorer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"outputs": [],
"source": [
"import pypowsybl.network as pn\n",
"import pypowsybl.loadflow as lf\n",
"from pypowsybl_jupyter import network_explorer"
]
},
Expand All @@ -31,6 +30,17 @@
"source": [
"network_explorer(network, depth=4)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c0f04493-8f25-409e-95a2-39bb3a331f6f",
"metadata": {},
"outputs": [],
"source": [
"#uses NadParameters and SldParameters to customize the diagrams\n",
"network_explorer(network, depth=0, sld_parameters=pn.SldParameters(nodes_infos=True), nad_parameters=pn.NadParameters(edge_info_along_edge=True))"
]
}
],
"metadata": {
Expand Down
14 changes: 13 additions & 1 deletion examples/demo_sld_simple.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@
"#display a SLD for a network's VL, with pan and zoom\n",
"display_sld(network.get_single_line_diagram(network.get_voltage_levels().index[1]))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f81ed51d-906f-4c80-8c4e-e89712a82a3c",
"metadata": {},
"outputs": [],
"source": [
"##uses SldParameters to customize the SLD\n",
"pars=pn.SldParameters(diagonal_label=True, nodes_infos=True)\n",
"display_sld(network.get_single_line_diagram(network.get_voltage_levels().index[1], parameters=pars))"
]
}
],
"metadata": {
Expand All @@ -49,7 +61,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.2"
"version": "3.12.3"
}
},
"nbformat": 4,
Expand Down
6 changes: 3 additions & 3 deletions src/pypowsybl_jupyter/networkexplorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
# SPDX-License-Identifier: MPL-2.0
#

from pypowsybl.network import Network, NadParameters, LayoutParameters
from pypowsybl.network import Network, NadParameters, SldParameters
from .nadwidget import display_nad, update_nad
from .sldwidget import display_sld, update_sld

import ipywidgets as widgets

def network_explorer(network: Network, vl_id : str = None, depth: int = 0, high_nominal_voltage_bound: float = -1, low_nominal_voltage_bound: float = -1, nad_parameters: NadParameters = None, sld_parameters: LayoutParameters = None):
def network_explorer(network: Network, vl_id : str = None, depth: int = 0, high_nominal_voltage_bound: float = -1, low_nominal_voltage_bound: float = -1, nad_parameters: NadParameters = None, sld_parameters: SldParameters = None):
"""
Creates a combined NAD and SLD explorer widget for the network. Diagrams are displayed on two different tabs.
Expand Down Expand Up @@ -51,7 +51,7 @@ def network_explorer(network: Network, vl_id : str = None, depth: int = 0, high_
bus_legend=False,
substation_description_displayed=True)

spars=sld_parameters if sld_parameters is not None else LayoutParameters(use_name=True)
spars=sld_parameters if sld_parameters is not None else SldParameters(use_name=True)

def go_to_vl(event: any):
nonlocal selected_vl
Expand Down

0 comments on commit 28d400d

Please sign in to comment.