Skip to content

Commit ddb5f0f

Browse files
committed
add encroachment_points method and test coverage
1 parent 3bacbd6 commit ddb5f0f

File tree

3 files changed

+511
-2
lines changed

3 files changed

+511
-2
lines changed

src/rashdf/plan.py

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,8 +1381,47 @@ def get_results_volume_accounting_attrs(self) -> Dict:
13811381
"""
13821382
return self.get_attrs(self.VOLUME_ACCOUNTING_PATH)
13831383

1384-
def enroachment_points(self) -> GeoDataFrame: # noqa: D102
1385-
raise NotImplementedError
1384+
def encroachment_points(self, profile_name: str) -> GeoDataFrame:
1385+
"""Return encroachment points from a HEC-RAS plan HDF file based on a user-specified flow profile.
1386+
1387+
Returns
1388+
-------
1389+
GeoDataframe
1390+
A GeoDataFrame with cross-section encroachments represented as Point geometry features along with pertinent attributes.
1391+
"""
1392+
XSs = self.cross_sections()
1393+
XSs["Enc_Profile"] = profile_name
1394+
1395+
leftmost_sta = self.cross_sections_elevations()["elevation info"].apply(
1396+
lambda x: x[0][0]
1397+
)
1398+
left_enc_sta = self.cross_sections_additional_enc_station_left()[profile_name]
1399+
left_enc_points = GeoDataFrame(
1400+
pd.concat(
1401+
[
1402+
XSs[["River", "Reach", "RS", "Enc_Profile"]],
1403+
left_enc_sta.rename("Enc_Sta", inplace=False),
1404+
],
1405+
axis=1,
1406+
),
1407+
geometry=XSs.geometry.interpolate(left_enc_sta - leftmost_sta),
1408+
)
1409+
left_enc_points["Side"] = "Left"
1410+
1411+
right_enc_sta = self.cross_sections_additional_enc_station_right()[profile_name]
1412+
right_enc_points = GeoDataFrame(
1413+
pd.concat(
1414+
[
1415+
XSs[["River", "Reach", "RS", "Enc_Profile"]],
1416+
right_enc_sta.rename("Enc_Sta", inplace=False),
1417+
],
1418+
axis=1,
1419+
),
1420+
geometry=XSs.geometry.interpolate(right_enc_sta - leftmost_sta),
1421+
)
1422+
right_enc_points["Side"] = "Right"
1423+
1424+
return GeoDataFrame(pd.concat([left_enc_points, right_enc_points]))
13861425

13871426
def steady_flow_names(self) -> list:
13881427
"""Return the profile information for each steady flow event.

0 commit comments

Comments
 (0)