Skip to main content

A python package for easy generation and customization of water network graphs.

Project description

https://github.com/tylertrimble/viswaternet/blob/main/logo/viswaternet_logo.png?raw=true https://joss.theoj.org/papers/10.21105/joss.05139/status.svg https://img.shields.io/pypi/v/viswaternet.svg Documentation Status https://img.shields.io/pypi/l/ansicolortags.svg

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")
Basic network layout

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)
Basic network layout

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.

History

2.0.0 (2024-04-12)

  • Added new label customization options

  • Added ability to plot valves as links, and pumps as markers

  • Added EPANET icons for pumps, valves, reservoirs, and tanks.

  • Renamed, consolidated many arguments for clarity and to reduce # of aruments.

  • Removed superfluous arguments.

  • Added ability to make discrete legend text color align with interval color.

  • Legend label colors can now be changed independently for base legend and discrete legend.

  • Title color for discrete legend can now be changed.

  • Rewrote code to use data structures more consistently.

  • Base links and nodes are now only drawn when necessary when not all nodes/links have data associated with them.

  • Added ability to choose to include pump/valve or reservoir/tank data.

  • Further improved animate plot speed for excel data plotting

  • Animate plot output layout now conforms to normal plotting layout.

  • Fixed discrete plotting when empty interval is present.

  • Fixed animation issue where color bar label would be cut off.

  • Fixed animation of custom data and excel data

  • Fixed node size legend not properly showing up

  • Fixed case where base elements legend and discrete legend were joined into one legend

  • Fixed missing argument passes

  • Fixed instances where network elements don’t know show up when they should.

1.2.0 (2023-08-01)

  • Overhauled animate_plot function to allow for plotting of custom data and use different file formats

  • Plotting custom data now uses new parameter data_file instead of parameter

  • Improved initilization time by switching to numpy

  • Fixed blank figure appearing before plotting occurs

1.1.0a (2023-03-15)

  • Fixed colorbar functionality with subplots

  • Added ability to customize colorbar size

  • Legend/colorbar labels are automatically generated based on parameter/value type

  • A default matplotlib figure and axis is created if no axis is specified

  • Fixed deprecation issue with matplotlib colormaps

  • Updated supported versions of dependecies

  • Updated supported python versions

1.0.0 (2023-02-07)

  • Greatly improved animate_plot() function speed

  • Fixed numerous bugs related to excel data plotting

  • Added ability to use directional arrows with continuous plots

0.1.5 (2023-01-22)

  • Complete documentation

  • Fixed animate plot bugs

  • Changed how num_interval parameter works

  • Fixed warnings

0.1.4 (2022-12-19)

  • Updated requirements

0.1.3 (2022-12-17)

  • Bug fixes

  • Some documentation added

0.1.2 (2022-11-11)

  • Rename package once more to avoid confusion with R package ‘visnetwork’.

0.1.1 (2022-11-11)

  • Fix import errors due to package name change.

0.1.0 (2022-11-11)

  • First release on PyPI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

viswaternet-2.0.0.tar.gz (14.0 MB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page