wet_width

This commit is contained in:
Theophile Terraz committed 2024-07-17 16:25:03 +02:00
1 parent f6a2240b1f
commit 04e5b61732
3 files changed
+61 -5

No files matched your search

+3
View File
@@ -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)
+56
View File
@@ -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.