EPANET 2.0 calls from python
Project description
Python interface for the popular urban drainage model EPANET 2.0 engine. EPANET2 is realeased by United States Environmental Protection Agency to public domain. This python package is copyrighted by Assela Pathirana and released under GNU General Public License version 3.
README.txt
Epanet 2.0 Python calling interface
Since version 0.4.0.1 the library is compatible with Python 3.0
What is it?
A python package enabling user to call all the epanet programmers toolkit functions within python scripts.
Installation
- Windows:
Download the MS Windows installer and run to install. Since version 0.4.0.1 “python wheels “ packages are also provided. So, the following command can also be used to install on windows
pip install epanettools
- POSIX (e.g. Linux, OS-X):
Download source archive (zip file), extract and run (as root)
[sudo] python setup.py install
or just type
[sudo] pip install epanettools
Usage:
>>> from epanet import epanet2 as et >>> p="epanet/examples/simple/" >>> ret=et.ENopen(p+"Net3.inp",p+"Net3.rpt","")
- Example 1:
Retrieve simulation properties.
Basic properties of the network
>>> ret,result=et.ENgetcount(et.EN_LINKCOUNT) >>> print(ret) 0 >>> print(result) 119 >>> ret,result=et.ENgetcount(et.EN_NODECOUNT) >>> print(ret) 0 >>> print(result) 97 >>> node='105' >>> ret,index=et.ENgetnodeindex(node) >>> print(ret) 0 >>> print ("Node " + node + " has index : " + str(index)) Node 105 has index : 12
Get the list of nodes
>>> ret,nnodes=et.ENgetcount(et.EN_NODECOUNT) >>> nodes=[] >>> pres=[] >>> time=[] >>> for index in range(1,nnodes): ... ret,t=et.ENgetnodeid(index) ... nodes.append(t) ... t=[] ... pres.append(t) >>> print (nodes) #doctest: +ELLIPSIS ... #doctest: +NORMALIZE_WHITESPACE ['10', '15', '20', '35', '40', '50', '60', ..., '275', 'River', 'Lake', '1', '2']
Hydraulic Simulation
>>> et.ENopenH() 0 >>> et.ENinitH(0) 0 >>> while True : ... ret,t=et.ENrunH() ... time.append(t) ... # Retrieve hydraulic results for time t ... for i in range(0,len(nodes)): ... ret,p=et.ENgetnodevalue(i+1, et.EN_PRESSURE ) ... pres[i].append(p) ... ret,tstep=et.ENnextH() ... if (tstep<=0): ... break >>> ret=et.ENcloseH() >>> print([round(x,4) for x in pres[0]]) #doctest: +ELLIPSIS ... #doctest: +NORMALIZE_WHITESPACE [-0.6398, 40.1651, 40.891, 41.0433, ..., 0.569, -0.8864, 0.2997]
Pressure at the node ‘10’
>>> ret,ind=et.ENgetnodeindex("10") >>> print (ind) 1 >>> print([round(x,4) for x in pres[ind+1]]) # remember epanet count starts at 1. ... #doctest: +ELLIPSIS ... #doctest: +NORMALIZE_WHITESPACE [12.5657, 12.9353, 13.4351, 14.0307, ..., 13.1174, 13.3985, 13.5478]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file EPANET-0.4.0.1dev.zip
.
File metadata
- Download URL: EPANET-0.4.0.1dev.zip
- Upload date:
- Size: 152.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7036f48ad30f5881b7341cbf1d8b90aed1d32a924fc8e432f343d8c24c0d1420 |
|
MD5 | caad92659c5a4a29afe772881a4936bf |
|
BLAKE2b-256 | 7a148545ffbcb100f62d7e958cd808a525f7f54b8ca32a4e0fb89af31f70d79b |
File details
Details for the file EPANET-0.4.0.1dev.win-amd64-py3.3.exe
.
File metadata
- Download URL: EPANET-0.4.0.1dev.win-amd64-py3.3.exe
- Upload date:
- Size: 343.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0327f34ba4edbe9f41f6ebb0c303834808f64c0504c74afb87338d7c4207144a |
|
MD5 | 0ba7a49c538a8cbaf40592e8d65fdb6b |
|
BLAKE2b-256 | 298db5bd658ef78e8bc2b040efecda0a8b08eb8097e100b48488394c6d11d6e4 |
File details
Details for the file EPANET-0.4.0.1dev-cp33-none-win_amd64.whl
.
File metadata
- Download URL: EPANET-0.4.0.1dev-cp33-none-win_amd64.whl
- Upload date:
- Size: 119.5 kB
- Tags: CPython 3.3, Windows x86-64
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d4650408651ca2d04b3f2da958f1fbad516edd07252232d275a583546bf2e95 |
|
MD5 | 777b1f057c9d6a6a3ae9e25802f69fc0 |
|
BLAKE2b-256 | 9705b9b61b414b6f7a696758517268f42bee2ed9c257a048c1505bad4c05549f |