epyt-flow 0.1.1__py3-none-any.whl → 0.3.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.
- epyt_flow/EPANET/compile_linux.sh +4 -0
- epyt_flow/EPANET/compile_macos.sh +4 -0
- epyt_flow/VERSION +1 -1
- epyt_flow/__init__.py +29 -18
- epyt_flow/data/benchmarks/leakdb.py +7 -12
- epyt_flow/data/networks.py +404 -40
- epyt_flow/rest_api/base_handler.py +14 -0
- epyt_flow/rest_api/scada_data/__init__.py +0 -0
- epyt_flow/rest_api/{scada_data_handler.py → scada_data/data_handlers.py} +3 -162
- epyt_flow/rest_api/scada_data/export_handlers.py +140 -0
- epyt_flow/rest_api/scada_data/handlers.py +209 -0
- epyt_flow/rest_api/scenario/__init__.py +0 -0
- epyt_flow/rest_api/scenario/event_handlers.py +118 -0
- epyt_flow/rest_api/{scenario_handler.py → scenario/handlers.py} +86 -67
- epyt_flow/rest_api/scenario/simulation_handlers.py +174 -0
- epyt_flow/rest_api/scenario/uncertainty_handlers.py +118 -0
- epyt_flow/rest_api/server.py +61 -24
- epyt_flow/simulation/events/leakages.py +27 -17
- epyt_flow/simulation/scada/scada_data.py +545 -14
- epyt_flow/simulation/scada/scada_data_export.py +39 -12
- epyt_flow/simulation/scenario_config.py +14 -20
- epyt_flow/simulation/scenario_simulator.py +358 -114
- epyt_flow/simulation/sensor_config.py +693 -37
- epyt_flow/topology.py +149 -8
- epyt_flow/utils.py +75 -18
- {epyt_flow-0.1.1.dist-info → epyt_flow-0.3.0.dist-info}/METADATA +33 -5
- {epyt_flow-0.1.1.dist-info → epyt_flow-0.3.0.dist-info}/RECORD +30 -22
- epyt_flow/EPANET/compile.sh +0 -4
- {epyt_flow-0.1.1.dist-info → epyt_flow-0.3.0.dist-info}/LICENSE +0 -0
- {epyt_flow-0.1.1.dist-info → epyt_flow-0.3.0.dist-info}/WHEEL +0 -0
- {epyt_flow-0.1.1.dist-info → epyt_flow-0.3.0.dist-info}/top_level.txt +0 -0
|
@@ -8,7 +8,8 @@ from scipy.io import savemat
|
|
|
8
8
|
import pandas as pd
|
|
9
9
|
|
|
10
10
|
from .scada_data import ScadaData
|
|
11
|
-
from ..sensor_config import SensorConfig
|
|
11
|
+
from ..sensor_config import SensorConfig, massunit_to_str, flowunit_to_str, qualityunit_to_str, \
|
|
12
|
+
is_flowunit_simetric
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
class ScadaDataExport():
|
|
@@ -73,13 +74,7 @@ class ScadaDataExport():
|
|
|
73
74
|
"""
|
|
74
75
|
old_sensor_config = scada_data.sensor_config
|
|
75
76
|
|
|
76
|
-
sensor_config = SensorConfig(
|
|
77
|
-
links=old_sensor_config.links,
|
|
78
|
-
valves=old_sensor_config.valves,
|
|
79
|
-
pumps=old_sensor_config.pumps,
|
|
80
|
-
tanks=old_sensor_config.tanks,
|
|
81
|
-
bulk_species=old_sensor_config.bulk_species,
|
|
82
|
-
surface_species=old_sensor_config.surface_species)
|
|
77
|
+
sensor_config = SensorConfig.create_empty_sensor_config(old_sensor_config)
|
|
83
78
|
sensor_config.pressure_sensors = sensor_config.nodes
|
|
84
79
|
sensor_config.flow_sensors = sensor_config.links
|
|
85
80
|
sensor_config.demand_sensors = sensor_config.nodes
|
|
@@ -112,13 +107,42 @@ class ScadaDataExport():
|
|
|
112
107
|
"""
|
|
113
108
|
sensor_readings = scada_data.get_data()
|
|
114
109
|
|
|
110
|
+
def __get_sensor_unit(sensor_type):
|
|
111
|
+
if sensor_type == "pressure":
|
|
112
|
+
if is_flowunit_simetric(scada_data.sensor_config.flow_unit):
|
|
113
|
+
return "psi"
|
|
114
|
+
else:
|
|
115
|
+
return "meter"
|
|
116
|
+
elif sensor_type == "flow" or sensor_type == "demand":
|
|
117
|
+
return flowunit_to_str(scada_data.sensor_config.flow_unit)
|
|
118
|
+
elif sensor_type == "quality_node" or sensor_type == "quality_link":
|
|
119
|
+
return qualityunit_to_str(scada_data.sensor_config.quality_unit)
|
|
120
|
+
elif sensor_type == "tank_volume":
|
|
121
|
+
if is_flowunit_simetric(scada_data.sensor_config.flow_unit):
|
|
122
|
+
return "cubic meter"
|
|
123
|
+
else:
|
|
124
|
+
return "cubic foot"
|
|
125
|
+
else:
|
|
126
|
+
return ""
|
|
127
|
+
|
|
115
128
|
col_desc = [None for _ in range(sensor_readings.shape[1])]
|
|
116
129
|
sensor_config = scada_data.sensor_config
|
|
117
130
|
sensors_id_to_idx = sensor_config.sensors_id_to_idx
|
|
118
131
|
for sensor_type in sensors_id_to_idx:
|
|
132
|
+
unit_desc = __get_sensor_unit(sensor_type)
|
|
119
133
|
for item_id in sensors_id_to_idx[sensor_type]:
|
|
120
134
|
col_id = sensors_id_to_idx[sensor_type][item_id]
|
|
121
|
-
|
|
135
|
+
|
|
136
|
+
if sensor_type == "bulk_species_node" or sensor_type == "bulk_species_link":
|
|
137
|
+
bulk_species_idx = sensor_config.bulk_species.index(item_id)
|
|
138
|
+
unit_desc = massunit_to_str(sensor_config.
|
|
139
|
+
bulk_species_mass_unit[bulk_species_idx])
|
|
140
|
+
elif sensor_type == "surface_species":
|
|
141
|
+
surface_species_idx = sensor_config.surface_species.index(item_id)
|
|
142
|
+
unit_desc = massunit_to_str(sensor_config.
|
|
143
|
+
bulk_species_mass_unit[surface_species_idx])
|
|
144
|
+
|
|
145
|
+
col_desc[col_id] = [sensor_type, item_id, unit_desc]
|
|
122
146
|
|
|
123
147
|
return np.array(col_desc, dtype=object)
|
|
124
148
|
|
|
@@ -169,7 +193,8 @@ class ScadaDataNumpyExport(ScadaDataExport):
|
|
|
169
193
|
scada_data.change_sensor_config(old_sensor_config)
|
|
170
194
|
|
|
171
195
|
np.savez(self.f_out, sensor_readings=sensor_readings, col_desc=col_desc,
|
|
172
|
-
sensor_readings_time=sensor_readings_time
|
|
196
|
+
sensor_readings_time=sensor_readings_time,
|
|
197
|
+
flow_unit=scada_data.sensor_config.flow_unit)
|
|
173
198
|
|
|
174
199
|
|
|
175
200
|
class ScadaDataXlsxExport(ScadaDataExport):
|
|
@@ -214,7 +239,7 @@ class ScadaDataXlsxExport(ScadaDataExport):
|
|
|
214
239
|
to_excel(writer, sheet_name="Sensor readings", index=False)
|
|
215
240
|
pd.DataFrame(sensor_readings_time, columns=["Time (s)"]). \
|
|
216
241
|
to_excel(writer, sheet_name="Sensor readings time", index=False)
|
|
217
|
-
pd.DataFrame(col_desc, columns=["Name", "Type", "Location"]). \
|
|
242
|
+
pd.DataFrame(col_desc, columns=["Name", "Type", "Location", "Unit"]). \
|
|
218
243
|
to_excel(writer, sheet_name="Sensors description", index=False)
|
|
219
244
|
|
|
220
245
|
|
|
@@ -252,4 +277,6 @@ class ScadaDataMatlabExport(ScadaDataExport):
|
|
|
252
277
|
scada_data.change_sensor_config(old_sensor_config)
|
|
253
278
|
|
|
254
279
|
savemat(self.f_out, {"sensor_readings": sensor_readings,
|
|
255
|
-
"sensor_readings_time": sensor_readings_time,
|
|
280
|
+
"sensor_readings_time": sensor_readings_time,
|
|
281
|
+
"col_desc": col_desc,
|
|
282
|
+
"flow_unit": scada_data.sensor_config.flow_unit})
|
|
@@ -415,8 +415,8 @@ class ScenarioConfig(Serializable):
|
|
|
415
415
|
general_params["demand_model"] = general_settings["demand_model"]
|
|
416
416
|
if "quality_model" in general_settings.keys():
|
|
417
417
|
general_params["quality_model"] = general_settings["quality_model"]
|
|
418
|
-
if "
|
|
419
|
-
general_params["
|
|
418
|
+
if "flow_units_id" in general_settings.keys():
|
|
419
|
+
general_params["flow_units_id"] = general_settings["flow_units_id"]
|
|
420
420
|
|
|
421
421
|
sensor_config = data["sensors"]
|
|
422
422
|
|
|
@@ -582,24 +582,18 @@ class ScenarioConfig(Serializable):
|
|
|
582
582
|
sensor_config = None
|
|
583
583
|
from .scenario_simulator import ScenarioSimulator
|
|
584
584
|
with ScenarioSimulator(f_inp_in) as scenario:
|
|
585
|
-
sensor_config = SensorConfig(
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
valve_state_sensors=valve_state_sensors,
|
|
598
|
-
pump_state_sensors=pump_state_sensors,
|
|
599
|
-
tank_volume_sensors=tank_volume_sensors,
|
|
600
|
-
bulk_species_node_sensors=bulk_species_node_sensors,
|
|
601
|
-
bulk_species_link_sensors=bulk_species_link_sensors,
|
|
602
|
-
surface_species_sensors=surface_species_sensors)
|
|
585
|
+
sensor_config = SensorConfig.create_empty_sensor_config(scenario.sensor_config)
|
|
586
|
+
sensor_config.pressure_sensors = pressure_sensors
|
|
587
|
+
sensor_config.flow_sensors = flow_sensors
|
|
588
|
+
sensor_config.demand_sensors = demand_sensors
|
|
589
|
+
sensor_config.quality_node_sensors = node_quality_sensors
|
|
590
|
+
sensor_config.quality_link_sensors = link_quality_sensors
|
|
591
|
+
sensor_config.valve_state_sensors = valve_state_sensors
|
|
592
|
+
sensor_config.pump_state_sensors = pump_state_sensors
|
|
593
|
+
sensor_config.tank_volume_sensors = tank_volume_sensors
|
|
594
|
+
sensor_config.bulk_species_node_sensors = bulk_species_node_sensors
|
|
595
|
+
sensor_config.bulk_species_link_sensors = bulk_species_link_sensors
|
|
596
|
+
sensor_config.surface_species_sensors = surface_species_sensors
|
|
603
597
|
|
|
604
598
|
# Create final scenario configuration
|
|
605
599
|
return ScenarioConfig(f_inp_in=f_inp_in, f_msx_in=f_msx_in, general_params=general_params,
|