epyt-flow 0.8.0__py3-none-any.whl → 0.9.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/VERSION +1 -1
- epyt_flow/__init__.py +1 -0
- epyt_flow/data/benchmarks/batadal.py +1 -1
- epyt_flow/data/benchmarks/battledim.py +4 -3
- epyt_flow/data/benchmarks/gecco_water_quality.py +4 -4
- epyt_flow/data/benchmarks/leakdb.py +9 -9
- epyt_flow/data/benchmarks/water_usage.py +2 -2
- epyt_flow/data/networks.py +15 -27
- epyt_flow/gym/control_gyms.py +2 -2
- epyt_flow/gym/scenario_control_env.py +1 -1
- epyt_flow/metrics.py +28 -28
- epyt_flow/models/sensor_interpolation_detector.py +3 -3
- epyt_flow/rest_api/base_handler.py +4 -4
- epyt_flow/rest_api/scada_data/data_handlers.py +11 -11
- epyt_flow/rest_api/scada_data/export_handlers.py +2 -2
- epyt_flow/rest_api/scada_data/handlers.py +9 -9
- epyt_flow/rest_api/scenario/event_handlers.py +6 -6
- epyt_flow/rest_api/scenario/handlers.py +15 -15
- epyt_flow/rest_api/scenario/simulation_handlers.py +7 -7
- epyt_flow/rest_api/scenario/uncertainty_handlers.py +6 -6
- epyt_flow/serialization.py +4 -2
- epyt_flow/simulation/events/actuator_events.py +1 -1
- epyt_flow/simulation/events/leakages.py +1 -1
- epyt_flow/simulation/events/quality_events.py +16 -5
- epyt_flow/simulation/events/sensor_reading_attack.py +1 -1
- epyt_flow/simulation/events/sensor_reading_event.py +3 -3
- epyt_flow/simulation/events/system_event.py +1 -1
- epyt_flow/simulation/parallel_simulation.py +1 -1
- epyt_flow/simulation/scada/advanced_control.py +2 -2
- epyt_flow/simulation/scada/scada_data.py +117 -131
- epyt_flow/simulation/scada/scada_data_export.py +1 -1
- epyt_flow/simulation/scenario_config.py +1 -1
- epyt_flow/simulation/scenario_simulator.py +120 -26
- epyt_flow/simulation/scenario_visualizer.py +9 -9
- epyt_flow/simulation/sensor_config.py +22 -28
- epyt_flow/topology.py +2 -2
- epyt_flow/uncertainty/model_uncertainty.py +624 -147
- epyt_flow/uncertainty/sensor_noise.py +94 -19
- epyt_flow/uncertainty/uncertainties.py +4 -4
- epyt_flow/uncertainty/utils.py +7 -7
- epyt_flow/utils.py +9 -8
- {epyt_flow-0.8.0.dist-info → epyt_flow-0.9.0.dist-info}/METADATA +1 -1
- {epyt_flow-0.8.0.dist-info → epyt_flow-0.9.0.dist-info}/RECORD +46 -46
- {epyt_flow-0.8.0.dist-info → epyt_flow-0.9.0.dist-info}/LICENSE +0 -0
- {epyt_flow-0.8.0.dist-info → epyt_flow-0.9.0.dist-info}/WHEEL +0 -0
- {epyt_flow-0.8.0.dist-info → epyt_flow-0.9.0.dist-info}/top_level.txt +0 -0
epyt_flow/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.9.0
|
epyt_flow/__init__.py
CHANGED
|
@@ -91,7 +91,7 @@ def load_data(download_dir: str = None, return_X_y: bool = False,
|
|
|
91
91
|
`dict`
|
|
92
92
|
Dictionary of the loaded benchmark data. The dictionary contains the two training
|
|
93
93
|
data sets ("train_1" and "train_2"), as well as the test data set ("test").
|
|
94
|
-
If `return_X_y` is False, each dictionary entry is a Pandas dataframe.
|
|
94
|
+
If `return_X_y` is False, each dictionary entry is a `Pandas dataframe <https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.html>`_.
|
|
95
95
|
Otherwise, it is a tuple of sensor readings and labels (except for the test set) --
|
|
96
96
|
if `return_ground_truth` is True or `return_features_desc` is True, the corresponding
|
|
97
97
|
data is appended to the tuple.
|
|
@@ -286,7 +286,7 @@ def load_data(return_test_scenario: bool, download_dir: str = None, return_X_y:
|
|
|
286
286
|
|
|
287
287
|
Returns
|
|
288
288
|
-------
|
|
289
|
-
Either a `pandas.DataFrame
|
|
289
|
+
Either a `pandas.DataFrame <https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.html>`_ instance or a tuple of `Numpy arrays <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_.
|
|
290
290
|
Benchmark data set.
|
|
291
291
|
"""
|
|
292
292
|
# Download data files if necessary
|
|
@@ -389,8 +389,9 @@ def load_scada_data(return_test_scenario: bool, download_dir: str = None,
|
|
|
389
389
|
:class:`~epyt_flow.simulation.scada.scada_data.ScadaData` or `list[tuple[numpy.ndarray, numpy.ndarray]]`
|
|
390
390
|
The simulated benchmark scenario as either a
|
|
391
391
|
:class:`~epyt_flow.simulation.scada.scada_data.ScadaData` instance or as a tuple of
|
|
392
|
-
(X, y) Numpy arrays.
|
|
393
|
-
|
|
392
|
+
(X, y) `Numpy arrays <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_.
|
|
393
|
+
If 'return_leak_locations' is True, the leak locations are included
|
|
394
|
+
as an instance of `scipy.sparse.bsr_array <https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.bsr_array.html>`_ as well.
|
|
394
395
|
"""
|
|
395
396
|
download_dir = download_dir if download_dir is not None else get_temp_folder()
|
|
396
397
|
|
|
@@ -31,9 +31,9 @@ def compute_evaluation_score(y_pred: np.ndarray, y: np.ndarray) -> float:
|
|
|
31
31
|
|
|
32
32
|
Parameters
|
|
33
33
|
----------
|
|
34
|
-
y_pred : `numpy.ndarray
|
|
34
|
+
y_pred : `numpy.ndarray <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
|
|
35
35
|
Event indication prediction over time
|
|
36
|
-
y : `numpy.ndarray
|
|
36
|
+
y : `numpy.ndarray <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
|
|
37
37
|
Ground truth event indication over time.
|
|
38
38
|
|
|
39
39
|
Returns
|
|
@@ -85,7 +85,7 @@ def load_gecco2017_water_quality_data(download_dir: str = None, return_X_y: bool
|
|
|
85
85
|
|
|
86
86
|
Returns
|
|
87
87
|
-------
|
|
88
|
-
`pandas.DataFrame
|
|
88
|
+
`pandas.DataFrame <https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.html>`_ or `tuple[numpy.ndarray, numpy.ndarray] <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
|
|
89
89
|
The benchmark data set as either a Pandas data frame or as a pair of (X, y) Numpy arrays.
|
|
90
90
|
"""
|
|
91
91
|
url_data = "https://zenodo.org/records/3884465/files/1_gecco2017_water_quality.csv?download=1"
|
|
@@ -154,7 +154,7 @@ def load_gecco2018_water_quality_data(download_dir: str = None, return_X_y: bool
|
|
|
154
154
|
|
|
155
155
|
Returns
|
|
156
156
|
-------
|
|
157
|
-
`pandas.DataFrame
|
|
157
|
+
`pandas.DataFrame <https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.html>`_ or `tuple[numpy.ndarray, numpy.ndarray] <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
|
|
158
158
|
The benchmark data set as either a Pandas data frame or as a pair of (X, y) Numpy arrays.
|
|
159
159
|
"""
|
|
160
160
|
# Download data if necessary
|
|
@@ -97,7 +97,7 @@ def compute_evaluation_score(scenarios_id: list[int], use_net1: bool,
|
|
|
97
97
|
List of scenarios ID that are to be evaluated -- there is a total number of 1000 scenarios.
|
|
98
98
|
use_net1 : `bool`
|
|
99
99
|
If True, Net1 LeakDB will be used for evaluation, otherwise the Hanoi LeakDB will be used.
|
|
100
|
-
y_pred_labels_per_scenario : `list[numpy.ndarray]
|
|
100
|
+
y_pred_labels_per_scenario : `list[numpy.ndarray] <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
|
|
101
101
|
Predicted binary labels (over time) for each scenario in `scenarios_id`.
|
|
102
102
|
|
|
103
103
|
Returns
|
|
@@ -201,7 +201,7 @@ def load_data(scenarios_id: list[int], use_net1: bool, download_dir: str = None,
|
|
|
201
201
|
The default is False.
|
|
202
202
|
return_leak_locations : `bool`
|
|
203
203
|
If True and if `return_X_y` is True, the leak locations are returned as well --
|
|
204
|
-
as an instance of `scipy.sparse.bsr_array
|
|
204
|
+
as an instance of `scipy.sparse.bsr_array <https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.bsr_array.html>`_.
|
|
205
205
|
|
|
206
206
|
The default is False.
|
|
207
207
|
verbose : `bool`, optional
|
|
@@ -327,7 +327,7 @@ def load_scada_data(scenarios_id: list[int], use_net1: bool = True, download_dir
|
|
|
327
327
|
The default is False.
|
|
328
328
|
return_leak_locations : `bool`
|
|
329
329
|
If True, the leak locations are returned as well --
|
|
330
|
-
as an instance of `scipy.sparse.bsr_array
|
|
330
|
+
as an instance of `scipy.sparse.bsr_array <https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.bsr_array.html>`_.
|
|
331
331
|
|
|
332
332
|
The default is False.
|
|
333
333
|
verbose : `bool`, optional
|
|
@@ -341,7 +341,7 @@ def load_scada_data(scenarios_id: list[int], use_net1: bool = True, download_dir
|
|
|
341
341
|
The simulated benchmark scenarios as either a list of
|
|
342
342
|
:class:`~epyt_flow.simulation.scada.scada_data.ScadaData` instances or as a list of
|
|
343
343
|
(X, y) Numpy arrays. If 'return_leak_locations' is True, the leak locations are included
|
|
344
|
-
as an instance of `scipy.sparse.bsr_array
|
|
344
|
+
as an instance of `scipy.sparse.bsr_array <https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.bsr_array.html>`_ as well.
|
|
345
345
|
"""
|
|
346
346
|
download_dir = download_dir if download_dir is not None else get_temp_folder()
|
|
347
347
|
|
|
@@ -491,9 +491,9 @@ def load_scenarios(scenarios_id: list[int], use_net1: bool = True,
|
|
|
491
491
|
|
|
492
492
|
return dem_final
|
|
493
493
|
|
|
494
|
-
week_pattern_url = "https://
|
|
494
|
+
week_pattern_url = "https://filedn.com/lumBFq2P9S74PNoLPWtzxG4/EPyT-Flow/Networks/CCWI-WDSA2018/" +\
|
|
495
495
|
"Dataset_Generator_Py3/weekPat_30min.mat"
|
|
496
|
-
year_offset_url = "https://
|
|
496
|
+
year_offset_url = "https://filedn.com/lumBFq2P9S74PNoLPWtzxG4/EPyT-Flow/Networks/CCWI-WDSA2018/" +\
|
|
497
497
|
"Dataset_Generator_Py3/yearOffset_30min.mat"
|
|
498
498
|
|
|
499
499
|
download_if_necessary(os.path.join(download_dir, "weekPat_30min.mat"),
|
|
@@ -544,9 +544,9 @@ def load_scenarios(scenarios_id: list[int], use_net1: bool = True,
|
|
|
544
544
|
upper = data + z
|
|
545
545
|
return lower + np.random.uniform() * (upper - lower)
|
|
546
546
|
|
|
547
|
-
my_uncertainties = {"
|
|
548
|
-
"
|
|
549
|
-
"
|
|
547
|
+
my_uncertainties = {"global_pipe_length_uncertainty": MyUniformUncertainty(low=0, high=0.25),
|
|
548
|
+
"global_pipe_roughness_uncertainty": MyUniformUncertainty(low=0, high=0.25),
|
|
549
|
+
"global_base_demand_uncertainty": MyUniformUncertainty(low=0, high=0.25)}
|
|
550
550
|
model_uncertainty = ModelUncertainty(**my_uncertainties)
|
|
551
551
|
|
|
552
552
|
# Create sensor config (place pressure and flow sensors everywhere)
|
|
@@ -22,9 +22,9 @@ def compute_evaluation_score(y_pred: np.ndarray, y: np.ndarray) -> dict:
|
|
|
22
22
|
|
|
23
23
|
Parameters
|
|
24
24
|
----------
|
|
25
|
-
y_pred : `numpy.ndarray
|
|
25
|
+
y_pred : `numpy.ndarray <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
|
|
26
26
|
Event indication prediction over time
|
|
27
|
-
y : `numpy.ndarray
|
|
27
|
+
y : `numpy.ndarray <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
|
|
28
28
|
Ground truth event indication over time.
|
|
29
29
|
|
|
30
30
|
Returns
|
epyt_flow/data/networks.py
CHANGED
|
@@ -102,7 +102,7 @@ def load_inp(f_in: str, include_empty_sensor_config: bool = True,
|
|
|
102
102
|
Scenario configuration for the .inp file.
|
|
103
103
|
"""
|
|
104
104
|
if not os.path.isfile(f_in):
|
|
105
|
-
raise ValueError("Can not find
|
|
105
|
+
raise ValueError(f"Can not find {f_in}")
|
|
106
106
|
|
|
107
107
|
if include_empty_sensor_config is True:
|
|
108
108
|
return ScenarioConfig(f_inp_in=f_in, sensor_config=create_empty_sensor_config(f_inp=f_in),
|
|
@@ -153,8 +153,7 @@ def load_net1(download_dir: str = get_temp_folder(), verbose: bool = True,
|
|
|
153
153
|
:class:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator`.
|
|
154
154
|
"""
|
|
155
155
|
f_in = os.path.join(download_dir, "Net1.inp")
|
|
156
|
-
url = "https://
|
|
157
|
-
"asce-tf-wdst/Net1.inp"
|
|
156
|
+
url = "https://filedn.com/lumBFq2P9S74PNoLPWtzxG4/EPyT-Flow/Networks/Net1.inp"
|
|
158
157
|
|
|
159
158
|
download_if_necessary(f_in, url, verbose)
|
|
160
159
|
return load_inp(f_in, flow_units_id=flow_units_id)
|
|
@@ -201,8 +200,7 @@ def load_net2(download_dir: str = get_temp_folder(), verbose: bool = True,
|
|
|
201
200
|
:class:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator`.
|
|
202
201
|
"""
|
|
203
202
|
f_in = os.path.join(download_dir, "Net2.inp")
|
|
204
|
-
url = "https://
|
|
205
|
-
"asce-tf-wdst/Net2.inp"
|
|
203
|
+
url = "https://filedn.com/lumBFq2P9S74PNoLPWtzxG4/EPyT-Flow/Networks/Net2.inp"
|
|
206
204
|
|
|
207
205
|
download_if_necessary(f_in, url, verbose)
|
|
208
206
|
return load_inp(f_in, flow_units_id=flow_units_id)
|
|
@@ -249,8 +247,7 @@ def load_net3(download_dir: str = get_temp_folder(), verbose: bool = True,
|
|
|
249
247
|
:class:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator`.
|
|
250
248
|
"""
|
|
251
249
|
f_in = os.path.join(download_dir, "Net3.inp")
|
|
252
|
-
url = "https://
|
|
253
|
-
"asce-tf-wdst/Net3.inp"
|
|
250
|
+
url = "https://filedn.com/lumBFq2P9S74PNoLPWtzxG4/EPyT-Flow/Networks/Net3.inp"
|
|
254
251
|
|
|
255
252
|
download_if_necessary(f_in, url, verbose)
|
|
256
253
|
return load_inp(f_in, flow_units_id=flow_units_id)
|
|
@@ -297,7 +294,7 @@ def load_net6(download_dir: str = get_temp_folder(), verbose: bool = True,
|
|
|
297
294
|
:class:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator`.
|
|
298
295
|
"""
|
|
299
296
|
f_in = os.path.join(download_dir, "Net6.inp")
|
|
300
|
-
url = "https://
|
|
297
|
+
url = "https://filedn.com/lumBFq2P9S74PNoLPWtzxG4/EPyT-Flow/Networks/Net6.inp"
|
|
301
298
|
|
|
302
299
|
download_if_necessary(f_in, url, verbose)
|
|
303
300
|
return load_inp(f_in, flow_units_id=flow_units_id)
|
|
@@ -344,8 +341,7 @@ def load_richmond(download_dir: str = get_temp_folder(), verbose: bool = True,
|
|
|
344
341
|
:class:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator`.
|
|
345
342
|
"""
|
|
346
343
|
f_in = os.path.join(download_dir, "Richmond_standard.inp")
|
|
347
|
-
url = "https://
|
|
348
|
-
"exeter-benchmarks/Richmond_standard.inp"
|
|
344
|
+
url = "https://filedn.com/lumBFq2P9S74PNoLPWtzxG4/EPyT-Flow/Networks/Richmond_standard.inp"
|
|
349
345
|
|
|
350
346
|
download_if_necessary(f_in, url, verbose)
|
|
351
347
|
return load_inp(f_in, flow_units_id=flow_units_id)
|
|
@@ -392,8 +388,7 @@ def load_micropolis(download_dir: str = get_temp_folder(), verbose: bool = True,
|
|
|
392
388
|
:class:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator`.
|
|
393
389
|
"""
|
|
394
390
|
f_in = os.path.join(download_dir, "MICROPOLIS_v1.inp")
|
|
395
|
-
url = "https://
|
|
396
|
-
"MICROPOLIS_v1.inp"
|
|
391
|
+
url = "https://filedn.com/lumBFq2P9S74PNoLPWtzxG4/EPyT-Flow/Networks/MICROPOLIS_v1.inp"
|
|
397
392
|
|
|
398
393
|
download_if_necessary(f_in, url, verbose)
|
|
399
394
|
return load_inp(f_in, flow_units_id=flow_units_id)
|
|
@@ -440,8 +435,7 @@ def load_balerma(download_dir: str = get_temp_folder(), verbose: bool = True,
|
|
|
440
435
|
:class:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator`.
|
|
441
436
|
"""
|
|
442
437
|
f_in = os.path.join(download_dir, "Balerma.inp")
|
|
443
|
-
url = "https://
|
|
444
|
-
"asce-tf-wdst/Balerma.inp"
|
|
438
|
+
url = "https://filedn.com/lumBFq2P9S74PNoLPWtzxG4/EPyT-Flow/Networks/Balerma.inp"
|
|
445
439
|
|
|
446
440
|
download_if_necessary(f_in, url, verbose)
|
|
447
441
|
return load_inp(f_in, flow_units_id=flow_units_id)
|
|
@@ -488,8 +482,7 @@ def load_rural(download_dir: str = get_temp_folder(), verbose: bool = True,
|
|
|
488
482
|
:class:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator`.
|
|
489
483
|
"""
|
|
490
484
|
f_in = os.path.join(download_dir, "RuralNetwork.inp")
|
|
491
|
-
url = "https://
|
|
492
|
-
"asce-tf-wdst/RuralNetwork.inp"
|
|
485
|
+
url = "https://filedn.com/lumBFq2P9S74PNoLPWtzxG4/EPyT-Flow/Networks/RuralNetwork.inp"
|
|
493
486
|
|
|
494
487
|
download_if_necessary(f_in, url, verbose)
|
|
495
488
|
return load_inp(f_in, flow_units_id=flow_units_id)
|
|
@@ -536,8 +529,7 @@ def load_bwsn1(download_dir: str = get_temp_folder(), verbose: bool = True,
|
|
|
536
529
|
:class:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator`.
|
|
537
530
|
"""
|
|
538
531
|
f_in = os.path.join(download_dir, "BWSN_Network_1.inp")
|
|
539
|
-
url = "https://
|
|
540
|
-
"asce-tf-wdst/BWSN_Network_1.inp"
|
|
532
|
+
url = "https://filedn.com/lumBFq2P9S74PNoLPWtzxG4/EPyT-Flow/Networks/BWSN_Network_1.inp"
|
|
541
533
|
|
|
542
534
|
download_if_necessary(f_in, url, verbose)
|
|
543
535
|
return load_inp(f_in, flow_units_id=flow_units_id)
|
|
@@ -584,8 +576,7 @@ def load_bwsn2(download_dir: str = get_temp_folder(), verbose: bool = True,
|
|
|
584
576
|
:class:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator`.
|
|
585
577
|
"""
|
|
586
578
|
f_in = os.path.join(download_dir, "BWSN_Network_2.inp")
|
|
587
|
-
url = "https://
|
|
588
|
-
"asce-tf-wdst/BWSN_Network_2.inp"
|
|
579
|
+
url = "https://filedn.com/lumBFq2P9S74PNoLPWtzxG4/EPyT-Flow/Networks/BWSN_Network_2.inp"
|
|
589
580
|
|
|
590
581
|
download_if_necessary(f_in, url, verbose)
|
|
591
582
|
return load_inp(f_in, flow_units_id=flow_units_id)
|
|
@@ -632,8 +623,7 @@ def load_anytown(download_dir: str = get_temp_folder(), verbose: bool = True,
|
|
|
632
623
|
:class:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator`.
|
|
633
624
|
"""
|
|
634
625
|
f_in = os.path.join(download_dir, "Anytown.inp")
|
|
635
|
-
url = "https://
|
|
636
|
-
"asce-tf-wdst/Anytown.inp"
|
|
626
|
+
url = "https://filedn.com/lumBFq2P9S74PNoLPWtzxG4/EPyT-Flow/Networks/Anytown.inp"
|
|
637
627
|
|
|
638
628
|
download_if_necessary(f_in, url, verbose)
|
|
639
629
|
return load_inp(f_in, flow_units_id=flow_units_id)
|
|
@@ -727,7 +717,7 @@ def load_ctown(download_dir: str = get_temp_folder(), verbose: bool = True,
|
|
|
727
717
|
:class:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator`.
|
|
728
718
|
"""
|
|
729
719
|
f_in = os.path.join(download_dir, "CTOWN.INP")
|
|
730
|
-
url = "https://
|
|
720
|
+
url = "https://filedn.com/lumBFq2P9S74PNoLPWtzxG4/EPyT-Flow/Networks/CTOWN.INP"
|
|
731
721
|
|
|
732
722
|
download_if_necessary(f_in, url, verbose)
|
|
733
723
|
return load_inp(f_in, flow_units_id=flow_units_id)
|
|
@@ -783,8 +773,7 @@ def load_kentucky(wdn_id: int = 1, download_dir: str = get_temp_folder(),
|
|
|
783
773
|
raise ValueError(f"Unknown network 'ky{wdn_id}.inp'")
|
|
784
774
|
|
|
785
775
|
f_in = os.path.join(download_dir, f"ky{wdn_id}.inp")
|
|
786
|
-
url = "https://
|
|
787
|
-
f"asce-tf-wdst/ky{wdn_id}.inp"
|
|
776
|
+
url = f"https://filedn.com/lumBFq2P9S74PNoLPWtzxG4/EPyT-Flow/Networks/ky{wdn_id}.inp"
|
|
788
777
|
|
|
789
778
|
download_if_necessary(f_in, url, verbose)
|
|
790
779
|
return load_inp(f_in, flow_units_id=flow_units_id)
|
|
@@ -836,8 +825,7 @@ def load_hanoi(download_dir: str = get_temp_folder(),
|
|
|
836
825
|
:class:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator`.
|
|
837
826
|
"""
|
|
838
827
|
f_in = os.path.join(download_dir, "Hanoi.inp")
|
|
839
|
-
url = "https://
|
|
840
|
-
"asce-tf-wdst/Hanoi.inp"
|
|
828
|
+
url = "https://filedn.com/lumBFq2P9S74PNoLPWtzxG4/EPyT-Flow/Networks/Hanoi.inp"
|
|
841
829
|
|
|
842
830
|
download_if_necessary(f_in, url, verbose)
|
|
843
831
|
config = load_inp(f_in, flow_units_id=flow_units_id)
|
epyt_flow/gym/control_gyms.py
CHANGED
|
@@ -15,7 +15,7 @@ def register(env_name: str, env: ScenarioControlEnv) -> None:
|
|
|
15
15
|
----------
|
|
16
16
|
env_name : `str`
|
|
17
17
|
Name of the environment -- must be unique among all environments.
|
|
18
|
-
env : :class
|
|
18
|
+
env : :class:`~epyt_flow.gym.scenario_control_env.ScenarioControlEnv`
|
|
19
19
|
Environment.
|
|
20
20
|
"""
|
|
21
21
|
if env_name in environments:
|
|
@@ -38,7 +38,7 @@ def make(env_name: str, **kwds) -> ScenarioControlEnv:
|
|
|
38
38
|
|
|
39
39
|
Returns
|
|
40
40
|
-------
|
|
41
|
-
:class
|
|
41
|
+
:class:`~epyt_flow.gym.scenario_control_env.ScenarioControlEnv`
|
|
42
42
|
Environment.
|
|
43
43
|
"""
|
|
44
44
|
if env_name not in environments:
|
|
@@ -194,7 +194,7 @@ class ScenarioControlEnv(ABC):
|
|
|
194
194
|
if pattern_idx == 0:
|
|
195
195
|
warnings.warn(f"No pattern for pump '{pump_id}' found -- a new pattern is created")
|
|
196
196
|
pattern_idx = self._scenario_sim.epanet_api.addPattern(f"pump_speed_{pump_id}")
|
|
197
|
-
self._scenario_sim.epanet_api.setLinkPumpPatternIndex(pattern_idx)
|
|
197
|
+
self._scenario_sim.epanet_api.setLinkPumpPatternIndex(pump_idx, pattern_idx)
|
|
198
198
|
|
|
199
199
|
self._scenario_sim.epanet_api.setPattern(pattern_idx, np.array([speed]))
|
|
200
200
|
|
epyt_flow/metrics.py
CHANGED
|
@@ -12,9 +12,9 @@ def r2_score(y_pred: np.ndarray, y: np.ndarray) -> float:
|
|
|
12
12
|
|
|
13
13
|
Parameters
|
|
14
14
|
----------
|
|
15
|
-
y_pred : `numpy.ndarray
|
|
15
|
+
y_pred : `numpy.ndarray <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
|
|
16
16
|
Predicted outputs.
|
|
17
|
-
y : `numpy.ndarray
|
|
17
|
+
y : `numpy.ndarray <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
|
|
18
18
|
Ground truth outputs.
|
|
19
19
|
|
|
20
20
|
Returns
|
|
@@ -31,9 +31,9 @@ def running_r2_score(y_pred: np.ndarray, y: np.ndarray) -> list[float]:
|
|
|
31
31
|
|
|
32
32
|
Parameters
|
|
33
33
|
----------
|
|
34
|
-
y_pred : `numpy.ndarray
|
|
34
|
+
y_pred : `numpy.ndarray <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
|
|
35
35
|
Predicted outputs.
|
|
36
|
-
y : `numpy.ndarray
|
|
36
|
+
y : `numpy.ndarray <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
|
|
37
37
|
Ground truth outputs.
|
|
38
38
|
|
|
39
39
|
Returns
|
|
@@ -55,9 +55,9 @@ def mean_squared_error(y_pred: np.ndarray, y: np.ndarray) -> float:
|
|
|
55
55
|
|
|
56
56
|
Parameters
|
|
57
57
|
----------
|
|
58
|
-
y_pred : `numpy.ndarray
|
|
58
|
+
y_pred : `numpy.ndarray <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
|
|
59
59
|
Predicted outputs.
|
|
60
|
-
y : `numpy.ndarray
|
|
60
|
+
y : `numpy.ndarray <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
|
|
61
61
|
Ground truth outputs.
|
|
62
62
|
|
|
63
63
|
Returns
|
|
@@ -74,9 +74,9 @@ def running_mse(y_pred: np.ndarray, y: np.ndarray) -> list[float]:
|
|
|
74
74
|
|
|
75
75
|
Parameters
|
|
76
76
|
----------
|
|
77
|
-
y_pred : `numpy.ndarray
|
|
77
|
+
y_pred : `numpy.ndarray <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
|
|
78
78
|
Predicted outputs.
|
|
79
|
-
y : `numpy.ndarray
|
|
79
|
+
y : `numpy.ndarray <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
|
|
80
80
|
Ground truth outputs.
|
|
81
81
|
|
|
82
82
|
Returns
|
|
@@ -112,9 +112,9 @@ def mape(y_pred: np.ndarray, y: np.ndarray, epsilon: float = .05) -> float:
|
|
|
112
112
|
|
|
113
113
|
Parameters
|
|
114
114
|
----------
|
|
115
|
-
y_pred : `numpy.ndarray
|
|
115
|
+
y_pred : `numpy.ndarray <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
|
|
116
116
|
Predicted outputs.
|
|
117
|
-
y : `numpy.ndarray
|
|
117
|
+
y : `numpy.ndarray <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
|
|
118
118
|
Ground truth outputs.
|
|
119
119
|
epsilon : `float`, optional
|
|
120
120
|
Small number added to predictions and ground truth to avoid division-by-zero.
|
|
@@ -153,9 +153,9 @@ def smape(y_pred: np.ndarray, y: np.ndarray, epsilon: float = .05) -> float:
|
|
|
153
153
|
|
|
154
154
|
Parameters
|
|
155
155
|
----------
|
|
156
|
-
y_pred : `numpy.ndarray
|
|
156
|
+
y_pred : `numpy.ndarray <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
|
|
157
157
|
Predicted outputs.
|
|
158
|
-
y : `numpy.ndarray
|
|
158
|
+
y : `numpy.ndarray <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
|
|
159
159
|
Ground truth outputs.
|
|
160
160
|
epsilon : `float`, optional
|
|
161
161
|
Small number added to predictions and ground truth to avoid division-by-zero.
|
|
@@ -194,9 +194,9 @@ def mase(y_pred: np.ndarray, y: np.ndarray, epsilon: float = .05) -> float:
|
|
|
194
194
|
|
|
195
195
|
Parameters
|
|
196
196
|
----------
|
|
197
|
-
y_pred : `numpy.ndarray
|
|
197
|
+
y_pred : `numpy.ndarray <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
|
|
198
198
|
Predicted outputs.
|
|
199
|
-
y : `numpy.ndarray
|
|
199
|
+
y : `numpy.ndarray <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
|
|
200
200
|
Ground truth outputs.
|
|
201
201
|
epsilon : `float`, optional
|
|
202
202
|
Small number added to predictions and ground truth to avoid division-by-zero.
|
|
@@ -242,9 +242,9 @@ def f1_micro_score(y_pred: np.ndarray, y: np.ndarray) -> float:
|
|
|
242
242
|
|
|
243
243
|
Parameters
|
|
244
244
|
----------
|
|
245
|
-
y_pred : `numpy.ndarray
|
|
245
|
+
y_pred : `numpy.ndarray <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
|
|
246
246
|
Predicted labels.
|
|
247
|
-
y : `numpy.ndarray
|
|
247
|
+
y : `numpy.ndarray <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
|
|
248
248
|
Ground truth labels.
|
|
249
249
|
|
|
250
250
|
Returns
|
|
@@ -270,9 +270,9 @@ def roc_auc_score(y_pred: np.ndarray, y: np.ndarray) -> float:
|
|
|
270
270
|
|
|
271
271
|
Parameters
|
|
272
272
|
----------
|
|
273
|
-
y_pred : `numpy.ndarray
|
|
273
|
+
y_pred : `numpy.ndarray <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
|
|
274
274
|
Predicted labels.
|
|
275
|
-
y : `numpy.ndarray
|
|
275
|
+
y : `numpy.ndarray <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
|
|
276
276
|
Ground truth labels.
|
|
277
277
|
|
|
278
278
|
Returns
|
|
@@ -298,9 +298,9 @@ def true_positive_rate(y_pred: np.ndarray, y: np.ndarray) -> float:
|
|
|
298
298
|
|
|
299
299
|
Parameters
|
|
300
300
|
----------
|
|
301
|
-
y_pred : `numpy.ndarray
|
|
301
|
+
y_pred : `numpy.ndarray <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
|
|
302
302
|
Predicted labels.
|
|
303
|
-
y : `numpy.ndarray
|
|
303
|
+
y : `numpy.ndarray <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
|
|
304
304
|
Ground truth labels.
|
|
305
305
|
|
|
306
306
|
Returns
|
|
@@ -335,9 +335,9 @@ def true_negative_rate(y_pred: np.ndarray, y: np.ndarray) -> float:
|
|
|
335
335
|
|
|
336
336
|
Parameters
|
|
337
337
|
----------
|
|
338
|
-
y_pred : `numpy.ndarray
|
|
338
|
+
y_pred : `numpy.ndarray <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
|
|
339
339
|
Predicted labels.
|
|
340
|
-
y : `numpy.ndarray
|
|
340
|
+
y : `numpy.ndarray <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
|
|
341
341
|
Ground truth labels.
|
|
342
342
|
|
|
343
343
|
Returns
|
|
@@ -372,9 +372,9 @@ def precision_score(y_pred: np.ndarray, y: np.ndarray) -> float:
|
|
|
372
372
|
|
|
373
373
|
Parameters
|
|
374
374
|
----------
|
|
375
|
-
y_pred : `numpy.ndarray
|
|
375
|
+
y_pred : `numpy.ndarray <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
|
|
376
376
|
Predicted labels.
|
|
377
|
-
y : `numpy.ndarray
|
|
377
|
+
y : `numpy.ndarray <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
|
|
378
378
|
Ground truth labels.
|
|
379
379
|
|
|
380
380
|
Returns
|
|
@@ -405,9 +405,9 @@ def accuracy_score(y_pred: np.ndarray, y: np.ndarray) -> float:
|
|
|
405
405
|
|
|
406
406
|
Parameters
|
|
407
407
|
----------
|
|
408
|
-
y_pred : `numpy.ndarray
|
|
408
|
+
y_pred : `numpy.ndarray <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
|
|
409
409
|
Predicted labels.
|
|
410
|
-
y : `numpy.ndarray
|
|
410
|
+
y : `numpy.ndarray <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
|
|
411
411
|
Ground truth labels.
|
|
412
412
|
|
|
413
413
|
Returns
|
|
@@ -434,9 +434,9 @@ def f1_score(y_pred: np.ndarray, y: np.ndarray) -> float:
|
|
|
434
434
|
|
|
435
435
|
Parameters
|
|
436
436
|
----------
|
|
437
|
-
y_pred : `numpy.ndarray
|
|
437
|
+
y_pred : `numpy.ndarray <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
|
|
438
438
|
Predicted labels.
|
|
439
|
-
y : `numpy.ndarray
|
|
439
|
+
y : `numpy.ndarray <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
|
|
440
440
|
Ground truth labels.
|
|
441
441
|
|
|
442
442
|
Returns
|
|
@@ -20,7 +20,7 @@ class SensorInterpolationDetector(EventDetector):
|
|
|
20
20
|
Regressor class that will be used for the sensor interpolation.
|
|
21
21
|
Must implement the usual `fit` and `predict` functions.
|
|
22
22
|
|
|
23
|
-
The default is `sklearn.linear_model.LinearRegression
|
|
23
|
+
The default is `sklearn.linear_model.LinearRegression <https://scikit-learn.org/dev/modules/generated/sklearn.linear_model.LinearRegression.html>`_
|
|
24
24
|
"""
|
|
25
25
|
def __init__(self, regressor_type: Any = LinearRegression, **kwds):
|
|
26
26
|
self.__regressor_type = regressor_type
|
|
@@ -63,7 +63,7 @@ class SensorInterpolationDetector(EventDetector):
|
|
|
63
63
|
|
|
64
64
|
Parameters
|
|
65
65
|
----------
|
|
66
|
-
scada_data : :class:`~epyt_flow.simulation.scada.scada_data.ScadaData` or `numpy.ndarray
|
|
66
|
+
scada_data : :class:`~epyt_flow.simulation.scada.scada_data.ScadaData` or `numpy.ndarray <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
|
|
67
67
|
SCADA data to fit this detector.
|
|
68
68
|
"""
|
|
69
69
|
if isinstance(scada_data, ScadaData):
|
|
@@ -93,7 +93,7 @@ class SensorInterpolationDetector(EventDetector):
|
|
|
93
93
|
|
|
94
94
|
Parameters
|
|
95
95
|
----------
|
|
96
|
-
scada_data : :class:`~epyt_flow.simulation.scada.scada_data.ScadaData` or `numpy.ndarray
|
|
96
|
+
scada_data : :class:`~epyt_flow.simulation.scada.scada_data.ScadaData` or `numpy.ndarray <https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html>`_
|
|
97
97
|
SCADA data in which to look for events/anomalies.
|
|
98
98
|
|
|
99
99
|
Returns
|
|
@@ -17,7 +17,7 @@ class BaseHandler():
|
|
|
17
17
|
|
|
18
18
|
Parameters
|
|
19
19
|
----------
|
|
20
|
-
resp : `falcon.Response
|
|
20
|
+
resp : `falcon.Response <https://falcon.readthedocs.io/en/stable/api/request_and_response_asgi.html#response>`_
|
|
21
21
|
Response instance.
|
|
22
22
|
error_msg : `str`
|
|
23
23
|
Error message.
|
|
@@ -43,7 +43,7 @@ class BaseHandler():
|
|
|
43
43
|
|
|
44
44
|
Parameters
|
|
45
45
|
----------
|
|
46
|
-
resp : `falcon.Response
|
|
46
|
+
resp : `falcon.Response <https://falcon.readthedocs.io/en/stable/api/request_and_response_asgi.html#response>`_
|
|
47
47
|
Response instance.
|
|
48
48
|
"""
|
|
49
49
|
resp.status = falcon.HTTP_BAD_REQUEST
|
|
@@ -55,7 +55,7 @@ class BaseHandler():
|
|
|
55
55
|
|
|
56
56
|
Parameters
|
|
57
57
|
----------
|
|
58
|
-
req : `falcon.Request
|
|
58
|
+
req : `falcon.Request <https://falcon.readthedocs.io/en/stable/api/request_and_response_asgi.html#request>`_
|
|
59
59
|
Request instance.
|
|
60
60
|
|
|
61
61
|
Returns
|
|
@@ -74,7 +74,7 @@ class BaseHandler():
|
|
|
74
74
|
|
|
75
75
|
Parameters
|
|
76
76
|
----------
|
|
77
|
-
resp : `falcon.Response
|
|
77
|
+
resp : `falcon.Response <https://falcon.readthedocs.io/en/stable/api/request_and_response_asgi.html#response>`_
|
|
78
78
|
Response instance.
|
|
79
79
|
data : `Any`
|
|
80
80
|
Data to be sent.
|
|
@@ -18,7 +18,7 @@ class ScadaDataPressuresHandler(ScadaDataBaseHandler):
|
|
|
18
18
|
|
|
19
19
|
Parameters
|
|
20
20
|
----------
|
|
21
|
-
resp : `falcon.Response
|
|
21
|
+
resp : `falcon.Response <https://falcon.readthedocs.io/en/stable/api/request_and_response_asgi.html#response>`_
|
|
22
22
|
Response instance.
|
|
23
23
|
data_id : `str`
|
|
24
24
|
UUID of the SCADA data.
|
|
@@ -45,7 +45,7 @@ class ScadaDataFlowsHandler(ScadaDataBaseHandler):
|
|
|
45
45
|
|
|
46
46
|
Parameters
|
|
47
47
|
----------
|
|
48
|
-
resp : `falcon.Response
|
|
48
|
+
resp : `falcon.Response <https://falcon.readthedocs.io/en/stable/api/request_and_response_asgi.html#response>`_
|
|
49
49
|
Response instance.
|
|
50
50
|
data_id : `str`
|
|
51
51
|
UUID of the SCADA data.
|
|
@@ -72,7 +72,7 @@ class ScadaDataDemandsHandler(ScadaDataBaseHandler):
|
|
|
72
72
|
|
|
73
73
|
Parameters
|
|
74
74
|
----------
|
|
75
|
-
resp : `falcon.Response
|
|
75
|
+
resp : `falcon.Response <https://falcon.readthedocs.io/en/stable/api/request_and_response_asgi.html#response>`_
|
|
76
76
|
Response instance.
|
|
77
77
|
data_id : `str`
|
|
78
78
|
UUID of the SCADA data.
|
|
@@ -100,7 +100,7 @@ class ScadaDataValveStatesHandler(ScadaDataBaseHandler):
|
|
|
100
100
|
|
|
101
101
|
Parameters
|
|
102
102
|
----------
|
|
103
|
-
resp : `falcon.Response
|
|
103
|
+
resp : `falcon.Response <https://falcon.readthedocs.io/en/stable/api/request_and_response_asgi.html#response>`_
|
|
104
104
|
Response instance.
|
|
105
105
|
data_id : `str`
|
|
106
106
|
UUID of the SCADA data.
|
|
@@ -128,7 +128,7 @@ class ScadaDataPumpStatesHandler(ScadaDataBaseHandler):
|
|
|
128
128
|
|
|
129
129
|
Parameters
|
|
130
130
|
----------
|
|
131
|
-
resp : `falcon.Response
|
|
131
|
+
resp : `falcon.Response <https://falcon.readthedocs.io/en/stable/api/request_and_response_asgi.html#response>`_
|
|
132
132
|
Response instance.
|
|
133
133
|
data_id : `str`
|
|
134
134
|
UUID of the SCADA data.
|
|
@@ -156,7 +156,7 @@ class ScadaDataTankVolumesHandler(ScadaDataBaseHandler):
|
|
|
156
156
|
|
|
157
157
|
Parameters
|
|
158
158
|
----------
|
|
159
|
-
resp : `falcon.Response
|
|
159
|
+
resp : `falcon.Response <https://falcon.readthedocs.io/en/stable/api/request_and_response_asgi.html#response>`_
|
|
160
160
|
Response instance.
|
|
161
161
|
data_id : `str`
|
|
162
162
|
UUID of the SCADA data.
|
|
@@ -184,7 +184,7 @@ class ScadaDataNodesQualityHandler(ScadaDataBaseHandler):
|
|
|
184
184
|
|
|
185
185
|
Parameters
|
|
186
186
|
----------
|
|
187
|
-
resp : `falcon.Response
|
|
187
|
+
resp : `falcon.Response <https://falcon.readthedocs.io/en/stable/api/request_and_response_asgi.html#response>`_
|
|
188
188
|
Response instance.
|
|
189
189
|
data_id : `str`
|
|
190
190
|
UUID of the SCADA data.
|
|
@@ -212,7 +212,7 @@ class ScadaDataLinksQualityHandler(ScadaDataBaseHandler):
|
|
|
212
212
|
|
|
213
213
|
Parameters
|
|
214
214
|
----------
|
|
215
|
-
resp : `falcon.Response
|
|
215
|
+
resp : `falcon.Response <https://falcon.readthedocs.io/en/stable/api/request_and_response_asgi.html#response>`_
|
|
216
216
|
Response instance.
|
|
217
217
|
data_id : `str`
|
|
218
218
|
UUID of the SCADA data.
|
|
@@ -240,7 +240,7 @@ class ScadaDataNodeBulkSpeciesHandler(ScadaDataBaseHandler):
|
|
|
240
240
|
|
|
241
241
|
Parameters
|
|
242
242
|
----------
|
|
243
|
-
resp : `falcon.Response
|
|
243
|
+
resp : `falcon.Response <https://falcon.readthedocs.io/en/stable/api/request_and_response_asgi.html#response>`_
|
|
244
244
|
Response instance.
|
|
245
245
|
data_id : `str`
|
|
246
246
|
UUID of the SCADA data.
|
|
@@ -270,7 +270,7 @@ class ScadaDataLinkBulkSpeciesHandler(ScadaDataBaseHandler):
|
|
|
270
270
|
|
|
271
271
|
Parameters
|
|
272
272
|
----------
|
|
273
|
-
resp : `falcon.Response
|
|
273
|
+
resp : `falcon.Response <https://falcon.readthedocs.io/en/stable/api/request_and_response_asgi.html#response>`_
|
|
274
274
|
Response instance.
|
|
275
275
|
data_id : `str`
|
|
276
276
|
UUID of the SCADA data.
|
|
@@ -299,7 +299,7 @@ class ScadaDataSurfaceSpeciesHandler(ScadaDataBaseHandler):
|
|
|
299
299
|
|
|
300
300
|
Parameters
|
|
301
301
|
----------
|
|
302
|
-
resp : `falcon.Response
|
|
302
|
+
resp : `falcon.Response <https://falcon.readthedocs.io/en/stable/api/request_and_response_asgi.html#response>`_
|
|
303
303
|
Response instance.
|
|
304
304
|
data_id : `str`
|
|
305
305
|
UUID of the SCADA data.
|