diff --git a/pandapipes/plotting/plotly/simple_plotly.py b/pandapipes/plotting/plotly/simple_plotly.py index 0faee2c8..370b0e8e 100644 --- a/pandapipes/plotting/plotly/simple_plotly.py +++ b/pandapipes/plotting/plotly/simple_plotly.py @@ -5,7 +5,7 @@ import pandas as pd from pandapipes.plotting.plotly.traces import create_junction_trace, create_pipe_trace, \ - create_valve_trace, create_compressor_trace + create_valve_trace, create_compressor_trace, create_press_control_trace from pandapower.plotting.plotly.simple_plotly import _simple_plotly_generic, draw_traces try: @@ -129,15 +129,30 @@ def simple_plotly(net, use_pipe_geodata=None, on_map=False, auto_open=auto_open, showlegend=showlegend) if "valve" in net.keys() and len(net.valve) > 0: + if "source_name" in net.valve.columns: + info = net.valve.apply(lambda x: f"{x['name']}
{x['source_name']}", axis=1) + else: + info = None traces.extend(create_valve_trace(net, valves=net.valve.loc[net.valve.opened].index, size=valve_size, color=valve_color, + infofunc=info, trace_name="open valves")) traces.extend(create_valve_trace(net, valves=net.valve.loc[~net.valve.opened].index, size=valve_size, color=valve_color, dash="dot", + infofunc=info, trace_name="closed valves")) if "compressor" in net.keys() and len(net.compressor) > 0: traces.extend(create_compressor_trace(net, size=compressor_size, color=compressor_color)) + if "press_control" in net.keys() and len(net.press_control) > 0: + traces.extend( + create_press_control_trace(net, size=compressor_size, color="cyan", + trace_name='compressors SPO', + legendgroup='compressors SPO')) + traces.extend(create_junction_trace(net, net.press_control.controlled_junction.values, + color="red", size=10, + trace_name="controlled junction", + legendgroup='compressors SPO')) if additional_traces: if isinstance(additional_traces, dict): traces.append(additional_traces) diff --git a/pandapipes/plotting/plotly/traces.py b/pandapipes/plotting/plotly/traces.py index aa5e029c..8e487114 100644 --- a/pandapipes/plotting/plotly/traces.py +++ b/pandapipes/plotting/plotly/traces.py @@ -85,4 +85,29 @@ def create_compressor_trace(net, compressors=None, use_pipe_geodata=False, size= cmap=cmap, cbar_title=cbar_title, show_colorbar=show_colorbar, cmap_vals=cmap_vals, cmin=cmin, cmax=cmax, cpos=cpos, branch_element=branch_element, separator_element=separator_element, - node_element=node_element, cmap_vals_category="compr_power_mw") \ No newline at end of file + node_element=node_element, cmap_vals_category="compr_power_mw") + + +def create_press_control_trace(net, compressors=None, size=3.0, + color='cyan', infofunc=None, trace_name='pressure controller', + legendgroup='pressure controller'): + branch_element = "press_control" + node_element = "junction" + separator_element = "valve" + respect_valves = False + cmap = None + cbar_title = None + show_colorbar = True + cmap_vals = None + cmin = None + cmax = None + cpos = 1.1 + use_pipe_geodata = False + + return _create_branch_trace(net=net, branches=compressors, use_branch_geodata=use_pipe_geodata, + respect_separators=respect_valves, width=size, color=color, + infofunc=infofunc, trace_name=trace_name, legendgroup=legendgroup, + cmap=cmap, cbar_title=cbar_title, show_colorbar=show_colorbar, + cmap_vals=cmap_vals, cmin=cmin, cmax=cmax, cpos=cpos, + branch_element=branch_element, separator_element=separator_element, + node_element=node_element, cmap_vals_category="controlled_p_bar")