CurveRegistry#
module wntr.network.model
- class CurveRegistry[source]#
Bases:
Registry
A registry for curves.
- add_curve(name, curve_type, xy_tuples_list)[source]#
Adds a curve to the water network model.
- Parameters:
name (string) – Name of the curve.
curve_type (string) – Type of curve. Options are HEAD, EFFICIENCY, VOLUME, HEADLOSS.
xy_tuples_list (list of (x, y) tuples) – List of X-Y coordinate tuples on the curve.
- 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]
- efficiency_curves()[source]#
Generator to get all efficiency curves
- Yields:
name (str) – The name of the curve
curve (Curve) – The efficiency curve object
- 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
- headloss_curves()[source]#
Generator to get all headloss curves
- Yields:
name (str) – The name of the curve
curve (Curve) – The headloss curve object
- items() a set-like object providing a view on D's items #
- 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.
- pump_curves()[source]#
Generator to get all pump curves
- Yields:
name (str) – The name of the curve
curve (Curve) – The pump curve object
- remove_usage(key, *args)#
remove args from usage[key]
- set_curve_type(key, curve_type)[source]#
Sets curve type.
WARNING – this does not check to make sure key is typed before assigning it - you could end up with a curve that is used for more than one type
- setdefault(k[, d]) D.get(k,d), also set D[k]=d if k not in D #
- to_dict()#
Dictionary representation of the registry
- to_list()#
List representation of the registry
- untyped_curves()[source]#
Generator to get all curves without type
- Yields:
name (str) – The name of the curve
curve (Curve) – The untyped curve object
- 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 #
- volume_curves()[source]#
Generator to get all volume curves
- Yields:
name (str) – The name of the curve
curve (Curve) – The volume curve object
- property efficiency_curve_names#
List of names of all efficiency curves
- property headloss_curve_names#
List of names of all headloss curves
- property pump_curve_names#
List of names of all pump curves
- property untyped_curve_names#
List of names of all curves without types
- property volume_curve_names#
List of names of all volume curves