Skip to main content

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

Project description

.. image:: https://github.com/tylertrimble/viswaternet/blob/main/logo/viswaternet_logo.png?raw=true :target: https://github.com/tylertrimble/viswaternet/blob/main/logo/viswaternet_logo.png?raw=true

.. image:: https://joss.theoj.org/papers/10.21105/joss.05139/status.svg :target: https://doi.org/10.21105/joss.05139

.. image:: https://img.shields.io/pypi/v/viswaternet.svg :target: https://pypi.python.org/pypi/viswaternet

.. image:: https://readthedocs.org/projects/viswaternet/badge/?version=latest :target: https://viswaternet.readthedocs.io/en/latest/ :alt: Documentation Status

.. image:: https://img.shields.io/pypi/l/ansicolortags.svg :target: https://pypi.python.org/pypi/ansicolortags/

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

.. _documentation here: https://viswaternet.readthedocs.io

Dependencies

â—‰ WNTR â—‰ NetworkX 2.7+ â—‰ Matplotlib 3.5.0+ â—‰ Pandas â—‰ NumPy â—‰ imageio â—‰

VisWaterNet has been tested on Python 3.8+.

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:

.. code:: python

pip install viswaternet

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

.. code:: python

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

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

.. code:: python

python setup.py install

Getting Started

To get started, import the VisWaterNet package:

.. code:: python

import viswaternet as vis

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

.. code:: python

model = vis.VisWNModel('Networks/CTown.inp')
style = vis.NetworkStyle(discrete_legend_loc='lower left', legend_sig_figs=0)

.. _Ostfeld (2016): https://uknowledge.uky.edu/wdst_models/2/

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:

.. code:: python

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

.. figure:: logo/readme1.png :width: 600 :alt: 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:

.. code:: python

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

.. figure:: logo/readme2.png :width: 600 :alt: 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:

.. code:: python

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.

.. _Matplotlib docs: https://matplotlib.org/stable/index.html .. _colors: https://matplotlib.org/stable/gallery/color/named_colors.html .. _colorbars: https://matplotlib.org/stable/tutorials/colors/colormaps.html#sphx-glr-tutorials-colors-colormaps-py .. _node markers: https://matplotlib.org/stable/gallery/lines_bars_and_markers/marker_reference.html .. _line styles: https://matplotlib.org/stable/gallery/lines_bars_and_markers/linestyles.html

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

.. _Example Applications: https://viswaternet.readthedocs.io/en/latest/examples.html

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_.

.. _CONTRIBUTING page: https://github.com/tylertrimble/viswaternet/blob/main/CONTRIBUTING.rst .. _docs: https://viswaternet.readthedocs.io/en/latest/contributing.html .. _run automated tests: https://viswaternet.readthedocs.io/en/latest/contributing.html#testing

Cite Us

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

.. _VisWaterNet: A Python package for visualization of water distribution networks: https://joss.theoj.org/papers/10.21105/joss.05139

::

@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.

.. _Cookiecutter: https://github.com/audreyr/cookiecutter .. _audreyr/cookiecutter-pypackage: https://github.com/audreyr/cookiecutter-pypackage

======= History

2.2.2 (2024-10-22)

*Fixed draw_links() issue when trying to customize specific links. *Fixed default style typo causing error when link color is not specified.

2.2.1 (2024-7-30)

*Fix bug with models that use the same names for pipes and nodes. *Allow for custom color maps

2.2.0 (2024-7-30)

*Added additional colorbar style options: Colorbar location, label location, font color, and font size. *Updated Python dependency to be 3.8+

2.1.0 (2024-05-25)

  • Added new style object
  • Converted all functions to work with style objects

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.2.3.tar.gz (11.7 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

viswaternet-2.2.3-py2.py3-none-any.whl (41.1 kB view details)

Uploaded Python 2Python 3

File details

Details for the file viswaternet-2.2.3.tar.gz.

File metadata

  • Download URL: viswaternet-2.2.3.tar.gz
  • Upload date:
  • Size: 11.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for viswaternet-2.2.3.tar.gz
Algorithm Hash digest
SHA256 9d0c782c4f5684d4913f2f5814565d1f2cc9abd38603366f6da1b2e51d66f48d
MD5 b40058e462721ff800affa6798a33495
BLAKE2b-256 9186e545a651efdcf4c89f340a4869e82907f596f3e4822c12277c8f38d5322e

See more details on using hashes here.

File details

Details for the file viswaternet-2.2.3-py2.py3-none-any.whl.

File metadata

  • Download URL: viswaternet-2.2.3-py2.py3-none-any.whl
  • Upload date:
  • Size: 41.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for viswaternet-2.2.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 ede516471e122775d0bdc86a3f7c828a68e0424a3c5b3d4786215fb2d747bcc5
MD5 d2cfe5f93c182a3d5e2bce9db9f5b33b
BLAKE2b-256 78442fc6a4dd5a3c1946bea6efe6891821bf5f6a15bfc05bce21ac20894f9522

See more details on using hashes here.

Supported by

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