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.
Files changed (178) hide show
  1. floodmodeller_api/__init__.py +8 -9
  2. floodmodeller_api/_base.py +169 -176
  3. floodmodeller_api/backup.py +273 -273
  4. floodmodeller_api/dat.py +889 -831
  5. floodmodeller_api/diff.py +136 -119
  6. floodmodeller_api/ied.py +302 -306
  7. floodmodeller_api/ief.py +553 -637
  8. floodmodeller_api/ief_flags.py +253 -253
  9. floodmodeller_api/inp.py +260 -266
  10. floodmodeller_api/libs/libifcoremd.dll +0 -0
  11. floodmodeller_api/libs/libifcoremt.so.5 +0 -0
  12. floodmodeller_api/libs/libifport.so.5 +0 -0
  13. floodmodeller_api/{libmmd.dll → libs/libimf.so} +0 -0
  14. floodmodeller_api/libs/libintlc.so.5 +0 -0
  15. floodmodeller_api/libs/libmmd.dll +0 -0
  16. floodmodeller_api/libs/libsvml.so +0 -0
  17. floodmodeller_api/libs/libzzn_read.so +0 -0
  18. floodmodeller_api/libs/zzn_read.dll +0 -0
  19. floodmodeller_api/logs/__init__.py +2 -2
  20. floodmodeller_api/logs/lf.py +364 -312
  21. floodmodeller_api/logs/lf_helpers.py +354 -352
  22. floodmodeller_api/logs/lf_params.py +643 -529
  23. floodmodeller_api/mapping.py +84 -0
  24. floodmodeller_api/test/__init__.py +4 -4
  25. floodmodeller_api/test/conftest.py +16 -8
  26. floodmodeller_api/test/test_backup.py +117 -117
  27. floodmodeller_api/test/test_conveyance.py +107 -0
  28. floodmodeller_api/test/test_dat.py +222 -92
  29. floodmodeller_api/test/test_data/All Units 4_6.DAT +1081 -1081
  30. floodmodeller_api/test/test_data/All Units 4_6.feb +1081 -1081
  31. floodmodeller_api/test/test_data/BRIDGE.DAT +926 -926
  32. floodmodeller_api/test/test_data/Culvert_Inlet_Outlet.dat +36 -36
  33. floodmodeller_api/test/test_data/Culvert_Inlet_Outlet.feb +36 -36
  34. floodmodeller_api/test/test_data/DamBreakADI.xml +52 -52
  35. floodmodeller_api/test/test_data/DamBreakFAST.xml +58 -58
  36. floodmodeller_api/test/test_data/DamBreakFAST_dy.xml +53 -53
  37. floodmodeller_api/test/test_data/DamBreakTVD.xml +55 -55
  38. floodmodeller_api/test/test_data/DefenceBreach.xml +53 -53
  39. floodmodeller_api/test/test_data/DefenceBreachFAST.xml +60 -60
  40. floodmodeller_api/test/test_data/DefenceBreachFAST_dy.xml +55 -55
  41. floodmodeller_api/test/test_data/Domain1+2_QH.xml +76 -76
  42. floodmodeller_api/test/test_data/Domain1_H.xml +41 -41
  43. floodmodeller_api/test/test_data/Domain1_Q.xml +41 -41
  44. floodmodeller_api/test/test_data/Domain1_Q_FAST.xml +48 -48
  45. floodmodeller_api/test/test_data/Domain1_Q_FAST_dy.xml +48 -48
  46. floodmodeller_api/test/test_data/Domain1_Q_xml_expected.json +263 -0
  47. floodmodeller_api/test/test_data/Domain1_W.xml +41 -41
  48. floodmodeller_api/test/test_data/EX1.DAT +321 -321
  49. floodmodeller_api/test/test_data/EX1.ext +107 -107
  50. floodmodeller_api/test/test_data/EX1.feb +320 -320
  51. floodmodeller_api/test/test_data/EX1.gxy +107 -107
  52. floodmodeller_api/test/test_data/EX17.DAT +421 -422
  53. floodmodeller_api/test/test_data/EX17.ext +213 -213
  54. floodmodeller_api/test/test_data/EX17.feb +422 -422
  55. floodmodeller_api/test/test_data/EX18.DAT +375 -375
  56. floodmodeller_api/test/test_data/EX18_DAT_expected.json +3876 -0
  57. floodmodeller_api/test/test_data/EX2.DAT +302 -302
  58. floodmodeller_api/test/test_data/EX3.DAT +926 -926
  59. floodmodeller_api/test/test_data/EX3_DAT_expected.json +16235 -0
  60. floodmodeller_api/test/test_data/EX3_IEF_expected.json +61 -0
  61. floodmodeller_api/test/test_data/EX6.DAT +2084 -2084
  62. floodmodeller_api/test/test_data/EX6.ext +532 -532
  63. floodmodeller_api/test/test_data/EX6.feb +2084 -2084
  64. floodmodeller_api/test/test_data/EX6_DAT_expected.json +31647 -0
  65. floodmodeller_api/test/test_data/Event Data Example.DAT +336 -336
  66. floodmodeller_api/test/test_data/Event Data Example.ext +107 -107
  67. floodmodeller_api/test/test_data/Event Data Example.feb +336 -336
  68. floodmodeller_api/test/test_data/Linked1D2D.xml +52 -52
  69. floodmodeller_api/test/test_data/Linked1D2DFAST.xml +53 -53
  70. floodmodeller_api/test/test_data/Linked1D2DFAST_dy.xml +48 -48
  71. floodmodeller_api/test/test_data/Linked1D2D_xml_expected.json +313 -0
  72. floodmodeller_api/test/test_data/blockage.dat +50 -50
  73. floodmodeller_api/test/test_data/blockage.ext +45 -45
  74. floodmodeller_api/test/test_data/blockage.feb +9 -9
  75. floodmodeller_api/test/test_data/blockage.gxy +71 -71
  76. floodmodeller_api/test/test_data/conveyance_test.dat +165 -0
  77. floodmodeller_api/test/test_data/conveyance_test.feb +116 -0
  78. floodmodeller_api/test/test_data/conveyance_test.gxy +85 -0
  79. floodmodeller_api/test/test_data/defaultUnits.dat +127 -127
  80. floodmodeller_api/test/test_data/defaultUnits.ext +45 -45
  81. floodmodeller_api/test/test_data/defaultUnits.feb +9 -9
  82. floodmodeller_api/test/test_data/defaultUnits.fmpx +58 -58
  83. floodmodeller_api/test/test_data/defaultUnits.gxy +85 -85
  84. floodmodeller_api/test/test_data/ex3.ief +20 -20
  85. floodmodeller_api/test/test_data/ex3.lf1 +2800 -2800
  86. floodmodeller_api/test/test_data/ex4.DAT +1374 -1374
  87. floodmodeller_api/test/test_data/ex4_changed.DAT +1374 -1374
  88. floodmodeller_api/test/test_data/example1.inp +329 -329
  89. floodmodeller_api/test/test_data/example2.inp +158 -158
  90. floodmodeller_api/test/test_data/example3.inp +297 -297
  91. floodmodeller_api/test/test_data/example4.inp +388 -388
  92. floodmodeller_api/test/test_data/example5.inp +147 -147
  93. floodmodeller_api/test/test_data/example6.inp +154 -154
  94. floodmodeller_api/test/test_data/expected_conveyance.csv +60 -0
  95. floodmodeller_api/test/test_data/jump.dat +176 -176
  96. floodmodeller_api/test/test_data/network.dat +1374 -1374
  97. floodmodeller_api/test/test_data/network.ext +45 -45
  98. floodmodeller_api/test/test_data/network.exy +1 -1
  99. floodmodeller_api/test/test_data/network.feb +45 -45
  100. floodmodeller_api/test/test_data/network.ied +45 -45
  101. floodmodeller_api/test/test_data/network.ief +20 -20
  102. floodmodeller_api/test/test_data/network.inp +147 -147
  103. floodmodeller_api/test/test_data/network.pxy +57 -57
  104. floodmodeller_api/test/test_data/network.zzd +122 -122
  105. floodmodeller_api/test/test_data/network_dat_expected.json +21837 -0
  106. floodmodeller_api/test/test_data/network_from_tabularCSV.csv +87 -87
  107. floodmodeller_api/test/test_data/network_ied_expected.json +287 -0
  108. floodmodeller_api/test/test_data/rnweir.dat +9 -9
  109. floodmodeller_api/test/test_data/rnweir.ext +45 -45
  110. floodmodeller_api/test/test_data/rnweir.feb +9 -9
  111. floodmodeller_api/test/test_data/rnweir.gxy +45 -45
  112. floodmodeller_api/test/test_data/rnweir_default.dat +74 -74
  113. floodmodeller_api/test/test_data/rnweir_default.ext +45 -45
  114. floodmodeller_api/test/test_data/rnweir_default.feb +9 -9
  115. floodmodeller_api/test/test_data/rnweir_default.fmpx +58 -58
  116. floodmodeller_api/test/test_data/rnweir_default.gxy +53 -53
  117. floodmodeller_api/test/test_data/unit checks.dat +16 -16
  118. floodmodeller_api/test/test_ied.py +29 -29
  119. floodmodeller_api/test/test_ief.py +136 -24
  120. floodmodeller_api/test/test_inp.py +47 -48
  121. floodmodeller_api/test/test_json.py +114 -0
  122. floodmodeller_api/test/test_logs_lf.py +102 -51
  123. floodmodeller_api/test/test_tool.py +165 -152
  124. floodmodeller_api/test/test_toolbox_structure_log.py +234 -239
  125. floodmodeller_api/test/test_xml2d.py +151 -156
  126. floodmodeller_api/test/test_zzn.py +36 -34
  127. floodmodeller_api/to_from_json.py +230 -0
  128. floodmodeller_api/tool.py +332 -329
  129. floodmodeller_api/toolbox/__init__.py +5 -5
  130. floodmodeller_api/toolbox/example_tool.py +45 -45
  131. floodmodeller_api/toolbox/model_build/__init__.py +2 -2
  132. floodmodeller_api/toolbox/model_build/add_siltation_definition.py +100 -98
  133. floodmodeller_api/toolbox/model_build/structure_log/__init__.py +1 -1
  134. floodmodeller_api/toolbox/model_build/structure_log/structure_log.py +287 -289
  135. floodmodeller_api/toolbox/model_build/structure_log_definition.py +76 -76
  136. floodmodeller_api/units/__init__.py +10 -10
  137. floodmodeller_api/units/_base.py +214 -212
  138. floodmodeller_api/units/boundaries.py +467 -467
  139. floodmodeller_api/units/comment.py +52 -55
  140. floodmodeller_api/units/conduits.py +382 -402
  141. floodmodeller_api/units/conveyance.py +301 -0
  142. floodmodeller_api/units/helpers.py +123 -131
  143. floodmodeller_api/units/iic.py +107 -101
  144. floodmodeller_api/units/losses.py +305 -306
  145. floodmodeller_api/units/sections.py +465 -446
  146. floodmodeller_api/units/structures.py +1690 -1683
  147. floodmodeller_api/units/units.py +93 -104
  148. floodmodeller_api/units/unsupported.py +44 -44
  149. floodmodeller_api/units/variables.py +87 -89
  150. floodmodeller_api/urban1d/__init__.py +11 -11
  151. floodmodeller_api/urban1d/_base.py +188 -179
  152. floodmodeller_api/urban1d/conduits.py +93 -85
  153. floodmodeller_api/urban1d/general_parameters.py +58 -58
  154. floodmodeller_api/urban1d/junctions.py +81 -79
  155. floodmodeller_api/urban1d/losses.py +81 -74
  156. floodmodeller_api/urban1d/outfalls.py +114 -110
  157. floodmodeller_api/urban1d/raingauges.py +111 -111
  158. floodmodeller_api/urban1d/subsections.py +92 -98
  159. floodmodeller_api/urban1d/xsections.py +147 -144
  160. floodmodeller_api/util.py +119 -21
  161. floodmodeller_api/validation/parameters.py +660 -660
  162. floodmodeller_api/validation/urban_parameters.py +388 -404
  163. floodmodeller_api/validation/validation.py +110 -108
  164. floodmodeller_api/version.py +1 -1
  165. floodmodeller_api/xml2d.py +632 -673
  166. floodmodeller_api/xml2d_template.py +37 -37
  167. floodmodeller_api/zzn.py +414 -363
  168. {floodmodeller_api-0.4.2.post1.dist-info → floodmodeller_api-0.4.4.dist-info}/LICENSE.txt +13 -13
  169. {floodmodeller_api-0.4.2.post1.dist-info → floodmodeller_api-0.4.4.dist-info}/METADATA +85 -82
  170. floodmodeller_api-0.4.4.dist-info/RECORD +185 -0
  171. {floodmodeller_api-0.4.2.post1.dist-info → floodmodeller_api-0.4.4.dist-info}/WHEEL +1 -1
  172. floodmodeller_api/libifcoremd.dll +0 -0
  173. floodmodeller_api/test/test_data/EX3.bmp +0 -0
  174. floodmodeller_api/test/test_data/test_output.csv +0 -87
  175. floodmodeller_api/zzn_read.dll +0 -0
  176. floodmodeller_api-0.4.2.post1.dist-info/RECORD +0 -164
  177. {floodmodeller_api-0.4.2.post1.dist-info → floodmodeller_api-0.4.4.dist-info}/entry_points.txt +0 -0
  178. {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) 2023 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
-
42
- def _read(self, line):
43
- unit_data = line.split()
44
-
45
- # TODO: add functionality to read comments
46
- # TODO: considering raising an exception if any of the required parameters are missing
47
-
48
- self.name = str(unit_data[0])
49
- self.elevation = _to_float(unit_data[1], 0.0)
50
- self.type = str(unit_data[2])
51
-
52
- if self.type in ("FREE", "NORMAL"):
53
- # Extend length of unit_data to account for missing optional arguments.
54
- while len(unit_data) < 5:
55
- unit_data.append("")
56
-
57
- self.gated = _to_str(unit_data[3], "NO")
58
- self.routeto = _to_str(unit_data[4], "")
59
-
60
- elif self.type in ("FIXED", "NORMAL", "TIMESERIES"):
61
- # Extend length of unit_data to account for missing optional arguments.
62
- while len(unit_data) < 6:
63
- unit_data.append("")
64
-
65
- if self.type == "FIXED":
66
- self.stage = _to_float(unit_data[3], 0.0)
67
-
68
- elif self.type == "NORMAL":
69
- self.tcurve = _to_str(unit_data[3], "")
70
-
71
- elif self.type == "TIMESERIES":
72
- self.tseries = _to_str(unit_data[3], "")
73
-
74
- self.gated = _to_str(unit_data[4], "NO")
75
- self.routeto = _to_str(unit_data[5], "")
76
-
77
- def _write(self):
78
- """Function to write a valid OUTFALL 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, self.elevation, self.type
86
- )
87
-
88
- if self.type in ("FREE", "NORMAL"):
89
- params2 = join_n_char_ljust(15, "", self.gated, self.routeto)
90
-
91
- elif self.type == "FIXED":
92
- params2 = join_n_char_ljust(15, self.stage, self.gated, self.routeto)
93
-
94
- elif self.type == "NORMAL":
95
- params2 = join_n_char_ljust(15, self.tcurve, self.gated, self.routeto)
96
-
97
- elif self.type == "TIMESERIES":
98
- params2 = join_n_char_ljust(15, self.tseries, self.gated, self.routeto)
99
-
100
- else:
101
- raise RuntimeError(f"{self.type} not supported")
102
-
103
- return params1 + params2
104
-
105
-
106
- class OUTFALLS(UrbanSubsection):
107
- """Class to read/write the table of outfalls"""
108
-
109
- _urban_unit_class = OUTFALL
110
- _attribute = "outfalls"
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) 2023 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 = str("")
67
- self.station = str("")
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 = str("")
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) 2023 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 Dict, 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", {"group": str, "attribute": str, "class": Type[UrbanSubsection]}
29
- )
30
-
31
- # Unit types and support
32
- # TODO: Update functionality - SWMM manual indicates only first 4 characters of subsection heading are needed
33
- SUPPORTED_SUBSECTIONS: Dict[str, SupportedSubsections] = {
34
- # '[TITLE]': {'attribute': 'Title', 'class': 'Title'}
35
- # "[OPTIONS]": {"group": "general", "attribute": "Options", "class": "Options"},
36
- "[JUNCTIONS]": {"group": "units", "attribute": "_junctions", "class": JUNCTIONS},
37
- "[OUTFALLS]": {"group": "units", "attribute": "_outfalls", "class": OUTFALLS},
38
- "[RAINGAGES]": {"group": "units", "attribute": "_raingauges", "class": RAINGAUGES},
39
- "[CONDUITS]": {"group": "units", "attribute": "_conduits", "class": CONDUITS},
40
- "[LOSSES]": {"group": "units", "attribute": "_losses", "class": LOSSES},
41
- "[XSECTIONS]": {"group": "units", "attribute": "_xsections", "class": XSECTIONS}
42
- # 'SPILL': {'group': 'structures', 'has_subtype': False},
43
- # 'INITIAL CONDITIONS': {'group': 'other', 'has_subtype': False},
44
- # '[TITLE]' : {
45
- # 'attribute' : 'title',
46
- # 'class' : Title}
47
- }
48
-
49
- UNSUPPORTED_SUBSECTIONS = {
50
- "[TITLE]",
51
- "[REPORT]",
52
- "[FILES]",
53
- "[EVAPORATION]",
54
- "[TEMPERATURE]",
55
- "[ADJUSTMENTS]",
56
- "[SUBCATCHMENTS]",
57
- "[SUBAREAS]",
58
- "[INFILTRATION]",
59
- "[LID_CONTROLS]", # first four characters not unique
60
- "[LID_USAGE]",
61
- "[AQUIFERS]",
62
- "[GROUNDWATER]",
63
- "[GWF]",
64
- "[SNOWPACKS]",
65
- "[DIVIDERS]",
66
- "[STORAGE]",
67
- "[PUMPS]",
68
- "[ORIFICES]",
69
- "[WEIRS]",
70
- "[OUTLETS]",
71
- "[XSECTIONS]",
72
- "[TRANSECTS]",
73
- "[CONTROLS]",
74
- "[POLLUTANTS]",
75
- "[LANDUSES]",
76
- "[COVERAGES]",
77
- "[LOADINGS]",
78
- "[BUILDUP]",
79
- "[WASHOFF]",
80
- "[TREATMENT]",
81
- "[INFLOWS]",
82
- "[DWF]",
83
- "[RDII]",
84
- "[HYDROGRAPHS]",
85
- "[CURVES]",
86
- "[TIMESERIES]",
87
- "[PATTERNS]",
88
- "[MAP]", # This and the below are Map Data
89
- "[POLYGONS]",
90
- "[COORDINATES]",
91
- "[VERTICES]",
92
- "[LABELS]",
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)