viswaternet.network package

Submodules

viswaternet.network.initialize module

The viswaternet.network.initalize module contains the code that builds the Viswaternet model. Eacg time you create a new VisWNModel object, you can define styles and parameters independently from other objects.

param inp_file:

The inp file is the EPANET input file. You can obtain this from EPANET by exporting as a Network in EPANET.

type inp_file:

string

param network_model:

If you have already loaded a network with WNTR you can pass it into VisWaterNet. The inp_file still needs to be passed in.

type network_model:

WNTR WaterNetworkModel Object

param figsize:

The figsize of the network plots automatically created by VisWaterNet.

type figsize:

tuple

param axis_frame:

Determines if a frame is drawn around the generated plot.

type axis_frame:

boolean

class viswaternet.network.initialize.VisWNModel(inp_file=None, network_model=None, figsize=(12, 12), axis_frame=False)[source]

Bases: object

animate_plot(function, ax=None, fps=3, first_timestep=0, last_timestep=None, save_name='animation', save_format='mp4', time_unit='s', **kwargs)

Builds .gif file animating network data across timesteps.

Parameters:
  • ax (axes._subplots.AxesSubplot) – Matplotlib axes object.

  • function (viswaternet) –

    One of the general viswaternet drawing functions.

    Usable Functions

    plot_basic_elements

    plot_discrete_nodes

    plot_discrete_links

    plot_continuous_nodes

    plot_continuous_links

    plot_unique_data

  • fps (integer) – Framerate that the .gif file will be generated with.

  • first_timestep (integer) – The starting timestep of the .gif file.

  • last_timestep (integer) – The last timestep of the .gif file.

  • save_name (string) – The file name that will be used when saving the animation.

  • save_format (string) –

    The file format that the animation will be saved to. A comprehensive list of formats can be found on the imageio docs page:

  • time_unit (string) –

    The time unit that will be reported for each frame of the .gif file.

    Time Units

    Default

    \(s\)

    min

    \(min\)

    hr

    \(hr\)

    day

    \(day\)

  • kwargs (Any) – Any arguments for the plotting function passed into the function argument can be passed into animate_plot.

bin_parameter(parameter_results, element_list, num_intervals, intervals='automatic', disable_interval_deleting=False, style=None)

Takes parameter results from get_parameter and puts them into bins.

Parameters:
  • parameter_results (array-like) – The data associated with each node.

  • element_list (array-like) – List of network elements that data will be retrieved for.

  • num_intervals (integer) – The number of intervals. Results in intervals-1 bins.

  • intervals (array-like, string) – If set to ‘automatic’ then intervals are created automatically on an equal interval basis. Otherwise, it is the edges of the intervals to be created. intervals array length should be num_intervals + 1.

  • disable_interval_deleting (boolean) – If True, empty intervals will be automatically deleted.

  • style (VisWaterNet Style Object) – The style object to be used.

convert_excel(file, parameter_type, data_type, element_index, value_index)
draw_base_elements(ax, draw_nodes=True, element_list=None, draw_originator=None, style=None)

Draws base elements (draw_nodes, draw_links, draw_reservoirs, draw_tanks, draw_pumps, and draw_valves) without any data associated with the elements.

Parameters:
  • ax (axes._subplots.AxesSubplot) – Matplotlib axes object.

  • draw_nodes (boolean) – Determines if base draw_nodes with no data associated with them are drawn. Set to False for all functions excep plot_basic_elements by default.

  • element_list (array-like) – The list of elements being drawn. Can either be links or nodes, but not a combination. When this is None, all links/nodes are drawn, but if not None only the ones listed are drawn.

  • draw_originator (string) – Used with element_list and stores whether the elements being drawn are nodes or links.

  • style (VisWaterNet Style Object) – The style object to be used.

draw_color_bar(ax, g, color_bar_title=None, style=None)

Draws the color bar for all continuous plotting functions. Like draw_legends, under normal use, draw_color_bar is not normally called by the user directly, even with more advanced applications. However, some specialized plots may require draw_color_bar to be called directly.

Parameters:
  • ax (axes._subplots.AxesSubplot) – Matplotlib axes object.

  • g (NetworkX path collection) – The list of elements drawn by NetworkX function.

  • color_bar_title (string) – The title of the color bar.

  • style (VisWaterNet Style Object) – The style object to be used.

Draws discretized link data onto the figure.

Parameters:
  • ax (axes._subplots.AxesSubplot) – Matplotlib axes object.

  • element_list (array-like) – List of network elements that data will be retrieved for.

  • intervals (dict) – The dictionary containting the intervals and the draw_links associated with each interval.

  • label_list (string, array-like) – List of labels for each interval.

draw_discrete_nodes(ax, element_list, intervals, label_list=None, style=None)

Draws discretized nodal data onto the figure.

Parameters:
  • ax (axes._subplots.AxesSubplot) – Matplotlib axes object.

  • element_list (array-like) – List of network elements that data will be retrieved for.

  • intervals (dict) – The dictionary containting the intervals and the draw_nodes assocaited with each interval.

  • label_list (string, array-like) – List of labels for each interval.

  • style (VisWaterNet Style Object) – The style object to be used.

draw_label(labels, x_coords, y_coords, ax=None, draw_nodes=None, draw_arrow=True, label_font_size=11, label_text_color='k', label_face_color='white', label_edge_color='k', label_alpha=0.9, label_font_style=None, label_edge_width=None)

Draws customizable labels on the figure. There are two modes of coordinate input: If the ‘draw_nodes’ argument is not specified, then the label coordinates are processed as absolute coordinates with possible values from 0 to 1. For instance, (0,0) would place the label in the bottom left of the figure, while (1,1) would place the label in the top right of the figure. If the ‘draw_nodes’ argument is specified, then the coordinates are processed as coordinates relative to it’s associated node. The scale of the coordinates scaling differs between networks. For instance, (50,100) would place the label 50 units to the right, and 100 units above the associated node.

Parameters:
  • ax (axes._subplots.AxesSubplot) – Matplotlib axes object.

  • labels (string, array-like) – The label(s) textual content.

  • x_coords (integer, array-like) – The x coordinate(s) of the labels.

  • y_coords (integer, array-like) – The y coordinate(s) of the labels.

  • draw_nodes (string, array-like) – A list of the draw_nodes the labels are to be associated with.

  • draw_arrow (boolean) – Determine if an arrow is drawn from the associated draw_nodes to labels.

  • label_font_size (integer) – The font size of the labels.

  • label_text_color (string) – The color of the text of the labels.

  • label_face_color (string) – The face color of the label.

  • label_edge_color (string) – The edge color of the label

  • label_alpha (integer) – The transparency of the label. Takes a value between 0.0 and 1.0.

  • label_font_style (string) – The font style of the label. Takes ‘normal’, ‘italic’, or ‘oblique’.

  • label_edge_width (integer) – The width of the label edge.

draw_legend(ax, intervals=None, title=None, element_size_intervals=None, element_size_legend_title=None, element_size_legend_loc=None, element_size_legend_labels=None, style=None)

Draws the legends for all other plotting functions. There are two legends that might be drawn. One is the base elements legend with displays what markers are associated with each element type (draw_nodes, draw_links, etc.) The other legend is the intervals legend which is the legend for discrete drawing. Under normal use, draw_legends is not normally called by the user directly, even with more advanced applications. However, some specialized plots may require draw_legend to be called directly.

Parameters:
  • ax (axes._subplots.AxesSubplot) – Matplotlib axes object.

  • intervals (array-like, string) – If set to ‘automatic’ then intervals are created automatically on an equal interval basis. Otherwise, it is the edges of the intervals to be created. intervals array length should be num_intervals + 1.

  • color_list (string, array-like) – The list of node colors for each interval. Both cmap and color_list can not be used at the same time to color draw_nodes. If both are, then color_list takes priority.

  • cmap (string) –

    The matplotlib color map to be used for plotting. Refer to matplotlib documentation for possible inputs.

  • title (string) – The title text of the legend.

  • element_size_intervals (integer) – The number of intervals to be used if an element size legend is used.

  • element_size_legend_title (string) – The title of the element size legend.

  • element_size_legend_loc (string) – The location of the element size legend on the figure.

  • element_size_legend_labels (array-like) – The labels of each interval of the element size legend.

  • style (VisWaterNet Style Object) – The style object to be used.

Draws continuous link data onto the figure.

Parameters:
  • ax (axes._subplots.AxesSubplot) – Matplotlib axes object.

  • link_list (string, array-like) – List of draw_links to be drawn.

  • parameter_results (array-like) – The data associated with each node.

  • link_width (string, array-like) –

    The width of the link being drawn. Can either be a single string value or an array of values for each link being drawn.

    Should only be used if calling draw_links() manually.

  • link_style (string, array-like) –

    The style of the link being drawn. Can either be a single string value or an array of values for each link being drawn.

    Should only be used if calling draw_links() manually.

    Refer to the matplotlib documentation for available link styles.

    https://matplotlib.org/stable/gallery/lines_bars_and_markers/linestyles.html

  • link_arrows (string, array-like) –

    Whether arrows should be drawn for each link. Can either be a single string value or an array of values for each link being drawn.

    Should only be used if calling draw_links() manually.

  • link_color (string, array-like) –

    The color the link being drawn. Can either be a single string value or an array of values for each link being drawn.

    Should only be used if calling draw_links() manually.

  • vmin (integer) – The minimum value of the color bar.

  • vmax (integer) – The maximum value of the color bar.

  • label (string, array-like) –

    Labels to be assigned to each of the nodes drawn. Can either be a single string value or an array of values for each node being drawn.

    (Not Implemented Yet)

    Should only be used if calling draw_links() manually.

  • style (VisWaterNet Style Object) – The style object to be used.

draw_nodes(ax, node_list, parameter_results=None, node_size=None, node_shape=None, node_border_width=None, node_border_color=None, node_color=None, vmin=None, vmax=None, label=None, style=None)

Draws continuous nodal data onto the figure.

Parameters:
  • ax (axes._subplots.AxesSubplot) – Matplotlib axes object.

  • node_list (string, array-like) – List of draw_nodes to be drawn.

  • parameter_results (array-like) – The data associated with each node.

  • node_size (integer, array-like) –

    The size of the nodes being drawn. Can either be a single string value or an array of values for each node being drawn.

    Should only be used if calling draw_nodes() manually.

  • node_shape (string, array-like) –

    The shape of the nodes being drawn. Can either be a single string value or an array of values for each node being drawn.

    Should only be used if calling draw_nodes() manually.

    Refer to the matplotlib documentation for available marker types.

    https://matplotlib.org/stable/api/markers_api.html

  • node_border_color (string, array-like) –

    The color of the node borders for the nodes being drawn. Can either be a single string value or an array of values for each node being drawn.

    Should only be used if calling draw_nodes() manually.

  • node_border_width (integer, array-like) –

    The width of the node borders. Can either be a single string value or an array of values for each node being drawn.

    Should only be used if calling draw_nodes() manually.

  • vmin (integer) – The minimum value of the color bar.

  • vmax (integer) – The maximum value of the color bar.

  • label (string, array-like) –

    Labels to be assigned to each of the nodes drawn. Can either be a single string value or an array of values for each node being drawn.

    (Not Implemented Yet)

    Should only be used if calling draw_nodes() manually.

  • style (VisWaterNet Style Object) – The style object to be used.

get_parameter(parameter_type, parameter, value=None, element_list=None, include_tanks=False, include_reservoirs=False, include_pumps=True, include_valves=True)

Retrieves parameters from the network and simulation results

Parameters:
  • parameter_type (string) – The network object the parameter is associated with. Takes either ‘node’ or ‘link’.

  • parameter (string) – The parameter to be plotted. The following is a list of parameters available to use: Static Parameters - base_demand - elevation - emitter_coefficient - initial_quality Time-Dependent Parameters - head - demand - leak_demand - leak_area - leak_discharg_coeff - quality

  • value (integer, string) –

    For time-varying parameters only. Specifies which timestep or data summary will be plotted.

    Possible Inputs

    int

    Plots element data for specified timestep

    ’min’

    Plots minimum data point for each element

    ’max’

    Plots maximum data point for each element

    ’mean’

    Plots mean for each element

    ’stddev’

    Plots standard deviation for each element

    ’range’

    Plots range for each element

  • element_list (array-like) – List of network elements that data will be retrieved for.

  • include_reservoirs (boolean) – Determines if data for draw_reservoirs are retrieved.

  • include_pumps (boolean) – Determines if data for draw_pumps are retrieved.

  • include_valves (boolean) – Determines if data for draw_valves are retrieved.

plot_basic_elements(ax=None, draw_nodes=True, savefig=False, save_name=None, style=None)

User-level function that draws base elements with no data assocaited with them, draws a legend, and saves the figure.

Parameters:
  • ax (axes._subplots.AxesSubplot) – Matplotlib axes object.

  • draw_nodes (boolean) – Determines if base draw_nodes with no data associated with them are drawn. Set to False for all functions excep plot_basic_elements by default.

  • savefig (boolean) – Determines if the figure is saved.

  • save_name (string) –

    The inputted string will be appended to the name of the network.

    Example

    >>>import viswaternet as vis >>>model = vis.VisWNModel(r’Networks/Net3.inp’) … >>>model.save_fig(save_name=’_example’) <Net3_example.png>

  • style (VisWaterNet Style Object) – The style object to be used.

User-level function that draws continuous link data, base elements, legends, and saves the figure.

Parameters:
  • ax (axes._subplots.AxesSubplot) – Matplotlib axes object.

  • parameter (string) –

    The parameter to be plotted. The following is a list of parameters available to use: Static Parameters - length - minor_loss - bulk_coeff - wall_coeff

    Time-Dependent Parameters - flowrate - velocity - headloss - friction_factor - reaction_rate - quality

  • element_list (list) – A list of links for which the parameter will be plotted. By default, this is the list of all link names.

  • include_pumps (boolean) – Determines if data for draw_pumps are retreived.

  • include_valves (boolean) – Determines if data for draw_valves are retrieved

  • value (integer, string) –

    For time-varying parameters only. Specifies which timestep or data summary will be plotted.

    Possible Inputs

    int

    Plots element data for specified timestep

    ’min’

    Plots minimum data point for each element

    ’max’

    Plots maximum data point for each element

    ’mean’

    Plots mean for each element

    ’stddev’

    Plots standard deviation for each element

    ’range’

    Plots range for each element

  • unit (string) – The unit that the network data is to be converted to.

  • vmin (integer) – The minimum value of the color bar.

  • vmax (integer) – The maximum value of the color bar.

  • element_size_intervals (integer) – The number of intervals to be used if an element size legend is used.

  • element_size_legend_title (string) – The title of the element size legend.

  • element_size_legend_loc (string) – The location of the element size legend on the figure.

  • element_size_legend_labels (array-like) – The labels of each interval of the element size legend.

  • color_bar_title (string) – The title of the color bar.

  • savefig (boolean) – Determines if the figure is saved.

  • save_name (string) –

    The inputted string will be appended to the name of the network.

    Example

    >>>import viswaternet as vis >>>model = vis.VisWNModel(r’Networks/Net3.inp’) … >>>model.save_fig(save_name=’_example’) <Net3_example.png>

  • style (VisWaterNet Style Object) – The style object to be used.

plot_continuous_nodes(ax=None, parameter=None, element_list=None, include_tanks=False, include_reservoirs=False, value=None, unit=None, vmin=None, vmax=None, draw_nodes=False, element_size_intervals=None, element_size_legend_title=None, element_size_legend_loc=None, element_size_legend_labels=None, color_bar_title=None, savefig=False, save_name=None, style=None)

User-level function that draws continuous nodal data, base elements, legends, and saves the figure.

Parameters:
  • ax (axes._subplots.AxesSubplot) – Matplotlib axes object.

  • parameter (string) –

    The parameter to be plotted. The following is a list of parameters available to use:

    Static Parameters - base_demand - elevation - emitter_coefficient - initial_quality

    Time-Dependent Parameters - head - demand - pressure - quality - leak_demand - leak_area - leak_discharg_coeff

  • element_list (list) – A list of junctions for which the parameter will be plotted. By default, this is the list of all junction names.

  • include_tanks (boolean) – Determines if data for draw_tanks are retrieved.

  • include_reservoirs (boolean) – Determines if data for draw_reservoirs are retrieved.

  • value (integer, string) –

    For time-varying parameters only. Specifies which timestep or data summary will be plotted.

    Possible Inputs

    int

    Plots element data for specified timestep

    ’min’

    Plots minimum data point for each element

    ’max’

    Plots maximum data point for each element

    ’mean’

    Plots mean for each element

    ’stddev’

    Plots standard deviation for each element

    ’range’

    Plots range for each element

  • unit (string) – The unit that the network data is to be converted to.

  • vmin (integer) – The minimum value of the color bar.

  • vmax (integer) – The maximum value of the color bar.

  • element_size_intervals (integer) – The number of intervals to be used if an element size legend is used.

  • element_size_legend_title (string) – The title of the element size legend.

  • element_size_legend_loc (string) – The location of the element size legend on the figure.

  • element_size_legend_labels (array-like) – The labels of each interval of the element size legend.

  • color_bar_title (string) – The title of the color bar.

  • savefig (boolean) – Determines if the figure is saved.

  • save_name (string) –

    The inputted string will be appended to the name of the network.

    Example

    >>>import viswaternet as vis >>>model = vis.VisWNModel(r’Networks/Net3.inp’) … >>>model.save_fig(save_name=’_example’) <Net3_example.png>

  • style (VisWaterNet Style Object) – The style object to be used.

User-level function that draws discretized link data, base elements, legends, and saves the figure.

Parameters:
  • ax (axes._subplots.AxesSubplot) – Matplotlib axes object.

  • num_intervals (integer) – The number of intervals.

  • parameter (string) –

    The parameter to be plotted. The following is a list of parameters available to use:

    Static Parameters - length - minor_loss - bulk_coeff - wall_coeff

    Time-Dependent Parameters - flowrate - velocity - headloss - friction_factor - reaction_rate - quality

  • value (integer, string) –

    For time-varying parameters only. Specifies which timestep or data summary will be plotted.

    Possible Inputs

    int

    Plots element data for specified timestep

    ’min’

    Plots minimum data point for each element

    ’max’

    Plots maximum data point for each element

    ’mean’

    Plots mean for each element

    ’stddev’

    Plots standard deviation for each element

    ’range’

    Plots range for each element

  • unit (string) – The unit that the network data is to be converted to.

  • element_list (array-like) – List of network elements that data will be retrieved for.

  • include_pumps (boolean) – Determines if data for draw_pumps are retrieved.

  • include_valves (boolean) – Determines if data for draw_valves are retrieved.

  • intervals (integer, string) – If set to ‘automatic’ then intervals are created automatically on an equal interval basis. Otherwise, it is the edges of the intervals to be created. intervals array length should be num_intervals + 1.

  • disable_interval_deleting (boolean) – If True, empty intervals will be automatically deleted.

  • label_list (string, array-like) – List of labels for each interval.

  • draw_nodes (boolean) – Determines if draw_nodes with no data associated with them are drawn.

  • discrete_legend_title (string) – Title of the intervals legend.

  • savefig (boolean) – Determines if the figure is saved.

  • save_name (string) –

    The inputted string will be appended to the name of the network.

    Example

    >>>import viswaternet as vis >>>model = vis.VisWNModel(r’Networks/Net3.inp’) … >>>model.save_fig(save_name=’_example’) <Net3_example.png>

  • style (VisWaterNet Style Object) – The style object to be used.

plot_discrete_nodes(ax=None, num_intervals=5, parameter=None, value=None, unit=None, element_list=None, include_tanks=False, include_reservoirs=False, intervals='automatic', label_list=None, savefig=False, save_name=None, draw_nodes=True, discrete_legend_title=None, disable_interval_deleting=True, style=None)

User-level function that draws discretized nodal data, base elements, legends, and saves the figure.

Parameters:
  • ax (axes._subplots.AxesSubplot) – Matplotlib axes object.

  • num_intervals (integer) – The number of intervals. Results in intervals+1 bins.

  • parameter (string) –

    The parameter to be plotted. The following is a list of parameters available to use:

    Static Parameters - base_demand - elevation - emitter_coefficient - initial_quality

    Time-Dependent Parameters - head - demand - leak_demand - leak_area - leak_discharg_coeff - quality

  • value (integer, string) –

    For time-varying parameters only. Specifies which timestep or data summary will be plotted.

    Possible Inputs

    int

    Plots element data for specified timestep

    ’min’

    Plots minimum data point for each element

    ’max’

    Plots maximum data point for each element

    ’mean’

    Plots mean for each element

    ’stddev’

    Plots standard deviation for each element

    ’range’

    Plots range for each element

  • unit (string) – The unit that the network data is to be converted to.

  • element_list (array-like) – List of network elements that data will be retrieved for.

  • include_tanks (boolean) – Determines if data for draw_tanks are retrieved.

  • include_reservoirs (boolean) – Determines if data for draw_reservoirs are retrieved.

  • intervals (integer, string) – If set to ‘automatic’ then intervals are created automatically on a equal interval basis. Otherwise, it is the edges of the intervals to be created. Intervals array length should be num_intervals + 1.

  • label_list (string, array-like) – List of labels for each interval.

  • draw_nodes (boolean) – Determines if draw_nodes with no data associated with them are drawn.

  • disable_interval_deleting (boolean) – If True, empty intervals will be automatically deleted.

  • discrete_legend_title (string) – Title of the intervals legend.

  • savefig (boolean) – Determines if the figure is saved.

  • save_name (string) –

    The inputted string will be appended to the name of the network.

    Example

    >>>import viswaternet as vis >>>model = vis.VisWNModel(r’Networks/Net3.inp’) … >>>model.save_fig(save_name=’_example’) <Net3_example.png>

  • style (VisWaterNet Style Object) – The style object to be used.

plot_unique_data(ax=None, parameter=None, parameter_type=None, data_type=None, data_file=None, excel_columns=None, custom_data_values=None, unit=None, intervals='automatic', num_intervals=5, label_list=None, vmin=None, vmax=None, draw_nodes=False, discrete_legend_title=None, savefig=False, save_name=None, color_bar_title=None, element_size_intervals=None, element_size_legend_title=None, element_size_legend_loc=None, element_size_legend_labels=None, disable_interval_deleting=True, style=None)

A complex function that accomplishes tasks relating to categorical data, or ‘unique’ as used in viswaternet, as well as data not retrieved from WNTR.

There are three distinct modes of operation, and which one is used is controlled by the ‘parameter’ argument, which differs from previous use of the argument.

Setting the parameter argument to ‘demand_patterns’, ‘diameter’, or ‘roughness’ simply plots that parameter. These parameters are treated differently from others because in usually they are categorical. For instance, pipe diameters are not randomly chosen, and instead are chosen from a list of standard pipe sizes.

When the parameter argument is set to ‘excel_data’, the function deals with excel data, or data imported from an .xlsx file. Two excel columns with elements and data pairs are provided by the user, which are then converted into a format usable by viswaternet for plotting.

When the parameter argument is set to ‘custom_data’, the function deals with data directly inside of python. The user should expect to format the data themselves, although this shouldn’t be difficult. An example of ‘custom_data’ being used can be seen in example 10 located in the github repository.

Parameters:
  • ax (axes._subplots.AxesSubplot) – Matplotlib axes object.

  • parameter (string) – Should be set to ‘demand_patterns’, ‘diameter’, ‘roughness’, ‘custom_data’ or ‘excel_data’.

  • parameter_type (string) – Type of parameter (nodal, link)

  • data_type (string) – The type of data that the excel data is (Unique, continuous, or discrete.)

  • data_file (string) –

  • excel_columns (array-like) –

    Two values should be provided:

    The first should be the excel column that contains element names. Column A in excel is considered the 0th column for use with viswaternet.

    The second should be the excel column that contains element data. Column A in excel is considered the 0th column for use with viswaternet.

    If intending to animate data using this method, all columns except the first column are treated as data columns and will be animated in order.

  • custom_data_values (array-like) –

    Similar to ‘excel_columns’ two values should be provided. The first value should be an array with element names, and the second should be one with the element data.

    If intending to animate data using this method, all values except the first value are treated as data values and will be animated in order. This means that, for example, when animating 10 timesteps using this method you should have 11 arrays inside this array.

  • unit (string) – The unit that the network data is to be converted to.

  • intervals (integer, string) – If set to ‘automatic’ then intervals are created automatically on a equal interval basis. Otherwise, it is the edges of the intervals to be created. intervals array length should be num_intervals + 1.

  • num_intervals (integer) – The number of intervals.

  • disable_interval_deleting (boolean) – If True, empty intervals will be automatically deleted.

  • vmin (integer) – The minimum value of the color bar.

  • vmax (integer) – The maximum value of the color bar.

  • label_list (string, array-like) – List of labels for each interval.

  • draw_nodes (boolean) – Determines if draw_nodes with no data associated with them are drawn.

  • discrete_legend_title (string) – Title of the intervals legend.

  • savefig (boolean) – Determines if the figure is saved.

  • save_name (string) –

    The inputted string will be appended to the name of the network.

    Example

    >>>import viswaternet as vis >>>model = vis.VisWNModel(r’Networks/Net3.inp’) … >>>model.save_fig(save_name=’_example’) <Net3_example.png>

  • color_bar_title (string) – The title of the color bar.

  • element_size_intervals (integer) – The number of intervals to be used if an element size legend is used.

  • element_size_legend_title (string) – The title of the element size legend.

  • element_size_legend_loc (string) – The location of the element size legend on the figure.

  • element_size_legend_labels (array-like) – The labels of each interval of the element size legend.

  • disable_interval_deleting – If True, empty intervals will be automatically deleted.

  • style (VisWaterNet Style Object) – The style object to be used.

viswaternet.network.processing module

The viswaternet.network.processing module contains the code that extracts data from the EPANET simulation. It also handles the binning of parameters for discrete plotting.

viswaternet.network.processing.bin_parameter(self, parameter_results, element_list, num_intervals, intervals='automatic', disable_interval_deleting=False, style=None)[source]

Takes parameter results from get_parameter and puts them into bins.

Parameters:
  • parameter_results (array-like) – The data associated with each node.

  • element_list (array-like) – List of network elements that data will be retrieved for.

  • num_intervals (integer) – The number of intervals. Results in intervals-1 bins.

  • intervals (array-like, string) – If set to ‘automatic’ then intervals are created automatically on an equal interval basis. Otherwise, it is the edges of the intervals to be created. intervals array length should be num_intervals + 1.

  • disable_interval_deleting (boolean) – If True, empty intervals will be automatically deleted.

  • style (VisWaterNet Style Object) – The style object to be used.

viswaternet.network.processing.get_demand_patterns(self)[source]

Retrieves the demand pattern of each node, and bins them accordingly.

viswaternet.network.processing.get_parameter(self, parameter_type, parameter, value=None, element_list=None, include_tanks=False, include_reservoirs=False, include_pumps=True, include_valves=True)[source]

Retrieves parameters from the network and simulation results

Parameters:
  • parameter_type (string) – The network object the parameter is associated with. Takes either ‘node’ or ‘link’.

  • parameter (string) – The parameter to be plotted. The following is a list of parameters available to use: Static Parameters - base_demand - elevation - emitter_coefficient - initial_quality Time-Dependent Parameters - head - demand - leak_demand - leak_area - leak_discharg_coeff - quality

  • value (integer, string) –

    For time-varying parameters only. Specifies which timestep or data summary will be plotted.

    Possible Inputs

    int

    Plots element data for specified timestep

    ’min’

    Plots minimum data point for each element

    ’max’

    Plots maximum data point for each element

    ’mean’

    Plots mean for each element

    ’stddev’

    Plots standard deviation for each element

    ’range’

    Plots range for each element

  • element_list (array-like) – List of network elements that data will be retrieved for.

  • include_reservoirs (boolean) – Determines if data for draw_reservoirs are retrieved.

  • include_pumps (boolean) – Determines if data for draw_pumps are retrieved.

  • include_valves (boolean) – Determines if data for draw_valves are retrieved.

Module contents