floodmodeller-api 0.4.2.post1__py3-none-any.whl → 0.4.4__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.
- floodmodeller_api/__init__.py +8 -9
- floodmodeller_api/_base.py +169 -176
- floodmodeller_api/backup.py +273 -273
- floodmodeller_api/dat.py +889 -831
- floodmodeller_api/diff.py +136 -119
- floodmodeller_api/ied.py +302 -306
- floodmodeller_api/ief.py +553 -637
- floodmodeller_api/ief_flags.py +253 -253
- floodmodeller_api/inp.py +260 -266
- floodmodeller_api/libs/libifcoremd.dll +0 -0
- floodmodeller_api/libs/libifcoremt.so.5 +0 -0
- floodmodeller_api/libs/libifport.so.5 +0 -0
- floodmodeller_api/{libmmd.dll → libs/libimf.so} +0 -0
- floodmodeller_api/libs/libintlc.so.5 +0 -0
- floodmodeller_api/libs/libmmd.dll +0 -0
- floodmodeller_api/libs/libsvml.so +0 -0
- floodmodeller_api/libs/libzzn_read.so +0 -0
- floodmodeller_api/libs/zzn_read.dll +0 -0
- floodmodeller_api/logs/__init__.py +2 -2
- floodmodeller_api/logs/lf.py +364 -312
- floodmodeller_api/logs/lf_helpers.py +354 -352
- floodmodeller_api/logs/lf_params.py +643 -529
- floodmodeller_api/mapping.py +84 -0
- floodmodeller_api/test/__init__.py +4 -4
- floodmodeller_api/test/conftest.py +16 -8
- floodmodeller_api/test/test_backup.py +117 -117
- floodmodeller_api/test/test_conveyance.py +107 -0
- floodmodeller_api/test/test_dat.py +222 -92
- floodmodeller_api/test/test_data/All Units 4_6.DAT +1081 -1081
- floodmodeller_api/test/test_data/All Units 4_6.feb +1081 -1081
- floodmodeller_api/test/test_data/BRIDGE.DAT +926 -926
- floodmodeller_api/test/test_data/Culvert_Inlet_Outlet.dat +36 -36
- floodmodeller_api/test/test_data/Culvert_Inlet_Outlet.feb +36 -36
- floodmodeller_api/test/test_data/DamBreakADI.xml +52 -52
- floodmodeller_api/test/test_data/DamBreakFAST.xml +58 -58
- floodmodeller_api/test/test_data/DamBreakFAST_dy.xml +53 -53
- floodmodeller_api/test/test_data/DamBreakTVD.xml +55 -55
- floodmodeller_api/test/test_data/DefenceBreach.xml +53 -53
- floodmodeller_api/test/test_data/DefenceBreachFAST.xml +60 -60
- floodmodeller_api/test/test_data/DefenceBreachFAST_dy.xml +55 -55
- floodmodeller_api/test/test_data/Domain1+2_QH.xml +76 -76
- floodmodeller_api/test/test_data/Domain1_H.xml +41 -41
- floodmodeller_api/test/test_data/Domain1_Q.xml +41 -41
- floodmodeller_api/test/test_data/Domain1_Q_FAST.xml +48 -48
- floodmodeller_api/test/test_data/Domain1_Q_FAST_dy.xml +48 -48
- floodmodeller_api/test/test_data/Domain1_Q_xml_expected.json +263 -0
- floodmodeller_api/test/test_data/Domain1_W.xml +41 -41
- floodmodeller_api/test/test_data/EX1.DAT +321 -321
- floodmodeller_api/test/test_data/EX1.ext +107 -107
- floodmodeller_api/test/test_data/EX1.feb +320 -320
- floodmodeller_api/test/test_data/EX1.gxy +107 -107
- floodmodeller_api/test/test_data/EX17.DAT +421 -422
- floodmodeller_api/test/test_data/EX17.ext +213 -213
- floodmodeller_api/test/test_data/EX17.feb +422 -422
- floodmodeller_api/test/test_data/EX18.DAT +375 -375
- floodmodeller_api/test/test_data/EX18_DAT_expected.json +3876 -0
- floodmodeller_api/test/test_data/EX2.DAT +302 -302
- floodmodeller_api/test/test_data/EX3.DAT +926 -926
- floodmodeller_api/test/test_data/EX3_DAT_expected.json +16235 -0
- floodmodeller_api/test/test_data/EX3_IEF_expected.json +61 -0
- floodmodeller_api/test/test_data/EX6.DAT +2084 -2084
- floodmodeller_api/test/test_data/EX6.ext +532 -532
- floodmodeller_api/test/test_data/EX6.feb +2084 -2084
- floodmodeller_api/test/test_data/EX6_DAT_expected.json +31647 -0
- floodmodeller_api/test/test_data/Event Data Example.DAT +336 -336
- floodmodeller_api/test/test_data/Event Data Example.ext +107 -107
- floodmodeller_api/test/test_data/Event Data Example.feb +336 -336
- floodmodeller_api/test/test_data/Linked1D2D.xml +52 -52
- floodmodeller_api/test/test_data/Linked1D2DFAST.xml +53 -53
- floodmodeller_api/test/test_data/Linked1D2DFAST_dy.xml +48 -48
- floodmodeller_api/test/test_data/Linked1D2D_xml_expected.json +313 -0
- floodmodeller_api/test/test_data/blockage.dat +50 -50
- floodmodeller_api/test/test_data/blockage.ext +45 -45
- floodmodeller_api/test/test_data/blockage.feb +9 -9
- floodmodeller_api/test/test_data/blockage.gxy +71 -71
- floodmodeller_api/test/test_data/conveyance_test.dat +165 -0
- floodmodeller_api/test/test_data/conveyance_test.feb +116 -0
- floodmodeller_api/test/test_data/conveyance_test.gxy +85 -0
- floodmodeller_api/test/test_data/defaultUnits.dat +127 -127
- floodmodeller_api/test/test_data/defaultUnits.ext +45 -45
- floodmodeller_api/test/test_data/defaultUnits.feb +9 -9
- floodmodeller_api/test/test_data/defaultUnits.fmpx +58 -58
- floodmodeller_api/test/test_data/defaultUnits.gxy +85 -85
- floodmodeller_api/test/test_data/ex3.ief +20 -20
- floodmodeller_api/test/test_data/ex3.lf1 +2800 -2800
- floodmodeller_api/test/test_data/ex4.DAT +1374 -1374
- floodmodeller_api/test/test_data/ex4_changed.DAT +1374 -1374
- floodmodeller_api/test/test_data/example1.inp +329 -329
- floodmodeller_api/test/test_data/example2.inp +158 -158
- floodmodeller_api/test/test_data/example3.inp +297 -297
- floodmodeller_api/test/test_data/example4.inp +388 -388
- floodmodeller_api/test/test_data/example5.inp +147 -147
- floodmodeller_api/test/test_data/example6.inp +154 -154
- floodmodeller_api/test/test_data/expected_conveyance.csv +60 -0
- floodmodeller_api/test/test_data/jump.dat +176 -176
- floodmodeller_api/test/test_data/network.dat +1374 -1374
- floodmodeller_api/test/test_data/network.ext +45 -45
- floodmodeller_api/test/test_data/network.exy +1 -1
- floodmodeller_api/test/test_data/network.feb +45 -45
- floodmodeller_api/test/test_data/network.ied +45 -45
- floodmodeller_api/test/test_data/network.ief +20 -20
- floodmodeller_api/test/test_data/network.inp +147 -147
- floodmodeller_api/test/test_data/network.pxy +57 -57
- floodmodeller_api/test/test_data/network.zzd +122 -122
- floodmodeller_api/test/test_data/network_dat_expected.json +21837 -0
- floodmodeller_api/test/test_data/network_from_tabularCSV.csv +87 -87
- floodmodeller_api/test/test_data/network_ied_expected.json +287 -0
- floodmodeller_api/test/test_data/rnweir.dat +9 -9
- floodmodeller_api/test/test_data/rnweir.ext +45 -45
- floodmodeller_api/test/test_data/rnweir.feb +9 -9
- floodmodeller_api/test/test_data/rnweir.gxy +45 -45
- floodmodeller_api/test/test_data/rnweir_default.dat +74 -74
- floodmodeller_api/test/test_data/rnweir_default.ext +45 -45
- floodmodeller_api/test/test_data/rnweir_default.feb +9 -9
- floodmodeller_api/test/test_data/rnweir_default.fmpx +58 -58
- floodmodeller_api/test/test_data/rnweir_default.gxy +53 -53
- floodmodeller_api/test/test_data/unit checks.dat +16 -16
- floodmodeller_api/test/test_ied.py +29 -29
- floodmodeller_api/test/test_ief.py +136 -24
- floodmodeller_api/test/test_inp.py +47 -48
- floodmodeller_api/test/test_json.py +114 -0
- floodmodeller_api/test/test_logs_lf.py +102 -51
- floodmodeller_api/test/test_tool.py +165 -152
- floodmodeller_api/test/test_toolbox_structure_log.py +234 -239
- floodmodeller_api/test/test_xml2d.py +151 -156
- floodmodeller_api/test/test_zzn.py +36 -34
- floodmodeller_api/to_from_json.py +230 -0
- floodmodeller_api/tool.py +332 -329
- floodmodeller_api/toolbox/__init__.py +5 -5
- floodmodeller_api/toolbox/example_tool.py +45 -45
- floodmodeller_api/toolbox/model_build/__init__.py +2 -2
- floodmodeller_api/toolbox/model_build/add_siltation_definition.py +100 -98
- floodmodeller_api/toolbox/model_build/structure_log/__init__.py +1 -1
- floodmodeller_api/toolbox/model_build/structure_log/structure_log.py +287 -289
- floodmodeller_api/toolbox/model_build/structure_log_definition.py +76 -76
- floodmodeller_api/units/__init__.py +10 -10
- floodmodeller_api/units/_base.py +214 -212
- floodmodeller_api/units/boundaries.py +467 -467
- floodmodeller_api/units/comment.py +52 -55
- floodmodeller_api/units/conduits.py +382 -402
- floodmodeller_api/units/conveyance.py +301 -0
- floodmodeller_api/units/helpers.py +123 -131
- floodmodeller_api/units/iic.py +107 -101
- floodmodeller_api/units/losses.py +305 -306
- floodmodeller_api/units/sections.py +465 -446
- floodmodeller_api/units/structures.py +1690 -1683
- floodmodeller_api/units/units.py +93 -104
- floodmodeller_api/units/unsupported.py +44 -44
- floodmodeller_api/units/variables.py +87 -89
- floodmodeller_api/urban1d/__init__.py +11 -11
- floodmodeller_api/urban1d/_base.py +188 -179
- floodmodeller_api/urban1d/conduits.py +93 -85
- floodmodeller_api/urban1d/general_parameters.py +58 -58
- floodmodeller_api/urban1d/junctions.py +81 -79
- floodmodeller_api/urban1d/losses.py +81 -74
- floodmodeller_api/urban1d/outfalls.py +114 -110
- floodmodeller_api/urban1d/raingauges.py +111 -111
- floodmodeller_api/urban1d/subsections.py +92 -98
- floodmodeller_api/urban1d/xsections.py +147 -144
- floodmodeller_api/util.py +119 -21
- floodmodeller_api/validation/parameters.py +660 -660
- floodmodeller_api/validation/urban_parameters.py +388 -404
- floodmodeller_api/validation/validation.py +110 -108
- floodmodeller_api/version.py +1 -1
- floodmodeller_api/xml2d.py +632 -673
- floodmodeller_api/xml2d_template.py +37 -37
- floodmodeller_api/zzn.py +414 -363
- {floodmodeller_api-0.4.2.post1.dist-info → floodmodeller_api-0.4.4.dist-info}/LICENSE.txt +13 -13
- {floodmodeller_api-0.4.2.post1.dist-info → floodmodeller_api-0.4.4.dist-info}/METADATA +85 -82
- floodmodeller_api-0.4.4.dist-info/RECORD +185 -0
- {floodmodeller_api-0.4.2.post1.dist-info → floodmodeller_api-0.4.4.dist-info}/WHEEL +1 -1
- floodmodeller_api/libifcoremd.dll +0 -0
- floodmodeller_api/test/test_data/EX3.bmp +0 -0
- floodmodeller_api/test/test_data/test_output.csv +0 -87
- floodmodeller_api/zzn_read.dll +0 -0
- floodmodeller_api-0.4.2.post1.dist-info/RECORD +0 -164
- {floodmodeller_api-0.4.2.post1.dist-info → floodmodeller_api-0.4.4.dist-info}/entry_points.txt +0 -0
- {floodmodeller_api-0.4.2.post1.dist-info → floodmodeller_api-0.4.4.dist-info}/top_level.txt +0 -0
|
@@ -1,110 +1,114 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Flood Modeller Python API
|
|
3
|
-
Copyright (C)
|
|
4
|
-
|
|
5
|
-
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
|
|
6
|
-
as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
|
7
|
-
|
|
8
|
-
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
9
|
-
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
10
|
-
|
|
11
|
-
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.
|
|
12
|
-
|
|
13
|
-
If you have any query about this program or this License, please contact us at support@floodmodeller.com or write to the following
|
|
14
|
-
address: Jacobs UK Limited, Flood Modeller, Cottons Centre, Cottons Lane, London, SE1 2QG, United Kingdom.
|
|
15
|
-
"""
|
|
16
|
-
|
|
17
|
-
from floodmodeller_api.units.helpers import _to_float, _to_str, join_n_char_ljust
|
|
18
|
-
from floodmodeller_api.validation import _validate_unit
|
|
19
|
-
|
|
20
|
-
from ._base import UrbanSubsection, UrbanUnit
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
class OUTFALL(UrbanUnit):
|
|
24
|
-
"""Class to hold and process OUTFALL unit type
|
|
25
|
-
|
|
26
|
-
Args:
|
|
27
|
-
name (str): Unit name
|
|
28
|
-
elevation (float): Elevation of outfall invert (ft or m). (required)
|
|
29
|
-
type (string): "FREE", "NORMAL", "FIXED", "TIDAL" or "TIMESERIES". (required)
|
|
30
|
-
stage (float): elevation of fixed stage for outfall (ft or m) (required when "FIXED" type)
|
|
31
|
-
tcurve (string): name of curve in [CURVES] section containing tidal height (required when "TIDAL" type)
|
|
32
|
-
tseries (string): name of timeseries in [TIMESERIES] section that describes how outfall stage varies with time (required when "TIMESERIES" type)
|
|
33
|
-
gated (sring): "YES" or "NO" depending on whether flat gate is present that prevents reverse flow. (optional for all types, default is "NO") TODO: is this required, or can it be missing
|
|
34
|
-
routeto (string): Optional name of a subcatchment that recieves the outfall's discharge. (default is not be "", and to no route outfall's discharge)
|
|
35
|
-
|
|
36
|
-
Returns:
|
|
37
|
-
OUTFALL: Flood Modeller OUTFALL Unit class object TODO: add urban 1d in to all instances within urban 1d API
|
|
38
|
-
"""
|
|
39
|
-
|
|
40
|
-
_unit = "OUTFALL"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
self.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
)
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
1
|
+
"""
|
|
2
|
+
Flood Modeller Python API
|
|
3
|
+
Copyright (C) 2024 Jacobs U.K. Limited
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
|
|
6
|
+
as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
|
7
|
+
|
|
8
|
+
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
9
|
+
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
10
|
+
|
|
11
|
+
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.
|
|
12
|
+
|
|
13
|
+
If you have any query about this program or this License, please contact us at support@floodmodeller.com or write to the following
|
|
14
|
+
address: Jacobs UK Limited, Flood Modeller, Cottons Centre, Cottons Lane, London, SE1 2QG, United Kingdom.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from floodmodeller_api.units.helpers import _to_float, _to_str, join_n_char_ljust
|
|
18
|
+
from floodmodeller_api.validation import _validate_unit
|
|
19
|
+
|
|
20
|
+
from ._base import UrbanSubsection, UrbanUnit
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class OUTFALL(UrbanUnit):
|
|
24
|
+
"""Class to hold and process OUTFALL unit type
|
|
25
|
+
|
|
26
|
+
Args:
|
|
27
|
+
name (str): Unit name
|
|
28
|
+
elevation (float): Elevation of outfall invert (ft or m). (required)
|
|
29
|
+
type (string): "FREE", "NORMAL", "FIXED", "TIDAL" or "TIMESERIES". (required)
|
|
30
|
+
stage (float): elevation of fixed stage for outfall (ft or m) (required when "FIXED" type)
|
|
31
|
+
tcurve (string): name of curve in [CURVES] section containing tidal height (required when "TIDAL" type)
|
|
32
|
+
tseries (string): name of timeseries in [TIMESERIES] section that describes how outfall stage varies with time (required when "TIMESERIES" type)
|
|
33
|
+
gated (sring): "YES" or "NO" depending on whether flat gate is present that prevents reverse flow. (optional for all types, default is "NO") TODO: is this required, or can it be missing
|
|
34
|
+
routeto (string): Optional name of a subcatchment that recieves the outfall's discharge. (default is not be "", and to no route outfall's discharge)
|
|
35
|
+
|
|
36
|
+
Returns:
|
|
37
|
+
OUTFALL: Flood Modeller OUTFALL Unit class object TODO: add urban 1d in to all instances within urban 1d API
|
|
38
|
+
"""
|
|
39
|
+
|
|
40
|
+
_unit = "OUTFALL"
|
|
41
|
+
MIN_LENGTH_FREE_NORMAL = 5
|
|
42
|
+
MIN_LENGTH_FIXED_NORMAL_TIMESERIES = 6
|
|
43
|
+
|
|
44
|
+
def _read(self, line):
|
|
45
|
+
unit_data = line.split()
|
|
46
|
+
|
|
47
|
+
# TODO: add functionality to read comments
|
|
48
|
+
# TODO: considering raising an exception if any of the required parameters are missing
|
|
49
|
+
|
|
50
|
+
self.name = str(unit_data[0])
|
|
51
|
+
self.elevation = _to_float(unit_data[1], 0.0)
|
|
52
|
+
self.type = str(unit_data[2])
|
|
53
|
+
|
|
54
|
+
if self.type in ("FREE", "NORMAL"):
|
|
55
|
+
# Extend length of unit_data to account for missing optional arguments.
|
|
56
|
+
while len(unit_data) < self.MIN_LENGTH_FREE_NORMAL:
|
|
57
|
+
unit_data.append("")
|
|
58
|
+
|
|
59
|
+
self.gated = _to_str(unit_data[3], "NO")
|
|
60
|
+
self.routeto = _to_str(unit_data[4], "")
|
|
61
|
+
|
|
62
|
+
elif self.type in ("FIXED", "NORMAL", "TIMESERIES"):
|
|
63
|
+
# Extend length of unit_data to account for missing optional arguments.
|
|
64
|
+
while len(unit_data) < self.MIN_LENGTH_FIXED_NORMAL_TIMESERIES:
|
|
65
|
+
unit_data.append("")
|
|
66
|
+
|
|
67
|
+
if self.type == "FIXED":
|
|
68
|
+
self.stage = _to_float(unit_data[3], 0.0)
|
|
69
|
+
|
|
70
|
+
elif self.type == "NORMAL":
|
|
71
|
+
self.tcurve = _to_str(unit_data[3], "")
|
|
72
|
+
|
|
73
|
+
elif self.type == "TIMESERIES":
|
|
74
|
+
self.tseries = _to_str(unit_data[3], "")
|
|
75
|
+
|
|
76
|
+
self.gated = _to_str(unit_data[4], "NO")
|
|
77
|
+
self.routeto = _to_str(unit_data[5], "")
|
|
78
|
+
|
|
79
|
+
def _write(self):
|
|
80
|
+
"""Function to write a valid OUTFALL line"""
|
|
81
|
+
|
|
82
|
+
_validate_unit(self, urban=True)
|
|
83
|
+
|
|
84
|
+
# TODO:Improve indentation format when writing and include header for completeness
|
|
85
|
+
|
|
86
|
+
params1 = join_n_char_ljust(17, self.name) + join_n_char_ljust(
|
|
87
|
+
15,
|
|
88
|
+
self.elevation,
|
|
89
|
+
self.type,
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
if self.type in ("FREE", "NORMAL"):
|
|
93
|
+
params2 = join_n_char_ljust(15, "", self.gated, self.routeto)
|
|
94
|
+
|
|
95
|
+
elif self.type == "FIXED":
|
|
96
|
+
params2 = join_n_char_ljust(15, self.stage, self.gated, self.routeto)
|
|
97
|
+
|
|
98
|
+
elif self.type == "NORMAL":
|
|
99
|
+
params2 = join_n_char_ljust(15, self.tcurve, self.gated, self.routeto)
|
|
100
|
+
|
|
101
|
+
elif self.type == "TIMESERIES":
|
|
102
|
+
params2 = join_n_char_ljust(15, self.tseries, self.gated, self.routeto)
|
|
103
|
+
|
|
104
|
+
else:
|
|
105
|
+
raise RuntimeError(f"{self.type} not supported")
|
|
106
|
+
|
|
107
|
+
return params1 + params2
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
class OUTFALLS(UrbanSubsection):
|
|
111
|
+
"""Class to read/write the table of outfalls"""
|
|
112
|
+
|
|
113
|
+
_urban_unit_class = OUTFALL
|
|
114
|
+
_attribute = "outfalls"
|
|
@@ -1,111 +1,111 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Flood Modeller Python API
|
|
3
|
-
Copyright (C)
|
|
4
|
-
|
|
5
|
-
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
|
|
6
|
-
as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
|
7
|
-
|
|
8
|
-
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
9
|
-
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
10
|
-
|
|
11
|
-
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.
|
|
12
|
-
|
|
13
|
-
If you have any query about this program or this License, please contact us at support@floodmodeller.com or write to the following
|
|
14
|
-
address: Jacobs UK Limited, Flood Modeller, Cottons Centre, Cottons Lane, London, SE1 2QG, United Kingdom.
|
|
15
|
-
"""
|
|
16
|
-
|
|
17
|
-
from floodmodeller_api.units.helpers import _to_float, join_n_char_ljust
|
|
18
|
-
from floodmodeller_api.validation import _validate_unit
|
|
19
|
-
|
|
20
|
-
from ._base import UrbanSubsection, UrbanUnit
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
class RAINGAUGE(UrbanUnit):
|
|
24
|
-
"""Class to hold and process RAINGAUGE unit type
|
|
25
|
-
|
|
26
|
-
Args:
|
|
27
|
-
name (str): Unit name
|
|
28
|
-
format (str): Form of recorded rainfall, either 'INTENSITY', 'VOLUME' or 'CUMULATIVE' (mandatory)
|
|
29
|
-
interval (float): Time interval between gauge readings in decimal hours or hours:minutes format (e.g., 0:15 for 15-minute readings). (mandatory)
|
|
30
|
-
snow_catch_factor (float): Snow catch deficiency correction factor (SCF) (use 1.0 for no adjustment). (mandatory)
|
|
31
|
-
data_option (str):'TIMESERIES' or 'FILE' defining where the data is provdied.
|
|
32
|
-
timeseries (str): Name of time series in [TIMESERIES] section with rainfall data (mandatory, if data_option = 'TIMESERIES')
|
|
33
|
-
filename (str): Name of external file with rainfall data. (mandatory, if data_option = 'File')
|
|
34
|
-
station (str)Name of recording station used in the rain file (mandatory, if data_option = 'File')
|
|
35
|
-
units (str): Rain depth units used in the rain file, either 'IN' (inches) or 'MM' (millimeters).(mandatory, if data_option = 'File')
|
|
36
|
-
|
|
37
|
-
Returns:
|
|
38
|
-
RAINGAUGE: Flood Modeller RAINGAUGE Unit class object
|
|
39
|
-
"""
|
|
40
|
-
|
|
41
|
-
_unit = "RAINGAUGE"
|
|
42
|
-
|
|
43
|
-
def _read(self, line):
|
|
44
|
-
"""Function to read a given RAINGAUGE line and store data as class attributes"""
|
|
45
|
-
|
|
46
|
-
# TODO: add functionality to read comments
|
|
47
|
-
|
|
48
|
-
unit_data = line.split() # Get unit parameters
|
|
49
|
-
|
|
50
|
-
self.name = str(unit_data[0])
|
|
51
|
-
self.format = str(unit_data[1])
|
|
52
|
-
|
|
53
|
-
try:
|
|
54
|
-
self.interval = float(unit_data[2]) # Decimal hours
|
|
55
|
-
except ValueError:
|
|
56
|
-
self.interval = str(unit_data[2]) # HH:MM format
|
|
57
|
-
|
|
58
|
-
self.snow_catch_factor = _to_float(unit_data[3], 0.0)
|
|
59
|
-
self.data_option = str(unit_data[4])
|
|
60
|
-
|
|
61
|
-
# Check is raingauge data is provided as a TIMESERIES or as a FILE
|
|
62
|
-
if self.data_option == "TIMESERIES":
|
|
63
|
-
self.timeseries = str(unit_data[5])
|
|
64
|
-
|
|
65
|
-
# Creates empty fields to allow user to change data_option
|
|
66
|
-
self.filename =
|
|
67
|
-
self.station =
|
|
68
|
-
self.units = "MM"
|
|
69
|
-
elif self.data_option == "FILE":
|
|
70
|
-
self.filename = str(unit_data[5])
|
|
71
|
-
self.station = str(unit_data[6])
|
|
72
|
-
self.units = str(unit_data[7])
|
|
73
|
-
|
|
74
|
-
# Creates empty fields to allow user to change data_option
|
|
75
|
-
self.timeseries =
|
|
76
|
-
|
|
77
|
-
def _write(self):
|
|
78
|
-
"""Function to write a valid JUNCTION line"""
|
|
79
|
-
|
|
80
|
-
_validate_unit(self, urban=True)
|
|
81
|
-
|
|
82
|
-
# TODO:Improve indentation format when writing and include header for completeness
|
|
83
|
-
|
|
84
|
-
params1 = join_n_char_ljust(17, self.name) + join_n_char_ljust(
|
|
85
|
-
15,
|
|
86
|
-
self.format,
|
|
87
|
-
self.interval,
|
|
88
|
-
self.snow_catch_factor,
|
|
89
|
-
self.data_option,
|
|
90
|
-
) # First group of parameters
|
|
91
|
-
|
|
92
|
-
# Second group of parameters
|
|
93
|
-
if self.data_option == "TIMESERIES":
|
|
94
|
-
params2 = self.timeseries
|
|
95
|
-
|
|
96
|
-
elif self.data_option == "FILE":
|
|
97
|
-
params2 = join_n_char_ljust(15, self.filename, self.station, self.units)
|
|
98
|
-
|
|
99
|
-
else:
|
|
100
|
-
raise RuntimeError(f"{self.data_option} not supported")
|
|
101
|
-
|
|
102
|
-
return params1 + params2
|
|
103
|
-
|
|
104
|
-
# TODO: Implement validation that does not allow spaces to be entered in attribute values
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
class RAINGAUGES(UrbanSubsection):
|
|
108
|
-
"""Class to read/write the table of raingauges"""
|
|
109
|
-
|
|
110
|
-
_urban_unit_class = RAINGAUGE
|
|
111
|
-
_attribute = "raingauges"
|
|
1
|
+
"""
|
|
2
|
+
Flood Modeller Python API
|
|
3
|
+
Copyright (C) 2024 Jacobs U.K. Limited
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
|
|
6
|
+
as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
|
7
|
+
|
|
8
|
+
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
9
|
+
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
10
|
+
|
|
11
|
+
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.
|
|
12
|
+
|
|
13
|
+
If you have any query about this program or this License, please contact us at support@floodmodeller.com or write to the following
|
|
14
|
+
address: Jacobs UK Limited, Flood Modeller, Cottons Centre, Cottons Lane, London, SE1 2QG, United Kingdom.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from floodmodeller_api.units.helpers import _to_float, join_n_char_ljust
|
|
18
|
+
from floodmodeller_api.validation import _validate_unit
|
|
19
|
+
|
|
20
|
+
from ._base import UrbanSubsection, UrbanUnit
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class RAINGAUGE(UrbanUnit):
|
|
24
|
+
"""Class to hold and process RAINGAUGE unit type
|
|
25
|
+
|
|
26
|
+
Args:
|
|
27
|
+
name (str): Unit name
|
|
28
|
+
format (str): Form of recorded rainfall, either 'INTENSITY', 'VOLUME' or 'CUMULATIVE' (mandatory)
|
|
29
|
+
interval (float): Time interval between gauge readings in decimal hours or hours:minutes format (e.g., 0:15 for 15-minute readings). (mandatory)
|
|
30
|
+
snow_catch_factor (float): Snow catch deficiency correction factor (SCF) (use 1.0 for no adjustment). (mandatory)
|
|
31
|
+
data_option (str):'TIMESERIES' or 'FILE' defining where the data is provdied.
|
|
32
|
+
timeseries (str): Name of time series in [TIMESERIES] section with rainfall data (mandatory, if data_option = 'TIMESERIES')
|
|
33
|
+
filename (str): Name of external file with rainfall data. (mandatory, if data_option = 'File')
|
|
34
|
+
station (str)Name of recording station used in the rain file (mandatory, if data_option = 'File')
|
|
35
|
+
units (str): Rain depth units used in the rain file, either 'IN' (inches) or 'MM' (millimeters).(mandatory, if data_option = 'File')
|
|
36
|
+
|
|
37
|
+
Returns:
|
|
38
|
+
RAINGAUGE: Flood Modeller RAINGAUGE Unit class object
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
_unit = "RAINGAUGE"
|
|
42
|
+
|
|
43
|
+
def _read(self, line):
|
|
44
|
+
"""Function to read a given RAINGAUGE line and store data as class attributes"""
|
|
45
|
+
|
|
46
|
+
# TODO: add functionality to read comments
|
|
47
|
+
|
|
48
|
+
unit_data = line.split() # Get unit parameters
|
|
49
|
+
|
|
50
|
+
self.name = str(unit_data[0])
|
|
51
|
+
self.format = str(unit_data[1])
|
|
52
|
+
|
|
53
|
+
try:
|
|
54
|
+
self.interval = float(unit_data[2]) # Decimal hours
|
|
55
|
+
except ValueError:
|
|
56
|
+
self.interval = str(unit_data[2]) # HH:MM format
|
|
57
|
+
|
|
58
|
+
self.snow_catch_factor = _to_float(unit_data[3], 0.0)
|
|
59
|
+
self.data_option = str(unit_data[4])
|
|
60
|
+
|
|
61
|
+
# Check is raingauge data is provided as a TIMESERIES or as a FILE
|
|
62
|
+
if self.data_option == "TIMESERIES":
|
|
63
|
+
self.timeseries = str(unit_data[5])
|
|
64
|
+
|
|
65
|
+
# Creates empty fields to allow user to change data_option
|
|
66
|
+
self.filename = ""
|
|
67
|
+
self.station = ""
|
|
68
|
+
self.units = "MM"
|
|
69
|
+
elif self.data_option == "FILE":
|
|
70
|
+
self.filename = str(unit_data[5])
|
|
71
|
+
self.station = str(unit_data[6])
|
|
72
|
+
self.units = str(unit_data[7])
|
|
73
|
+
|
|
74
|
+
# Creates empty fields to allow user to change data_option
|
|
75
|
+
self.timeseries = ""
|
|
76
|
+
|
|
77
|
+
def _write(self):
|
|
78
|
+
"""Function to write a valid JUNCTION line"""
|
|
79
|
+
|
|
80
|
+
_validate_unit(self, urban=True)
|
|
81
|
+
|
|
82
|
+
# TODO:Improve indentation format when writing and include header for completeness
|
|
83
|
+
|
|
84
|
+
params1 = join_n_char_ljust(17, self.name) + join_n_char_ljust(
|
|
85
|
+
15,
|
|
86
|
+
self.format,
|
|
87
|
+
self.interval,
|
|
88
|
+
self.snow_catch_factor,
|
|
89
|
+
self.data_option,
|
|
90
|
+
) # First group of parameters
|
|
91
|
+
|
|
92
|
+
# Second group of parameters
|
|
93
|
+
if self.data_option == "TIMESERIES":
|
|
94
|
+
params2 = self.timeseries
|
|
95
|
+
|
|
96
|
+
elif self.data_option == "FILE":
|
|
97
|
+
params2 = join_n_char_ljust(15, self.filename, self.station, self.units)
|
|
98
|
+
|
|
99
|
+
else:
|
|
100
|
+
raise RuntimeError(f"{self.data_option} not supported")
|
|
101
|
+
|
|
102
|
+
return params1 + params2
|
|
103
|
+
|
|
104
|
+
# TODO: Implement validation that does not allow spaces to be entered in attribute values
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
class RAINGAUGES(UrbanSubsection):
|
|
108
|
+
"""Class to read/write the table of raingauges"""
|
|
109
|
+
|
|
110
|
+
_urban_unit_class = RAINGAUGE
|
|
111
|
+
_attribute = "raingauges"
|
|
@@ -1,98 +1,92 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Flood Modeller Python API
|
|
3
|
-
Copyright (C)
|
|
4
|
-
|
|
5
|
-
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
|
|
6
|
-
as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
|
7
|
-
|
|
8
|
-
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
9
|
-
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
10
|
-
|
|
11
|
-
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.
|
|
12
|
-
|
|
13
|
-
If you have any query about this program or this License, please contact us at support@floodmodeller.com or write to the following
|
|
14
|
-
address: Jacobs UK Limited, Flood Modeller, Cottons Centre, Cottons Lane, London, SE1 2QG, United Kingdom.
|
|
15
|
-
"""
|
|
16
|
-
|
|
17
|
-
from typing import
|
|
18
|
-
|
|
19
|
-
from ._base import UrbanSubsection
|
|
20
|
-
from .conduits import CONDUITS
|
|
21
|
-
from .junctions import JUNCTIONS
|
|
22
|
-
from .losses import LOSSES
|
|
23
|
-
from .outfalls import OUTFALLS
|
|
24
|
-
from .raingauges import RAINGAUGES
|
|
25
|
-
from .xsections import XSECTIONS
|
|
26
|
-
|
|
27
|
-
SupportedSubsections = TypedDict(
|
|
28
|
-
"SupportedSubsections",
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
#
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"[
|
|
37
|
-
"[
|
|
38
|
-
"[
|
|
39
|
-
"[
|
|
40
|
-
"[
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
"[
|
|
51
|
-
"[
|
|
52
|
-
"[
|
|
53
|
-
"[
|
|
54
|
-
"[
|
|
55
|
-
"[
|
|
56
|
-
"[
|
|
57
|
-
"[
|
|
58
|
-
"[
|
|
59
|
-
"[
|
|
60
|
-
"[
|
|
61
|
-
"[
|
|
62
|
-
"[
|
|
63
|
-
"[
|
|
64
|
-
"[
|
|
65
|
-
"[
|
|
66
|
-
"[
|
|
67
|
-
"[
|
|
68
|
-
"[
|
|
69
|
-
"[
|
|
70
|
-
"[
|
|
71
|
-
"[
|
|
72
|
-
"[
|
|
73
|
-
"[
|
|
74
|
-
"[
|
|
75
|
-
"[
|
|
76
|
-
"[
|
|
77
|
-
"[
|
|
78
|
-
"[
|
|
79
|
-
"[
|
|
80
|
-
"[
|
|
81
|
-
"[
|
|
82
|
-
"[
|
|
83
|
-
"[
|
|
84
|
-
"[
|
|
85
|
-
"[
|
|
86
|
-
"[
|
|
87
|
-
"[
|
|
88
|
-
"[
|
|
89
|
-
"[
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
"[SYMBOLS]",
|
|
94
|
-
"[BACKDROP]",
|
|
95
|
-
"[TAGS]", # UNKNOWN - not in manual
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
ALL_SUBSECTIONS = set(SUPPORTED_SUBSECTIONS.keys()).union(UNSUPPORTED_SUBSECTIONS)
|
|
1
|
+
"""
|
|
2
|
+
Flood Modeller Python API
|
|
3
|
+
Copyright (C) 2024 Jacobs U.K. Limited
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
|
|
6
|
+
as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
|
7
|
+
|
|
8
|
+
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
|
9
|
+
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
10
|
+
|
|
11
|
+
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.
|
|
12
|
+
|
|
13
|
+
If you have any query about this program or this License, please contact us at support@floodmodeller.com or write to the following
|
|
14
|
+
address: Jacobs UK Limited, Flood Modeller, Cottons Centre, Cottons Lane, London, SE1 2QG, United Kingdom.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from typing import Type, TypedDict
|
|
18
|
+
|
|
19
|
+
from ._base import UrbanSubsection
|
|
20
|
+
from .conduits import CONDUITS
|
|
21
|
+
from .junctions import JUNCTIONS
|
|
22
|
+
from .losses import LOSSES
|
|
23
|
+
from .outfalls import OUTFALLS
|
|
24
|
+
from .raingauges import RAINGAUGES
|
|
25
|
+
from .xsections import XSECTIONS
|
|
26
|
+
|
|
27
|
+
SupportedSubsections = TypedDict(
|
|
28
|
+
"SupportedSubsections",
|
|
29
|
+
{"group": str, "attribute": str, "class": Type[UrbanSubsection]},
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
# Unit types and support
|
|
33
|
+
# TODO: Update functionality - SWMM manual indicates only first 4 characters of subsection heading are needed
|
|
34
|
+
SUPPORTED_SUBSECTIONS: dict[str, SupportedSubsections] = {
|
|
35
|
+
"[JUNCTIONS]": {"group": "units", "attribute": "_junctions", "class": JUNCTIONS},
|
|
36
|
+
"[OUTFALLS]": {"group": "units", "attribute": "_outfalls", "class": OUTFALLS},
|
|
37
|
+
"[RAINGAGES]": {"group": "units", "attribute": "_raingauges", "class": RAINGAUGES},
|
|
38
|
+
"[CONDUITS]": {"group": "units", "attribute": "_conduits", "class": CONDUITS},
|
|
39
|
+
"[LOSSES]": {"group": "units", "attribute": "_losses", "class": LOSSES},
|
|
40
|
+
"[XSECTIONS]": {"group": "units", "attribute": "_xsections", "class": XSECTIONS},
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
UNSUPPORTED_SUBSECTIONS = {
|
|
44
|
+
"[TITLE]",
|
|
45
|
+
"[REPORT]",
|
|
46
|
+
"[FILES]",
|
|
47
|
+
"[EVAPORATION]",
|
|
48
|
+
"[TEMPERATURE]",
|
|
49
|
+
"[ADJUSTMENTS]",
|
|
50
|
+
"[SUBCATCHMENTS]",
|
|
51
|
+
"[SUBAREAS]",
|
|
52
|
+
"[INFILTRATION]",
|
|
53
|
+
"[LID_CONTROLS]", # first four characters not unique
|
|
54
|
+
"[LID_USAGE]",
|
|
55
|
+
"[AQUIFERS]",
|
|
56
|
+
"[GROUNDWATER]",
|
|
57
|
+
"[GWF]",
|
|
58
|
+
"[SNOWPACKS]",
|
|
59
|
+
"[DIVIDERS]",
|
|
60
|
+
"[STORAGE]",
|
|
61
|
+
"[PUMPS]",
|
|
62
|
+
"[ORIFICES]",
|
|
63
|
+
"[WEIRS]",
|
|
64
|
+
"[OUTLETS]",
|
|
65
|
+
"[XSECTIONS]",
|
|
66
|
+
"[TRANSECTS]",
|
|
67
|
+
"[CONTROLS]",
|
|
68
|
+
"[POLLUTANTS]",
|
|
69
|
+
"[LANDUSES]",
|
|
70
|
+
"[COVERAGES]",
|
|
71
|
+
"[LOADINGS]",
|
|
72
|
+
"[BUILDUP]",
|
|
73
|
+
"[WASHOFF]",
|
|
74
|
+
"[TREATMENT]",
|
|
75
|
+
"[INFLOWS]",
|
|
76
|
+
"[DWF]",
|
|
77
|
+
"[RDII]",
|
|
78
|
+
"[HYDROGRAPHS]",
|
|
79
|
+
"[CURVES]",
|
|
80
|
+
"[TIMESERIES]",
|
|
81
|
+
"[PATTERNS]",
|
|
82
|
+
"[MAP]", # This and the below are Map Data
|
|
83
|
+
"[POLYGONS]",
|
|
84
|
+
"[COORDINATES]",
|
|
85
|
+
"[VERTICES]",
|
|
86
|
+
"[LABELS]",
|
|
87
|
+
"[SYMBOLS]",
|
|
88
|
+
"[BACKDROP]",
|
|
89
|
+
"[TAGS]", # UNKNOWN - not in manual
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
ALL_SUBSECTIONS = set(SUPPORTED_SUBSECTIONS.keys()).union(UNSUPPORTED_SUBSECTIONS)
|