Skip to content

tylertrimble/viswaternet

Repository files navigation

image

image

image

Documentation Status

image

An open-source Python package for easy generation and customization of water distribution network visualizations. Find the documentation here.

Dependencies

◉ WNTR ◉ NetworkX 2.7+ ◉ Matplotlib 3.5.0+ ◉ Pandas ◉ NumPy ◉ imageio ◉

VisWaterNet has been tested on Python 3.8 and 3.9.

Features

VisWaterNet is designed to plot simulation data onto a network graph, with a large variety of customization options available. The package includes the capabilities to:

  • Discretize network or simulation data.
  • Visualize discretized or continuous data on network graphs.
  • Import data from excel files or data generated with Python.
  • Create GIFs of data across simulation timesteps.
  • Customize style of virtually every element of the network graph, including: reservoirs, tanks, valves, pumps, links, and nodes.
  • Draw labels relative to nodes or based on an absolute position on the figure.
  • Draw specific nodes or links with their own data and style.

Installation

To install VisWaterNet, run this command in your terminal:

pip install viswaternet

Alternatively, the sources for VisWaterNet can be downloaded from the Github repo. You can clone the public repository:

git clone git://github.com/tylertrimble/viswaternet

Once you have a copy of the source, you can install it with:

python setup.py install

Getting Started

To get started, import the VisWaterNet package:

import viswaternet as vis

Next, initialize a VisWaterNet model. For example purposes, we use the CTown network from Ostfeld (2016) included in the Examples folder:

model = vis.VisWNModel('Networks/CTown.inp')

Then, call on any of the plotting functions with the argument inputs of your choice. For example, the following line of code displays the network layout of CTown with each node colored according its mean pressure (in psi). This is a continuous node plot, where the nodal colors are assigned based a gradient scale:

model.plot_continuous_nodes(parameter="pressure", value='mean', unit="psi")

We can represent the same data in a different way by generating a discrete node plot in which mean pressure data is grouped into 4 discrete intervals and node colors are assigned based on the corresponding value shown on a legend:

model.plot_discrete_nodes(parameter="pressure", value='mean', unit="psi",
                          legend_loc_2 = 'lower left', intervals = [0,40,80,120],
                          legend_sig_figs =0)

If the plot does not show up after you run the script, it is possible that your IDE does not support interactive plotting (e.g., IDLE) or interactive mode is off. To see the plot, add the following line to display the figures:

plt.show()

Since several VisWaterNet function arguments rely on Matplotlib visualization inputs, it is recommended to visit the Matplotlib docs to view customization options for colors, colorbars, node markers, line styles, etc.

More examples that demonstrate the range of VisWaterNet's plotting abilities can be found in the Example Applications section of the docs.

Contributing

We welcome contributions in the form of suggestions, feedback, reports of bugs, and additions to code functionality and documentation from all users! You can find instructions to raise issues, submit pull requests, and run automated tests in the docs or the CONTRIBUTING page.

Cite Us

To cite VisWaterNet, please use the following publication: VisWaterNet: A Python package for visualization of water distribution networks

@article{doi:10.21105/joss.05139,
 title={VisWaterNet: A Python package for visualization of water distribution networks},
 author={Thomas, Meghna and Trimble, Tyler and Sela, Lina},
 journal={Journal of Open Source Software},
 volume={8},
 number={84},
 pages={5139},
 year={2023}}

Contact

Tyler Trimble - tylerl.trimble@utexas.edu

Meghna Thomas - meghnathomas@utexas.edu

Lina Sela - linasela@utexas.edu

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

About

A Python package for easy generation and customization of water distribution network visualizations.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •