Commit 04e5b617 authored by Theophile Terraz's avatar Theophile Terraz
Browse files

wet_width

No related merge requests found
Pipeline #56699 passed with stages
in 56 seconds
Showing with 61 additions and 5 deletions
+61 -5
......@@ -351,6 +351,9 @@ class Profile(object):
def wet_points(self, z):
raise NotImplementedMethodeError(self, self.wet_point)
def wet_width(self, z):
raise NotImplementedMethodeError(self, self.wet_width)
def wet_perimeter(self, z):
raise NotImplementedMethodeError(self, self.wet_perimeter)
......
......@@ -401,6 +401,18 @@ class ProfileXYZ(Profile, SQLSubModel):
return abs(rg.dist(rd))
def wet_width(self, z):
start, end = self.get_all_water_limits_ac(z)
if len(start) == 0:
return 0
length = 0.0
for s,e in zip(start, end):
length += abs(s - e)
return length
def wet_perimeter(self, z):
lines = self.wet_lines(z)
......@@ -515,6 +527,50 @@ class ProfileXYZ(Profile, SQLSubModel):
return n_zones
def get_all_water_limits_ac(self, z):
"""
Determine all water limits for z elevation.
"""
points = self._points
if len(points) < 3:
return None
zz = list(map(lambda p: p.z, points))
station = self._get_station(points)
start = []
if points[0].z <= z:
start.append(station[0])
for i in range(self.number_points-1):
if zz[i] > z and zz[i+1] <= z:
y = np.interp(
z,
[zz[i], zz[i+1]],
[station[i], station[i+1]]
)
start.append(y)
end = []
for i in reversed(range(self.number_points-1)):
if zz[i-1] <= z and zz[i] > z:
y = np.interp(
z,
[zz[i-1], zz[i]],
[station[i-1], station[i]]
)
end.append(y)
if points[-1].z <= z:
end.append(station[-1])
if len(start) != len(end):
logger.error(f"ERROR in get_all_water_limits_ac")
return [], []
return start, list(reversed(end))
def get_water_limits(self, z):
"""
Determine left and right limits of water elevation.
......
......@@ -93,11 +93,8 @@ class TableModel(PamhyrTableModel):
v = self._lst[row].geometry.speed(q, z)
return f"{v:.4f}"
elif self._headers[column] == "width":
pt_left, pt_right = self._lst[row].get_ts_key(
self._timestamp,
"water_limits"
)
v = pt_left.dist_2d(pt_right)
z = self._lst[row].get_ts_key(self._timestamp, "Z")
v = self._lst[row].geometry.wet_width(z)
return f"{v:.4f}"
elif self._headers[column] == "depth":
z = self._lst[row].get_ts_key(self._timestamp, "Z")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment