floodmodeller-api 0.4.2__py3-none-any.whl → 0.4.3__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 +184 -176
  3. floodmodeller_api/backup.py +273 -273
  4. floodmodeller_api/dat.py +909 -838
  5. floodmodeller_api/diff.py +136 -119
  6. floodmodeller_api/ied.py +307 -311
  7. floodmodeller_api/ief.py +647 -646
  8. floodmodeller_api/ief_flags.py +253 -253
  9. floodmodeller_api/inp.py +266 -268
  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 +320 -314
  21. floodmodeller_api/logs/lf_helpers.py +354 -346
  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 +9 -8
  26. floodmodeller_api/test/test_backup.py +117 -117
  27. floodmodeller_api/test/test_dat.py +221 -92
  28. floodmodeller_api/test/test_data/All Units 4_6.DAT +1081 -1081
  29. floodmodeller_api/test/test_data/All Units 4_6.feb +1081 -1081
  30. floodmodeller_api/test/test_data/BRIDGE.DAT +926 -926
  31. floodmodeller_api/test/test_data/Culvert_Inlet_Outlet.dat +36 -36
  32. floodmodeller_api/test/test_data/Culvert_Inlet_Outlet.feb +36 -36
  33. floodmodeller_api/test/test_data/DamBreakADI.xml +52 -52
  34. floodmodeller_api/test/test_data/DamBreakFAST.xml +58 -58
  35. floodmodeller_api/test/test_data/DamBreakFAST_dy.xml +53 -53
  36. floodmodeller_api/test/test_data/DamBreakTVD.xml +55 -55
  37. floodmodeller_api/test/test_data/DefenceBreach.xml +53 -53
  38. floodmodeller_api/test/test_data/DefenceBreachFAST.xml +60 -60
  39. floodmodeller_api/test/test_data/DefenceBreachFAST_dy.xml +55 -55
  40. floodmodeller_api/test/test_data/Domain1+2_QH.xml +76 -76
  41. floodmodeller_api/test/test_data/Domain1_H.xml +41 -41
  42. floodmodeller_api/test/test_data/Domain1_Q.xml +41 -41
  43. floodmodeller_api/test/test_data/Domain1_Q_FAST.xml +48 -48
  44. floodmodeller_api/test/test_data/Domain1_Q_FAST_dy.xml +48 -48
  45. floodmodeller_api/test/test_data/Domain1_Q_xml_expected.json +263 -0
  46. floodmodeller_api/test/test_data/Domain1_W.xml +41 -41
  47. floodmodeller_api/test/test_data/EX1.DAT +321 -321
  48. floodmodeller_api/test/test_data/EX1.ext +107 -107
  49. floodmodeller_api/test/test_data/EX1.feb +320 -320
  50. floodmodeller_api/test/test_data/EX1.gxy +107 -107
  51. floodmodeller_api/test/test_data/EX17.DAT +421 -422
  52. floodmodeller_api/test/test_data/EX17.ext +213 -213
  53. floodmodeller_api/test/test_data/EX17.feb +422 -422
  54. floodmodeller_api/test/test_data/EX18.DAT +375 -375
  55. floodmodeller_api/test/test_data/EX18_DAT_expected.json +3876 -0
  56. floodmodeller_api/test/test_data/EX2.DAT +302 -302
  57. floodmodeller_api/test/test_data/EX3.DAT +926 -926
  58. floodmodeller_api/test/test_data/EX3_DAT_expected.json +16235 -0
  59. floodmodeller_api/test/test_data/EX3_IEF_expected.json +61 -0
  60. floodmodeller_api/test/test_data/EX6.DAT +2084 -2084
  61. floodmodeller_api/test/test_data/EX6.ext +532 -532
  62. floodmodeller_api/test/test_data/EX6.feb +2084 -2084
  63. floodmodeller_api/test/test_data/EX6_DAT_expected.json +31647 -0
  64. floodmodeller_api/test/test_data/Event Data Example.DAT +336 -336
  65. floodmodeller_api/test/test_data/Event Data Example.ext +107 -107
  66. floodmodeller_api/test/test_data/Event Data Example.feb +336 -336
  67. floodmodeller_api/test/test_data/Linked1D2D.xml +52 -52
  68. floodmodeller_api/test/test_data/Linked1D2DFAST.xml +53 -53
  69. floodmodeller_api/test/test_data/Linked1D2DFAST_dy.xml +48 -48
  70. floodmodeller_api/test/test_data/Linked1D2D_xml_expected.json +313 -0
  71. floodmodeller_api/test/test_data/blockage.dat +50 -50
  72. floodmodeller_api/test/test_data/blockage.ext +45 -45
  73. floodmodeller_api/test/test_data/blockage.feb +9 -9
  74. floodmodeller_api/test/test_data/blockage.gxy +71 -71
  75. floodmodeller_api/test/test_data/defaultUnits.dat +127 -127
  76. floodmodeller_api/test/test_data/defaultUnits.ext +45 -45
  77. floodmodeller_api/test/test_data/defaultUnits.feb +9 -9
  78. floodmodeller_api/test/test_data/defaultUnits.fmpx +58 -58
  79. floodmodeller_api/test/test_data/defaultUnits.gxy +85 -85
  80. floodmodeller_api/test/test_data/ex3.ief +20 -20
  81. floodmodeller_api/test/test_data/ex3.lf1 +2800 -2800
  82. floodmodeller_api/test/test_data/ex4.DAT +1374 -1374
  83. floodmodeller_api/test/test_data/ex4_changed.DAT +1374 -1374
  84. floodmodeller_api/test/test_data/example1.inp +329 -329
  85. floodmodeller_api/test/test_data/example2.inp +158 -158
  86. floodmodeller_api/test/test_data/example3.inp +297 -297
  87. floodmodeller_api/test/test_data/example4.inp +388 -388
  88. floodmodeller_api/test/test_data/example5.inp +147 -147
  89. floodmodeller_api/test/test_data/example6.inp +154 -154
  90. floodmodeller_api/test/test_data/jump.dat +176 -176
  91. floodmodeller_api/test/test_data/network.dat +1374 -1374
  92. floodmodeller_api/test/test_data/network.ext +45 -45
  93. floodmodeller_api/test/test_data/network.exy +1 -1
  94. floodmodeller_api/test/test_data/network.feb +45 -45
  95. floodmodeller_api/test/test_data/network.ied +45 -45
  96. floodmodeller_api/test/test_data/network.ief +20 -20
  97. floodmodeller_api/test/test_data/network.inp +147 -147
  98. floodmodeller_api/test/test_data/network.pxy +57 -57
  99. floodmodeller_api/test/test_data/network.zzd +122 -122
  100. floodmodeller_api/test/test_data/network_dat_expected.json +21837 -0
  101. floodmodeller_api/test/test_data/network_from_tabularCSV.csv +87 -87
  102. floodmodeller_api/test/test_data/network_ied_expected.json +287 -0
  103. floodmodeller_api/test/test_data/rnweir.dat +9 -9
  104. floodmodeller_api/test/test_data/rnweir.ext +45 -45
  105. floodmodeller_api/test/test_data/rnweir.feb +9 -9
  106. floodmodeller_api/test/test_data/rnweir.gxy +45 -45
  107. floodmodeller_api/test/test_data/rnweir_default.dat +74 -74
  108. floodmodeller_api/test/test_data/rnweir_default.ext +45 -45
  109. floodmodeller_api/test/test_data/rnweir_default.feb +9 -9
  110. floodmodeller_api/test/test_data/rnweir_default.fmpx +58 -58
  111. floodmodeller_api/test/test_data/rnweir_default.gxy +53 -53
  112. floodmodeller_api/test/test_data/unit checks.dat +16 -16
  113. floodmodeller_api/test/test_ied.py +29 -29
  114. floodmodeller_api/test/test_ief.py +125 -24
  115. floodmodeller_api/test/test_inp.py +47 -48
  116. floodmodeller_api/test/test_json.py +114 -0
  117. floodmodeller_api/test/test_logs_lf.py +48 -51
  118. floodmodeller_api/test/test_tool.py +165 -154
  119. floodmodeller_api/test/test_toolbox_structure_log.py +234 -239
  120. floodmodeller_api/test/test_xml2d.py +151 -156
  121. floodmodeller_api/test/test_zzn.py +36 -34
  122. floodmodeller_api/to_from_json.py +218 -0
  123. floodmodeller_api/tool.py +332 -330
  124. floodmodeller_api/toolbox/__init__.py +5 -5
  125. floodmodeller_api/toolbox/example_tool.py +45 -45
  126. floodmodeller_api/toolbox/model_build/__init__.py +2 -2
  127. floodmodeller_api/toolbox/model_build/add_siltation_definition.py +100 -94
  128. floodmodeller_api/toolbox/model_build/structure_log/__init__.py +1 -1
  129. floodmodeller_api/toolbox/model_build/structure_log/structure_log.py +287 -289
  130. floodmodeller_api/toolbox/model_build/structure_log_definition.py +76 -72
  131. floodmodeller_api/units/__init__.py +10 -10
  132. floodmodeller_api/units/_base.py +214 -209
  133. floodmodeller_api/units/boundaries.py +467 -469
  134. floodmodeller_api/units/comment.py +52 -55
  135. floodmodeller_api/units/conduits.py +382 -403
  136. floodmodeller_api/units/helpers.py +123 -132
  137. floodmodeller_api/units/iic.py +107 -101
  138. floodmodeller_api/units/losses.py +305 -308
  139. floodmodeller_api/units/sections.py +444 -445
  140. floodmodeller_api/units/structures.py +1690 -1684
  141. floodmodeller_api/units/units.py +93 -102
  142. floodmodeller_api/units/unsupported.py +44 -44
  143. floodmodeller_api/units/variables.py +87 -89
  144. floodmodeller_api/urban1d/__init__.py +11 -11
  145. floodmodeller_api/urban1d/_base.py +188 -177
  146. floodmodeller_api/urban1d/conduits.py +93 -85
  147. floodmodeller_api/urban1d/general_parameters.py +58 -58
  148. floodmodeller_api/urban1d/junctions.py +81 -79
  149. floodmodeller_api/urban1d/losses.py +81 -74
  150. floodmodeller_api/urban1d/outfalls.py +114 -107
  151. floodmodeller_api/urban1d/raingauges.py +111 -108
  152. floodmodeller_api/urban1d/subsections.py +92 -93
  153. floodmodeller_api/urban1d/xsections.py +147 -141
  154. floodmodeller_api/util.py +77 -21
  155. floodmodeller_api/validation/parameters.py +660 -660
  156. floodmodeller_api/validation/urban_parameters.py +388 -404
  157. floodmodeller_api/validation/validation.py +110 -112
  158. floodmodeller_api/version.py +1 -1
  159. floodmodeller_api/xml2d.py +688 -684
  160. floodmodeller_api/xml2d_template.py +37 -37
  161. floodmodeller_api/zzn.py +387 -365
  162. {floodmodeller_api-0.4.2.dist-info → floodmodeller_api-0.4.3.dist-info}/LICENSE.txt +13 -13
  163. {floodmodeller_api-0.4.2.dist-info → floodmodeller_api-0.4.3.dist-info}/METADATA +82 -82
  164. floodmodeller_api-0.4.3.dist-info/RECORD +179 -0
  165. {floodmodeller_api-0.4.2.dist-info → floodmodeller_api-0.4.3.dist-info}/WHEEL +1 -1
  166. floodmodeller_api-0.4.3.dist-info/entry_points.txt +3 -0
  167. floodmodeller_api/libifcoremd.dll +0 -0
  168. floodmodeller_api/test/test_data/EX3.bmp +0 -0
  169. floodmodeller_api/test/test_data/test_output.csv +0 -87
  170. floodmodeller_api/zzn_read.dll +0 -0
  171. floodmodeller_api-0.4.2.data/scripts/fmapi-add_siltation.bat +0 -2
  172. floodmodeller_api-0.4.2.data/scripts/fmapi-add_siltation.py +0 -3
  173. floodmodeller_api-0.4.2.data/scripts/fmapi-structure_log.bat +0 -2
  174. floodmodeller_api-0.4.2.data/scripts/fmapi-structure_log.py +0 -3
  175. floodmodeller_api-0.4.2.data/scripts/fmapi-toolbox.bat +0 -2
  176. floodmodeller_api-0.4.2.data/scripts/fmapi-toolbox.py +0 -41
  177. floodmodeller_api-0.4.2.dist-info/RECORD +0 -169
  178. {floodmodeller_api-0.4.2.dist-info → floodmodeller_api-0.4.3.dist-info}/top_level.txt +0 -0
@@ -1,141 +1,147 @@
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_int, join_n_char_ljust
18
- from floodmodeller_api.validation import _validate_unit
19
-
20
- from ._base import UrbanSubsection, UrbanUnit
21
-
22
-
23
- class XSECTION(UrbanUnit):
24
- """Class to hold and process XSECTION unit type
25
-
26
- Args:
27
- name (str): Link name of the conduit, orifice, or weir. (required)
28
- shape (str): cross-section shape type (see Tables D-1 or 3-1 for available shapes). (required)
29
- geom1 (float): Full height of the cross-section (ft or m). (required, for shape types or "CUSTOM" or "IREGULAR)
30
- geom2 (float): auxiliary parameter (width, side slopes, etc.) as listed in Table D-1. (required, applicable to shape types)
31
- geom3 (float): auxiliary parameter (width, side slopes, etc.) as listed in Table D-1. (required, applicable to shape types)
32
- geom4 (float):auxiliary parameter (width, side slopes, etc.) as listed in Table D-1. (required, applicable to shape types)
33
- barrels (float): Barrels type number of barrels (i.e., number of parallel pipes of equal size, slope, and roughness) associated with a conduit of shape type , or "CUSTOM" type (optional, default is 1).
34
- culvert (int): Culvert code number from Table A.10 for the conduit’s inlet geometry if it is a culvert subject to possible inlet flow control. Only an option for shape type (leave blank otherwise) (optional, default is "").
35
- curve (str): Curve name of a Shape Curve in the [CURVES] section that defines how width varies with depth. (optional, applicable to shape types only)
36
- tsect (str): Name of an entry in the [TRANSECTS] section that describes the cross-section geometry of an irregular channel. (required, applicable to "IREGUALAR types only)
37
-
38
-
39
- Returns:
40
- XSECTION: Flood Modeller XSECTION Unit class object TODO: add urban 1d in to all instances within urban 1d API
41
- """
42
-
43
- _unit = "XSECTION"
44
-
45
- def _read(self, line):
46
- unit_data = line.split()
47
-
48
- # TODO: add functionality to read comments
49
- # TODO: consider appropriate defaults
50
- self.name = str(unit_data[0])
51
-
52
- if unit_data[1] in _shape_options:
53
- # Extend length of unit_data to account for missing optional arguments.
54
-
55
- while len(unit_data) < 8:
56
- unit_data.append("")
57
-
58
- self.shape = str(unit_data[1])
59
- self.geom1 = _to_float(unit_data[2], 0.0)
60
- self.geom2 = _to_float(unit_data[3], 0.0)
61
- self.geom3 = _to_float(unit_data[4], 0.0)
62
- self.geom4 = _to_float(unit_data[5], 0.0)
63
- self.barrels = _to_int(unit_data[6], 1)
64
- self.culvert = _to_int(unit_data[7], "")
65
-
66
- elif unit_data[1] == "CUSTOM":
67
- while len(unit_data) < 5:
68
- unit_data.append("")
69
-
70
- self.shape = str(unit_data[1])
71
- self.geom1 = _to_float(unit_data[2], "")
72
- self.barrels = _to_int(unit_data[6], 1)
73
-
74
- elif unit_data[1] == "IRREGULAR":
75
- while len(unit_data) < 3:
76
- unit_data.append("")
77
-
78
- self.shape = str(unit_data[1])
79
- self.tsect = str(unit_data[2])
80
-
81
- def _write(self):
82
- """Function to write a valid OUTFALL line"""
83
-
84
- _validate_unit(self, urban=True)
85
-
86
- # TODO:Improve indentation format when writing and include header for completeness
87
-
88
- params1 = join_n_char_ljust(17, self.name)
89
-
90
- if self.shape in _shape_options:
91
- params2 = join_n_char_ljust(
92
- 15,
93
- self.shape,
94
- self.geom1,
95
- self.geom2,
96
- self.geom3,
97
- self.geom4,
98
- self.barrels,
99
- self.culvert,
100
- )
101
-
102
- elif self.shape == "CUSTOM":
103
- params2 = join_n_char_ljust(15, self.shape, self.geom1, self.barrels)
104
-
105
- elif self.shape == "IRREGULAR":
106
- params2 = join_n_char_ljust(15, self.shape, self.tsect)
107
-
108
- return params1 + params2
109
-
110
-
111
- class XSECTIONS(UrbanSubsection):
112
- """Class to read/write the table of junctions"""
113
-
114
- _urban_unit_class = XSECTION
115
- _attribute = "xsections"
116
-
117
-
118
- _shape_options = [
119
- "CIRCULAR",
120
- "FORCE_MAIN",
121
- "FILLED_CIRCULAR2",
122
- "RECT_CLOSED",
123
- "RECT_OPEN",
124
- "TRAPEZOIDAL",
125
- "TRIANGULAR",
126
- "HORIZ_ELLIPSE",
127
- "VERT_ELLIPSE",
128
- "ARCH",
129
- "PARABOLIC",
130
- "POWER",
131
- "RECT_TRIANGULAR",
132
- "RECT_ROUND",
133
- "MODBASKETHANDLE",
134
- "EGG",
135
- "HORSESHOE",
136
- "GOTHIC",
137
- "CATENARY",
138
- "SEMIELLIPTICAL",
139
- "BASKETHANDLE",
140
- "SEMICIRCULAR",
141
- ]
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_int, join_n_char_ljust
18
+ from floodmodeller_api.validation import _validate_unit
19
+
20
+ from ._base import UrbanSubsection, UrbanUnit
21
+
22
+
23
+ class XSECTION(UrbanUnit):
24
+ """Class to hold and process XSECTION unit type
25
+
26
+ Args:
27
+ name (str): Link name of the conduit, orifice, or weir. (required)
28
+ shape (str): cross-section shape type (see Tables D-1 or 3-1 for available shapes). (required)
29
+ geom1 (float): Full height of the cross-section (ft or m). (required, for shape types or "CUSTOM" or "IREGULAR)
30
+ geom2 (float): auxiliary parameter (width, side slopes, etc.) as listed in Table D-1. (required, applicable to shape types)
31
+ geom3 (float): auxiliary parameter (width, side slopes, etc.) as listed in Table D-1. (required, applicable to shape types)
32
+ geom4 (float):auxiliary parameter (width, side slopes, etc.) as listed in Table D-1. (required, applicable to shape types)
33
+ barrels (float): Barrels type number of barrels (i.e., number of parallel pipes of equal size, slope, and roughness) associated with a conduit of shape type , or "CUSTOM" type (optional, default is 1).
34
+ culvert (int): Culvert code number from Table A.10 for the conduit’s inlet geometry if it is a culvert subject to possible inlet flow control. Only an option for shape type (leave blank otherwise) (optional, default is "").
35
+ curve (str): Curve name of a Shape Curve in the [CURVES] section that defines how width varies with depth. (optional, applicable to shape types only)
36
+ tsect (str): Name of an entry in the [TRANSECTS] section that describes the cross-section geometry of an irregular channel. (required, applicable to "IREGUALAR types only)
37
+
38
+
39
+ Returns:
40
+ XSECTION: Flood Modeller XSECTION Unit class object TODO: add urban 1d in to all instances within urban 1d API
41
+ """
42
+
43
+ _unit = "XSECTION"
44
+ MIN_LENGTH_OTHER = 8
45
+ MIN_LENGTH_CUSTOM = 5
46
+ MIN_LENGTH_IRREGULAR = 3
47
+
48
+ def _read(self, line):
49
+ unit_data = line.split()
50
+
51
+ # TODO: add functionality to read comments
52
+ # TODO: consider appropriate defaults
53
+ self.name = str(unit_data[0])
54
+
55
+ if unit_data[1] in _shape_options:
56
+ # Extend length of unit_data to account for missing optional arguments.
57
+
58
+ while len(unit_data) < self.MIN_LENGTH_OTHER:
59
+ unit_data.append("")
60
+
61
+ self.shape = str(unit_data[1])
62
+ self.geom1 = _to_float(unit_data[2], 0.0)
63
+ self.geom2 = _to_float(unit_data[3], 0.0)
64
+ self.geom3 = _to_float(unit_data[4], 0.0)
65
+ self.geom4 = _to_float(unit_data[5], 0.0)
66
+ self.barrels = _to_int(unit_data[6], 1)
67
+ self.culvert = _to_int(unit_data[7], "")
68
+
69
+ elif unit_data[1] == "CUSTOM":
70
+ while len(unit_data) < self.MIN_LENGTH_CUSTOM:
71
+ unit_data.append("")
72
+
73
+ self.shape = str(unit_data[1])
74
+ self.geom1 = _to_float(unit_data[2], "")
75
+ self.barrels = _to_int(unit_data[6], 1)
76
+
77
+ elif unit_data[1] == "IRREGULAR":
78
+ while len(unit_data) < self.MIN_LENGTH_IRREGULAR:
79
+ unit_data.append("")
80
+
81
+ self.shape = str(unit_data[1])
82
+ self.tsect = str(unit_data[2])
83
+
84
+ def _write(self):
85
+ """Function to write a valid OUTFALL line"""
86
+
87
+ _validate_unit(self, urban=True)
88
+
89
+ # TODO:Improve indentation format when writing and include header for completeness
90
+
91
+ params1 = join_n_char_ljust(17, self.name)
92
+
93
+ if self.shape in _shape_options:
94
+ params2 = join_n_char_ljust(
95
+ 15,
96
+ self.shape,
97
+ self.geom1,
98
+ self.geom2,
99
+ self.geom3,
100
+ self.geom4,
101
+ self.barrels,
102
+ self.culvert,
103
+ )
104
+
105
+ elif self.shape == "CUSTOM":
106
+ params2 = join_n_char_ljust(15, self.shape, self.geom1, self.barrels)
107
+
108
+ elif self.shape == "IRREGULAR":
109
+ params2 = join_n_char_ljust(15, self.shape, self.tsect)
110
+
111
+ else:
112
+ raise RuntimeError(f"{self.shape} not supported")
113
+
114
+ return params1 + params2
115
+
116
+
117
+ class XSECTIONS(UrbanSubsection):
118
+ """Class to read/write the table of junctions"""
119
+
120
+ _urban_unit_class = XSECTION
121
+ _attribute = "xsections"
122
+
123
+
124
+ _shape_options = [
125
+ "CIRCULAR",
126
+ "FORCE_MAIN",
127
+ "FILLED_CIRCULAR2",
128
+ "RECT_CLOSED",
129
+ "RECT_OPEN",
130
+ "TRAPEZOIDAL",
131
+ "TRIANGULAR",
132
+ "HORIZ_ELLIPSE",
133
+ "VERT_ELLIPSE",
134
+ "ARCH",
135
+ "PARABOLIC",
136
+ "POWER",
137
+ "RECT_TRIANGULAR",
138
+ "RECT_ROUND",
139
+ "MODBASKETHANDLE",
140
+ "EGG",
141
+ "HORSESHOE",
142
+ "GOTHIC",
143
+ "CATENARY",
144
+ "SEMIELLIPTICAL",
145
+ "BASKETHANDLE",
146
+ "SEMICIRCULAR",
147
+ ]
floodmodeller_api/util.py CHANGED
@@ -1,21 +1,77 @@
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 webbrowser
18
-
19
-
20
- def open_docs():
21
- webbrowser.open_new_tab("https://api.floodmodeller.com/api/")
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 __future__ import annotations
18
+
19
+ import sys
20
+ import webbrowser
21
+ from pathlib import Path
22
+ from typing import TYPE_CHECKING
23
+
24
+ if TYPE_CHECKING:
25
+ from ._base import FMFile
26
+
27
+
28
+ def open_docs():
29
+ webbrowser.open_new_tab("https://api.floodmodeller.com/api/")
30
+
31
+
32
+ def read_file(filepath: str | Path) -> FMFile:
33
+ """Helper function to create an instance of an API class based on the provided filepath.
34
+
35
+ This function maps file suffixes to specific classes and returns an instance of the
36
+ corresponding class for handling the file.
37
+
38
+ Args:
39
+ filepath (Union[str, Path]): The path to the file to be read, as a string or Path object.
40
+
41
+ Returns:
42
+ FMFile: An instance of the class corresponding to the file type identified by the file suffix.
43
+
44
+ Raises:
45
+ ValueError: If the file suffix does not correspond to any supported file type.
46
+
47
+ Example:
48
+ .. code-block:: python
49
+
50
+ from floodmodeller_api import read_file
51
+
52
+ ief = read_file("/path/to/file.ief")
53
+
54
+
55
+ """
56
+ from . import DAT, IED, IEF, INP, LF1, LF2, XML2D, ZZN
57
+
58
+ suffix_to_class = {
59
+ ".ief": IEF,
60
+ ".dat": DAT,
61
+ ".ied": IED,
62
+ ".xml": XML2D,
63
+ ".zzn": ZZN,
64
+ ".inp": INP,
65
+ ".lf1": LF1,
66
+ ".lf2": LF2,
67
+ }
68
+ filepath = Path(filepath)
69
+ api_class = suffix_to_class.get(filepath.suffix.lower())
70
+ if api_class:
71
+ return api_class(filepath)
72
+
73
+ raise ValueError(f"Unsupported file type: {filepath.suffix}")
74
+
75
+
76
+ def is_windows() -> bool:
77
+ return sys.platform.startswith("win")