From 28d400d3cf568446d7987eb15b56d89fb3a7ff33 Mon Sep 17 00:00:00 2001 From: Christian Biasuzzi Date: Fri, 7 Jun 2024 17:39:43 +0200 Subject: [PATCH] Replaces LayoutParameters with SldParameters (#11) * replaces LayoutParameters with SldParameters * updates widgets examples to demonstrate SldParameters and NadParameters Signed-off-by: Christian Biasuzzi --- examples/demo_nad_simple.ipynb | 17 ++++++++++++++--- examples/demo_network_explorer.ipynb | 12 +++++++++++- examples/demo_sld_simple.ipynb | 14 +++++++++++++- src/pypowsybl_jupyter/networkexplorer.py | 6 +++--- 4 files changed, 41 insertions(+), 8 deletions(-) diff --git a/examples/demo_nad_simple.ipynb b/examples/demo_nad_simple.ipynb index b742bcf..86e9c5b 100644 --- a/examples/demo_nad_simple.ipynb +++ b/examples/demo_nad_simple.ipynb @@ -8,7 +8,6 @@ "outputs": [], "source": [ "import pypowsybl.network as pn\n", - "import pypowsybl.loadflow as lf\n", "from pypowsybl_jupyter import display_nad" ] }, @@ -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))" ] } ], @@ -50,7 +61,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.2" + "version": "3.12.3" } }, "nbformat": 4, diff --git a/examples/demo_network_explorer.ipynb b/examples/demo_network_explorer.ipynb index d660085..d7dd25b 100644 --- a/examples/demo_network_explorer.ipynb +++ b/examples/demo_network_explorer.ipynb @@ -8,7 +8,6 @@ "outputs": [], "source": [ "import pypowsybl.network as pn\n", - "import pypowsybl.loadflow as lf\n", "from pypowsybl_jupyter import network_explorer" ] }, @@ -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": { diff --git a/examples/demo_sld_simple.ipynb b/examples/demo_sld_simple.ipynb index df4074a..dfc1468 100644 --- a/examples/demo_sld_simple.ipynb +++ b/examples/demo_sld_simple.ipynb @@ -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": { @@ -49,7 +61,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.2" + "version": "3.12.3" } }, "nbformat": 4, diff --git a/src/pypowsybl_jupyter/networkexplorer.py b/src/pypowsybl_jupyter/networkexplorer.py index cc2f69e..2f8a92b 100644 --- a/src/pypowsybl_jupyter/networkexplorer.py +++ b/src/pypowsybl_jupyter/networkexplorer.py @@ -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. @@ -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