epyt-flow 0.1.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/EPANET/SRC_engines/AUTHORS +28 -0
- epyt_flow/EPANET/EPANET/SRC_engines/LICENSE +21 -0
- epyt_flow/EPANET/EPANET/SRC_engines/Readme_SRC_Engines.txt +18 -0
- epyt_flow/EPANET/EPANET/SRC_engines/enumstxt.h +134 -0
- epyt_flow/EPANET/EPANET/SRC_engines/epanet.c +5578 -0
- epyt_flow/EPANET/EPANET/SRC_engines/epanet2.c +865 -0
- epyt_flow/EPANET/EPANET/SRC_engines/epanet2.def +131 -0
- epyt_flow/EPANET/EPANET/SRC_engines/errors.dat +73 -0
- epyt_flow/EPANET/EPANET/SRC_engines/funcs.h +193 -0
- epyt_flow/EPANET/EPANET/SRC_engines/genmmd.c +1000 -0
- epyt_flow/EPANET/EPANET/SRC_engines/hash.c +177 -0
- epyt_flow/EPANET/EPANET/SRC_engines/hash.h +28 -0
- epyt_flow/EPANET/EPANET/SRC_engines/hydcoeffs.c +1151 -0
- epyt_flow/EPANET/EPANET/SRC_engines/hydraul.c +1117 -0
- epyt_flow/EPANET/EPANET/SRC_engines/hydsolver.c +720 -0
- epyt_flow/EPANET/EPANET/SRC_engines/hydstatus.c +476 -0
- epyt_flow/EPANET/EPANET/SRC_engines/include/epanet2.h +431 -0
- epyt_flow/EPANET/EPANET/SRC_engines/include/epanet2_2.h +1786 -0
- epyt_flow/EPANET/EPANET/SRC_engines/include/epanet2_enums.h +468 -0
- epyt_flow/EPANET/EPANET/SRC_engines/inpfile.c +810 -0
- epyt_flow/EPANET/EPANET/SRC_engines/input1.c +707 -0
- epyt_flow/EPANET/EPANET/SRC_engines/input2.c +864 -0
- epyt_flow/EPANET/EPANET/SRC_engines/input3.c +2170 -0
- epyt_flow/EPANET/EPANET/SRC_engines/main.c +93 -0
- epyt_flow/EPANET/EPANET/SRC_engines/mempool.c +142 -0
- epyt_flow/EPANET/EPANET/SRC_engines/mempool.h +24 -0
- epyt_flow/EPANET/EPANET/SRC_engines/output.c +852 -0
- epyt_flow/EPANET/EPANET/SRC_engines/project.c +1359 -0
- epyt_flow/EPANET/EPANET/SRC_engines/quality.c +685 -0
- epyt_flow/EPANET/EPANET/SRC_engines/qualreact.c +743 -0
- epyt_flow/EPANET/EPANET/SRC_engines/qualroute.c +694 -0
- epyt_flow/EPANET/EPANET/SRC_engines/report.c +1489 -0
- epyt_flow/EPANET/EPANET/SRC_engines/rules.c +1362 -0
- epyt_flow/EPANET/EPANET/SRC_engines/smatrix.c +871 -0
- epyt_flow/EPANET/EPANET/SRC_engines/text.h +497 -0
- epyt_flow/EPANET/EPANET/SRC_engines/types.h +874 -0
- epyt_flow/EPANET/EPANET-MSX/MSX_Updates.txt +53 -0
- epyt_flow/EPANET/EPANET-MSX/Src/dispersion.h +27 -0
- epyt_flow/EPANET/EPANET-MSX/Src/hash.c +107 -0
- epyt_flow/EPANET/EPANET-MSX/Src/hash.h +28 -0
- epyt_flow/EPANET/EPANET-MSX/Src/include/epanetmsx.h +102 -0
- epyt_flow/EPANET/EPANET-MSX/Src/include/epanetmsx_export.h +42 -0
- epyt_flow/EPANET/EPANET-MSX/Src/mathexpr.c +937 -0
- epyt_flow/EPANET/EPANET-MSX/Src/mathexpr.h +39 -0
- epyt_flow/EPANET/EPANET-MSX/Src/mempool.c +204 -0
- epyt_flow/EPANET/EPANET-MSX/Src/mempool.h +24 -0
- epyt_flow/EPANET/EPANET-MSX/Src/msxchem.c +1285 -0
- epyt_flow/EPANET/EPANET-MSX/Src/msxcompiler.c +368 -0
- epyt_flow/EPANET/EPANET-MSX/Src/msxdict.h +42 -0
- epyt_flow/EPANET/EPANET-MSX/Src/msxdispersion.c +586 -0
- epyt_flow/EPANET/EPANET-MSX/Src/msxerr.c +116 -0
- epyt_flow/EPANET/EPANET-MSX/Src/msxfile.c +260 -0
- epyt_flow/EPANET/EPANET-MSX/Src/msxfuncs.c +175 -0
- epyt_flow/EPANET/EPANET-MSX/Src/msxfuncs.h +35 -0
- epyt_flow/EPANET/EPANET-MSX/Src/msxinp.c +1504 -0
- epyt_flow/EPANET/EPANET-MSX/Src/msxout.c +401 -0
- epyt_flow/EPANET/EPANET-MSX/Src/msxproj.c +791 -0
- epyt_flow/EPANET/EPANET-MSX/Src/msxqual.c +2010 -0
- epyt_flow/EPANET/EPANET-MSX/Src/msxrpt.c +400 -0
- epyt_flow/EPANET/EPANET-MSX/Src/msxtank.c +422 -0
- epyt_flow/EPANET/EPANET-MSX/Src/msxtoolkit.c +1164 -0
- epyt_flow/EPANET/EPANET-MSX/Src/msxtypes.h +551 -0
- epyt_flow/EPANET/EPANET-MSX/Src/msxutils.c +524 -0
- epyt_flow/EPANET/EPANET-MSX/Src/msxutils.h +56 -0
- epyt_flow/EPANET/EPANET-MSX/Src/newton.c +158 -0
- epyt_flow/EPANET/EPANET-MSX/Src/newton.h +34 -0
- epyt_flow/EPANET/EPANET-MSX/Src/rk5.c +287 -0
- epyt_flow/EPANET/EPANET-MSX/Src/rk5.h +39 -0
- epyt_flow/EPANET/EPANET-MSX/Src/ros2.c +293 -0
- epyt_flow/EPANET/EPANET-MSX/Src/ros2.h +35 -0
- epyt_flow/EPANET/EPANET-MSX/Src/smatrix.c +816 -0
- epyt_flow/EPANET/EPANET-MSX/Src/smatrix.h +29 -0
- epyt_flow/EPANET/EPANET-MSX/readme.txt +14 -0
- epyt_flow/EPANET/compile.sh +4 -0
- epyt_flow/VERSION +1 -0
- epyt_flow/__init__.py +24 -0
- epyt_flow/data/__init__.py +0 -0
- epyt_flow/data/benchmarks/__init__.py +11 -0
- epyt_flow/data/benchmarks/batadal.py +257 -0
- epyt_flow/data/benchmarks/batadal_data.py +28 -0
- epyt_flow/data/benchmarks/battledim.py +473 -0
- epyt_flow/data/benchmarks/battledim_data.py +51 -0
- epyt_flow/data/benchmarks/gecco_water_quality.py +267 -0
- epyt_flow/data/benchmarks/leakdb.py +592 -0
- epyt_flow/data/benchmarks/leakdb_data.py +18923 -0
- epyt_flow/data/benchmarks/water_usage.py +123 -0
- epyt_flow/data/networks.py +650 -0
- epyt_flow/gym/__init__.py +4 -0
- epyt_flow/gym/control_gyms.py +47 -0
- epyt_flow/gym/scenario_control_env.py +101 -0
- epyt_flow/metrics.py +404 -0
- epyt_flow/models/__init__.py +2 -0
- epyt_flow/models/event_detector.py +31 -0
- epyt_flow/models/sensor_interpolation_detector.py +118 -0
- epyt_flow/rest_api/__init__.py +4 -0
- epyt_flow/rest_api/base_handler.py +70 -0
- epyt_flow/rest_api/res_manager.py +95 -0
- epyt_flow/rest_api/scada_data_handler.py +476 -0
- epyt_flow/rest_api/scenario_handler.py +352 -0
- epyt_flow/rest_api/server.py +106 -0
- epyt_flow/serialization.py +438 -0
- epyt_flow/simulation/__init__.py +5 -0
- epyt_flow/simulation/events/__init__.py +6 -0
- epyt_flow/simulation/events/actuator_events.py +259 -0
- epyt_flow/simulation/events/event.py +81 -0
- epyt_flow/simulation/events/leakages.py +404 -0
- epyt_flow/simulation/events/sensor_faults.py +267 -0
- epyt_flow/simulation/events/sensor_reading_attack.py +185 -0
- epyt_flow/simulation/events/sensor_reading_event.py +170 -0
- epyt_flow/simulation/events/system_event.py +88 -0
- epyt_flow/simulation/parallel_simulation.py +147 -0
- epyt_flow/simulation/scada/__init__.py +3 -0
- epyt_flow/simulation/scada/advanced_control.py +134 -0
- epyt_flow/simulation/scada/scada_data.py +1589 -0
- epyt_flow/simulation/scada/scada_data_export.py +255 -0
- epyt_flow/simulation/scenario_config.py +608 -0
- epyt_flow/simulation/scenario_simulator.py +1897 -0
- epyt_flow/simulation/scenario_visualizer.py +61 -0
- epyt_flow/simulation/sensor_config.py +1289 -0
- epyt_flow/topology.py +290 -0
- epyt_flow/uncertainty/__init__.py +3 -0
- epyt_flow/uncertainty/model_uncertainty.py +302 -0
- epyt_flow/uncertainty/sensor_noise.py +73 -0
- epyt_flow/uncertainty/uncertainties.py +555 -0
- epyt_flow/uncertainty/utils.py +206 -0
- epyt_flow/utils.py +306 -0
- epyt_flow-0.1.0.dist-info/LICENSE +21 -0
- epyt_flow-0.1.0.dist-info/METADATA +139 -0
- epyt_flow-0.1.0.dist-info/RECORD +131 -0
- epyt_flow-0.1.0.dist-info/WHEEL +5 -0
- epyt_flow-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,650 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Module provides functions for loading different water distribution networks.
|
|
3
|
+
"""
|
|
4
|
+
import os
|
|
5
|
+
|
|
6
|
+
from ..simulation import ScenarioConfig, ScenarioSimulator, SensorConfig
|
|
7
|
+
from ..utils import get_temp_folder, download_if_necessary
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def create_empty_sensor_config(f_inp: str) -> SensorConfig:
|
|
11
|
+
"""
|
|
12
|
+
Creates an empty sensor configuration for a given .inp file.
|
|
13
|
+
|
|
14
|
+
Parameters
|
|
15
|
+
----------
|
|
16
|
+
f_inp : `str`
|
|
17
|
+
Path to the .inp file.
|
|
18
|
+
|
|
19
|
+
Returns
|
|
20
|
+
-------
|
|
21
|
+
:class:`~epyt_flow.simulation.sensor_config.SensorConfig`
|
|
22
|
+
Sensor configuration.
|
|
23
|
+
"""
|
|
24
|
+
with ScenarioSimulator(f_inp_in=f_inp) as sim:
|
|
25
|
+
return sim.sensor_config
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def get_default_hydraulic_options() -> dict:
|
|
29
|
+
"""
|
|
30
|
+
Gets standard hydraulic default options -- i.e. switch to pressure-driven analysis.
|
|
31
|
+
|
|
32
|
+
Returns
|
|
33
|
+
-------
|
|
34
|
+
`dict`
|
|
35
|
+
Dictionary with default hydraulics options that can be passed to
|
|
36
|
+
:func:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator.set_general_parameters`.
|
|
37
|
+
"""
|
|
38
|
+
return {"demand_model": {"type": "PDA", "pressure_min": 0, "pressure_required": 0.1,
|
|
39
|
+
"pressure_exponent": 0.5}}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def load_inp(f_in: str, include_empty_sensor_config: bool = True) -> ScenarioConfig:
|
|
43
|
+
"""
|
|
44
|
+
Loads an .inp file and wraps it into a scenario configuration.
|
|
45
|
+
|
|
46
|
+
Parameters
|
|
47
|
+
----------
|
|
48
|
+
f_in : `str`
|
|
49
|
+
Path to the .inp file.
|
|
50
|
+
include_empty_sensor_config : `bool`, optional
|
|
51
|
+
If True, an empty sensor configuration will be included in the returned
|
|
52
|
+
scenario configuration.
|
|
53
|
+
|
|
54
|
+
The default is True.
|
|
55
|
+
|
|
56
|
+
Returns
|
|
57
|
+
-------
|
|
58
|
+
:class:`~epyt_flow.simulation.scenario_config.ScenarioConfig`
|
|
59
|
+
Scenario configuration for the .inp file.
|
|
60
|
+
"""
|
|
61
|
+
if not os.path.isfile(f_in):
|
|
62
|
+
raise ValueError("Can not find 'f_in'")
|
|
63
|
+
|
|
64
|
+
if include_empty_sensor_config is True:
|
|
65
|
+
return ScenarioConfig(f_inp_in=f_in, sensor_config=create_empty_sensor_config(f_inp=f_in),
|
|
66
|
+
general_params=get_default_hydraulic_options())
|
|
67
|
+
else:
|
|
68
|
+
return ScenarioConfig(f_inp_in=f_in, general_params=get_default_hydraulic_options())
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def load_net1(download_dir: str = get_temp_folder(), verbose: bool = True) -> ScenarioConfig:
|
|
72
|
+
"""
|
|
73
|
+
Loads (and downloads if necessary) the Net1 network.
|
|
74
|
+
|
|
75
|
+
Parameters
|
|
76
|
+
----------
|
|
77
|
+
download_dir : `str`, optional
|
|
78
|
+
Path to the directory where the .inp file is stored.
|
|
79
|
+
|
|
80
|
+
The default is the OS-specific temporary directory (e.g. "C:\\\\temp", "/tmp/", etc.)
|
|
81
|
+
verbose : `bool`, optional
|
|
82
|
+
If True, a progress bar is shown while downloading the file.
|
|
83
|
+
|
|
84
|
+
The default is True.
|
|
85
|
+
|
|
86
|
+
Returns
|
|
87
|
+
-------
|
|
88
|
+
:class:`~epyt_flow.simulation.scenario_config.ScenarioConfig`
|
|
89
|
+
Net1 network loaded into a scenario configuration that can be passed on to
|
|
90
|
+
:class:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator`.
|
|
91
|
+
"""
|
|
92
|
+
f_in = os.path.join(download_dir, "Net1.inp")
|
|
93
|
+
url = "https://raw.githubusercontent.com/OpenWaterAnalytics/EPyT/main/epyt/networks/" + \
|
|
94
|
+
"asce-tf-wdst/Net1.inp"
|
|
95
|
+
|
|
96
|
+
download_if_necessary(f_in, url, verbose)
|
|
97
|
+
return load_inp(f_in)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def load_net2(download_dir: str = get_temp_folder(), verbose: bool = True) -> ScenarioConfig:
|
|
101
|
+
"""
|
|
102
|
+
Loads (and downloads if necessary) the Net2 network.
|
|
103
|
+
|
|
104
|
+
Parameters
|
|
105
|
+
----------
|
|
106
|
+
download_dir : `str`, optional
|
|
107
|
+
Path to the directory where the .inp file is stored.
|
|
108
|
+
|
|
109
|
+
The default is the OS-specific temporary directory (e.g. "C:\\\\temp", "/tmp/", etc.)
|
|
110
|
+
verbose : `bool`, optional
|
|
111
|
+
If True, a progress bar is shown while downloading the file.
|
|
112
|
+
|
|
113
|
+
The default is True.
|
|
114
|
+
|
|
115
|
+
Returns
|
|
116
|
+
-------
|
|
117
|
+
:class:`~epyt_flow.simulation.scenario_config.ScenarioConfig`
|
|
118
|
+
Net2 network loaded into a scenario configuration that can be passed on to
|
|
119
|
+
:class:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator`.
|
|
120
|
+
"""
|
|
121
|
+
f_in = os.path.join(download_dir, "Net2.inp")
|
|
122
|
+
url = "https://raw.githubusercontent.com/OpenWaterAnalytics/EPyT/main/epyt/networks/" + \
|
|
123
|
+
"asce-tf-wdst/Net2.inp"
|
|
124
|
+
|
|
125
|
+
download_if_necessary(f_in, url, verbose)
|
|
126
|
+
return load_inp(f_in)
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def load_net3(download_dir: str = get_temp_folder(), verbose: bool = True) -> ScenarioConfig:
|
|
130
|
+
"""
|
|
131
|
+
Loads (and downloads if necessary) the Net3 network.
|
|
132
|
+
|
|
133
|
+
Parameters
|
|
134
|
+
----------
|
|
135
|
+
download_dir : `str`, optional
|
|
136
|
+
Path to the directory where the .inp file is stored.
|
|
137
|
+
|
|
138
|
+
The default is the OS-specific temporary directory (e.g. "C:\\\\temp", "/tmp/", etc.)
|
|
139
|
+
verbose : `bool`, optional
|
|
140
|
+
If True, a progress bar is shown while downloading the file.
|
|
141
|
+
|
|
142
|
+
The default is True.
|
|
143
|
+
|
|
144
|
+
Returns
|
|
145
|
+
-------
|
|
146
|
+
:class:`~epyt_flow.simulation.scenario_config.ScenarioConfig`
|
|
147
|
+
Net3 network loaded into a scenario configuration that can be passed on to
|
|
148
|
+
:class:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator`.
|
|
149
|
+
"""
|
|
150
|
+
f_in = os.path.join(download_dir, "Net3.inp")
|
|
151
|
+
url = "https://raw.githubusercontent.com/OpenWaterAnalytics/EPyT/main/epyt/networks/" + \
|
|
152
|
+
"asce-tf-wdst/Net3.inp"
|
|
153
|
+
|
|
154
|
+
download_if_necessary(f_in, url, verbose)
|
|
155
|
+
return load_inp(f_in)
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def load_net6(download_dir: str = get_temp_folder(), verbose: bool = True) -> ScenarioConfig:
|
|
159
|
+
"""
|
|
160
|
+
Loads (and downloads if necessary) the Net6 network.
|
|
161
|
+
|
|
162
|
+
Parameters
|
|
163
|
+
----------
|
|
164
|
+
download_dir : `str`, optional
|
|
165
|
+
Path to the directory where the .inp file is stored.
|
|
166
|
+
|
|
167
|
+
The default is the OS-specific temporary directory (e.g. "C:\\\\temp", "/tmp/", etc.)
|
|
168
|
+
verbose : `bool`, optional
|
|
169
|
+
If True, a progress bar is shown while downloading the file.
|
|
170
|
+
|
|
171
|
+
The default is True.
|
|
172
|
+
|
|
173
|
+
Returns
|
|
174
|
+
-------
|
|
175
|
+
:class:`~epyt_flow.simulation.scenario_config.ScenarioConfig`
|
|
176
|
+
Net6 network loaded into a scenario configuration that can be passed on to
|
|
177
|
+
:class:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator`.
|
|
178
|
+
"""
|
|
179
|
+
f_in = os.path.join(download_dir, "Net6.inp")
|
|
180
|
+
url = "https://github.com/OpenWaterAnalytics/WNTR/raw/main/examples/networks/Net6.inp"
|
|
181
|
+
|
|
182
|
+
download_if_necessary(f_in, url, verbose)
|
|
183
|
+
return load_inp(f_in)
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
def load_richmond(download_dir: str = get_temp_folder(), verbose: bool = True) -> ScenarioConfig:
|
|
187
|
+
"""
|
|
188
|
+
Loads (and downloads if necessary) the Richmond network.
|
|
189
|
+
|
|
190
|
+
Parameters
|
|
191
|
+
----------
|
|
192
|
+
download_dir : `str`, optional
|
|
193
|
+
Path to the directory where the .inp file is stored.
|
|
194
|
+
|
|
195
|
+
The default is the OS-specific temporary directory (e.g. "C:\\\\temp", "/tmp/", etc.)
|
|
196
|
+
verbose : `bool`, optional
|
|
197
|
+
If True, a progress bar is shown while downloading the file.
|
|
198
|
+
|
|
199
|
+
The default is True.
|
|
200
|
+
|
|
201
|
+
Returns
|
|
202
|
+
-------
|
|
203
|
+
:class:`~epyt_flow.simulation.scenario_config.ScenarioConfig`
|
|
204
|
+
Richmond network loaded into a scenario configuration that can be passed on to
|
|
205
|
+
:class:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator`.
|
|
206
|
+
"""
|
|
207
|
+
f_in = os.path.join(download_dir, "Richmond_standard.inp")
|
|
208
|
+
url = "https://raw.githubusercontent.com/OpenWaterAnalytics/EPyT/main/epyt/networks/" + \
|
|
209
|
+
"exeter-benchmarks/Richmond_standard.inp"
|
|
210
|
+
|
|
211
|
+
download_if_necessary(f_in, url, verbose)
|
|
212
|
+
return load_inp(f_in)
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
def load_micropolis(download_dir: str = get_temp_folder(), verbose: bool = True) -> ScenarioConfig:
|
|
216
|
+
"""
|
|
217
|
+
Loads (and downloads if necessary) the MICROPOLIS network.
|
|
218
|
+
|
|
219
|
+
Parameters
|
|
220
|
+
----------
|
|
221
|
+
download_dir : `str`, optional
|
|
222
|
+
Path to the directory where the .inp file is stored.
|
|
223
|
+
|
|
224
|
+
The default is the OS-specific temporary directory (e.g. "C:\\\\temp", "/tmp/", etc.)
|
|
225
|
+
verbose : `bool`, optional
|
|
226
|
+
If True, a progress bar is shown while downloading the file.
|
|
227
|
+
|
|
228
|
+
The default is True.
|
|
229
|
+
|
|
230
|
+
Returns
|
|
231
|
+
-------
|
|
232
|
+
:class:`~epyt_flow.simulation.scenario_config.ScenarioConfig`
|
|
233
|
+
MICROPOLIS network loaded into a scenario configuration that can be passed on to
|
|
234
|
+
:class:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator`.
|
|
235
|
+
"""
|
|
236
|
+
f_in = os.path.join(download_dir, "MICROPOLIS_v1.inp")
|
|
237
|
+
url = "https://github.com/OpenWaterAnalytics/EPyT/raw/main/epyt/networks/asce-tf-wdst/" + \
|
|
238
|
+
"MICROPOLIS_v1.inp"
|
|
239
|
+
|
|
240
|
+
download_if_necessary(f_in, url, verbose)
|
|
241
|
+
return load_inp(f_in)
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
def load_balerma(download_dir: str = get_temp_folder(), verbose: bool = True) -> ScenarioConfig:
|
|
245
|
+
"""
|
|
246
|
+
Loads (and downloads if necessary) the Balerma network.
|
|
247
|
+
|
|
248
|
+
Parameters
|
|
249
|
+
----------
|
|
250
|
+
download_dir : `str`, optional
|
|
251
|
+
Path to the directory where the .inp file is stored.
|
|
252
|
+
|
|
253
|
+
The default is the OS-specific temporary directory (e.g. "C:\\\\temp", "/tmp/", etc.)
|
|
254
|
+
verbose : `bool`, optional
|
|
255
|
+
If True, a progress bar is shown while downloading the file.
|
|
256
|
+
|
|
257
|
+
The default is True.
|
|
258
|
+
|
|
259
|
+
Returns
|
|
260
|
+
-------
|
|
261
|
+
:class:`~epyt_flow.simulation.scenario_config.ScenarioConfig`
|
|
262
|
+
Balerma network loaded into a scenario configuration that can be passed on to
|
|
263
|
+
:class:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator`.
|
|
264
|
+
"""
|
|
265
|
+
f_in = os.path.join(download_dir, "Balerma.inp")
|
|
266
|
+
url = "https://github.com/OpenWaterAnalytics/EPyT/raw/main/epyt/networks/" + \
|
|
267
|
+
"asce-tf-wdst/Balerma.inp"
|
|
268
|
+
|
|
269
|
+
download_if_necessary(f_in, url, verbose)
|
|
270
|
+
return load_inp(f_in)
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
def load_rural(download_dir: str = get_temp_folder(), verbose: bool = True) -> ScenarioConfig:
|
|
274
|
+
"""
|
|
275
|
+
Loads (and downloads if necessary) the Rural network.
|
|
276
|
+
|
|
277
|
+
Parameters
|
|
278
|
+
----------
|
|
279
|
+
download_dir : `str`, optional
|
|
280
|
+
Path to the directory where the .inp file is stored.
|
|
281
|
+
|
|
282
|
+
The default is the OS-specific temporary directory (e.g. "C:\\\\temp", "/tmp/", etc.)
|
|
283
|
+
verbose : `bool`, optional
|
|
284
|
+
If True, a progress bar is shown while downloading the file.
|
|
285
|
+
|
|
286
|
+
The default is True.
|
|
287
|
+
|
|
288
|
+
Returns
|
|
289
|
+
-------
|
|
290
|
+
:class:`~epyt_flow.simulation.scenario_config.ScenarioConfig`
|
|
291
|
+
Rural network loaded into a scenario configuration that can be passed on to
|
|
292
|
+
:class:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator`.
|
|
293
|
+
"""
|
|
294
|
+
f_in = os.path.join(download_dir, "RuralNetwork.inp")
|
|
295
|
+
url = "https://github.com/OpenWaterAnalytics/EPyT/raw/main/epyt/networks/" + \
|
|
296
|
+
"asce-tf-wdst/RuralNetwork.inp"
|
|
297
|
+
|
|
298
|
+
download_if_necessary(f_in, url, verbose)
|
|
299
|
+
return load_inp(f_in)
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
def load_bwsn1(download_dir: str = get_temp_folder(), verbose: bool = True) -> ScenarioConfig:
|
|
303
|
+
"""
|
|
304
|
+
Loads (and downloads if necessary) the BWSN-1 network.
|
|
305
|
+
|
|
306
|
+
Parameters
|
|
307
|
+
----------
|
|
308
|
+
download_dir : `str`, optional
|
|
309
|
+
Path to the directory where the .inp file is stored.
|
|
310
|
+
|
|
311
|
+
The default is the OS-specific temporary directory (e.g. "C:\\\\temp", "/tmp/", etc.)
|
|
312
|
+
verbose : `bool`, optional
|
|
313
|
+
If True, a progress bar is shown while downloading the file.
|
|
314
|
+
|
|
315
|
+
The default is True.
|
|
316
|
+
|
|
317
|
+
Returns
|
|
318
|
+
-------
|
|
319
|
+
:class:`~epyt_flow.simulation.scenario_config.ScenarioConfig`
|
|
320
|
+
BWSN-1 network loaded into a scenario configuration that can be passed on to
|
|
321
|
+
:class:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator`.
|
|
322
|
+
"""
|
|
323
|
+
f_in = os.path.join(download_dir, "BWSN_Network_1.inp")
|
|
324
|
+
url = "https://github.com/OpenWaterAnalytics/EPyT/raw/main/epyt/networks/" + \
|
|
325
|
+
"asce-tf-wdst/BWSN_Network_1.inp"
|
|
326
|
+
|
|
327
|
+
download_if_necessary(f_in, url, verbose)
|
|
328
|
+
return load_inp(f_in)
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
def load_bwsn2(download_dir: str = get_temp_folder(), verbose: bool = True) -> ScenarioConfig:
|
|
332
|
+
"""
|
|
333
|
+
Loads (and downloads if necessary) the BWSN-2 network.
|
|
334
|
+
|
|
335
|
+
Parameters
|
|
336
|
+
----------
|
|
337
|
+
download_dir : `str`, optional
|
|
338
|
+
Path to the directory where the .inp file is stored.
|
|
339
|
+
|
|
340
|
+
The default is the OS-specific temporary directory (e.g. "C:\\\\temp", "/tmp/", etc.)
|
|
341
|
+
verbose : `bool`, optional
|
|
342
|
+
If True, a progress bar is shown while downloading the file.
|
|
343
|
+
|
|
344
|
+
The default is True.
|
|
345
|
+
|
|
346
|
+
Returns
|
|
347
|
+
-------
|
|
348
|
+
:class:`~epyt_flow.simulation.scenario_config.ScenarioConfig`
|
|
349
|
+
BWSN-2 network loaded into a scenario configuration that can be passed on to
|
|
350
|
+
:class:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator`.
|
|
351
|
+
"""
|
|
352
|
+
f_in = os.path.join(download_dir, "BWSN_Network_2.inp")
|
|
353
|
+
url = "https://github.com/OpenWaterAnalytics/EPyT/raw/main/epyt/networks/" + \
|
|
354
|
+
"asce-tf-wdst/BWSN_Network_2.inp"
|
|
355
|
+
|
|
356
|
+
download_if_necessary(f_in, url, verbose)
|
|
357
|
+
return load_inp(f_in)
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
def load_anytown(download_dir: str = get_temp_folder(), verbose: bool = True) -> ScenarioConfig:
|
|
361
|
+
"""
|
|
362
|
+
Loads (and downloads if necessary) the Anytown network.
|
|
363
|
+
|
|
364
|
+
Parameters
|
|
365
|
+
----------
|
|
366
|
+
download_dir : `str`, optional
|
|
367
|
+
Path to the directory where the .inp file is stored.
|
|
368
|
+
|
|
369
|
+
The default is the OS-specific temporary directory (e.g. "C:\\\\temp", "/tmp/", etc.)
|
|
370
|
+
verbose : `bool`, optional
|
|
371
|
+
If True, a progress bar is shown while downloading the file.
|
|
372
|
+
|
|
373
|
+
The default is True.
|
|
374
|
+
|
|
375
|
+
Returns
|
|
376
|
+
-------
|
|
377
|
+
:class:`~epyt_flow.simulation.scenario_config.ScenarioConfig`
|
|
378
|
+
Anytown network loaded into a scenario configuration that can be passed on to
|
|
379
|
+
:class:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator`.
|
|
380
|
+
"""
|
|
381
|
+
f_in = os.path.join(download_dir, "Anytown.inp")
|
|
382
|
+
url = "https://raw.githubusercontent.com/OpenWaterAnalytics/EPyT/main/epyt/networks/" + \
|
|
383
|
+
"asce-tf-wdst/Anytown.inp"
|
|
384
|
+
|
|
385
|
+
download_if_necessary(f_in, url, verbose)
|
|
386
|
+
return load_inp(f_in)
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
def load_dtown(download_dir: str = get_temp_folder(), verbose: bool = True) -> ScenarioConfig:
|
|
390
|
+
"""
|
|
391
|
+
Loads (and downloads if necessary) the D-Town network.
|
|
392
|
+
|
|
393
|
+
Parameters
|
|
394
|
+
----------
|
|
395
|
+
download_dir : `str`, optional
|
|
396
|
+
Path to the directory where the .inp file is stored.
|
|
397
|
+
|
|
398
|
+
The default is the OS-specific temporary directory (e.g. "C:\\\\temp", "/tmp/", etc.)
|
|
399
|
+
verbose : `bool`, optional
|
|
400
|
+
If True, a progress bar is shown while downloading the file.
|
|
401
|
+
|
|
402
|
+
The default is True.
|
|
403
|
+
|
|
404
|
+
Returns
|
|
405
|
+
-------
|
|
406
|
+
:class:`~epyt_flow.simulation.scenario_config.ScenarioConfig`
|
|
407
|
+
D-Town network loaded into a scenario configuration that can be passed on to
|
|
408
|
+
:class:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator`.
|
|
409
|
+
"""
|
|
410
|
+
f_in = os.path.join(download_dir, "d-town.inp")
|
|
411
|
+
url = "https://www.exeter.ac.uk/media/universityofexeter/emps/research/cws/downloads/d-town.inp"
|
|
412
|
+
|
|
413
|
+
download_if_necessary(f_in, url, verbose)
|
|
414
|
+
return load_inp(f_in)
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
def load_ctown(download_dir: str = get_temp_folder(), verbose: bool = True) -> ScenarioConfig:
|
|
418
|
+
"""
|
|
419
|
+
Loads (and downloads if necessary) the C-Town network.
|
|
420
|
+
|
|
421
|
+
Parameters
|
|
422
|
+
----------
|
|
423
|
+
download_dir : `str`, optional
|
|
424
|
+
Path to the directory where the .inp file is stored.
|
|
425
|
+
|
|
426
|
+
The default is the OS-specific temporary directory (e.g. "C:\\\\temp", "/tmp/", etc.)
|
|
427
|
+
verbose : `bool`, optional
|
|
428
|
+
If True, a progress bar is shown while downloading the file.
|
|
429
|
+
|
|
430
|
+
The default is True.
|
|
431
|
+
|
|
432
|
+
Returns
|
|
433
|
+
-------
|
|
434
|
+
:class:`~epyt_flow.simulation.scenario_config.ScenarioConfig`
|
|
435
|
+
C-Town network loaded into a scenario configuration that can be passed on to
|
|
436
|
+
:class:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator`.
|
|
437
|
+
"""
|
|
438
|
+
f_in = os.path.join(download_dir, "CTOWN.INP")
|
|
439
|
+
url = "https://github.com/scy-phy/www.batadal.net/raw/master/data/CTOWN.INP"
|
|
440
|
+
|
|
441
|
+
download_if_necessary(f_in, url, verbose)
|
|
442
|
+
return load_inp(f_in)
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
def load_kentucky(wdn_id: int = 1, download_dir: str = get_temp_folder(),
|
|
446
|
+
verbose: bool = True) -> ScenarioConfig:
|
|
447
|
+
"""
|
|
448
|
+
Loads (and downloads if necessary) the specified Kentucky network.
|
|
449
|
+
|
|
450
|
+
Parameters
|
|
451
|
+
----------
|
|
452
|
+
wdn_id : `int`, optional
|
|
453
|
+
The ID (1-15) of the particular network.
|
|
454
|
+
|
|
455
|
+
The default is wdn_id=1
|
|
456
|
+
download_dir : `str`, optional
|
|
457
|
+
Path to the directory where the .inp file is stored.
|
|
458
|
+
|
|
459
|
+
The default is the OS-specific temporary directory (e.g. "C:\\\\temp", "/tmp/", etc.)
|
|
460
|
+
verbose : `bool`, optional
|
|
461
|
+
If True, a progress bar is shown while downloading the file.
|
|
462
|
+
|
|
463
|
+
The default is True.
|
|
464
|
+
|
|
465
|
+
Returns
|
|
466
|
+
-------
|
|
467
|
+
:class:`~epyt_flow.simulation.scenario_config.ScenarioConfig`
|
|
468
|
+
Kentucky network loaded into a scenario configuration that can be passed on to
|
|
469
|
+
:class:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator`.
|
|
470
|
+
"""
|
|
471
|
+
if not isinstance(wdn_id, int):
|
|
472
|
+
raise ValueError("'wdn_id' must be an integer in [1, 15]")
|
|
473
|
+
if wdn_id < 1 or wdn_id > 15:
|
|
474
|
+
raise ValueError(f"Unknown network 'ky{wdn_id}.inp'")
|
|
475
|
+
|
|
476
|
+
f_in = os.path.join(download_dir, f"ky{wdn_id}.inp")
|
|
477
|
+
url = "https://raw.githubusercontent.com/OpenWaterAnalytics/EPyT/main/epyt/networks/" + \
|
|
478
|
+
f"asce-tf-wdst/ky{wdn_id}.inp"
|
|
479
|
+
|
|
480
|
+
download_if_necessary(f_in, url, verbose)
|
|
481
|
+
return load_inp(f_in)
|
|
482
|
+
|
|
483
|
+
|
|
484
|
+
def load_hanoi(download_dir: str = get_temp_folder(),
|
|
485
|
+
include_default_sensor_placement: bool = False,
|
|
486
|
+
verbose: bool = True) -> ScenarioConfig:
|
|
487
|
+
"""
|
|
488
|
+
Loads (and downloads if necessary) the Hanoi network.
|
|
489
|
+
|
|
490
|
+
Parameters
|
|
491
|
+
----------
|
|
492
|
+
download_dir : `str`, optional
|
|
493
|
+
Path to the directory where the .inp file is stored.
|
|
494
|
+
|
|
495
|
+
The default is the OS-specific temporary directory (e.g. "C:\\\\temp", "/tmp/", etc.)
|
|
496
|
+
include_default_sensor_placement : `bool`, optional
|
|
497
|
+
If True, a default sensor placement will be included in the returned scenario configuration.
|
|
498
|
+
|
|
499
|
+
The default is False
|
|
500
|
+
verbose : `bool`, optional
|
|
501
|
+
If True, a progress bar is shown while downloading the file.
|
|
502
|
+
|
|
503
|
+
The default is True.
|
|
504
|
+
|
|
505
|
+
Returns
|
|
506
|
+
-------
|
|
507
|
+
:class:`~epyt_flow.simulation.scenario_config.ScenarioConfig`
|
|
508
|
+
Hanoi network loaded into a scenario configuration that can be passed on to
|
|
509
|
+
:class:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator`.
|
|
510
|
+
"""
|
|
511
|
+
f_in = os.path.join(download_dir, "Hanoi.inp")
|
|
512
|
+
url = "https://raw.githubusercontent.com/OpenWaterAnalytics/EPyT/main/epyt/networks/" + \
|
|
513
|
+
"asce-tf-wdst/Hanoi.inp"
|
|
514
|
+
|
|
515
|
+
download_if_necessary(f_in, url, verbose)
|
|
516
|
+
config = load_inp(f_in)
|
|
517
|
+
|
|
518
|
+
if include_default_sensor_placement is True:
|
|
519
|
+
sensor_config = config.sensor_config
|
|
520
|
+
sensor_config.pressure_sensors = ["13", "16", "22", "30"]
|
|
521
|
+
sensor_config.flow_sensors = ["1"]
|
|
522
|
+
|
|
523
|
+
config = ScenarioConfig(scenario_config=config, sensor_config=sensor_config)
|
|
524
|
+
|
|
525
|
+
return config
|
|
526
|
+
|
|
527
|
+
|
|
528
|
+
def load_ltown(download_dir: str = get_temp_folder(), use_realistic_demands: bool = False,
|
|
529
|
+
include_default_sensor_placement: bool = False,
|
|
530
|
+
verbose: bool = True) -> ScenarioConfig:
|
|
531
|
+
"""
|
|
532
|
+
Loads (and downloads if necessary) the L-TOWN_v2 network.
|
|
533
|
+
|
|
534
|
+
Parameters
|
|
535
|
+
----------
|
|
536
|
+
download_dir : `str`, optional
|
|
537
|
+
Path to the directory where the .inp file is stored.
|
|
538
|
+
|
|
539
|
+
The default is the OS-specific temporary directory (e.g. "C:\\\\temp", "/tmp/", etc.)
|
|
540
|
+
use_realistic_demands : `bool`, optional
|
|
541
|
+
If True, realistic demands from the BattLeDIM challenge will be included,
|
|
542
|
+
toy demands will be included otherwise.
|
|
543
|
+
|
|
544
|
+
The default is False
|
|
545
|
+
include_default_sensor_placement : `bool`, optional
|
|
546
|
+
If True, the L-TOWN default sensor placement will be included
|
|
547
|
+
in the returned scenario configuration.
|
|
548
|
+
|
|
549
|
+
The default is False
|
|
550
|
+
verbose : `bool`, optional
|
|
551
|
+
If True, a progress bar is shown while downloading the file.
|
|
552
|
+
|
|
553
|
+
The default is True.
|
|
554
|
+
|
|
555
|
+
Returns
|
|
556
|
+
-------
|
|
557
|
+
:class:`~epyt_flow.simulation.scenario_config.ScenarioConfig`
|
|
558
|
+
L-TOWN_v2 network loaded into a scenario configuration that can be passed on to
|
|
559
|
+
:class:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator`.
|
|
560
|
+
"""
|
|
561
|
+
f_inp = "L-TOWN_v2_Model.inp" if use_realistic_demands is False else "L-TOWN_v2_Real.inp"
|
|
562
|
+
|
|
563
|
+
f_in = os.path.join(download_dir, f_inp)
|
|
564
|
+
if not use_realistic_demands:
|
|
565
|
+
url = "https://zenodo.org/records/4017659/files/L-TOWN.inp?download=1"
|
|
566
|
+
else:
|
|
567
|
+
url = "https://zenodo.org/records/4017659/files/L-TOWN_Real.inp?download=1"
|
|
568
|
+
|
|
569
|
+
download_if_necessary(f_in, url, verbose)
|
|
570
|
+
config = load_inp(f_in)
|
|
571
|
+
|
|
572
|
+
if include_default_sensor_placement is True:
|
|
573
|
+
sensor_config = config.sensor_config
|
|
574
|
+
sensor_config.pressure_sensors = ["n54", "n105", "n114", "n163", "n188", "n229", "n288",
|
|
575
|
+
"n296", "n332", "n342", "n410", "n415", "n429", "n458",
|
|
576
|
+
"n469", "n495", "n506", "n516", "n519", "n549", "n613",
|
|
577
|
+
"n636", "n644", "n679", "n722", "n726", "n740", "n752",
|
|
578
|
+
"n769"]
|
|
579
|
+
sensor_config.flow_sensors = ["p227", "p235"]
|
|
580
|
+
sensor_config.tank_volume_sensors = ["T1"]
|
|
581
|
+
sensor_config.demand_sensors = ["n1", "n2", "n3", "n4", "n6", "n7", "n8", "n9", "n10",
|
|
582
|
+
"n11", "n13", "n16", "n17", "n18", "n19", "n20", "n21",
|
|
583
|
+
"n22", "n23", "n24", "n25", "n26", "n27", "n28", "n29",
|
|
584
|
+
"n30", "n31", "n32", "n33", "n34", "n35", "n36", "n39",
|
|
585
|
+
"n40", "n41", "n42", "n43", "n44", "n45", "n343", "n344",
|
|
586
|
+
"n345", "n346", "n347", "n349", "n350", "n351", "n352",
|
|
587
|
+
"n353", "n354", "n355", "n356", "n357", "n358", "n360",
|
|
588
|
+
"n361", "n362", "n364", "n365", "n366", "n367", "n368",
|
|
589
|
+
"n369", "n370", "n371", "n372", "n373", "n374", "n375",
|
|
590
|
+
"n376", "n377", "n378", "n379", "n381", "n382", "n383",
|
|
591
|
+
"n384", "n385", "n386", "n387", "n388", "n389"]
|
|
592
|
+
|
|
593
|
+
config = ScenarioConfig(scenario_config=config, sensor_config=sensor_config)
|
|
594
|
+
|
|
595
|
+
return config
|
|
596
|
+
|
|
597
|
+
|
|
598
|
+
def load_ltown_a(download_dir: str = get_temp_folder(), use_realistic_demands: bool = False,
|
|
599
|
+
include_default_sensor_placement: bool = False,
|
|
600
|
+
verbose: bool = True) -> ScenarioConfig:
|
|
601
|
+
"""
|
|
602
|
+
Loads (and downloads if necessary) the L-TOWN-A network (area "A" of the L-TOWN network).
|
|
603
|
+
|
|
604
|
+
Parameters
|
|
605
|
+
----------
|
|
606
|
+
download_dir : `str`, optional
|
|
607
|
+
Path to the directory where the .inp file is stored.
|
|
608
|
+
|
|
609
|
+
The default is the OS-specific temporary directory (e.g. "C:\\\\temp", "/tmp/", etc.)
|
|
610
|
+
use_realistic_demands : `bool`, optional
|
|
611
|
+
If True, realistic demands from the BattLeDIM challenge will be included,
|
|
612
|
+
toy demands will be included otherwise.
|
|
613
|
+
|
|
614
|
+
The default is False
|
|
615
|
+
include_default_sensor_placement : `bool`, optional
|
|
616
|
+
If True, the L-TOWN default sensor placement will be included
|
|
617
|
+
in the returned scenario configuration.
|
|
618
|
+
|
|
619
|
+
The default is False
|
|
620
|
+
verbose : `bool`, optional
|
|
621
|
+
If True, a progress bar is shown while downloading the file.
|
|
622
|
+
|
|
623
|
+
The default is True.
|
|
624
|
+
|
|
625
|
+
Returns
|
|
626
|
+
-------
|
|
627
|
+
:class:`~epyt_flow.simulation.scenario_config.ScenarioConfig`
|
|
628
|
+
L-TOWN-A network loaded into a scenario configuration that can be passed on to
|
|
629
|
+
:class:`~epyt_flow.simulation.scenario_simulator.ScenarioSimulator`.
|
|
630
|
+
"""
|
|
631
|
+
f_inp = "L-TOWN_v2-A_Model.inp" if use_realistic_demands is False else "L-TOWN_v2-A_Real.inp"
|
|
632
|
+
|
|
633
|
+
f_in = os.path.join(download_dir, f_inp)
|
|
634
|
+
url = f"https://filedn.com/lumBFq2P9S74PNoLPWtzxG4/EPyT-Flow/Networks/{f_inp}"
|
|
635
|
+
|
|
636
|
+
download_if_necessary(f_in, url, verbose)
|
|
637
|
+
config = load_inp(f_in)
|
|
638
|
+
|
|
639
|
+
if include_default_sensor_placement is True:
|
|
640
|
+
sensor_config = config.sensor_config
|
|
641
|
+
sensor_config.pressure_sensors = ["n54", "n105", "n114", "n163", "n188", "n229", "n288",
|
|
642
|
+
"n296", "n332", "n342", "n410", "n415", "n429", "n458",
|
|
643
|
+
"n469", "n495", "n506", "n516", "n519", "n549", "n613",
|
|
644
|
+
"n636", "n644", "n679", "n722", "n726", "n740", "n752",
|
|
645
|
+
"n769"]
|
|
646
|
+
sensor_config.flow_sensors = ["p227", "p235"]
|
|
647
|
+
|
|
648
|
+
config = ScenarioConfig(scenario_config=config, sensor_config=sensor_config)
|
|
649
|
+
|
|
650
|
+
return config
|