mirror of https://gitlab.com/pamhyr/pamhyr2
add zfd in results
parent
3277cf551b
commit
9670bde56f
|
|
@ -63,9 +63,12 @@ class Profile(object):
|
||||||
return self._data[timestamp][key]
|
return self._data[timestamp][key]
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def has_sediment(self):
|
def has_sediment_layers(self):
|
||||||
return any(map(lambda ts: "sl" in self._data[ts], self._data))
|
return any(map(lambda ts: "sl" in self._data[ts], self._data))
|
||||||
|
|
||||||
|
def has_bedload(self):
|
||||||
|
return any(map(lambda ts: "zfd" in self._data[ts], self._data))
|
||||||
|
|
||||||
|
|
||||||
class Reach(object):
|
class Reach(object):
|
||||||
def __init__(self, reach, study):
|
def __init__(self, reach, study):
|
||||||
|
|
@ -115,7 +118,11 @@ class Reach(object):
|
||||||
self._profiles[profile_id].set(timestamp, key, data)
|
self._profiles[profile_id].set(timestamp, key, data)
|
||||||
|
|
||||||
def has_sediment(self):
|
def has_sediment(self):
|
||||||
return any(map(lambda profile: profile.has_sediment(), self._profiles))
|
return any(map(lambda profile: profile.has_sediment_layers(),
|
||||||
|
self._profiles))
|
||||||
|
|
||||||
|
def has_bedload(self):
|
||||||
|
return any(map(lambda profile: profile.has_bedload(), self._profiles))
|
||||||
|
|
||||||
def bufferize(self, timestamps, key):
|
def bufferize(self, timestamps, key):
|
||||||
self._buffers[key] = np.zeros((len(timestamps), len(self)))
|
self._buffers[key] = np.zeros((len(timestamps), len(self)))
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
from functools import reduce
|
||||||
|
|
||||||
from tools import timer, trace, logger_exception
|
from tools import timer, trace, logger_exception
|
||||||
|
|
||||||
|
|
@ -1276,6 +1277,40 @@ class Mage8(Mage):
|
||||||
)
|
)
|
||||||
end = newline().size <= 0
|
end = newline().size <= 0
|
||||||
|
|
||||||
|
ts_list = sorted(ts)
|
||||||
|
|
||||||
|
logger.info(f"compute river bed elevation...")
|
||||||
|
|
||||||
|
for r in reachs:
|
||||||
|
z_min = reach.geometry.get_z_min()
|
||||||
|
sls = list(map(
|
||||||
|
lambda p: p.get_ts_key(ts_list[0], "sl")[0],
|
||||||
|
r.profiles
|
||||||
|
))
|
||||||
|
z_br = list(map(
|
||||||
|
lambda z, sl: reduce(
|
||||||
|
lambda z, h: z - h[0],
|
||||||
|
sl, z
|
||||||
|
),
|
||||||
|
z_min, # Original geometry
|
||||||
|
sls # Original sediment layers
|
||||||
|
))
|
||||||
|
for t in ts_list:
|
||||||
|
sls = list(map(
|
||||||
|
lambda p: p.get_ts_key(t, "sl")[0],
|
||||||
|
r.profiles
|
||||||
|
))
|
||||||
|
zfd = list(map(
|
||||||
|
lambda z, sl: reduce(
|
||||||
|
lambda z, h: z + h[0],
|
||||||
|
sl, z
|
||||||
|
),
|
||||||
|
z_br, # bedrock
|
||||||
|
sls # Original sediment layers
|
||||||
|
))
|
||||||
|
for i, p in enumerate(r.profiles):
|
||||||
|
r.set(i, t, "zfd", zfd[i])
|
||||||
|
|
||||||
results.set("sediment_timestamps", ts)
|
results.set("sediment_timestamps", ts)
|
||||||
logger.info(f"read_gra: ... end with {len(ts)} timestamp read")
|
logger.info(f"read_gra: ... end with {len(ts)} timestamp read")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1630,7 +1630,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||||
)
|
)
|
||||||
|
|
||||||
if result1 is None:
|
if result1 is None:
|
||||||
# TODO message
|
logger.warning(f"diff_results: result1 is None")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
result2 = solver2.results(
|
result2 = solver2.results(
|
||||||
|
|
@ -1639,19 +1639,17 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||||
)
|
)
|
||||||
|
|
||||||
if result2 is None:
|
if result2 is None:
|
||||||
# TODO message
|
logger.warning(f"diff_results: result2 is None")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if result2.get("nb_reach") != result1.get("nb_reach"):
|
if result2.get("nb_reach") != result1.get("nb_reach"):
|
||||||
# TODO message
|
logger.warning(f"diff_results: nb_reach missmatch")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if result2.get("nb_profile") != result1.get("nb_profile"):
|
if result2.get("nb_profile") != result1.get("nb_profile"):
|
||||||
# TODO message
|
logger.warning(f"diff_results: nb_profile missmatch")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# return [result1, result2]
|
|
||||||
|
|
||||||
result3 = Results(self._study, solver3)
|
result3 = Results(self._study, solver3)
|
||||||
result4 = Results(self._study, solver1)
|
result4 = Results(self._study, solver1)
|
||||||
result5 = Results(self._study, solver2)
|
result5 = Results(self._study, solver2)
|
||||||
|
|
@ -1673,7 +1671,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||||
r = result4.river.add(i)
|
r = result4.river.add(i)
|
||||||
r = result5.river.add(i)
|
r = result5.river.add(i)
|
||||||
|
|
||||||
for timestamp in result3.get("timestamps"):
|
for timestamp in ts:
|
||||||
for r in range(int(result1.get("nb_reach"))):
|
for r in range(int(result1.get("nb_reach"))):
|
||||||
reach1 = result1.river.reach(r)
|
reach1 = result1.river.reach(r)
|
||||||
reach2 = result2.river.reach(r)
|
reach2 = result2.river.reach(r)
|
||||||
|
|
@ -1689,6 +1687,16 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||||
reach3.set(p, timestamp, key, d)
|
reach3.set(p, timestamp, key, d)
|
||||||
reach4.set(p, timestamp, key, d1)
|
reach4.set(p, timestamp, key, d1)
|
||||||
reach5.set(p, timestamp, key, d2)
|
reach5.set(p, timestamp, key, d2)
|
||||||
|
if reach1.has_bedload():
|
||||||
|
d1 = profile1.get_ts_key(timestamp, 'zfd')
|
||||||
|
reach4.set(p, timestamp, 'zfd', d1)
|
||||||
|
if reach2.has_bedload():
|
||||||
|
d2 = profile2.get_ts_key(timestamp, 'zfd')
|
||||||
|
reach5.set(p, timestamp, 'zfd', d2)
|
||||||
|
if reach1.has_bedload():
|
||||||
|
d3 = d1-d2
|
||||||
|
reach3.set(p, timestamp, 'zfd', d3)
|
||||||
|
|
||||||
limits = reach3.profile(p).geometry.get_water_limits(
|
limits = reach3.profile(p).geometry.get_water_limits(
|
||||||
reach3.profile(p).get_ts_key(timestamp, "Z")
|
reach3.profile(p).get_ts_key(timestamp, "Z")
|
||||||
)
|
)
|
||||||
|
|
@ -1702,6 +1710,13 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||||
limits = profile2.get_ts_key(timestamp, "water_limits")
|
limits = profile2.get_ts_key(timestamp, "water_limits")
|
||||||
reach5.set(p, timestamp, "water_limits", limits)
|
reach5.set(p, timestamp, "water_limits", limits)
|
||||||
|
|
||||||
|
for res in (result3, result4, result5):
|
||||||
|
for r in range(int(res.get("nb_reach"))):
|
||||||
|
for key in ["Z", "Q", "V"]:
|
||||||
|
res.river.reach(r).bufferize(ts, key)
|
||||||
|
if res.river.reach(r).has_bedload():
|
||||||
|
res.river.reach(r).bufferize(ts, "zfd")
|
||||||
|
|
||||||
return [result4, result5, result3]
|
return [result4, result5, result3]
|
||||||
|
|
||||||
def open_results_adists(self):
|
def open_results_adists(self):
|
||||||
|
|
|
||||||
|
|
@ -96,24 +96,33 @@ class PlotRKC(PamhyrPlot):
|
||||||
self._init = True
|
self._init = True
|
||||||
|
|
||||||
def draw_bottom(self, reach):
|
def draw_bottom(self, reach):
|
||||||
if reach.has_sediment():
|
if reach.has_bedload():
|
||||||
self.draw_bottom_with_bedload(reach)
|
self.draw_bottom_with_bedload(reach)
|
||||||
else:
|
else:
|
||||||
self.draw_bottom_geometry(reach)
|
self.draw_bottom_geometry(reach)
|
||||||
|
|
||||||
def draw_bottom_with_bedload(self, reach):
|
def draw_bottom_with_bedload(self, reach):
|
||||||
self._bedrock = self.sl_compute_bedrock(reach)
|
# self._bedrock = self.sl_compute_bedrock(reach)
|
||||||
|
|
||||||
rk = reach.geometry.get_rk()
|
rk = reach.geometry.get_rk()
|
||||||
z = self.sl_compute_current_z(reach)
|
# z = self.sl_compute_current_z(reach)
|
||||||
|
|
||||||
|
zfd = list(
|
||||||
|
map(
|
||||||
|
lambda p: p.get_ts_key(
|
||||||
|
self._current_timestamp, "zfd"
|
||||||
|
),
|
||||||
|
reach.profiles
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
self.line_bottom, = self.canvas.axes.plot(
|
self.line_bottom, = self.canvas.axes.plot(
|
||||||
rk, z,
|
rk, zfd,
|
||||||
linestyle="solid", lw=1.,
|
linestyle="solid", lw=1.,
|
||||||
color=self.color_plot_river_bottom,
|
color=self.color_plot_river_bottom,
|
||||||
)
|
)
|
||||||
|
|
||||||
self._river_bottom = z
|
self._river_bottom = zfd
|
||||||
|
|
||||||
def draw_profiles_hs(self, reach):
|
def draw_profiles_hs(self, reach):
|
||||||
results = self.results[self._current_res_id]
|
results = self.results[self._current_res_id]
|
||||||
|
|
@ -147,58 +156,6 @@ class PlotRKC(PamhyrPlot):
|
||||||
fontsize=9, color=self.color_plot_previous,
|
fontsize=9, color=self.color_plot_previous,
|
||||||
)
|
)
|
||||||
|
|
||||||
def sl_compute_bedrock(self, reach):
|
|
||||||
z_min = reach.geometry.get_z_min()
|
|
||||||
sl = self.sl_compute_initial(reach)
|
|
||||||
|
|
||||||
z = list(
|
|
||||||
map(
|
|
||||||
lambda z, sl: reduce(
|
|
||||||
lambda z, h: z - h[0],
|
|
||||||
sl, z
|
|
||||||
),
|
|
||||||
z_min, # Original geometry
|
|
||||||
sl # Original sediment layers
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
return z
|
|
||||||
|
|
||||||
def sl_compute_current_z(self, reach):
|
|
||||||
z_br = self._bedrock
|
|
||||||
sl = self.sl_compute_current(reach)
|
|
||||||
|
|
||||||
z = list(
|
|
||||||
map(
|
|
||||||
lambda z, sl: reduce(
|
|
||||||
lambda z, h: z + h[0],
|
|
||||||
sl, z
|
|
||||||
),
|
|
||||||
z_br, # Bedrock elevation
|
|
||||||
sl # Current sediment layers
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
return z
|
|
||||||
|
|
||||||
def sl_compute_initial(self, reach):
|
|
||||||
"""
|
|
||||||
Get SL list for profile p at initial time (initial data)
|
|
||||||
"""
|
|
||||||
return map(
|
|
||||||
lambda p: p.get_ts_key(min(self._timestamps), "sl")[0],
|
|
||||||
reach.profiles
|
|
||||||
)
|
|
||||||
|
|
||||||
def sl_compute_current(self, reach):
|
|
||||||
"""
|
|
||||||
Get SL list for profile p at current time
|
|
||||||
"""
|
|
||||||
return map(
|
|
||||||
lambda p: p.get_ts_key(self._current_timestamp, "sl")[0],
|
|
||||||
reach.profiles
|
|
||||||
)
|
|
||||||
|
|
||||||
def draw_bottom_geometry(self, reach):
|
def draw_bottom_geometry(self, reach):
|
||||||
rk = reach.geometry.get_rk()
|
rk = reach.geometry.get_rk()
|
||||||
z_min = reach.geometry.get_z_min()
|
z_min = reach.geometry.get_z_min()
|
||||||
|
|
@ -337,7 +294,7 @@ class PlotRKC(PamhyrPlot):
|
||||||
|
|
||||||
results = self.results[self._current_res_id]
|
results = self.results[self._current_res_id]
|
||||||
reach = results.river.reach(self._current_reach_id)
|
reach = results.river.reach(self._current_reach_id)
|
||||||
if reach.has_sediment():
|
if reach.has_bedload():
|
||||||
self.update_bottom_with_bedload()
|
self.update_bottom_with_bedload()
|
||||||
|
|
||||||
self.update_water_elevation()
|
self.update_water_elevation()
|
||||||
|
|
@ -397,14 +354,23 @@ class PlotRKC(PamhyrPlot):
|
||||||
results = self.results[self._current_res_id]
|
results = self.results[self._current_res_id]
|
||||||
reach = results.river.reach(self._current_reach_id)
|
reach = results.river.reach(self._current_reach_id)
|
||||||
rk = reach.geometry.get_rk()
|
rk = reach.geometry.get_rk()
|
||||||
z = self.sl_compute_current_z(reach)
|
# z = self.sl_compute_current_z(reach)
|
||||||
|
|
||||||
|
zfd = list(
|
||||||
|
map(
|
||||||
|
lambda p: p.get_ts_key(
|
||||||
|
self._current_timestamp, "zfd"
|
||||||
|
),
|
||||||
|
reach.profiles
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
self.line_bottom.remove()
|
self.line_bottom.remove()
|
||||||
|
|
||||||
self.line_bottom, = self.canvas.axes.plot(
|
self.line_bottom, = self.canvas.axes.plot(
|
||||||
rk, z,
|
rk, zfd,
|
||||||
linestyle="solid", lw=1.,
|
linestyle="solid", lw=1.,
|
||||||
color=self.color_plot_river_bottom,
|
color=self.color_plot_river_bottom,
|
||||||
)
|
)
|
||||||
|
|
||||||
self._river_bottom = z
|
self._river_bottom = zfd
|
||||||
|
|
|
||||||
|
|
@ -546,7 +546,7 @@ class ResultsWindow(PamhyrWindow):
|
||||||
table = self.find(QTableView, f"tableView_solver")
|
table = self.find(QTableView, f"tableView_solver")
|
||||||
indexes = table.selectedIndexes()
|
indexes = table.selectedIndexes()
|
||||||
if len(indexes) == 0:
|
if len(indexes) == 0:
|
||||||
return
|
return []
|
||||||
|
|
||||||
return [i.row() for i in indexes]
|
return [i.row() for i in indexes]
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue