epyt-flow 0.11.0__py3-none-any.whl → 0.12.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. epyt_flow/VERSION +1 -1
  2. epyt_flow/data/benchmarks/gecco_water_quality.py +2 -2
  3. epyt_flow/data/benchmarks/leakdb.py +40 -5
  4. epyt_flow/data/benchmarks/water_usage.py +4 -3
  5. epyt_flow/gym/__init__.py +0 -3
  6. epyt_flow/gym/scenario_control_env.py +3 -10
  7. epyt_flow/rest_api/scenario/control_handlers.py +118 -0
  8. epyt_flow/rest_api/scenario/event_handlers.py +114 -1
  9. epyt_flow/rest_api/scenario/handlers.py +33 -0
  10. epyt_flow/rest_api/server.py +14 -2
  11. epyt_flow/simulation/backend/__init__.py +1 -0
  12. epyt_flow/simulation/backend/my_epyt.py +1056 -0
  13. epyt_flow/simulation/events/quality_events.py +3 -1
  14. epyt_flow/simulation/scada/scada_data.py +201 -12
  15. epyt_flow/simulation/scenario_simulator.py +142 -59
  16. epyt_flow/topology.py +8 -7
  17. epyt_flow/utils.py +30 -0
  18. epyt_flow/visualization/scenario_visualizer.py +159 -69
  19. epyt_flow/visualization/visualization_utils.py +144 -17
  20. {epyt_flow-0.11.0.dist-info → epyt_flow-0.12.0.dist-info}/METADATA +4 -4
  21. {epyt_flow-0.11.0.dist-info → epyt_flow-0.12.0.dist-info}/RECORD +24 -27
  22. {epyt_flow-0.11.0.dist-info → epyt_flow-0.12.0.dist-info}/WHEEL +1 -1
  23. epyt_flow/gym/control_gyms.py +0 -55
  24. epyt_flow/metrics.py +0 -471
  25. epyt_flow/models/__init__.py +0 -2
  26. epyt_flow/models/event_detector.py +0 -36
  27. epyt_flow/models/sensor_interpolation_detector.py +0 -123
  28. epyt_flow/simulation/scada/advanced_control.py +0 -138
  29. {epyt_flow-0.11.0.dist-info → epyt_flow-0.12.0.dist-info/licenses}/LICENSE +0 -0
  30. {epyt_flow-0.11.0.dist-info → epyt_flow-0.12.0.dist-info}/top_level.txt +0 -0
@@ -1,138 +0,0 @@
1
- """
2
- Deprecated -- use epyt_flow.simulation.scada.custom_control instead
3
- """
4
- import warnings
5
- from abc import abstractmethod, ABC
6
- import numpy as np
7
- import epyt
8
-
9
- from . import ScadaData
10
-
11
-
12
- warnings.warn("'epyt_flow.simulation.scada.advanced_control' is deprecated and will be removed " +
13
- "in future releases -- use 'epyt_flow.simulation.scada.custom_control' instead")
14
-
15
-
16
- class AdvancedControlModule(ABC):
17
- """
18
- Base class for a control module.
19
-
20
- Attributes
21
- ----------
22
- epanet_api : `epyt.epanet <https://epanet-python-toolkit-epyt.readthedocs.io/en/latest/api.html#epyt.epanet.epanet>`_
23
- API to EPANET and EPANET-MSX. Is set in :func:`init`.
24
- """
25
- def __init__(self, **kwds):
26
- self._epanet_api = None
27
-
28
- super().__init__(**kwds)
29
-
30
- def init(self, epanet_api: epyt.epanet) -> None:
31
- """
32
- Initializes the control module.
33
-
34
- Parameters
35
- ----------
36
- epanet_api : `epyt.epanet <https://epanet-python-toolkit-epyt.readthedocs.io/en/latest/api.html#epyt.epanet.epanet>`_
37
- API to EPANET for implementing the control module.
38
- """
39
- if not isinstance(epanet_api, epyt.epanet):
40
- raise TypeError("'epanet_api' must be an instance of 'epyt.epanet' but not of " +
41
- f"'{type(epanet_api)}'")
42
-
43
- self._epanet_api = epanet_api
44
-
45
- def set_pump_status(self, pump_id: str, status: int) -> None:
46
- """
47
- Sets the status of a pump.
48
-
49
- Parameters
50
- ----------
51
- pump_id : `str`
52
- ID of the pump for which the status is set.
53
- status : `int`
54
- New status of the pump -- either active (i.e. open) or inactive (i.e. closed).
55
-
56
- Must be one of the following constants defined in
57
- :class:`~epyt_flow.simulation.events.actuator_events.ActuatorConstants`:
58
-
59
- - EN_CLOSED = 0
60
- - EN_OPEN = 1
61
- """
62
- pump_idx = self._epanet_api.getLinkPumpNameID().index(pump_id)
63
- pump_link_idx = self._epanet_api.getLinkPumpIndex(pump_idx + 1)
64
- self._epanet_api.setLinkStatus(pump_link_idx, status)
65
-
66
- def set_pump_speed(self, pump_id: str, speed: float) -> None:
67
- """
68
- Sets the speed of a pump.
69
-
70
- Parameters
71
- ----------
72
- pump_id : `str`
73
- ID of the pump for which the pump speed is set.
74
- speed : `float`
75
- New pump speed.
76
- """
77
- pump_idx = self._epanet_api.getLinkPumpNameID().index(pump_id)
78
- pattern_idx = self._epanet_api.getLinkPumpPatternIndex(pump_idx + 1)
79
-
80
- if pattern_idx == 0:
81
- warnings.warn(f"No pattern for pump '{pump_id}' found -- a new pattern is created")
82
- pattern_idx = self._epanet_api.addPattern(f"pump_speed_{pump_id}")
83
- self._epanet_api.setLinkPumpPatternIndex(pattern_idx)
84
-
85
- self._epanet_api.setPattern(pattern_idx, np.array([speed]))
86
-
87
- def set_valve_status(self, valve_id: str, status: int) -> None:
88
- """
89
- Sets the status of a valve.
90
-
91
- Parameters
92
- ----------
93
- valve_id : `str`
94
- ID of the valve for which the status is set.
95
- status : `int`
96
- New status of the valve -- either open or closed.
97
-
98
- Must be one of the following constants defined in
99
- :class:`~epyt_flow.simulation.events.actuator_events.ActuatorConstants`:
100
-
101
- - EN_CLOSED = 0
102
- - EN_OPEN = 1
103
- """
104
- valve_idx = self._epanet_api.getLinkValveNameID().index(valve_id)
105
- valve_link_idx = self._epanet_api.getLinkValveIndex()[valve_idx]
106
- self._epanet_api.setLinkStatus(valve_link_idx, status)
107
-
108
- def set_node_quality_source_value(self, node_id: str, pattern_id: str,
109
- qual_value: float) -> None:
110
- """
111
- Sets the quality source at a particular node to a specific value -- e.g.
112
- setting the chlorine concentration injection to a specified value.
113
-
114
- Parameters
115
- ----------
116
- node_id : `str`
117
- ID of the node.
118
- pattern_id : `str`
119
- ID of the quality pattern at the specific node.
120
- qual_value : `float`
121
- New quality source value.
122
- """
123
- node_idx = self._epanet_api.getNodeIndex(node_id)
124
- pattern_idx = self._epanet_api.getPatternIndex(pattern_id)
125
- self._epanet_api.setNodeSourceQuality(node_idx, 1)
126
- self._epanet_api.setPattern(pattern_idx, np.array([qual_value]))
127
-
128
- @abstractmethod
129
- def step(self, scada_data: ScadaData) -> None:
130
- """
131
- Implements the control algorithm -- i.e. mapping of sensor reading to actions.
132
-
133
- Parameters
134
- ----------
135
- scada_data : :class:`~epyt_flow.simulation.scada.scada_data.ScadaData`
136
- Sensor readings.
137
- """
138
- raise NotImplementedError()