NodeRegistry#
module wntr.network.model
- class NodeRegistry[source]#
Bases:
Registry
A registry for nodes.
- add_junction(name, base_demand=0.0, demand_pattern=None, elevation=0.0, coordinates=None, demand_category=None, emitter_coeff=None, initial_quality=None)[source]#
Adds a junction to the water network model.
- Parameters:
name (string) – Name of the junction.
base_demand (float) – Base demand at the junction.
demand_pattern (string or Pattern) – Name of the demand pattern or the Pattern object
elevation (float) – Elevation of the junction.
coordinates (tuple of floats, optional) – X-Y coordinates of the node location.
demand_category (str, optional) – Category to the base demand
emitter_coeff (float, optional) – Emitter coefficient
initial_quality (float, optional) – Initial quality at this junction
- add_reservoir(name, base_head=0.0, head_pattern=None, coordinates=None)[source]#
Adds a reservoir to the water network model.
- add_tank(name, elevation=0.0, init_level=3.048, min_level=0.0, max_level=6.096, diameter=15.24, min_vol=0.0, vol_curve=None, overflow=False, coordinates=None)[source]#
Adds a tank to the water network model.
- Parameters:
name (string) – Name of the tank.
elevation (float) – Elevation at the tank.
init_level (float) – Initial tank level.
min_level (float) – Minimum tank level.
max_level (float) – Maximum tank level.
diameter (float) – Tank diameter of a cylindrical tank (only used when the volume curve is None)
min_vol (float) – Minimum tank volume (only used when the volume curve is None)
vol_curve (string, optional) – Name of a volume curve. The volume curve overrides the tank diameter and minimum volume.
overflow (bool, optional) – Overflow indicator (Always False for the WNTRSimulator)
coordinates (tuple of floats, optional) – X-Y coordinates of the node location.
- add_usage(key, *args)#
add args to usage[key]
- clear() None. Remove all items from D. #
- clear_usage(key)#
if key in usage, clear usage[key]
- get(k[, d]) D[k] if k in D, else d. d defaults to None. #
- get_usage(key)#
Get a set of items using an object by key.
- Returns:
Set of (name, typestr) of the external object using the item
- Return type:
set of 2-tuples
- items() a set-like object providing a view on D's items #
- junctions()[source]#
Generator to get all junctions
- Yields:
name (str) – The name of the junction
node (Junction) – The junction object
- keys() a set-like object providing a view on D's keys #
- orphaned()#
Get a list of orphaned usages.
If removed without appropriate checks, it is possible that a some other item will point to an object that has been deleted. (This is why the user should always use the “remove_*” methods). This method returns a list of names for objects that are referenced, but no longer exist.
- Returns:
The names of any orphaned items
- Return type:
- pop(k[, d]) v, remove specified key and return the corresponding value. #
If key is not found, d is returned if given, otherwise KeyError is raised.
- popitem() (k, v), remove and return some (key, value) pair #
as a 2-tuple; but raise KeyError if D is empty.
- remove_usage(key, *args)#
remove args from usage[key]
- reservoirs()[source]#
Generator to get all reservoirs
- Yields:
name (str) – The name of the reservoir
node (Reservoir) – The reservoir object
- setdefault(k[, d]) D.get(k,d), also set D[k]=d if k not in D #
- tanks()[source]#
Generator to get all tanks
- Yields:
name (str) – The name of the tank
node (Tank) – The tank object
- to_dict()#
Dictionary representation of the registry
- to_list()#
List representation of the registry
- unused()#
Get a list of items which are unused by other objects in the model.
In most cases, this method will give little information. For nodes, however, this method could be important to identify a node which has become completely disconnected from the network. For patterns or curves, it may be used to find extra patterns or curves that are no longer necessary (or which the user forgot ot assign). It is not terribly useful for links.
- Returns:
The names of any unused objects in the registry
- Return type:
- update([E, ]**F) None. Update D from mapping/iterable E and F. #
If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v
- usage()#
Generator to get the usage for all objects in the registry
- Yields:
key (str) – The name of the object in the registry
value (tuple of (str, str)) – Tuple of (name, typestr) of the external items using the object
- values() an object providing a view on D's values #
- property junction_names#
List of names of all junctions
- property reservoir_names#
List of names of all junctions
- property tank_names#
List of names of all junctions