rashdf 0.8.0__py3-none-any.whl → 0.8.2__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.
- rashdf/geom.py +59 -29
- {rashdf-0.8.0.dist-info → rashdf-0.8.2.dist-info}/METADATA +2 -2
- {rashdf-0.8.0.dist-info → rashdf-0.8.2.dist-info}/RECORD +7 -7
- {rashdf-0.8.0.dist-info → rashdf-0.8.2.dist-info}/WHEEL +0 -0
- {rashdf-0.8.0.dist-info → rashdf-0.8.2.dist-info}/entry_points.txt +0 -0
- {rashdf-0.8.0.dist-info → rashdf-0.8.2.dist-info}/licenses/LICENSE +0 -0
- {rashdf-0.8.0.dist-info → rashdf-0.8.2.dist-info}/top_level.txt +0 -0
rashdf/geom.py
CHANGED
|
@@ -17,6 +17,8 @@ from shapely import (
|
|
|
17
17
|
)
|
|
18
18
|
|
|
19
19
|
from typing import Dict, List, Optional, Union
|
|
20
|
+
from warnings import warn
|
|
21
|
+
from pathlib import Path
|
|
20
22
|
|
|
21
23
|
|
|
22
24
|
from .base import RasHdf
|
|
@@ -29,7 +31,7 @@ from .utils import (
|
|
|
29
31
|
|
|
30
32
|
|
|
31
33
|
class RasGeomHdfError(Exception):
|
|
32
|
-
"""HEC-RAS
|
|
34
|
+
"""HEC-RAS Geometry HDF error class."""
|
|
33
35
|
|
|
34
36
|
pass
|
|
35
37
|
|
|
@@ -43,6 +45,7 @@ class RasGeomHdf(RasHdf):
|
|
|
43
45
|
BC_LINES_PATH = f"{GEOM_PATH}/Boundary Condition Lines"
|
|
44
46
|
IC_POINTS_PATH = f"{GEOM_PATH}/IC Points"
|
|
45
47
|
BREAKLINES_PATH = f"{GEOM_PATH}/2D Flow Area Break Lines"
|
|
48
|
+
REFINEMENT_REGIONS_PATH = f"{GEOM_PATH}/2D Flow Area Refinement Regions"
|
|
46
49
|
REFERENCE_LINES_PATH = f"{GEOM_PATH}/Reference Lines"
|
|
47
50
|
REFERENCE_POINTS_PATH = f"{GEOM_PATH}/Reference Points"
|
|
48
51
|
CROSS_SECTIONS = f"{GEOM_PATH}/Cross Sections"
|
|
@@ -103,10 +106,15 @@ class RasGeomHdf(RasHdf):
|
|
|
103
106
|
mesh_area_names = self.mesh_area_names()
|
|
104
107
|
if not mesh_area_names:
|
|
105
108
|
return GeoDataFrame()
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
109
|
+
|
|
110
|
+
mesh_area_polygons = []
|
|
111
|
+
for n in mesh_area_names:
|
|
112
|
+
try:
|
|
113
|
+
mesh_area_polygons.append(
|
|
114
|
+
Polygon(self[f"{self.FLOW_AREA_2D_PATH}/{n}/Perimeter"][()])
|
|
115
|
+
)
|
|
116
|
+
except KeyError as e:
|
|
117
|
+
raise RasGeomHdfError(f"Data for mesh '{n}' not found.") from e
|
|
110
118
|
return GeoDataFrame(
|
|
111
119
|
{"mesh_name": mesh_area_names, "geometry": mesh_area_polygons},
|
|
112
120
|
geometry="geometry",
|
|
@@ -295,19 +303,28 @@ class RasGeomHdf(RasHdf):
|
|
|
295
303
|
polyline_points = self[polyline_points_path][()]
|
|
296
304
|
|
|
297
305
|
geoms = []
|
|
298
|
-
for pnt_start, pnt_cnt, part_start, part_cnt in polyline_info:
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
306
|
+
for i, (pnt_start, pnt_cnt, part_start, part_cnt) in enumerate(polyline_info):
|
|
307
|
+
try:
|
|
308
|
+
points = polyline_points[pnt_start : pnt_start + pnt_cnt]
|
|
309
|
+
if part_cnt == 1:
|
|
310
|
+
geoms.append(LineString(points))
|
|
311
|
+
else: # pragma: no cover | TODO: add test coverage for this
|
|
312
|
+
parts = polyline_parts[part_start : part_start + part_cnt]
|
|
313
|
+
geoms.append(
|
|
314
|
+
MultiLineString(
|
|
315
|
+
list(
|
|
316
|
+
points[part_pnt_start : part_pnt_start + part_pnt_cnt]
|
|
317
|
+
for part_pnt_start, part_pnt_cnt in parts
|
|
318
|
+
)
|
|
309
319
|
)
|
|
310
320
|
)
|
|
321
|
+
except (
|
|
322
|
+
Exception
|
|
323
|
+
) as e: # pragma: no cover | TODO: add test coverage for this
|
|
324
|
+
geoms.append(None)
|
|
325
|
+
warn(
|
|
326
|
+
f"Feature ID {i} within '{Path(path).name}' layer set to null due to invalid geometry. {e}",
|
|
327
|
+
UserWarning,
|
|
311
328
|
)
|
|
312
329
|
return geoms
|
|
313
330
|
|
|
@@ -370,25 +387,38 @@ class RasGeomHdf(RasHdf):
|
|
|
370
387
|
GeoDataFrame
|
|
371
388
|
A GeoDataFrame containing the 2D mesh area refinement regions if they exist.
|
|
372
389
|
"""
|
|
373
|
-
if
|
|
390
|
+
if self.REFINEMENT_REGIONS_PATH not in self:
|
|
374
391
|
return GeoDataFrame()
|
|
375
|
-
rr_data = self[
|
|
392
|
+
rr_data = self[self.REFINEMENT_REGIONS_PATH]
|
|
376
393
|
rr_ids = range(rr_data["Attributes"][()].shape[0])
|
|
377
394
|
names = np.vectorize(convert_ras_hdf_string)(rr_data["Attributes"][()]["Name"])
|
|
378
395
|
geoms = list()
|
|
379
|
-
for pnt_start, pnt_cnt, part_start, part_cnt in
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
396
|
+
for i, (pnt_start, pnt_cnt, part_start, part_cnt) in enumerate(
|
|
397
|
+
rr_data["Polygon Info"][()]
|
|
398
|
+
):
|
|
399
|
+
try:
|
|
400
|
+
points = rr_data["Polygon Points"][()][pnt_start : pnt_start + pnt_cnt]
|
|
401
|
+
if part_cnt == 1:
|
|
402
|
+
geoms.append(Polygon(points))
|
|
403
|
+
else: # pragma: no cover | TODO: add test coverage for this
|
|
404
|
+
parts = rr_data["Polygon Parts"][()][
|
|
405
|
+
part_start : part_start + part_cnt
|
|
406
|
+
]
|
|
407
|
+
geoms.append(
|
|
408
|
+
MultiPolygon(
|
|
409
|
+
list(
|
|
410
|
+
points[part_pnt_start : part_pnt_start + part_pnt_cnt]
|
|
411
|
+
for part_pnt_start, part_pnt_cnt in parts
|
|
412
|
+
)
|
|
390
413
|
)
|
|
391
414
|
)
|
|
415
|
+
except (
|
|
416
|
+
Exception
|
|
417
|
+
) as e: # pragma: no cover | TODO: add test coverage for this
|
|
418
|
+
geoms.append(None)
|
|
419
|
+
warn(
|
|
420
|
+
f"Feature ID {i} within '{Path(self.REFINEMENT_REGIONS_PATH).name}' layer set to null due to invalid geometry. {e}",
|
|
421
|
+
UserWarning,
|
|
392
422
|
)
|
|
393
423
|
return GeoDataFrame(
|
|
394
424
|
{"rr_id": rr_ids, "name": names, "geometry": geoms},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: rashdf
|
|
3
|
-
Version: 0.8.
|
|
3
|
+
Version: 0.8.2
|
|
4
4
|
Summary: Read data from HEC-RAS HDF files.
|
|
5
5
|
Project-URL: repository, https://github.com/fema-ffrd/rashdf
|
|
6
6
|
Classifier: Development Status :: 4 - Beta
|
|
@@ -16,7 +16,7 @@ License-File: LICENSE
|
|
|
16
16
|
Requires-Dist: h5py
|
|
17
17
|
Requires-Dist: geopandas<2.0,>=1.0
|
|
18
18
|
Requires-Dist: pyarrow
|
|
19
|
-
Requires-Dist: xarray
|
|
19
|
+
Requires-Dist: xarray<=2025.4.0
|
|
20
20
|
Provides-Extra: dev
|
|
21
21
|
Requires-Dist: pre-commit; extra == "dev"
|
|
22
22
|
Requires-Dist: ruff; extra == "dev"
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
cli.py,sha256=HbyrdUVKfrmtU2T9ljKTPQ-ugomJqYbCA26ghGJDJh0,6588
|
|
2
2
|
rashdf/__init__.py,sha256=XXFtJDgLPCimqAhfsFz_pTWYECJiRT0i-Kb1uflXmVU,156
|
|
3
3
|
rashdf/base.py,sha256=cAQJX1aeBJKb3MJ06ltpbRTUaZX5NkuxpR1J4f7FyTU,2507
|
|
4
|
-
rashdf/geom.py,sha256=
|
|
4
|
+
rashdf/geom.py,sha256=ODdqxcK152AcBAYCw-gcvsmGRxhch7wvzN11YuDzz6Q,28495
|
|
5
5
|
rashdf/plan.py,sha256=d8YhpC6cV8rhh3qf1o12TbhUvo_4pMh75vIdDkcAvjE,63971
|
|
6
6
|
rashdf/utils.py,sha256=Cba6sULF0m0jg6CQass4bPm2oxTd_avoe1pRQxq082c,10896
|
|
7
|
-
rashdf-0.8.
|
|
8
|
-
rashdf-0.8.
|
|
9
|
-
rashdf-0.8.
|
|
10
|
-
rashdf-0.8.
|
|
11
|
-
rashdf-0.8.
|
|
12
|
-
rashdf-0.8.
|
|
7
|
+
rashdf-0.8.2.dist-info/licenses/LICENSE,sha256=L_0QaLpQVHPcglVjiaJPnOocwzP8uXevDRjUPr9DL1Y,1065
|
|
8
|
+
rashdf-0.8.2.dist-info/METADATA,sha256=wtCbEs_hvNJ9MfbAoLkmtulhTEv34tTlxP3r5BT7xrE,6072
|
|
9
|
+
rashdf-0.8.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
10
|
+
rashdf-0.8.2.dist-info/entry_points.txt,sha256=LHHMR1lLy4wRyscMuW1RlYDXemtPgqQhNcILz0DtStY,36
|
|
11
|
+
rashdf-0.8.2.dist-info/top_level.txt,sha256=SrmLb6FFTJtM_t6O1v0M0JePshiQJMHr0yYVkHL7ztk,11
|
|
12
|
+
rashdf-0.8.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|