SWMM5 Python calling interface
(c) Assela Pathirana
Released under GNU GPL v.3
[Source code repository](https://github.com/asselapathirana/swmm5-python)
Release History:
----------------
Version 5.2.4
Newer version of swmm (5.2.4)
Support for python 3.11 added
version 5.2.1
----------------
Newer version of swmm (5.2.1)
Support for python 3.10 added.
Still linux version does not work. (removing custom_build_ext gets to build, but causes buffer overflow)
version 5.2.0.post6
(fixed upstream bugs in swmm code https://www.openswmm.org/Topic/31733/undeclared-problems-when-compiling-swmm5-2-on-linux)
However, linux version still not working (Core dumping. For linux, I suggest to use 5.1.015 for the moment!)
version 5.2.000 released in 2022
version 5.1.015 released in 2021
version 1.0.0.1 first production (non-beta) release.
version 1.1.0.1 version with new SWMM 5.1 version (instead of SWMM 5.0)
Installation:
-------------
:Windows:
As of version 1.0.0.1 SWMM5 is verified to work with Python 3 as well.
Now (as of version 1.0.0.1) the package is provided as python Wheel too. This means for windows the following command should install SWMM5
::
pip install SWMM5
Alternatively, use the SWMM5-x.y.z.k.win32.exe file downloaded from the repository for click and install.
If you have your own C compilers, then SWMM5-x.y.z.k.zip can be used to install as
::
python setup.py install
:Linux:
Download SWMM5-x.y.z.k.zip can be used to install as
::
python setup.py install
Or, just with,
::
pip install SWMM5
Usage:
------
:New Interface:
One should always use the new interface. The old interface (below) is left only for backward compatibility. The key features of new interface are
* More pythonic interface
* A number of convenience functions
Import new interface and run SWMM
::
>>> from swmm5.swmm5tools import SWMM5Simulation
>>> st=SWMM5Simulation("swmm5/examples/simple/swmm5Example.inp")
:Example 1: Retrive simulation properties.
::
>>> st.SWMM5_Version() # Version of underlying SWMM5 engine.
'5.2.004'
>>> st.SWMM5_VERSION # same thing as an integer
52004
>>> st.Flow_Units() # Flow units.
'LPS'
>>> st.SWMM_FlowUnits # returns flow units as an index. 0 = CFS, 1 = GPM, 2 = MGD, 3 = CMS, 4 = LPS, and 5 = LPD
4
>>> st.SWMM_Nperiods # number of reporting periods
360
>>> st.SWMM_Nsubcatch # number of subcatchments
6
>>> st.SWMM_Nnodes # number of drainage system nodes
12
>>> st.SWMM_Nlinks # number of drainage system links
11
>>> st.SWMM_Npolluts # number of pollutants tracked
0
>>> print ("%.2f"%st.SWMM_StartDate) # start date of simulation
40844.00
>>> st.SWMM_ReportStep
60
>>>
:Example 2: Prints available entities
::
>>> st.entityList()
['SUBCATCH', 'NODE', 'LINK', 'SYS']
>>> st.Subcatch() # Deprecated
['A2', 'A1', 'A3', 'A4', 'A5', 'E1']
>>> st.entityList(within='SUBCATCH') # use these new since version 5.2
['A2', 'A1', 'A3', 'A4', 'A5', 'E1']
>>> st.Node() # Deprecated
['J1', 'J2', 'J3', 'J4', 'J5', 'J6', 'J7', 'J8', 'J9', 'J10', 'J11', 'J12']
>>> st.entityList(within='NODE') # use these new since version 5.2
['J1', 'J2', 'J3', 'J4', 'J5', 'J6', 'J7', 'J8', 'J9', 'J10', 'J11', 'J12']
>>> st.Link() # Deprecated
['T4-1', 'T4-2', 'T4-3', 'T1-1', 'T1-2', 'T2-1', 'T2-2', 'T2-3', 'T3-1', 'T3-2', 'T5']
>>> st.entityList(within='LINK')
['T4-1', 'T4-2', 'T4-3', 'T1-1', 'T1-2', 'T2-1', 'T2-2', 'T2-3', 'T3-1', 'T3-2', 'T5']
>>> st.Sys() # Deprecated
['SYS']
>>> st.entityList(within='SYS') # use these new since version 5.2
['SYS']
>>> st.Pollutants() # no pollutants in this file.
[]
>>> wq=SWMM5Simulation("swmm5/examples/waterquality/Example5-EXP5.1.inp")
>>> wq.SWMM_Npolluts
1
>>> wq.Pollutants() # TSS in this case.
['TSS']
>>> lst=st.varList("SUBCATCH")
>>> print ("\n".join( "%4i %s"% (i,v) for i,v in enumerate(lst))) # print in a column with index.
0 Rainfall (in/hr or mm/hr)
1 Snow depth (in or mm)
2 Evaporation loss (in/hr or mm/hr)
3 Infiltration loss (in/hr or mm/hr)
4 Runoff rate (flow units)
5 Groundwater outflow rate (flow units)
6 Groundwater water table elevation (ft or m)
7 Soil Moisture (volumetric fraction, less or equal tosoil porosity)
>>> lst=wq.varList("SUBCATCH") # for the network that has pollutants.
>>> print ("\n".join( "%4i %s"% (i,v) for i,v in enumerate(lst))) # print in a column with index.
0 Rainfall (in/hr or mm/hr)
1 Snow depth (in or mm)
2 Evaporation loss (in/hr or mm/hr)
3 Infiltration loss (in/hr or mm/hr)
4 Runoff rate (flow units)
5 Groundwater outflow rate (flow units)
6 Groundwater water table elevation (ft or m)
7 Soil Moisture (volumetric fraction, less or equal tosoil porosity)
8 Runoff concentration of TSS (mg/l)
>>> lst=wq.varList("NODE")
>>> print ("\n".join( "%4i %s"% (i,v) for i,v in enumerate(lst))) # print in a column with index.
0 Depth of water above invert (ft or m)
1 Hydraulic head (ft or m)
2 Volume of stored + ponded water (ft3 or m3)
3 Lateral inflow (flow units)
4 Total inflow (lateral + upstream) (flow units)
5 Flow lost to flooding (flow units)
6 Concentration of TSS (mg/l)
>>> lst=wq.varList("LINK")
>>> print ("\n".join( "%4i %s"% (i,v) for i,v in enumerate(lst))) # print in a column with index.
0 Flow rate (flow units)
1 Flow depth (ft or m)
2 Flow velocity (ft/s or m/s)
3 Froude number
4 Capacity (fraction of conduit filled)
5 Concentration of TSS (mg/l)
>>> lst=wq.varList("SYS")
>>> print ("\n".join( "%4i %s"% (i,v) for i,v in enumerate(lst))) # print in a column with index.
0 Air temperature (deg. F or deg. C)
1 Rainfall (in/hr or mm/hr)
2 Snow depth (in or mm)
3 Evaporation + infiltration loss rate (in/hr or mm/hr)
4 Runoff flow (flow units)
5 Dry weather inflow (flow units)
6 Groundwater inflow (flow units)
7 RDII inflow (flow units)
8 User supplied direct inflow (flow units)
9 Total lateral inflow (sum of variables 4 to 8) (flow units)
10 Flow lost to flooding (flow units)
11 Flow leaving through outfalls (flow units)
12 Volume of stored water (ft3 or m3)
13 Evaporation rate (in/day or mm/day)
14 Potential evaporation rate (PET) in/day or mm/day)
:Example 3: Results
::
>>> r=list(st.Results('NODE','J1', 4)) # total inflow into node "J1". The Results function returns a generator. We convert it to a list.
>>> print ("\n".join( "%5.2f"% (i) for i in r[0:10])) # Lets print the first 10 items.
0.00
0.00
0.00
3.21
12.02
25.68
43.48
61.88
78.69
100.23
>>> r=st.Results('SYS','SYS', 1) #1 Rainfall (in/hr or mm/hr). This time we use the generator directly.
>>> print ("\n".join(["%5.2f"% (i) for i in r])) #doctest: +ELLIPSIS
0.00
0.00
7.20
7.20
7.20
7.60
7.60
7.60
8.00
...
0.00
:Example 4: Pollutant Concentration
::
>>> wq.entityList(within='SUBCATCH')
['S1', 'S2', 'S3', 'S4', 'S5', 'S6', 'S7']
>>> r=list(wq.Results('SUBCATCH','S3', 8)) # TSS out of catchment 'S3'. We convert it to a list.
>>> print ("\n".join( "%5.2f"% (i) for i in r[0:10])) # Lets print the first 10 items. #doctest.NORMALIZE_WHITESPACE
0.00
0.00
0.00
0.00
0.00
13.45
14.11
14.71
15.24
15.70
::
>>> wq.entityList(within='NODE')
['J1', 'J2', 'J3', 'J4', 'J5', 'J6', 'J7', 'J8', 'J9', 'J10', 'J11', 'O1']
>>> r=list(wq.Results('NODE','J3', 6)) # TSS out of Node 'J3'. We convert it to a list.
>>> print ("\n".join( "%5.2f"% (i) for i in r[0:10])) # Lets print the first 10 items.
0.00
0.00
0.00
0.00
0.00
10.73
13.97
14.58
15.14
15.64
>>> wq.entityList(within='LINK')
['C1', 'C2', 'C3', 'C4', 'C5', 'C6', 'C7', 'C8', 'C9', 'C10', 'C11']
>>> r=list(wq.Results('LINK','C11', 5)) # TSS out of Link 'C11'. We convert it to a list.
>>> print ("\n".join( "%5.2f"% (i) for i in r)) # #doctest: +ELLIPSIS
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
6.50
12.81
16.77
19.81
22.73
...
0.00
:Example 5: Get all results once (inefficient, but easy)
::
>>> simtemp=SWMM5Simulation("swmm5/examples/simple/swmm5Example.inp")
>>> ar=simtemp.allResults()
>>> len(ar)
4
>>> list(ar.keys())
['SUBCATCH', 'NODE', 'LINK', 'SYS']
>>> len(ar['NODE'])
12
>>> list(ar['NODE'].keys())
['J1', 'J2', 'J3', 'J4', 'J5', 'J6', 'J7', 'J8', 'J9', 'J10', 'J11', 'J12']
>>> list(ar['NODE']['J1'].keys())[5]
'Flow lost to flooding (flow units)'
>>> max(list(ar['NODE']['J1']['Flow lost to flooding (flow units)'])) # doctest: +ELLIPSIS
4267.9...
>>> # or we can use the index for shorthand
>>> max(list(list(ar['NODE']['J10'].values())[5])) # doctest: +ELLIPSIS
2252.7...
:Example 6: Tracking output files
::
>>> simtemp=SWMM5Simulation("swmm5/examples/simple/swmm5Example.inp")
>>> f=simtemp.getFiles()
>>> f #doctest: +ELLIPSIS
['swmm5/examples/simple/swmm5Example.inp', '...swmm5Example....rpt', '...swmm5Example....dat']
>>> from os.path import isfile
>>> [isfile(x) for x in f] # do they exist in the operating system.
[True, True, True]
>>> simtemp.clean()
>>> [isfile(x) for x in f] # do they exist in the operating system.
[True, False, False]
Thread Safety
-------------
Calling SWMM5Simulation with input file as only argument (SWMM5Simulation will
choose the report and binary output file names) and subsequent use of the object
to retreive results is threadsafe to the degree I could verify.
There is a test ``test_multithreading.py`` in the test directory, which can be run to test this to some degree. It should be run as ``python test_multithreading.py``.
Legacy interface
----------------
:Note: This is provided only for backward compatibility. Always use the new interface (above).
import swmm5 module
::
>>> from swmm5 import swmm5 as sw
>>>
run a sample network
::
>>> ret=sw.RunSwmmDll("./swmm5/examples/simple/swmm5Example.inp","swmm5Example.rpt","swmm5.dat")
>>>
should return 0 if everything is OK (according to to swmm convension)
::
>>> print (ret)
0
>>>
Now it is possible to retrive results.
Open the swmm results file
::
>>> sw.OpenSwmmOutFile("swmm5.dat")
0
>>>
How many time steps are there?
::
>>> sw.cvar.SWMM_Nperiods
360
>>>
Let's retrive rainfall in the system.
Systems rainfall at fifth timestep
::
>>> ret,x=sw.GetSwmmResult(3,0,1,5)
>>> print ('%.2f' % x)
7.20
>>>
Acknowlegements
----------------
* David Townshend
* Tim Cera
Raw data
{
"_id": null,
"home_page": "http://assela.pathirana.net/SWMM5-Python",
"name": "SWMM5",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "Hydraulics,Hydrology,Urban Drainage,Sewerage,Water Engineering,Numerical Methods,Computer Model,Environmental Science,Engineering,Science",
"author": "Assela Pathirana",
"author_email": "assela@pathirana.net",
"download_url": "https://files.pythonhosted.org/packages/20/62/2a6e6a518f73958d7c88f0dff83ad6a3a4d43ed9f3a9108e4d0a687db418/SWMM5-5.2.4.tar.gz",
"platform": null,
"description": "SWMM5 Python calling interface\r\n(c) Assela Pathirana\r\nReleased under GNU GPL v.3\r\n\r\n[Source code repository](https://github.com/asselapathirana/swmm5-python)\r\n\r\nRelease History:\r\n----------------\r\n\r\nVersion 5.2.4\r\nNewer version of swmm (5.2.4)\r\nSupport for python 3.11 added \r\n\r\nversion 5.2.1\r\n----------------\r\n\r\nNewer version of swmm (5.2.1)\r\nSupport for python 3.10 added.\r\nStill linux version does not work. (removing custom_build_ext gets to build, but causes buffer overflow)\r\n\r\nversion 5.2.0.post6\r\n(fixed upstream bugs in swmm code https://www.openswmm.org/Topic/31733/undeclared-problems-when-compiling-swmm5-2-on-linux)\r\nHowever, linux version still not working (Core dumping. For linux, I suggest to use 5.1.015 for the moment!)\r\nversion 5.2.000 released in 2022\r\n\r\nversion 5.1.015 released in 2021\r\n\r\nversion 1.0.0.1 first production (non-beta) release. \r\n\r\nversion 1.1.0.1 version with new SWMM 5.1 version (instead of SWMM 5.0)\r\n\r\n\r\n\r\nInstallation:\r\n-------------\r\n:Windows: \r\n\r\nAs of version 1.0.0.1 SWMM5 is verified to work with Python 3 as well. \r\n\r\nNow (as of version 1.0.0.1) the package is provided as python Wheel too. This means for windows the following command should install SWMM5\r\n\r\n\r\n::\r\n\r\n pip install SWMM5\r\n \r\nAlternatively, use the SWMM5-x.y.z.k.win32.exe file downloaded from the repository for click and install. \r\n\r\nIf you have your own C compilers, then SWMM5-x.y.z.k.zip can be used to install as \r\n\r\n::\r\n\r\n python setup.py install\r\n \r\n:Linux: \r\n\r\nDownload SWMM5-x.y.z.k.zip can be used to install as \r\n\r\n::\r\n\r\n python setup.py install\r\n\r\nOr, just with, \r\n::\r\n\r\n pip install SWMM5\r\n\r\nUsage:\r\n------\r\n\r\n:New Interface:\r\n\r\nOne should always use the new interface. The old interface (below) is left only for backward compatibility. The key features of new interface are \r\n * More pythonic interface\r\n * A number of convenience functions\r\n \r\n Import new interface and run SWMM\r\n\r\n::\r\n\r\n >>> from swmm5.swmm5tools import SWMM5Simulation\r\n >>> st=SWMM5Simulation(\"swmm5/examples/simple/swmm5Example.inp\")\r\n \r\n \r\n \r\n:Example 1: Retrive simulation properties. \r\n\r\n\r\n::\r\n\r\n >>> st.SWMM5_Version() # Version of underlying SWMM5 engine. \r\n '5.2.004'\r\n >>> st.SWMM5_VERSION # same thing as an integer \r\n 52004\r\n >>> st.Flow_Units() # Flow units. \r\n 'LPS'\r\n >>> st.SWMM_FlowUnits # returns flow units as an index. 0 = CFS, 1 = GPM, 2 = MGD, 3 = CMS, 4 = LPS, and 5 = LPD \r\n 4\r\n >>> st.SWMM_Nperiods # number of reporting periods \r\n 360\r\n >>> st.SWMM_Nsubcatch # number of subcatchments\r\n 6\r\n >>> st.SWMM_Nnodes # number of drainage system nodes\r\n 12\r\n >>> st.SWMM_Nlinks # number of drainage system links\r\n 11\r\n >>> st.SWMM_Npolluts # number of pollutants tracked\r\n 0\r\n >>> print (\"%.2f\"%st.SWMM_StartDate) # start date of simulation\r\n 40844.00\r\n >>> st.SWMM_ReportStep\r\n 60\r\n >>>\r\n\r\n:Example 2: Prints available entities\r\n\r\n::\r\n\r\n >>> st.entityList()\r\n ['SUBCATCH', 'NODE', 'LINK', 'SYS']\r\n >>> st.Subcatch() # Deprecated\r\n ['A2', 'A1', 'A3', 'A4', 'A5', 'E1']\r\n >>> st.entityList(within='SUBCATCH') # use these new since version 5.2\r\n ['A2', 'A1', 'A3', 'A4', 'A5', 'E1']\r\n >>> st.Node() # Deprecated\r\n ['J1', 'J2', 'J3', 'J4', 'J5', 'J6', 'J7', 'J8', 'J9', 'J10', 'J11', 'J12']\r\n >>> st.entityList(within='NODE') # use these new since version 5.2\r\n ['J1', 'J2', 'J3', 'J4', 'J5', 'J6', 'J7', 'J8', 'J9', 'J10', 'J11', 'J12']\r\n >>> st.Link() # Deprecated\r\n ['T4-1', 'T4-2', 'T4-3', 'T1-1', 'T1-2', 'T2-1', 'T2-2', 'T2-3', 'T3-1', 'T3-2', 'T5']\r\n >>> st.entityList(within='LINK')\r\n ['T4-1', 'T4-2', 'T4-3', 'T1-1', 'T1-2', 'T2-1', 'T2-2', 'T2-3', 'T3-1', 'T3-2', 'T5']\r\n >>> st.Sys() # Deprecated\r\n ['SYS']\r\n >>> st.entityList(within='SYS') # use these new since version 5.2\r\n ['SYS']\r\n >>> st.Pollutants() # no pollutants in this file. \r\n []\r\n >>> wq=SWMM5Simulation(\"swmm5/examples/waterquality/Example5-EXP5.1.inp\")\r\n >>> wq.SWMM_Npolluts\r\n 1\r\n >>> wq.Pollutants() # TSS in this case. \r\n ['TSS']\r\n >>> lst=st.varList(\"SUBCATCH\")\r\n >>> print (\"\\n\".join( \"%4i %s\"% (i,v) for i,v in enumerate(lst))) # print in a column with index.\r\n 0 Rainfall (in/hr or mm/hr)\r\n 1 Snow depth (in or mm)\r\n 2 Evaporation loss (in/hr or mm/hr)\r\n 3 Infiltration loss (in/hr or mm/hr)\r\n 4 Runoff rate (flow units)\r\n 5 Groundwater outflow rate (flow units)\r\n 6 Groundwater water table elevation (ft or m)\r\n 7 Soil Moisture (volumetric fraction, less or equal tosoil porosity)\r\n\r\n\r\n\r\n >>> lst=wq.varList(\"SUBCATCH\") # for the network that has pollutants. \r\n >>> print (\"\\n\".join( \"%4i %s\"% (i,v) for i,v in enumerate(lst))) # print in a column with index.\r\n 0 Rainfall (in/hr or mm/hr)\r\n 1 Snow depth (in or mm)\r\n 2 Evaporation loss (in/hr or mm/hr)\r\n 3 Infiltration loss (in/hr or mm/hr)\r\n 4 Runoff rate (flow units)\r\n 5 Groundwater outflow rate (flow units)\r\n 6 Groundwater water table elevation (ft or m)\r\n 7 Soil Moisture (volumetric fraction, less or equal tosoil porosity)\r\n 8 Runoff concentration of TSS (mg/l)\r\n \r\n >>> lst=wq.varList(\"NODE\")\r\n >>> print (\"\\n\".join( \"%4i %s\"% (i,v) for i,v in enumerate(lst))) # print in a column with index.\r\n 0 Depth of water above invert (ft or m)\r\n 1 Hydraulic head (ft or m)\r\n 2 Volume of stored + ponded water (ft3 or m3)\r\n 3 Lateral inflow (flow units)\r\n 4 Total inflow (lateral + upstream) (flow units)\r\n 5 Flow lost to flooding (flow units)\r\n 6 Concentration of TSS (mg/l)\r\n >>> lst=wq.varList(\"LINK\")\r\n >>> print (\"\\n\".join( \"%4i %s\"% (i,v) for i,v in enumerate(lst))) # print in a column with index.\r\n 0 Flow rate (flow units)\r\n 1 Flow depth (ft or m)\r\n 2 Flow velocity (ft/s or m/s)\r\n 3 Froude number\r\n 4 Capacity (fraction of conduit filled)\r\n 5 Concentration of TSS (mg/l)\r\n >>> lst=wq.varList(\"SYS\")\r\n >>> print (\"\\n\".join( \"%4i %s\"% (i,v) for i,v in enumerate(lst))) # print in a column with index.\r\n 0 Air temperature (deg. F or deg. C)\r\n 1 Rainfall (in/hr or mm/hr)\r\n 2 Snow depth (in or mm)\r\n 3 Evaporation + infiltration loss rate (in/hr or mm/hr)\r\n 4 Runoff flow (flow units)\r\n 5 Dry weather inflow (flow units)\r\n 6 Groundwater inflow (flow units)\r\n 7 RDII inflow (flow units)\r\n 8 User supplied direct inflow (flow units)\r\n 9 Total lateral inflow (sum of variables 4 to 8) (flow units)\r\n 10 Flow lost to flooding (flow units)\r\n 11 Flow leaving through outfalls (flow units)\r\n 12 Volume of stored water (ft3 or m3)\r\n 13 Evaporation rate (in/day or mm/day)\r\n 14 Potential evaporation rate (PET) in/day or mm/day)\r\n \r\n \r\n \r\n:Example 3: Results\r\n\r\n::\r\n\r\n >>> r=list(st.Results('NODE','J1', 4)) # total inflow into node \"J1\". The Results function returns a generator. We convert it to a list.\r\n >>> print (\"\\n\".join( \"%5.2f\"% (i) for i in r[0:10])) # Lets print the first 10 items. \r\n 0.00\r\n 0.00\r\n 0.00\r\n 3.21\r\n 12.02\r\n 25.68\r\n 43.48\r\n 61.88\r\n 78.69\r\n 100.23\r\n >>> r=st.Results('SYS','SYS', 1) #1 Rainfall (in/hr or mm/hr). This time we use the generator directly. \r\n >>> print (\"\\n\".join([\"%5.2f\"% (i) for i in r])) #doctest: +ELLIPSIS\r\n 0.00\r\n 0.00\r\n 7.20\r\n 7.20\r\n 7.20\r\n 7.60\r\n 7.60\r\n 7.60\r\n 8.00\r\n ...\r\n 0.00\r\n \r\n\r\n:Example 4: Pollutant Concentration\r\n\r\n::\r\n\r\n >>> wq.entityList(within='SUBCATCH')\r\n ['S1', 'S2', 'S3', 'S4', 'S5', 'S6', 'S7']\r\n\t\r\n >>> r=list(wq.Results('SUBCATCH','S3', 8)) # TSS out of catchment 'S3'. We convert it to a list.\r\n >>> print (\"\\n\".join( \"%5.2f\"% (i) for i in r[0:10])) # Lets print the first 10 items. #doctest.NORMALIZE_WHITESPACE\r\n 0.00\r\n 0.00\r\n 0.00\r\n 0.00\r\n 0.00\r\n 13.45\r\n 14.11\r\n 14.71\r\n 15.24\r\n 15.70\r\n\r\n\t\r\n::\r\n\r\n >>> wq.entityList(within='NODE')\r\n ['J1', 'J2', 'J3', 'J4', 'J5', 'J6', 'J7', 'J8', 'J9', 'J10', 'J11', 'O1']\r\n\t\r\n >>> r=list(wq.Results('NODE','J3', 6)) # TSS out of Node 'J3'. We convert it to a list.\r\n >>> print (\"\\n\".join( \"%5.2f\"% (i) for i in r[0:10])) # Lets print the first 10 items. \r\n 0.00\r\n 0.00\r\n 0.00\r\n 0.00\r\n 0.00\r\n 10.73\r\n 13.97\r\n 14.58\r\n 15.14\r\n 15.64\r\n\r\n >>> wq.entityList(within='LINK')\r\n ['C1', 'C2', 'C3', 'C4', 'C5', 'C6', 'C7', 'C8', 'C9', 'C10', 'C11']\r\n\t\r\n >>> r=list(wq.Results('LINK','C11', 5)) # TSS out of Link 'C11'. We convert it to a list.\r\n >>> print (\"\\n\".join( \"%5.2f\"% (i) for i in r)) # #doctest: +ELLIPSIS\r\n 0.00\r\n 0.00\r\n 0.00\r\n 0.00\r\n 0.00\r\n 0.00\r\n 0.00\r\n 0.00\r\n 0.00\r\n 0.00\r\n 0.00\r\n 0.00\r\n 6.50\r\n 12.81\r\n 16.77\r\n 19.81\r\n 22.73\r\n ...\r\n 0.00\r\n\r\n:Example 5: Get all results once (inefficient, but easy)\r\n\r\n::\r\n\r\n >>> simtemp=SWMM5Simulation(\"swmm5/examples/simple/swmm5Example.inp\")\r\n >>> ar=simtemp.allResults()\r\n >>> len(ar)\r\n 4\r\n >>> list(ar.keys())\r\n ['SUBCATCH', 'NODE', 'LINK', 'SYS']\r\n >>> len(ar['NODE'])\r\n 12\r\n >>> list(ar['NODE'].keys())\r\n ['J1', 'J2', 'J3', 'J4', 'J5', 'J6', 'J7', 'J8', 'J9', 'J10', 'J11', 'J12']\r\n >>> list(ar['NODE']['J1'].keys())[5]\r\n 'Flow lost to flooding (flow units)'\r\n >>> max(list(ar['NODE']['J1']['Flow lost to flooding (flow units)'])) # doctest: +ELLIPSIS\r\n 4267.9...\r\n >>> # or we can use the index for shorthand\r\n >>> max(list(list(ar['NODE']['J10'].values())[5])) # doctest: +ELLIPSIS\r\n 2252.7...\r\n\r\n\r\n:Example 6: Tracking output files\r\n\r\n::\r\n\r\n >>> simtemp=SWMM5Simulation(\"swmm5/examples/simple/swmm5Example.inp\")\r\n >>> f=simtemp.getFiles()\r\n >>> f #doctest: +ELLIPSIS\r\n ['swmm5/examples/simple/swmm5Example.inp', '...swmm5Example....rpt', '...swmm5Example....dat']\r\n >>> from os.path import isfile\r\n >>> [isfile(x) for x in f] # do they exist in the operating system. \r\n [True, True, True]\r\n >>> simtemp.clean()\r\n >>> [isfile(x) for x in f] # do they exist in the operating system. \r\n [True, False, False]\r\n \r\nThread Safety\r\n-------------\r\nCalling SWMM5Simulation with input file as only argument (SWMM5Simulation will \r\nchoose the report and binary output file names) and subsequent use of the object \r\nto retreive results is threadsafe to the degree I could verify. \r\n\r\nThere is a test ``test_multithreading.py`` in the test directory, which can be run to test this to some degree. It should be run as ``python test_multithreading.py``. \r\n\r\n\r\n \r\nLegacy interface \r\n----------------\r\n\r\n:Note: This is provided only for backward compatibility. Always use the new interface (above). \r\n\r\nimport swmm5 module\r\n\r\n::\r\n\r\n >>> from swmm5 import swmm5 as sw\r\n >>>\r\n \r\nrun a sample network\r\n\r\n::\r\n\r\n >>> ret=sw.RunSwmmDll(\"./swmm5/examples/simple/swmm5Example.inp\",\"swmm5Example.rpt\",\"swmm5.dat\")\r\n >>>\r\n\r\n\r\nshould return 0 if everything is OK (according to to swmm convension)\r\n\r\n::\r\n\r\n >>> print (ret)\r\n 0\r\n >>>\r\n\r\nNow it is possible to retrive results. \r\nOpen the swmm results file\r\n\r\n::\r\n\r\n >>> sw.OpenSwmmOutFile(\"swmm5.dat\")\r\n 0\r\n >>>\r\n \r\nHow many time steps are there?\r\n\r\n::\r\n\r\n >>> sw.cvar.SWMM_Nperiods\r\n 360\r\n >>>\r\n\r\nLet's retrive rainfall in the system. \r\nSystems rainfall at fifth timestep\r\n::\r\n \r\n >>> ret,x=sw.GetSwmmResult(3,0,1,5)\r\n >>> print ('%.2f' % x)\r\n 7.20\r\n >>>\r\n\r\n\r\n\r\nAcknowlegements\r\n----------------\r\n * David Townshend \r\n * Tim Cera\r\n",
"bugtrack_url": null,
"license": "GNU General Public License version 3",
"summary": "SWMM5 calls from python",
"version": "5.2.4",
"project_urls": {
"Homepage": "http://assela.pathirana.net/SWMM5-Python"
},
"split_keywords": [
"hydraulics",
"hydrology",
"urban drainage",
"sewerage",
"water engineering",
"numerical methods",
"computer model",
"environmental science",
"engineering",
"science"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "bef431e3fb6ae5acada1eeb2ae58e1dc49638a1e3c2a33074c705ca6df9963f3",
"md5": "79dcd7cfc52b4fea3149248625eb43f8",
"sha256": "04d806dc5ce35912df09f33ecd2976d23e6da86183dc0fa53eed5964a59bd643"
},
"downloads": -1,
"filename": "SWMM5-5.2.4-cp311-cp311-win_amd64.whl",
"has_sig": false,
"md5_digest": "79dcd7cfc52b4fea3149248625eb43f8",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": null,
"size": 283702,
"upload_time": "2024-03-13T15:38:17",
"upload_time_iso_8601": "2024-03-13T15:38:17.039794Z",
"url": "https://files.pythonhosted.org/packages/be/f4/31e3fb6ae5acada1eeb2ae58e1dc49638a1e3c2a33074c705ca6df9963f3/SWMM5-5.2.4-cp311-cp311-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "20622a6e6a518f73958d7c88f0dff83ad6a3a4d43ed9f3a9108e4d0a687db418",
"md5": "a7fbb1fffefc6014dba6b430203ff483",
"sha256": "575924391767c138d859f12ce591be39734cdb1740e7c235f14c07e8ce594d16"
},
"downloads": -1,
"filename": "SWMM5-5.2.4.tar.gz",
"has_sig": false,
"md5_digest": "a7fbb1fffefc6014dba6b430203ff483",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 528798,
"upload_time": "2024-03-13T15:38:19",
"upload_time_iso_8601": "2024-03-13T15:38:19.239788Z",
"url": "https://files.pythonhosted.org/packages/20/62/2a6e6a518f73958d7c88f0dff83ad6a3a4d43ed9f3a9108e4d0a687db418/SWMM5-5.2.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-13 15:38:19",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "swmm5"
}