raingages module

Raingages module for the pythonic interface to SWMM5.

class pyswmm.raingages.RainGage(model, raingageid)[source]

Bases: object

Raingage Methods.

Parameters:
  • model (object) – Open Model Instance
  • raingageid (str) – Raingage ID

Examples:

>>> from pyswmm import Simulation, Raingages
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     rg1 = Raingages(sim)["Gage1"]
...     print(rg1.raingageid)
...     for step in simulation:
...         print(rg1.total_precip)
... Gage1
... 0
... 10
rainfall

Get raingage total rainfall rate (like in/hr or mm/hr).

Returns:Parameter Value
Return type:float

Examples:

>>> from pyswmm import Simulation, RainGages
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     rg1 = RainGages(sim)["Gage1"]
...     print(rg1.rainfall)
>>> 1.0
raingageid

Get Rain Gage ID.

Returns:Parameter Value
Return type:float

Examples:

>>> from pyswmm import Simulation, RainGages
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     rg = RainGage(sim)["Gage1"]
...     print(rg.raingageid)
>>> Gage1
snowfall

Get raingage total snowfall rate (like in/hr or mm/hr).

Returns:Parameter Value
Return type:float

Examples:

>>> from pyswmm import Simulation, RainGages
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     rg1 = RainGages(sim)["Gage1"]
...     print(rg1.snowfall)
>>> 0.0
total_precip

Get/set raingage total precipitation rate (like in/hr or mm/hr).

Returns:Parameter Value
Return type:float

Examples:

>>> from pyswmm import Simulation, RainGages
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     rg1 = RainGages(sim)["Gage1"]
...     print(rg1.total_precip)
>>> 1.0

Setting the value

>>> from pyswmm import Simulation, RainGages
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     rg1 = RainGages(sim)["Gage1"]
...     print(rg1.total_precip)
...     rg1.total_precip = 0.2
...     print(rg1.total_precip)
>>> 1.0
>>> 0.2
class pyswmm.raingages.RainGages(model)[source]

Bases: object

Rain Gages Iterator Methods.

Parameters:model (object) – Open Model Instance

Examples:

>>> from pyswmm import Simulation, Nodes
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     for raingage in RainGages(sim):
...         print(raingage)
...         print(raingage.raingageid)
...
>>> <swmm5.RainGage object at 0x031B0350>
>>> Gage1
>>> <swmm5.RainGage object at 0x030693D0>
>>> Gage4
>>> <swmm5.RainGage object at 0x031B0350>
>>> Gage3
>>> <swmm5.RainGage object at 0x030693D0>
>>> Gage10

Iterating over Nodes Object

>>> raingages = RainGages(sim)
>>> for raingage in raingages:
...     print(raingage.raingageid)
>>> Gage1
>>> Gage4
>>> Gage3
>>> Gage10

Testing Existence

>>> raingages = RainGages(sim)
>>> "Gage1" in raingages
>>> True

Initializing a node Object

>>> raingages = RainGages(sim)
>>> gage1 = raingages['Gage1']
>>> print(gage1.total_precip)
>>> 0.04
>>>
>>> gage1.total_precip = 1
>>> print(gage1.total_precip)
>>> 1
next()