Data layers

Data layers contain data which are not part of the water network model or graph, but can be used in analysis. Currently, WNTR includes a data format for valve layers; additional data layers can be added in the future.

Valve layer

While valves are typically included in the water network model, the user can also define a valve layer to be used in additional analysis. A valve layer can be used to group links and nodes into segments based on the location of isolation valves. The segments can be used to compute valve layer attributes, including the number of valves surrounding each valve, the increase in segment demand if a given valve is removed, and the increase in segment pipe length if a given valve is removed. See Topographic metrics for more details. An example is included in the graphics section.

In a valve layer, the location of each valve is defined using the link the valve is installed on and the node the valve protects. This information is stored in a pandas DataFrame, which is indexed by valve number with columns named ‘link’ and ‘node.’ For example, the following valve layer defines a valve on Pipe 1 that protects Junction A (Figure 6).

>>> print(valve_layer)
     link        node
0  Pipe 1  Junction A
Valve placement

Figure 6 Example valve placement.

WNTR includes a method to generate valve layers based on random or strategic placement. The following example generates a random valve placement with 40 valves, “head()” is used to return the first 5 rows. The valve layer can be included in water network graphics (Figure 7).

>>> import wntr 

>>> wn = wntr.network.WaterNetworkModel('networks/Net3.inp') 
>>> random_valve_layer = wntr.network.generate_valve_layer(wn, 'random', 40)
>>> print(random_valve_layer.head())
  link node
0  317  273
1  221  161
2  283  239
3  295  249
4  303  257
>>> ax = wntr.graphics.plot_valve_layer(wn, random_valve_layer, add_colorbar=False)
Valve layer

Figure 7 Valve layer using random placement.

The strategic placement specifies the number of pipes (n) from each node that do NOT contain a valve. In this case, n is generally 0, 1, or 2 (i.e., N, N-1, or N-2 valve placement) [WaWC06] [LWFZ17]. For example, if three pipes connect to a node and n = 2, then two of those pipes will not contain a valve and one pipe will contain a valve. The following example generates a strategic N-2 valve placement. The valve layer can be included in water network graphics (Figure 8).

>>> strategic_valve_layer = wntr.network.generate_valve_layer(wn, 'strategic', 2)
>>> ax = wntr.graphics.plot_valve_layer(wn, strategic_valve_layer, add_colorbar=False)
Valve layer

Figure 8 Valve layer using strategic N-2 placement.