nodes module

Nodes module for the pythonic interface to SWMM5.

class pyswmm.nodes.Nodes(model)[source]

Bases: object

Node Iterator Methods.

Parameters:model (object) – Open Model Instance

Examples:

>>> from pyswmm import Simulation, Nodes
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     for node in Nodes(sim):
...         print node
...         print node.nodeid
...
>>> <swmm5.Node object at 0x031B0350>
>>> J1
>>> <swmm5.Node object at 0x030693D0>
>>> J2
>>> <swmm5.Node object at 0x031B0350>
>>> J3
>>> <swmm5.Node object at 0x030693D0>
>>> J0

Iterating over Nodes Object

>>> nodes = Nodes(sim)
>>> for node in nodes:
...     print node.nodeid
>>> J0
>>> J1
>>> J2
>>> J3

Testing Existence

>>> nodes = Nodes(sim)
>>> "J1" in nodes
>>> True

Initializing a node Object

>>> nodes = Nodes(sim)
>>> j1 = nodes['J1']
>>> print(j1.invert_elevation)
>>> 12
>>>
>>> j1.invert_elevation = 200
>>> print(j1.invert_elevation)
>>> 200
next()
class pyswmm.nodes.Node(model, nodeid)[source]

Bases: object

Node Methods.

Parameters:
  • model (object) – Open Model Instance
  • nodeid (str) – Node ID

Examples:

>>> from pyswmm import Simulation, Nodes
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     j1 = Nodes(sim)["J1"]
...     print j1.invert_el
...     for step in simulation:
...         print j1.depth
... 0.0
depth

Get Node Results for 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, Nodes
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     j1 = Nodes(sim)["J1"]
...     for step in sim:
...         print j1.depth
>>> 0
>>> 0.5
>>> 0.51
>>> 0.52
>>> 0.49
flooding

Get Node Results for Flooding 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, Nodes
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     j1 = Nodes(sim)["J1"]
...     for step in sim:
...         print j1.flooding
>>> 0
>>> 0
>>> 0.01
>>> 0
>>> 0
full_depth

Get node full depth (Physical Depth of manhole).

Returns:Parameter Value
Return type:float

Examples:

>>> from pyswmm import Simulation, Nodes
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     j1 = Nodes(sim)["J1"]
...     print j1.full_depth
>>> 10

Setting the value

>>> from pyswmm import Simulation, Nodes
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     j1 = Nodes(sim)["J1"]
...     print j1.full_depth
...     j1.full_depth = 50
...     print j1.full_depth
>>> 10
>>> 50
generated_inflow(inflowrate)[source]

Generate and Set a Node Inflow Rate.

The value is held constant in the model until it is redefined. Generated inflows work like any SWMM inflow. This does not introduce any continuity errors since all flows is counted as an inflow.

Parameters:inflowrate (float) – Inflow Rate

Examples:

>>> from pyswmm import Simulation, Nodes
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     j1 = Nodes(sim)["J1"]
...     for step in sim:
...         j1.generated_inflow(9)
>>>
head

Get Node Results for Head.

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, Nodes
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     j1 = Nodes(sim)["J1"]
...     for step in sim:
...         print j1.head
>>> 10
>>> 10.5
>>> 10.51
>>> 10.52
>>> 10.49
initial_depth

Get/set node initial depth.

Returns:Parameter Value
Return type:float

Examples:

>>> from pyswmm import Simulation, Nodes
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     j1 = Nodes(sim)["J1"]
...     print j1.initial_depth
>>> 0

Setting the value

>>> from pyswmm import Simulation, Nodes
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     j1 = Nodes(sim)["J1"]
...     print j1.initial_depth
...     j1.initial_depth = 1
...     print j1.initial_depth
>>> 0
>>> 1
invert_elevation

Get/set node invert elevation.

Returns:Parameter Value
Return type:float

Examples:

>>> from pyswmm import Simulation, Nodes
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     j1 = Nodes(sim)["J1"]
...     print j1.invert_elevation
>>> 0.1

Setting the value

>>> from pyswmm import Simulation, Nodes
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     j1 = Nodes(sim)["J1"]
...     print j1.invert_elevation
...     j1.invert_elevation = 0.2
...     print j1.invert_elevation
>>> 0.1
>>> 0.2
is_divider()[source]

Check if node is a Divider Type.

Returns:is divider
Return type:bool

Examples:

>>> from pyswmm import Simulation, Nodes
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     j1 = Nodes(sim)["J1"]
...     print j1.is_divider()
>>> True
is_junction()[source]

Check if node is a Junction Type.

Returns:is junction
Return type:bool

Examples:

>>> from pyswmm import Simulation, Nodes
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     j1 = Nodes(sim)["J1"]
...     print j1.is_junction()
>>> True
is_outfall()[source]

Check if node is a Outfall Type.

Returns:is outfall
Return type:bool

Examples:

>>> from pyswmm import Simulation, Nodes
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     j1 = Nodes(sim)["J1"]
...     print j1.is_outfall()
>>> True
is_storage()[source]

Check if node is a Storage Type.

Returns:is storage
Return type:bool

Examples:

>>> from pyswmm import Simulation, Nodes
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     j1 = Nodes(sim)["J1"]
...     print j1.is_storage()
>>> True
lateral_inflow

Get Node Results for lateral Inflow 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, Nodes
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     j1 = Nodes(sim)["J1"]
...     for step in sim:
...         print j1.lateral_inflow
>>> 0
>>> 0.25
>>> 0.25
>>> 0.3
>>> 0.4
losses

Get Node Results for Losses Rate (Evap and Exfiltration).

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, Nodes
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     j1 = Nodes(sim)["J1"]
...     for step in sim:
...         print j1.losses
>>> 0
>>> 0.01
>>> 0.01
>>> 0.01
>>> 0.01
nodeid

Get Node ID.

Returns:Parameter Value
Return type:float

Examples:

>>> from pyswmm import Simulation, Nodes
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     j1 = Nodes(sim)["J1"]
...     print j1.nodeid
>>> J1
ponding_area

Get/set node ponding area.

Returns:Parameter Value
Return type:float

Examples:

>>> from pyswmm import Simulation, Nodes
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     j1 = Nodes(sim)["J1"]
...     print j1.ponding_area
>>> 0

Setting the value

>>> from pyswmm import Simulation, Nodes
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     j1 = Nodes(sim)["J1"]
...     print j1.ponding_area
...     j1.ponding_area = 50
...     print j1.ponding_area
>>> 0
>>> 50
statistics

Node Statistics. The stats returned are rolling/cumulative. Indeces are as follows:

average_depth
max_depth
max_depth_date
max_report_depth
flooding_volume
flooding_duration
surcharge_duration
courant_crit_duration
lateral_inflow_vol
peak_lateral_inflowrate
peak_total_inflow
peak_flooding_rate
max_ponded_volume
max_inflow_date
max_flooding_date
Returns:Group of Stats
Return type:dict
surcharge_depth

Get/set node surcharge depth.

Returns:Parameter Value
Return type:float

Examples:

>>> from pyswmm import Simulation, Nodes
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     j1 = Nodes(sim)["J1"]
...     print j1.surcharge_depth
>>> 10

Setting the value

>>> from pyswmm import Simulation, Nodes
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     j1 = Nodes(sim)["J1"]
...     print j1.surcharge_depth
...     j1.surcharge_depth = 50
...     print j1.surcharge_depth
>>> 10
>>> 50
total_inflow

Get Node Results for Total Inflow 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, Nodes
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     j1 = Nodes(sim)["J1"]
...     for step in sim:
...         print j1.total_inflow
>>> 0
>>> 1.2
>>> 1.5
>>> 1.9
>>> 1.2
total_outflow

Get Node Results for Total Outflow 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, Nodes
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     j1 = Nodes(sim)["J1"]
...     for step in sim:
...         print j1.total_outflow
>>> 0
>>> 1.2
>>> 1.5
>>> 1.9
>>> 1.2
volume

Get Node Results for Volume.

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, Nodes
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     j1 = Nodes(sim)["J1"]
...     for step in sim:
...         print j1.volume
>>> 0
>>> 1.2
>>> 1.5
>>> 1.9
>>> 1.2
class pyswmm.nodes.Outfall[source]

Bases: pyswmm.nodes.Node

Outfall Object: Subclass of Node Object.

cumulative_inflow

Get Cumulative Outfall Loading.

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

Returns:Cumulative Volume
Return type:float
outfall_stage(stage)[source]

Generate and Set an Outfall Stage (head).

The value is held constant in the model until it is redefined. Using the function overrides the mechanism within SWMM that would internerally set the outfall stage. This does not introduce any continuity errors since all flows is counted as an inflow.

Parameters:stage (float) – Outfall Stage (Head)

Examples:

>>> from pyswmm import Simulation, Nodes
>>>
>>> with Simulation('tests/data/TestModel1_weirSetting.inp') as sim:
...     j1 = Nodes(sim)["J1"]
...     for step in sim:
...         j1.outfall_stage(9)
>>>
outfall_statistics

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

average_flowrate
peak_flowrate
pollutant_loading
total_periods
Returns:Group of Stats
Return type:list
class pyswmm.nodes.Storage[source]

Bases: pyswmm.nodes.Node

Storage Object: Subclass of Node Object.

storage_statistics

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

initial_volume
average_volume
max_volume
peak_flowrate
evap_loss
exfil_loss
max_vol_date
Returns:Group of Stats
Return type:list