subcatchments module

Subcatchments module for the pythonic interface to SWMM5.

class pyswmm.subcatchments.Subcatchments(model)[source]

Bases: object

Subcatchment Iterator Methods.

Parameters:model (object) – Open Model Instance

Examples:

>>> from pyswmm import Simulation, Subcatchments
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     for subcatchment in Subcatchments(sim):
...         print subcatchment
...         print subcatchment.subcatchmentid
...
>>> <swmm5.Subcatchment object at 0x031B0350>
>>> S1
>>> <swmm5.Subcatchment object at 0x030693D0>
>>> S2
>>> <swmm5.Subcatchment object at 0x031B0350>
>>> S3
>>> <swmm5.Subcatchment object at 0x030693D0>
>>> S4

Iterating over Subcatchments Object

>>> subcatchments = Subcatchments(sim)
>>> for subcatchment in subcatchments:
...     print subcatchment.subcatchmentid
>>> S0
>>> S1
>>> S2
>>> S3

Testing Existence

>>> subcatchments = Subcatchments(sim)
>>> "S1" in subcatchments
>>> True

Initializing a subcatchment Object

>>> subcatchments = Subcatchments(sim)
>>> s1 = subcatchments['S1']
>>> print(s1.area)
>>> 12
>>>
>>> s1.area = 200
>>> print(s1.area)
>>> 200
next()
class pyswmm.subcatchments.Subcatchment(model, subcatchmentid)[source]

Bases: object

Subcatchment Methods.

Parameters:
  • model (object) – Open Model Instance
  • subcatchmentid (str) – Subcatchment ID

Examples:

>>> from pyswmm import Simulation, Subcatchments
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     s1 = Subcatchments(sim)["S1"]
...     print s1.rainfall
...     for step in simulation:
...         print s1.rainfall
... 0.04
area

Get/set subcatchment area.

Returns:Parameter Value
Return type:float

Examples:

>>> from pyswmm import Simulation, Subcatchments
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     s1 = Subcatchments(sim)["S1"]
...     print s1.area
>>> 10

Setting the value

>>> from pyswmm import Simulation, Subcatchments
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     s1 = Subcatchments(sim)["S1"]
...     print s1.area
...     s1.area = 50
...     print s1.area
>>> 10
>>> 50
connection

Get Subcatchment Outlet Connection.

This function return the type of loading surface and the ID. The two load to objects are nodes and other subcatchments.

Node 2
Subcatchment 1
Returns:(Loading Surface Type, ID)
Return type:tuple

Examples:

>>> from pyswmm import Simulation, Subcatchments
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     s1 = Subcatchments(sim)["S1"]
...     print s1.connection
>>> (2, 'J2')
curb_length

Get/set subcatchment curb length.

Returns:Parameter Value
Return type:float

Examples:

>>> from pyswmm import Simulation, Subcatchments
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     s1 = Subcatchments(sim)["S1"]
...     print s1.curb_length
>>> 0

Setting the value

>>> from pyswmm import Simulation, Subcatchments
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     s1 = Subcatchments(sim)["S1"]
...     print s1.curb_length
...     s1.curb_length = 100
...     print s1.curb_length
>>> 0
>>> 100
evaporation_loss

Get Subcatchment Results for evaporation loss.

If Simulation is not running this method will raise a warning and return 0.

Returns:Parameter Value
Return type:float

Examples:

>>> from pyswmm import Simulation, Subcatchments
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     s1 = Subcatchments(sim)["S1"]
...     for step in sim:
...         print s1.evaporation_loss
>>> 0.01
>>> 0.01
>>> 0.01
>>> 0.01
>>> 0.01
infiltration_loss

Get Subcatchment Results for Infiltration Loss.

If Simulation is not running this method will raise a warning and return 0.

Returns:Parameter Value
Return type:float

Examples:

>>> from pyswmm import Simulation, Subcatchments
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     s1 = Subcatchments(sim)["S1"]
...     for step in sim:
...         print s1.infiltration_loss
>>> 0
>>> 0.01
>>> 0.01
>>> 0.01
>>> 0.01
percent_impervious

Get/set subcatchment percent impervious.

Returns:Parameter Value
Return type:float

Examples:

>>> from pyswmm import Simulation, Subcatchments
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     s1 = Subcatchments(sim)["S1"]
...     print s1.percent_impervious
>>> 10

Setting the value

>>> from pyswmm import Simulation, Subcatchments
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     s1 = Subcatchments(sim)["S1"]
...     print s1.percent_impervious
...     s1.percent_impervious = 50
...     print s1.percent_impervious
>>> 10
>>> 50
rainfall

Get Subcatchment Results for Rainfall.

If Simulation is not running this method will raise a warning and return 0.

Returns:Parameter Value
Return type:float

Examples:

>>> from pyswmm import Simulation, Subcatchments
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     s1 = Subcatchments(sim)["S1"]
...     for step in sim:
...         print s1.rainfall
>>> 0
>>> 1.2
>>> 1.5
>>> 1.9
>>> 1.2
runoff

Get Subcatchment Results for Run Off Rate.

If Simulation is not running this method will raise a warning and return 0.

Returns:Parameter Value
Return type:float

Examples:

>>> from pyswmm import Simulation, Subcatchments
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     s1 = Subcatchments(sim)["S1"]
...     for step in sim:
...         print s1.runoff
>>> 0
>>> 0
>>> 0.01
>>> 0
>>> 0
runon

Get Subcatchment Results for Run On.

If Simulation is not running this method will raise a warning and return 0.

Returns:Parameter Value
Return type:float

Examples:

>>> from pyswmm import Simulation, Subcatchments
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     s1 = Subcatchments(sim)["S1"]
...     for step in sim:
...         print s1.runon
>>> 0
>>> 1.2
>>> 1.5
>>> 1.9
>>> 1.2
slope

Get/set subcatchment slope.

Returns:Parameter Value
Return type:float

Examples:

>>> from pyswmm import Simulation, Subcatchments
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     s1 = Subcatchments(sim)["S1"]
...     print s1.slope
>>> 0.01

Setting the value

>>> from pyswmm import Simulation, Subcatchments
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     s1 = Subcatchments(sim)["S1"]
...     print s1.slope
...     s1.slope = 0.02
...     print s1.slope
>>> 0.1
>>> 0.2
snow_depth

Get Subcatchment Results for Snow Depth.

If Simulation is not running this method will raise a warning and return 0.

Returns:Parameter Value
Return type:float

Examples:

>>> from pyswmm import Simulation, Subcatchments
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     s1 = Subcatchments(sim)["S1"]
...     for step in sim:
...         print s1.snow_depth
>>> 0
>>> 0.5
>>> 0.51
>>> 0.52
>>> 0.49
statistics

Subcatchment Flow Stats. The stats returned are rolling/cumulative. Indeces are as follows:

precipitation
runon
evaporation
infiltration
runoff
peak_runoff_rate
pollutant_buildup
Returns:Group of Stats
Return type:dict
subcatchmentid

Get Subcatchment ID.

Returns:Parameter Value
Return type:float

Examples:

>>> from pyswmm import Simulation, Subcatchments
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     s1 = Subcatchments(sim)["S1"]
...     print s1.subcatchmentid
>>> S1
width

Get/set subcatchment width.

Returns:Parameter Value
Return type:float

Examples:

>>> from pyswmm import Simulation, Subcatchments
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     s1 = Subcatchments(sim)["S1"]
...     print s1.width
>>> 100.0

Setting the value

>>> from pyswmm import Simulation, Subcatchments
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     s1 = Subcatchments(sim)["S1"]
...     print s1.width
...     s1.width = 30
...     print s1.width
>>> 100
>>> 30