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,104 +1,93 @@
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
- from typing import Dict, TypedDict
17
-
18
- UnitTypes = TypedDict("UnitTypes", {"group": str, "has_subtype": bool})
19
-
20
- # Unit types and support
21
- SUPPORTED_UNIT_TYPES: Dict[str, UnitTypes] = {
22
- "QTBDY": {"group": "boundaries", "has_subtype": False},
23
- "HTBDY": {"group": "boundaries", "has_subtype": False},
24
- "QHBDY": {"group": "boundaries", "has_subtype": False},
25
- "REFHBDY": {"group": "boundaries", "has_subtype": False},
26
- "RIVER": {"group": "sections", "has_subtype": True},
27
- "BRIDGE": {"group": "structures", "has_subtype": True},
28
- "CONDUIT": {"group": "conduits", "has_subtype": True},
29
- "SLUICE": {"group": "structures", "has_subtype": True},
30
- "ORIFICE": {"group": "structures", "has_subtype": True},
31
- "SPILL": {"group": "structures", "has_subtype": False},
32
- "INITIAL CONDITIONS": {"group": "other", "has_subtype": False},
33
- "VARIABLES": {"group": "other", "has_subtype": False},
34
- "BLOCKAGE": {"group": "losses", "has_subtype": False},
35
- "CULVERT": {"group": "losses", "has_subtype": True},
36
- "RNWEIR": {"group": "structures", "has_subtype": False},
37
- "WEIR": {"group": "structures", "has_subtype": False}, # general weir
38
- "CRUMP": {"group": "structures", "has_subtype": False},
39
- "FLAT-V WEIR": {"group": "structures", "has_subtype": False},
40
- # "RESERVOIR": {"group":"structures", "has_subtype": False}, # Needs further testing
41
- "INTERPOLATE": {"group": "sections", "has_subtype": False},
42
- "REPLICATE": {"group": "sections", "has_subtype": False},
43
- "OUTFALL": {"group": "structures", "has_subtype": True},
44
- "COMMENT": {"group": "comments", "has_subtype": False},
45
- }
46
-
47
- UNSUPPORTED_UNIT_TYPES = {
48
- # "ASYMMETRIC" : CONDUIT
49
- "ABSTRACTION": {"has_subtype": False},
50
- # "BEND": CULVERT
51
- "BERNOULLI": {"has_subtype": False},
52
- "BREACH": {"has_subtype": False}, # breach
53
- # "CES": RIVER
54
- # "COMMENT": {"group": "other", "has_subtype": False},
55
- # "CONPUMP": {"group": ,"has_subtype": }, ### Konrad Adams to confirm whether these are still used
56
- # "CONVALVE": {"group": ,"has_subtype": }, ### Konrad Adams to confirm whether these are still used
57
- "FEHBDY": {"group": "boundaries", "has_subtype": False}, # RAINFALL RUNOFF METHOD boundary
58
- "FLOOD RELIEF": {"has_subtype": True}, # found in dat file
59
- "FLOOD RELIEF ARCH": {"group": "structures", "has_subtype": True}, # found in FM help
60
- "FLOODPLAIN": {"has_subtype": True}, # floodplain section culvert
61
- "FRQSIM": {"group": "boundaries", "has_subtype": False}, # flood FReQuency SIMulation
62
- "FSRBDY": {
63
- "group": "boundaries",
64
- "has_subtype": False,
65
- }, # FEH Method (FEH Rainfall Runoff Method)
66
- "FSSR16BDY": {"group": "boundaries", "has_subtype": False}, # FSSR16 Method
67
- # "FULLARCH": CONDUIT
68
- "GATED WEIR": {"group": "structures", "has_subtype": False}, # gated weir
69
- "GAUGE": {"has_subtype": False}, # Gauge
70
- "GERRBDY": {"group": "boundaries", "has_subtype": False}, # gen rainfall runoff
71
- "INVERTED SYPHON": {"group": "structures", "has_subtype": True}, # invert syphon
72
- "JUNCTION": {"has_subtype": True}, # [connector]
73
- "LABYRINTH WEIR": {"group": "structures", "has_subtype": False}, # labyrinth weir
74
- "LATERAL": {"has_subtype": False}, # [connector]
75
- # "LDPUMP": {"group": ,"has_subtype": }, #can still be read - v similar to OCPUMP
76
- "LOSS": {"has_subtype": False}, # found in .dat
77
- "LOSSID": {"has_subtype": False}, # found in .dat
78
- "MANHOLE": {"has_subtype": False}, # Manhole [connector]
79
- # "MUSKINGUM": RIVER
80
- # "MUSK-RSEC": RIVER
81
- # "MUSK-VPMC": RIVER
82
- # "MUSK-XSEC": RIVER
83
- "NCDBDY": {"group": "boundaries", "has_subtype": False}, # Normal/Critical Depth Boundary
84
- "NOTWEIR": {"group": "structures", "has_subtype": False}, # Notional Weir
85
- "OCPUMP": {"has_subtype": False}, # pump [junctions]
86
- "POND": {"has_subtype": True}, # Pond units, online pond etc [connector]
87
- "QH CONTROL": {"group": "structures", "has_subtype": False}, # Flow-head control weir
88
- "QRATING": {"group": "boundaries", "has_subtype": False}, # Rating Curves
89
- "REBDY": {"group": "boundaries", "has_subtype": False}, # Rainfall/Evaporation Boundary
90
- "REFH2BDY": {"group": "boundaries", "has_subtype": False}, # ReFH2 Method
91
- "RESERVOIR": {"has_subtype": False}, # reservoir unit [connector]
92
- # "SECTION": CONDUIT
93
- "SCSBDY": {
94
- "group": "boundaries",
95
- "has_subtype": False,
96
- }, # US SCS Method now SS for rainfall/runoff
97
- "SCWEIR": {"group": "structures", "has_subtype": False}, # sharp crested weir
98
- # "SPRUNG": CONDUIT
99
- "SYPHON": {"group": "structures", "has_subtype": False}, # syphon unit
100
- # "TIDAL": {"has_subtype": }, #can still be read - similar to TIDBY
101
- "TIDBDY": {"group": "boundaries", "has_subtype": False}, # tidal
102
- }
103
-
104
- ALL_UNIT_TYPES = set(SUPPORTED_UNIT_TYPES.keys()).union(UNSUPPORTED_UNIT_TYPES)
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 TypedDict
18
+
19
+
20
+ class UnitTypes(TypedDict):
21
+ group: str
22
+ has_subtype: bool
23
+
24
+
25
+ # Unit types and support
26
+ SUPPORTED_UNIT_TYPES: dict[str, UnitTypes] = {
27
+ "QTBDY": {"group": "boundaries", "has_subtype": False},
28
+ "HTBDY": {"group": "boundaries", "has_subtype": False},
29
+ "QHBDY": {"group": "boundaries", "has_subtype": False},
30
+ "REFHBDY": {"group": "boundaries", "has_subtype": False},
31
+ "RIVER": {"group": "sections", "has_subtype": True},
32
+ "BRIDGE": {"group": "structures", "has_subtype": True},
33
+ "CONDUIT": {"group": "conduits", "has_subtype": True},
34
+ "SLUICE": {"group": "structures", "has_subtype": True},
35
+ "ORIFICE": {"group": "structures", "has_subtype": True},
36
+ "SPILL": {"group": "structures", "has_subtype": False},
37
+ "INITIAL CONDITIONS": {"group": "other", "has_subtype": False},
38
+ "VARIABLES": {"group": "other", "has_subtype": False},
39
+ "BLOCKAGE": {"group": "losses", "has_subtype": False},
40
+ "CULVERT": {"group": "losses", "has_subtype": True},
41
+ "RNWEIR": {"group": "structures", "has_subtype": False},
42
+ "WEIR": {"group": "structures", "has_subtype": False}, # general weir
43
+ "CRUMP": {"group": "structures", "has_subtype": False},
44
+ "FLAT-V WEIR": {"group": "structures", "has_subtype": False},
45
+ "INTERPOLATE": {"group": "sections", "has_subtype": False},
46
+ "REPLICATE": {"group": "sections", "has_subtype": False},
47
+ "OUTFALL": {"group": "structures", "has_subtype": True},
48
+ "COMMENT": {"group": "comments", "has_subtype": False},
49
+ }
50
+
51
+ UNSUPPORTED_UNIT_TYPES = {
52
+ "ABSTRACTION": {"has_subtype": False},
53
+ "BERNOULLI": {"has_subtype": False},
54
+ "BREACH": {"has_subtype": False}, # breach
55
+ "FEHBDY": {"group": "boundaries", "has_subtype": False}, # RAINFALL RUNOFF METHOD boundary
56
+ "FLOOD RELIEF": {"has_subtype": True}, # found in dat file
57
+ "FLOOD RELIEF ARCH": {"group": "structures", "has_subtype": True}, # found in FM help
58
+ "FLOODPLAIN": {"has_subtype": True}, # floodplain section culvert
59
+ "FRQSIM": {"group": "boundaries", "has_subtype": False}, # flood FReQuency SIMulation
60
+ "FSRBDY": {
61
+ "group": "boundaries",
62
+ "has_subtype": False,
63
+ }, # FEH Method (FEH Rainfall Runoff Method)
64
+ "FSSR16BDY": {"group": "boundaries", "has_subtype": False}, # FSSR16 Method
65
+ "GATED WEIR": {"group": "structures", "has_subtype": False}, # gated weir
66
+ "GAUGE": {"has_subtype": False}, # Gauge
67
+ "GERRBDY": {"group": "boundaries", "has_subtype": False}, # gen rainfall runoff
68
+ "INVERTED SYPHON": {"group": "structures", "has_subtype": True}, # invert syphon
69
+ "JUNCTION": {"has_subtype": True}, # [connector]
70
+ "LABYRINTH WEIR": {"group": "structures", "has_subtype": False}, # labyrinth weir
71
+ "LATERAL": {"has_subtype": False}, # [connector]
72
+ "LOSS": {"has_subtype": False}, # found in .dat
73
+ "LOSSID": {"has_subtype": False}, # found in .dat
74
+ "MANHOLE": {"has_subtype": False}, # Manhole [connector]
75
+ "NCDBDY": {"group": "boundaries", "has_subtype": False}, # Normal/Critical Depth Boundary
76
+ "NOTWEIR": {"group": "structures", "has_subtype": False}, # Notional Weir
77
+ "OCPUMP": {"has_subtype": False}, # pump [junctions]
78
+ "POND": {"has_subtype": True}, # Pond units, online pond etc [connector]
79
+ "QH CONTROL": {"group": "structures", "has_subtype": False}, # Flow-head control weir
80
+ "QRATING": {"group": "boundaries", "has_subtype": False}, # Rating Curves
81
+ "REBDY": {"group": "boundaries", "has_subtype": False}, # Rainfall/Evaporation Boundary
82
+ "REFH2BDY": {"group": "boundaries", "has_subtype": False}, # ReFH2 Method
83
+ "RESERVOIR": {"has_subtype": False}, # reservoir unit [connector]
84
+ "SCSBDY": {
85
+ "group": "boundaries",
86
+ "has_subtype": False,
87
+ }, # US SCS Method now SS for rainfall/runoff
88
+ "SCWEIR": {"group": "structures", "has_subtype": False}, # sharp crested weir
89
+ "SYPHON": {"group": "structures", "has_subtype": False}, # syphon unit
90
+ "TIDBDY": {"group": "boundaries", "has_subtype": False}, # tidal
91
+ }
92
+
93
+ ALL_UNIT_TYPES = set(SUPPORTED_UNIT_TYPES.keys()).union(UNSUPPORTED_UNIT_TYPES)
@@ -1,44 +1,44 @@
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 ._base import Unit
18
- from .helpers import split_n_char
19
-
20
-
21
- class UNSUPPORTED(Unit):
22
- """Used to read in all unsupported unit types, simply returning the raw data on write"""
23
-
24
- def _read(self, block, unit_name, unit_type, subtype):
25
- self.name = unit_name
26
- self._unit = unit_type
27
- self._subtype = subtype
28
- self._raw_block = block
29
- self.comment = block[0].replace(self._unit, "").strip()
30
-
31
- if self._subtype is False:
32
- self.labels = split_n_char(f"{block[1]:<{2*self._label_len}}", self._label_len)
33
-
34
- else:
35
- self._subtype = block[1].split(" ")[0].strip()
36
- if self._unit == "JUNCTION":
37
- self.labels = split_n_char(block[2], self._label_len)
38
- self.labels = split_n_char(f"{block[2]:<{2*self._label_len}}", self._label_len)
39
-
40
- if self.labels[1] != "" and self._unit != "JUNCTION":
41
- self.ds_label = self.labels[1]
42
-
43
- def _write(self):
44
- return self._raw_block
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 ._base import Unit
18
+ from .helpers import split_n_char
19
+
20
+
21
+ class UNSUPPORTED(Unit):
22
+ """Used to read in all unsupported unit types, simply returning the raw data on write"""
23
+
24
+ def _read(self, block, unit_name, unit_type, subtype):
25
+ self.name = unit_name
26
+ self._unit = unit_type
27
+ self._subtype = subtype
28
+ self._raw_block = block
29
+ self.comment = block[0].replace(self._unit, "").strip()
30
+
31
+ if self._subtype is False:
32
+ self.labels = split_n_char(f"{block[1]:<{2*self._label_len}}", self._label_len)
33
+
34
+ else:
35
+ self._subtype = block[1].split(" ")[0].strip()
36
+ if self._unit == "JUNCTION":
37
+ self.labels = split_n_char(block[2], self._label_len)
38
+ self.labels = split_n_char(f"{block[2]:<{2*self._label_len}}", self._label_len)
39
+
40
+ if self.labels[1] != "" and self._unit != "JUNCTION":
41
+ self.ds_label = self.labels[1]
42
+
43
+ def _write(self):
44
+ return self._raw_block
@@ -1,89 +1,87 @@
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
- import pandas as pd
18
-
19
- from ..diff import check_item_with_dataframe_equal
20
- from .helpers import join_10_char
21
-
22
- # Variables, Rules & Varrules Classes
23
-
24
-
25
- class Variables:
26
- """Class to hold VARIABLES"""
27
-
28
- def __init__(self, var_block):
29
- self._read(var_block)
30
-
31
- def __repr__(self):
32
- return "<floodmodeller_api Variables Class: Variables()>"
33
-
34
- def _read(self, var_block):
35
- header = [
36
- "name",
37
- "type",
38
- "initial value",
39
- "initial status",
40
- ]
41
- data_list = []
42
- for line in var_block[1:-1]:
43
- name = line[:20].strip()
44
- _type = line[20:30].strip()
45
- initial_value = line[30:40].strip()
46
- if _type.upper() == "TIMER":
47
- initial_status = line[40:50].strip()
48
- else:
49
- initial_status = (
50
- "n/a" # unless the type is a timer, nothing else has an initial status
51
- )
52
- data_list.append(
53
- [
54
- name,
55
- _type,
56
- initial_value,
57
- initial_status,
58
- ]
59
- )
60
- self.data = pd.DataFrame(data_list, columns=header)
61
-
62
- def _write(self):
63
- var_block = [
64
- "VARIABLES",
65
- ]
66
- rows = []
67
- for _, name, _type, initial_value, initial_status in self.data.itertuples():
68
- string = f"{name:<{20}}"
69
- if _type.upper() == "TIMER":
70
- string += join_10_char(_type, initial_value, initial_status)
71
- else:
72
- string += join_10_char(_type, initial_value)
73
- rows.append(string)
74
-
75
- var_block.extend(rows)
76
- var_block.append("END VARIABLES")
77
-
78
- return var_block
79
-
80
- def _get_diff(self, other):
81
- return self.__eq__(other, return_diff=True) # pylint: disable=unnecessary-dunder-call
82
-
83
- def __eq__(self, other, return_diff=False):
84
- result = True
85
- diff = []
86
- result, diff = check_item_with_dataframe_equal(
87
- self.__dict__, other.__dict__, name="Variables", diff=diff
88
- )
89
- return (result, diff) if return_diff else result
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
+ import pandas as pd
18
+
19
+ from ..diff import check_item_with_dataframe_equal
20
+ from ..to_from_json import Jsonable
21
+ from .helpers import join_10_char
22
+
23
+
24
+ class Variables(Jsonable):
25
+ """Class to hold VARIABLES"""
26
+
27
+ def __init__(self, var_block):
28
+ self._read(var_block)
29
+
30
+ def __repr__(self):
31
+ return "<floodmodeller_api Variables Class: Variables()>"
32
+
33
+ def _read(self, var_block):
34
+ header = [
35
+ "name",
36
+ "type",
37
+ "initial value",
38
+ "initial status",
39
+ ]
40
+ data_list = []
41
+ for line in var_block[1:-1]:
42
+ name = line[:20].strip()
43
+ _type = line[20:30].strip()
44
+ initial_value = line[30:40].strip()
45
+ # unless the type is a timer, nothing else has an initial status
46
+ initial_status = line[40:50].strip() if _type.upper() == "TIMER" else "n/a"
47
+ data_list.append(
48
+ [
49
+ name,
50
+ _type,
51
+ initial_value,
52
+ initial_status,
53
+ ],
54
+ )
55
+ self.data = pd.DataFrame(data_list, columns=header)
56
+
57
+ def _write(self):
58
+ var_block = [
59
+ "VARIABLES",
60
+ ]
61
+ rows = []
62
+ for _, name, _type, initial_value, initial_status in self.data.itertuples():
63
+ string = f"{name:<{20}}"
64
+ if _type.upper() == "TIMER":
65
+ string += join_10_char(_type, initial_value, initial_status)
66
+ else:
67
+ string += join_10_char(_type, initial_value)
68
+ rows.append(string)
69
+
70
+ var_block.extend(rows)
71
+ var_block.append("END VARIABLES")
72
+
73
+ return var_block
74
+
75
+ def _get_diff(self, other):
76
+ return self.__eq__(other, return_diff=True) # pylint: disable=unnecessary-dunder-call
77
+
78
+ def __eq__(self, other, return_diff=False):
79
+ result = True
80
+ diff = []
81
+ result, diff = check_item_with_dataframe_equal(
82
+ self.__dict__,
83
+ other.__dict__,
84
+ name="Variables",
85
+ diff=diff,
86
+ )
87
+ return (result, diff) if return_diff else result
@@ -1,11 +1,11 @@
1
- from .subsections import (
2
- ALL_SUBSECTIONS,
3
- CONDUITS,
4
- JUNCTIONS,
5
- LOSSES,
6
- OUTFALLS,
7
- RAINGAUGES,
8
- SUPPORTED_SUBSECTIONS,
9
- UNSUPPORTED_SUBSECTIONS,
10
- XSECTIONS,
11
- )
1
+ from .subsections import (
2
+ ALL_SUBSECTIONS,
3
+ CONDUITS,
4
+ JUNCTIONS,
5
+ LOSSES,
6
+ OUTFALLS,
7
+ RAINGAUGES,
8
+ SUPPORTED_SUBSECTIONS,
9
+ UNSUPPORTED_SUBSECTIONS,
10
+ XSECTIONS,
11
+ )