rashdf 0.8.0__py3-none-any.whl → 0.8.1__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 +50 -25
- {rashdf-0.8.0.dist-info → rashdf-0.8.1.dist-info}/METADATA +2 -2
- {rashdf-0.8.0.dist-info → rashdf-0.8.1.dist-info}/RECORD +7 -7
- {rashdf-0.8.0.dist-info → rashdf-0.8.1.dist-info}/WHEEL +0 -0
- {rashdf-0.8.0.dist-info → rashdf-0.8.1.dist-info}/entry_points.txt +0 -0
- {rashdf-0.8.0.dist-info → rashdf-0.8.1.dist-info}/licenses/LICENSE +0 -0
- {rashdf-0.8.0.dist-info → rashdf-0.8.1.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"
|
|
@@ -295,19 +298,28 @@ class RasGeomHdf(RasHdf):
|
|
|
295
298
|
polyline_points = self[polyline_points_path][()]
|
|
296
299
|
|
|
297
300
|
geoms = []
|
|
298
|
-
for pnt_start, pnt_cnt, part_start, part_cnt in polyline_info:
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
301
|
+
for i, (pnt_start, pnt_cnt, part_start, part_cnt) in enumerate(polyline_info):
|
|
302
|
+
try:
|
|
303
|
+
points = polyline_points[pnt_start : pnt_start + pnt_cnt]
|
|
304
|
+
if part_cnt == 1:
|
|
305
|
+
geoms.append(LineString(points))
|
|
306
|
+
else: # pragma: no cover | TODO: add test coverage for this
|
|
307
|
+
parts = polyline_parts[part_start : part_start + part_cnt]
|
|
308
|
+
geoms.append(
|
|
309
|
+
MultiLineString(
|
|
310
|
+
list(
|
|
311
|
+
points[part_pnt_start : part_pnt_start + part_pnt_cnt]
|
|
312
|
+
for part_pnt_start, part_pnt_cnt in parts
|
|
313
|
+
)
|
|
309
314
|
)
|
|
310
315
|
)
|
|
316
|
+
except (
|
|
317
|
+
Exception
|
|
318
|
+
) as e: # pragma: no cover | TODO: add test coverage for this
|
|
319
|
+
geoms.append(None)
|
|
320
|
+
warn(
|
|
321
|
+
f"Feature ID {i} within '{Path(path).name}' layer set to null due to invalid geometry. {e}",
|
|
322
|
+
UserWarning,
|
|
311
323
|
)
|
|
312
324
|
return geoms
|
|
313
325
|
|
|
@@ -370,25 +382,38 @@ class RasGeomHdf(RasHdf):
|
|
|
370
382
|
GeoDataFrame
|
|
371
383
|
A GeoDataFrame containing the 2D mesh area refinement regions if they exist.
|
|
372
384
|
"""
|
|
373
|
-
if
|
|
385
|
+
if self.REFINEMENT_REGIONS_PATH not in self:
|
|
374
386
|
return GeoDataFrame()
|
|
375
|
-
rr_data = self[
|
|
387
|
+
rr_data = self[self.REFINEMENT_REGIONS_PATH]
|
|
376
388
|
rr_ids = range(rr_data["Attributes"][()].shape[0])
|
|
377
389
|
names = np.vectorize(convert_ras_hdf_string)(rr_data["Attributes"][()]["Name"])
|
|
378
390
|
geoms = list()
|
|
379
|
-
for pnt_start, pnt_cnt, part_start, part_cnt in
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
391
|
+
for i, (pnt_start, pnt_cnt, part_start, part_cnt) in enumerate(
|
|
392
|
+
rr_data["Polygon Info"][()]
|
|
393
|
+
):
|
|
394
|
+
try:
|
|
395
|
+
points = rr_data["Polygon Points"][()][pnt_start : pnt_start + pnt_cnt]
|
|
396
|
+
if part_cnt == 1:
|
|
397
|
+
geoms.append(Polygon(points))
|
|
398
|
+
else: # pragma: no cover | TODO: add test coverage for this
|
|
399
|
+
parts = rr_data["Polygon Parts"][()][
|
|
400
|
+
part_start : part_start + part_cnt
|
|
401
|
+
]
|
|
402
|
+
geoms.append(
|
|
403
|
+
MultiPolygon(
|
|
404
|
+
list(
|
|
405
|
+
points[part_pnt_start : part_pnt_start + part_pnt_cnt]
|
|
406
|
+
for part_pnt_start, part_pnt_cnt in parts
|
|
407
|
+
)
|
|
390
408
|
)
|
|
391
409
|
)
|
|
410
|
+
except (
|
|
411
|
+
Exception
|
|
412
|
+
) as e: # pragma: no cover | TODO: add test coverage for this
|
|
413
|
+
geoms.append(None)
|
|
414
|
+
warn(
|
|
415
|
+
f"Feature ID {i} within '{Path(self.REFINEMENT_REGIONS_PATH).name}' layer set to null due to invalid geometry. {e}",
|
|
416
|
+
UserWarning,
|
|
392
417
|
)
|
|
393
418
|
return GeoDataFrame(
|
|
394
419
|
{"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.1
|
|
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=-GmHmddcdIcfOn-SFS940WyDLUilW9inrp_nuZ8aTHo,28306
|
|
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.1.dist-info/licenses/LICENSE,sha256=L_0QaLpQVHPcglVjiaJPnOocwzP8uXevDRjUPr9DL1Y,1065
|
|
8
|
+
rashdf-0.8.1.dist-info/METADATA,sha256=7h2fJs_IYE81euocfUfqCtY0qSPoMOJ-yV5kKdZ9Zco,6072
|
|
9
|
+
rashdf-0.8.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
10
|
+
rashdf-0.8.1.dist-info/entry_points.txt,sha256=LHHMR1lLy4wRyscMuW1RlYDXemtPgqQhNcILz0DtStY,36
|
|
11
|
+
rashdf-0.8.1.dist-info/top_level.txt,sha256=SrmLb6FFTJtM_t6O1v0M0JePshiQJMHr0yYVkHL7ztk,11
|
|
12
|
+
rashdf-0.8.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|