mirror of https://gitlab.com/pamhyr/pamhyr2
put compare solvers in results window
parent
8d9a196059
commit
41d1fb9d59
|
|
@ -81,7 +81,7 @@ from View.RunSolver.Window import (
|
|||
SolverLogWindow,
|
||||
CompareSolversWindow
|
||||
)
|
||||
from View.Results.Window import ResultsWindow, CompareResultsWindow
|
||||
from View.Results.Window import ResultsWindow # , CompareResultsWindow
|
||||
from View.RunSolver.WindowAdisTS import (
|
||||
SelectSolverWindowAdisTS,
|
||||
SolverLogWindowAdisTS
|
||||
|
|
@ -1437,7 +1437,6 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
|||
data=[
|
||||
self._study,
|
||||
None, # No config
|
||||
solver,
|
||||
results
|
||||
]
|
||||
):
|
||||
|
|
@ -1445,8 +1444,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
|||
|
||||
res = ResultsWindow(
|
||||
study=self._study,
|
||||
solver=solver,
|
||||
results=results,
|
||||
results=[results],
|
||||
parent=self
|
||||
)
|
||||
res.show()
|
||||
|
|
@ -1586,20 +1584,34 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
|||
data=[
|
||||
self._study,
|
||||
None, # No config
|
||||
results._solver,
|
||||
results
|
||||
results[0]
|
||||
]
|
||||
):
|
||||
w = self.get_sub_window(
|
||||
ResultsWindow,
|
||||
data=[
|
||||
self._study,
|
||||
None, # No config
|
||||
results[0]
|
||||
])
|
||||
#w.add_result(result[1], run.solver2)
|
||||
return
|
||||
|
||||
res = CompareResultsWindow(
|
||||
res = ResultsWindow(
|
||||
study=self._study,
|
||||
solver=results._solver,
|
||||
results=results,
|
||||
parent=self
|
||||
)
|
||||
res.show()
|
||||
|
||||
#res = CompareResultsWindow(
|
||||
#study=self._study,
|
||||
#solver=results._solver,
|
||||
#results=results,
|
||||
#parent=self
|
||||
#)
|
||||
#res.show()
|
||||
|
||||
|
||||
def diff_results(self, solver1, solver2):
|
||||
if solver1 is None:
|
||||
|
|
@ -1637,6 +1649,8 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
|||
# TODO message
|
||||
return None
|
||||
|
||||
return [result1, result2]
|
||||
|
||||
result3 = Results(self._study, solver3)
|
||||
result3.set("nb_reach", result1.get("nb_reach"))
|
||||
result3.set("nb_profile", result1.get("nb_profile"))
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ unit = {
|
|||
|
||||
class CustomPlot(PamhyrPlot):
|
||||
def __init__(self, x, y, envelop, reach, profile, timestamp,
|
||||
data=None, canvas=None, trad=None,
|
||||
data=None, canvas=None, trad=None, res_id=0,
|
||||
toolbar=None, parent=None):
|
||||
super(CustomPlot, self).__init__(
|
||||
canvas=canvas,
|
||||
|
|
@ -65,6 +65,7 @@ class CustomPlot(PamhyrPlot):
|
|||
self._reach = reach
|
||||
self._profile = profile
|
||||
self._timestamp = timestamp
|
||||
self._current_res_id = res_id
|
||||
|
||||
logger.debug(
|
||||
"Create custom plot for: " +
|
||||
|
|
@ -130,7 +131,7 @@ class CustomPlot(PamhyrPlot):
|
|||
"""
|
||||
Get SL list for profile p at initial time (initial data)
|
||||
"""
|
||||
t0 = min(list(self.data.get("timestamps")))
|
||||
t0 = min(list(self.data[self._current_res_id].get("timestamps")))
|
||||
return map(
|
||||
lambda p: p.get_ts_key(t0, "sl")[0],
|
||||
reach.profiles
|
||||
|
|
@ -146,7 +147,7 @@ class CustomPlot(PamhyrPlot):
|
|||
)
|
||||
|
||||
def get_ts_zmin(self, profile):
|
||||
results = self.data
|
||||
results = self.data[self._current_res_id]
|
||||
nt = len(list(results.get("timestamps")))
|
||||
reach = results.river.reach(self._reach)
|
||||
berdrock = self.sl_compute_bedrock(reach)
|
||||
|
|
@ -167,7 +168,7 @@ class CustomPlot(PamhyrPlot):
|
|||
return ts_z_min
|
||||
|
||||
def _draw_rk(self):
|
||||
results = self.data
|
||||
results = self.data[self._current_res_id]
|
||||
reach = results.river.reach(self._reach)
|
||||
rk = reach.geometry.get_rk()
|
||||
if reach.has_sediment():
|
||||
|
|
@ -485,7 +486,7 @@ class CustomPlot(PamhyrPlot):
|
|||
self.canvas.axes.legend(lns, labs, loc="best")
|
||||
|
||||
def _redraw_rk(self):
|
||||
results = self.data
|
||||
results = self.data[self._current_res_id]
|
||||
reach = results.river.reach(self._reach)
|
||||
rk = reach.geometry.get_rk()
|
||||
z_min = reach.geometry.get_z_min()
|
||||
|
|
@ -623,7 +624,7 @@ class CustomPlot(PamhyrPlot):
|
|||
self.canvas.axes.set_xticks(ticks=fx, labels=xt, rotation=45)
|
||||
|
||||
def _draw_time(self):
|
||||
results = self.data
|
||||
results = self.data[self._current_res_id]
|
||||
reach = results.river.reach(self._reach)
|
||||
profile = reach.profile(self._profile)
|
||||
|
||||
|
|
@ -774,7 +775,7 @@ class CustomPlot(PamhyrPlot):
|
|||
|
||||
def _redraw_time(self):
|
||||
|
||||
results = self.data
|
||||
results = self.data[self._current_res_id]
|
||||
reach = results.river.reach(self._reach)
|
||||
profile = reach.profile(self._profile)
|
||||
ts = list(results.get("timestamps"))
|
||||
|
|
@ -895,7 +896,7 @@ class CustomPlot(PamhyrPlot):
|
|||
elif self._x == "time":
|
||||
self._draw_time()
|
||||
if self._x == "rk":
|
||||
reach = self.data.river.reach(self._reach)
|
||||
reach = self.data[self._current_res_id].river.reach(self._reach)
|
||||
profile = reach.profile(self._profile)
|
||||
x = profile.rk
|
||||
elif self._x == "time":
|
||||
|
|
@ -935,6 +936,10 @@ class CustomPlot(PamhyrPlot):
|
|||
else:
|
||||
self.draw_current()
|
||||
|
||||
def set_result(self, res_id):
|
||||
self._current_res_id = res_id
|
||||
self.draw()
|
||||
|
||||
def set_timestamp(self, timestamp):
|
||||
self._timestamp = timestamp
|
||||
|
||||
|
|
@ -945,7 +950,7 @@ class CustomPlot(PamhyrPlot):
|
|||
|
||||
def draw_current(self):
|
||||
if self._x == "rk":
|
||||
reach = self.data.river.reach(self._reach)
|
||||
reach = self.data[self._current_res_id].river.reach(self._reach)
|
||||
profile = reach.profile(self._profile)
|
||||
x = profile.rk
|
||||
elif self._x == "time":
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ _translate = QCoreApplication.translate
|
|||
|
||||
class PlotAC(PamhyrPlot):
|
||||
def __init__(self, canvas=None, trad=None, toolbar=None,
|
||||
results=None, reach_id=0, profile_id=0,
|
||||
results=None, reach_id=0, profile_id=0, res_id=0,
|
||||
parent=None):
|
||||
super(PlotAC, self).__init__(
|
||||
canvas=canvas,
|
||||
|
|
@ -39,9 +39,10 @@ class PlotAC(PamhyrPlot):
|
|||
parent=parent
|
||||
)
|
||||
|
||||
self._current_timestamp = max(results.get("timestamps"))
|
||||
self._current_timestamp = max(results[res_id].get("timestamps"))
|
||||
self._current_reach_id = reach_id
|
||||
self._current_profile_id = profile_id
|
||||
self._current_res_id = res_id
|
||||
|
||||
self.label_x = self._trad['x']
|
||||
self.label_y = self._trad["unit_elevation"]
|
||||
|
|
@ -62,7 +63,7 @@ class PlotAC(PamhyrPlot):
|
|||
@results.setter
|
||||
def results(self, results):
|
||||
self.data = results
|
||||
self._current_timestamp = max(results.get("timestamps"))
|
||||
self._current_timestamp = max(results[self._current_res_id].get("timestamps"))
|
||||
|
||||
@timer
|
||||
def draw(self, highlight=None):
|
||||
|
|
@ -71,7 +72,11 @@ class PlotAC(PamhyrPlot):
|
|||
if self.results is None:
|
||||
return
|
||||
|
||||
reach = self.results.river.reach(self._current_reach_id)
|
||||
if self.results[self._current_res_id] is None:
|
||||
return
|
||||
|
||||
results = self.results[self._current_res_id]
|
||||
reach = results.river.reach(self._current_reach_id)
|
||||
profile = reach.profile(self._current_profile_id)
|
||||
|
||||
self.draw_profile(reach, profile)
|
||||
|
|
@ -137,10 +142,14 @@ class PlotAC(PamhyrPlot):
|
|||
self._current_profile_id = profile_id
|
||||
self.update()
|
||||
|
||||
def set_result(self, res_id):
|
||||
self._current_result_id = res_id
|
||||
self.update()
|
||||
|
||||
def set_timestamp(self, timestamp):
|
||||
self._current_timestamp = timestamp
|
||||
|
||||
reach = self.results.river.reach(self._current_reach_id)
|
||||
reach = self.results[self._current_res_id].river.reach(self._current_reach_id)
|
||||
profile = reach.profile(self._current_profile_id)
|
||||
x = profile.geometry.get_station()
|
||||
z = profile.geometry.z()
|
||||
|
|
@ -152,7 +161,7 @@ class PlotAC(PamhyrPlot):
|
|||
if not self._init:
|
||||
self.draw()
|
||||
|
||||
reach = self.results.river.reach(self._current_reach_id)
|
||||
reach = self.results[self._current_res_id].river.reach(self._current_reach_id)
|
||||
profile = reach.profile(self._current_profile_id)
|
||||
x = profile.geometry.get_station()
|
||||
z = profile.geometry.z()
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ logger = logging.getLogger()
|
|||
|
||||
class PlotH(PamhyrPlot):
|
||||
def __init__(self, canvas=None, trad=None, toolbar=None,
|
||||
results=None, reach_id=0, profile_id=0,
|
||||
results=None, reach_id=0, profile_id=0, res_id=0,
|
||||
parent=None):
|
||||
super(PlotH, self).__init__(
|
||||
canvas=canvas,
|
||||
|
|
@ -47,9 +47,10 @@ class PlotH(PamhyrPlot):
|
|||
|
||||
self._mode = "time"
|
||||
|
||||
self._current_timestamp = max(results.get("timestamps"))
|
||||
self._current_timestamp = max(results[res_id].get("timestamps"))
|
||||
self._current_reach_id = reach_id
|
||||
self._current_profile_id = profile_id
|
||||
self._current_res_id = res_id
|
||||
|
||||
self.label_x = self._trad["unit_time_s"]
|
||||
self.label_y = self._trad["unit_discharge"]
|
||||
|
|
@ -70,7 +71,7 @@ class PlotH(PamhyrPlot):
|
|||
@results.setter
|
||||
def results(self, results):
|
||||
self.data = results
|
||||
self._current_timestamp = max(results.get("timestamps"))
|
||||
self._current_timestamp = max(results[self._current_res_id].get("timestamps"))
|
||||
|
||||
@timer
|
||||
def draw(self, highlight=None):
|
||||
|
|
@ -79,7 +80,11 @@ class PlotH(PamhyrPlot):
|
|||
if self.results is None:
|
||||
return
|
||||
|
||||
reach = self.results.river.reach(self._current_reach_id)
|
||||
if self.results[self._current_res_id] is None:
|
||||
return
|
||||
|
||||
results = self.results[self._current_res_id]
|
||||
reach = results.river.reach(self._current_reach_id)
|
||||
profile = reach.profile(self._current_profile_id)
|
||||
|
||||
if reach.geometry.number_profiles == 0:
|
||||
|
|
@ -99,7 +104,7 @@ class PlotH(PamhyrPlot):
|
|||
self._init = True
|
||||
|
||||
def draw_data(self, reach, profile):
|
||||
self.ts = list(self.results.get("timestamps"))
|
||||
self.ts = list(self.results[self._current_res_id].get("timestamps"))
|
||||
self.ts.sort()
|
||||
|
||||
x = self.ts
|
||||
|
|
@ -123,7 +128,7 @@ class PlotH(PamhyrPlot):
|
|||
)
|
||||
|
||||
def draw_max(self, reach):
|
||||
self.ts = list(self.results.get("timestamps"))
|
||||
self.ts = list(self.results[self._current_res_id].get("timestamps"))
|
||||
self.ts.sort()
|
||||
|
||||
x = self.ts
|
||||
|
|
@ -152,6 +157,10 @@ class PlotH(PamhyrPlot):
|
|||
self._current_profile_id = profile_id
|
||||
self.update()
|
||||
|
||||
def set_result(self, res_id):
|
||||
self._current_result_id = res_id
|
||||
self.update()
|
||||
|
||||
def set_timestamp(self, timestamp):
|
||||
self._current_timestamp = timestamp
|
||||
self.update_current()
|
||||
|
|
@ -165,7 +174,8 @@ class PlotH(PamhyrPlot):
|
|||
self.update_idle()
|
||||
|
||||
def update_data(self):
|
||||
reach = self.results.river.reach(self._current_reach_id)
|
||||
results = self.results[self._current_res_id]
|
||||
reach = results.river.reach(self._current_reach_id)
|
||||
profile = reach.profile(self._current_profile_id)
|
||||
|
||||
x = self.ts
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ logger = logging.getLogger()
|
|||
|
||||
class PlotRKC(PamhyrPlot):
|
||||
def __init__(self, canvas=None, trad=None, toolbar=None,
|
||||
results=None, reach_id=0, profile_id=0,
|
||||
results=None, reach_id=0, profile_id=0, res_id=0,
|
||||
parent=None):
|
||||
super(PlotRKC, self).__init__(
|
||||
canvas=canvas,
|
||||
|
|
@ -42,10 +42,12 @@ class PlotRKC(PamhyrPlot):
|
|||
parent=parent
|
||||
)
|
||||
|
||||
self._timestamps = results.get("timestamps")
|
||||
self._timestamps = results[res_id].get("timestamps")
|
||||
self._current_timestamp = max(results[res_id].get("timestamps"))
|
||||
self._current_timestamp = max(self._timestamps)
|
||||
self._current_reach_id = reach_id
|
||||
self._current_profile_id = profile_id
|
||||
self._current_res_id = res_id
|
||||
|
||||
self.label_x = self._trad["unit_rk"]
|
||||
self.label_y = self._trad["unit_elevation"]
|
||||
|
|
@ -63,7 +65,7 @@ class PlotRKC(PamhyrPlot):
|
|||
@results.setter
|
||||
def results(self, results):
|
||||
self.data = results
|
||||
self._current_timestamp = max(results.get("timestamps"))
|
||||
self._current_timestamp = max(results[self._current_res_id].get("timestamps"))
|
||||
|
||||
@timer
|
||||
def draw(self, highlight=None):
|
||||
|
|
@ -72,7 +74,11 @@ class PlotRKC(PamhyrPlot):
|
|||
if self.results is None:
|
||||
return
|
||||
|
||||
reach = self.results.river.reach(self._current_reach_id)
|
||||
if self.results[self._current_res_id] is None:
|
||||
return
|
||||
|
||||
results = self.results[self._current_res_id]
|
||||
reach = results.river.reach(self._current_reach_id)
|
||||
|
||||
self.draw_bottom(reach)
|
||||
self.draw_water_elevation(reach)
|
||||
|
|
@ -111,7 +117,7 @@ class PlotRKC(PamhyrPlot):
|
|||
lambda hs: hs._input_reach.reach is reach.geometry,
|
||||
filter(
|
||||
lambda hs: hs._input_reach is not None,
|
||||
self.results.study.river.hydraulic_structures.lst
|
||||
self.results[self._current_res_id].study.river.hydraulic_structures.lst
|
||||
)
|
||||
)
|
||||
|
||||
|
|
@ -312,6 +318,10 @@ class PlotRKC(PamhyrPlot):
|
|||
self._current_profile_id = profile_id
|
||||
self.update_current()
|
||||
|
||||
def set_result(self, res_id):
|
||||
self._current_result_id = res_id
|
||||
self.update()
|
||||
|
||||
def set_timestamp(self, timestamp):
|
||||
self._current_timestamp = timestamp
|
||||
self.update()
|
||||
|
|
@ -320,7 +330,8 @@ class PlotRKC(PamhyrPlot):
|
|||
if not self._init:
|
||||
self.draw()
|
||||
|
||||
reach = self.results.river.reach(self._current_reach_id)
|
||||
results = self.results[self._current_res_id]
|
||||
reach = results.river.reach(self._current_reach_id)
|
||||
if reach.has_sediment():
|
||||
self.update_bottom_with_bedload()
|
||||
|
||||
|
|
@ -329,7 +340,8 @@ class PlotRKC(PamhyrPlot):
|
|||
self.update_idle()
|
||||
|
||||
def update_water_elevation(self):
|
||||
reach = self.results.river.reach(self._current_reach_id)
|
||||
results = self.results[self._current_res_id]
|
||||
reach = results.river.reach(self._current_reach_id)
|
||||
rk = reach.geometry.get_rk()
|
||||
z_min = reach.geometry.get_z_min()
|
||||
|
||||
|
|
@ -354,7 +366,8 @@ class PlotRKC(PamhyrPlot):
|
|||
)
|
||||
|
||||
def update_current(self):
|
||||
reach = self.results.river.reach(self._current_reach_id)
|
||||
results = self.results[self._current_res_id]
|
||||
reach = results.river.reach(self._current_reach_id)
|
||||
rk = reach.geometry.get_rk()
|
||||
z_min = reach.geometry.get_z_min()
|
||||
z_max = reach.geometry.get_z_max()
|
||||
|
|
@ -367,7 +380,8 @@ class PlotRKC(PamhyrPlot):
|
|||
self.canvas.figure.canvas.draw_idle()
|
||||
|
||||
def update_bottom_with_bedload(self):
|
||||
reach = self.results.river.reach(self._current_reach_id)
|
||||
results = self.results[self._current_res_id]
|
||||
reach = results.river.reach(self._current_reach_id)
|
||||
rk = reach.geometry.get_rk()
|
||||
z = self.sl_compute_current_z(reach)
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ logger = logging.getLogger()
|
|||
|
||||
class PlotXY(PamhyrPlot):
|
||||
def __init__(self, canvas=None, trad=None, toolbar=None,
|
||||
results=None, reach_id=0, profile_id=0,
|
||||
results=None, reach_id=0, profile_id=0, res_id=0,
|
||||
display_current=True, parent=None):
|
||||
super(PlotXY, self).__init__(
|
||||
canvas=canvas,
|
||||
|
|
@ -52,10 +52,11 @@ class PlotXY(PamhyrPlot):
|
|||
self.line_gl = []
|
||||
self.overflow = []
|
||||
|
||||
self._timestamps = results.get("timestamps")
|
||||
self._timestamps = results[res_id].get("timestamps")
|
||||
self._current_timestamp = max(self._timestamps)
|
||||
self._current_reach_id = reach_id
|
||||
self._current_profile_id = profile_id
|
||||
self._current_res_id = res_id
|
||||
|
||||
self.label_x = _translate("Results", "X (m)")
|
||||
self.label_y = _translate("Results", "Y (m)")
|
||||
|
|
@ -136,7 +137,7 @@ class PlotXY(PamhyrPlot):
|
|||
@results.setter
|
||||
def results(self, results):
|
||||
self.data = results
|
||||
self._current_timestamp = max(results.get("timestamps"))
|
||||
self._current_timestamp = max(results[self._current_res_id].get("timestamps"))
|
||||
|
||||
@timer
|
||||
def draw(self, highlight=None):
|
||||
|
|
@ -145,8 +146,12 @@ class PlotXY(PamhyrPlot):
|
|||
if self.results is None:
|
||||
return
|
||||
|
||||
reach = self.results.river.reach(self._current_reach_id)
|
||||
reaches = self.results.river.reachs
|
||||
if self.results[self._current_res_id] is None:
|
||||
return
|
||||
|
||||
results = self.results[self._current_res_id]
|
||||
reach = results.river.reach(self._current_reach_id)
|
||||
reaches = results.river.reachs
|
||||
|
||||
self.draw_profiles(reach, reaches)
|
||||
self.draw_water_elevation(reach)
|
||||
|
|
@ -272,7 +277,8 @@ class PlotXY(PamhyrPlot):
|
|||
)
|
||||
|
||||
def draw_water_elevation(self, reach):
|
||||
reach = self.results.river.reach(self._current_reach_id)
|
||||
results = self.results[self._current_res_id]
|
||||
reach = results.river.reach(self._current_reach_id)
|
||||
poly_l_x, poly_l_y, poly_r_x, poly_r_y = [], [], [], []
|
||||
|
||||
for profile in reach.profiles:
|
||||
|
|
@ -308,6 +314,11 @@ class PlotXY(PamhyrPlot):
|
|||
self.update_profile()
|
||||
self.update_idle()
|
||||
|
||||
def set_result(self, res_id):
|
||||
self._current_result_id = res_id
|
||||
self.update_profile()
|
||||
self.update_idle()
|
||||
|
||||
def set_timestamp(self, timestamp):
|
||||
self._current_timestamp = timestamp
|
||||
self.update()
|
||||
|
|
@ -322,7 +333,8 @@ class PlotXY(PamhyrPlot):
|
|||
self.update_idle()
|
||||
|
||||
def update_profile(self):
|
||||
reach = self.results.river.reach(self._current_reach_id)
|
||||
results = self.results[self._current_res_id]
|
||||
reach = results.river.reach(self._current_reach_id)
|
||||
profile = reach.profile(self._current_profile_id)
|
||||
|
||||
self.plot_selected.set_data(
|
||||
|
|
@ -331,7 +343,8 @@ class PlotXY(PamhyrPlot):
|
|||
)
|
||||
|
||||
def update_water_elevation(self):
|
||||
reach = self.results.river.reach(self._current_reach_id)
|
||||
results = self.results[self._current_res_id]
|
||||
reach = results.river.reach(self._current_reach_id)
|
||||
poly_l_x, poly_l_y, poly_r_x, poly_r_y = [], [], [], []
|
||||
|
||||
for profile in reach.profiles:
|
||||
|
|
@ -358,7 +371,8 @@ class PlotXY(PamhyrPlot):
|
|||
self.water_fill[0].set_xy(poly)
|
||||
|
||||
def update_water_elevation_overflow(self):
|
||||
reach = self.results.river.reach(self._current_reach_id)
|
||||
results = self.results[self._current_res_id]
|
||||
reach = results.river.reach(self._current_reach_id)
|
||||
profile = reach.profile(self._current_profile_id)
|
||||
|
||||
overflow = []
|
||||
|
|
|
|||
|
|
@ -46,17 +46,15 @@ _translate = QCoreApplication.translate
|
|||
|
||||
class TableModel(PamhyrTableModel):
|
||||
def _setup_lst(self):
|
||||
_river = self._data.river
|
||||
print("data: ", self._data)
|
||||
print("river: ", _river)
|
||||
print("reaches: ", _river.reachs)
|
||||
_river = self._data[0].river
|
||||
if self._opt_data == "reach":
|
||||
self._lst = _river.reachs
|
||||
print("optreach: ", self._lst)
|
||||
elif self._opt_data == "profile":
|
||||
self._lst = _river.reach(0).profiles
|
||||
elif self._opt_data == "raw_data":
|
||||
self._lst = _river.reach(0).profiles
|
||||
elif self._opt_data == "solver":
|
||||
self._lst = self._parent._solvers
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self._timestamp = 0.0
|
||||
|
|
@ -80,6 +78,10 @@ class TableModel(PamhyrTableModel):
|
|||
elif self._headers[column] == "rk":
|
||||
v = self._lst[row].rk
|
||||
return f"{v:.4f}"
|
||||
elif self._opt_data == "solver":
|
||||
if self._headers[column] == "solver":
|
||||
v = self._lst[row].name
|
||||
return str(v)
|
||||
elif self._opt_data == "raw_data":
|
||||
p = self._lst[row]
|
||||
if self._headers[column] == "name":
|
||||
|
|
@ -139,12 +141,14 @@ class TableModel(PamhyrTableModel):
|
|||
return QVariant()
|
||||
|
||||
def update(self, reach):
|
||||
_river = self._data.river
|
||||
_river = self._data[0].river
|
||||
|
||||
if self._opt_data == "reach":
|
||||
self._lst = _river.reachs
|
||||
elif self._opt_data == "profile" or self._opt_data == "raw_data":
|
||||
self._lst = _river.reach(reach).profiles
|
||||
elif self._opt_data == "solver":
|
||||
self._lst = self._parent._solvers
|
||||
|
||||
self.layoutChanged.emit()
|
||||
|
||||
|
|
|
|||
|
|
@ -85,17 +85,18 @@ class ResultsWindow(PamhyrWindow):
|
|||
)
|
||||
|
||||
def __init__(self, study=None, config=None,
|
||||
solver=None, results=None,
|
||||
parent=None, trad=None):
|
||||
self._solver = solver
|
||||
results=None, parent=None, trad=None):
|
||||
self._solvers = [r._solver for r in results]
|
||||
self._results = results
|
||||
self._current_results = 0
|
||||
print("solver: " + results[0]._solver.name)
|
||||
|
||||
if trad is None:
|
||||
trad = ResultsTranslate()
|
||||
name = (
|
||||
trad[self._pamhyr_name] + " - "
|
||||
+ study.name + " - "
|
||||
+ self._solver.name
|
||||
+ self._solvers[self._current_results].name
|
||||
)
|
||||
|
||||
super(ResultsWindow, self).__init__(
|
||||
|
|
@ -106,13 +107,12 @@ class ResultsWindow(PamhyrWindow):
|
|||
parent=parent
|
||||
)
|
||||
|
||||
self._hash_data.append(self._solver)
|
||||
self._hash_data.append(self._results)
|
||||
|
||||
self._additional_plot = {}
|
||||
|
||||
try:
|
||||
self._timestamps = sorted(list(self._results.get("timestamps")))
|
||||
self._timestamps = sorted(list(self._results[self._current_results].get("timestamps")))
|
||||
|
||||
self.setup_slider()
|
||||
self.setup_table()
|
||||
|
|
@ -125,20 +125,24 @@ class ResultsWindow(PamhyrWindow):
|
|||
|
||||
def setup_table(self):
|
||||
self._table = {}
|
||||
for t in ["reach", "profile", "raw_data"]:
|
||||
for t in ["reach", "profile", "raw_data", "solver"]:
|
||||
table = self.find(QTableView, f"tableView_{t}")
|
||||
self._table[t] = TableModel(
|
||||
table_view=table,
|
||||
table_headers=self._trad.get_dict(f"table_headers_{t}"),
|
||||
data=self._results,
|
||||
undo=self._undo_stack,
|
||||
opt_data=t
|
||||
opt_data=t,
|
||||
parent=self
|
||||
)
|
||||
self._table[t]._timestamp = self._timestamps[
|
||||
self._slider_time.value()]
|
||||
if len(self._results) <= 1:
|
||||
table = self.find(QTableView, f"tableView_solver")
|
||||
table.hide()
|
||||
|
||||
def setup_slider(self):
|
||||
default_reach = self._results.river.reach(0)
|
||||
default_reach = self._results[self._current_results].river.reach(0)
|
||||
|
||||
self._slider_time = self.find(QSlider, f"horizontalSlider_time")
|
||||
self._slider_time.setMaximum(len(self._timestamps) - 1)
|
||||
|
|
@ -185,6 +189,7 @@ class ResultsWindow(PamhyrWindow):
|
|||
results=self._results,
|
||||
reach_id=0,
|
||||
profile_id=0,
|
||||
res_id=self._current_results,
|
||||
trad=self._trad,
|
||||
toolbar=self.toolbar,
|
||||
display_current=True,
|
||||
|
|
@ -209,6 +214,7 @@ class ResultsWindow(PamhyrWindow):
|
|||
results=self._results,
|
||||
reach_id=0,
|
||||
profile_id=0,
|
||||
res_id=self._current_results,
|
||||
trad=self._trad,
|
||||
toolbar=self.toolbar_2
|
||||
)
|
||||
|
|
@ -231,6 +237,7 @@ class ResultsWindow(PamhyrWindow):
|
|||
results=self._results,
|
||||
reach_id=0,
|
||||
profile_id=0,
|
||||
res_id=self._current_results,
|
||||
trad=self._trad,
|
||||
toolbar=self.toolbar_3
|
||||
)
|
||||
|
|
@ -254,6 +261,7 @@ class ResultsWindow(PamhyrWindow):
|
|||
results=self._results,
|
||||
reach_id=0,
|
||||
profile_id=0,
|
||||
res_id=self._current_results,
|
||||
trad=self._trad,
|
||||
toolbar=self.toolbar_4
|
||||
)
|
||||
|
|
@ -328,9 +336,10 @@ class ResultsWindow(PamhyrWindow):
|
|||
"reach": self._set_current_reach,
|
||||
"profile": self._set_current_profile,
|
||||
"raw_data": self._set_current_profile_raw_data,
|
||||
"solver": self._set_current_results,
|
||||
}
|
||||
|
||||
for t in ["reach", "profile", "raw_data"]:
|
||||
for t in ["reach", "profile", "raw_data", "solver"]:
|
||||
table = self.find(QTableView, f"tableView_{t}")
|
||||
|
||||
table.selectionModel()\
|
||||
|
|
@ -378,7 +387,28 @@ class ResultsWindow(PamhyrWindow):
|
|||
)
|
||||
table.scrollTo(index)
|
||||
|
||||
def update(self, reach_id=None, profile_id=None, timestamp=None):
|
||||
def update_table_selection_solver(self, ind):
|
||||
table = self.find(QTableView, f"tableView_solver")
|
||||
selectionModel = table.selectionModel()
|
||||
index = table.model().index(ind, 0)
|
||||
|
||||
selectionModel.select(
|
||||
index,
|
||||
QItemSelectionModel.Rows |
|
||||
QItemSelectionModel.ClearAndSelect |
|
||||
QItemSelectionModel.Select
|
||||
)
|
||||
table.scrollTo(index)
|
||||
|
||||
self._table["profile"].update(ind)
|
||||
self._table["raw_data"].update(ind)
|
||||
|
||||
def update(self,
|
||||
reach_id=None,
|
||||
profile_id=None,
|
||||
solver_id=None,
|
||||
timestamp=None):
|
||||
|
||||
if reach_id is not None:
|
||||
self.plot_xy.set_reach(reach_id)
|
||||
self.plot_ac.set_reach(reach_id)
|
||||
|
|
@ -402,6 +432,15 @@ class ResultsWindow(PamhyrWindow):
|
|||
|
||||
self.update_table_selection_profile(profile_id)
|
||||
|
||||
if solver_id is not None:
|
||||
self.plot_xy.set_result(solver_id)
|
||||
self.plot_ac.set_result(solver_id)
|
||||
self.plot_rkc.set_result(solver_id)
|
||||
self.plot_h.set_result(solver_id)
|
||||
|
||||
for plot in self._additional_plot:
|
||||
self._additional_plot[plot].set_result(solver_id)
|
||||
|
||||
if timestamp is not None:
|
||||
self.plot_xy.set_timestamp(timestamp)
|
||||
self.plot_ac.set_timestamp(timestamp)
|
||||
|
|
@ -462,6 +501,14 @@ class ResultsWindow(PamhyrWindow):
|
|||
ind = indexes[0].row()
|
||||
self.update(profile_id=ind)
|
||||
|
||||
def _set_current_results(self):
|
||||
table = self.find(QTableView, f"tableView_solver")
|
||||
indexes = table.selectedIndexes()
|
||||
if len(indexes) == 0:
|
||||
return
|
||||
|
||||
self.update(solver_id=indexes[0].row())
|
||||
|
||||
def _set_current_timestamp(self):
|
||||
timestamp = self._timestamps[self._slider_time.value()]
|
||||
self.update(timestamp=timestamp)
|
||||
|
|
@ -861,36 +908,36 @@ class ResultsWindow(PamhyrWindow):
|
|||
return my_dict
|
||||
|
||||
|
||||
class CompareResultsWindow(ResultsWindow):
|
||||
_pamhyr_ui = "Results"
|
||||
_pamhyr_name = "Results"
|
||||
#class CompareResultsWindow(ResultsWindow):
|
||||
#_pamhyr_ui = "CompareResults"
|
||||
#_pamhyr_name = "CompareResults"
|
||||
|
||||
def _path_file(self, filename):
|
||||
return os.path.abspath(
|
||||
os.path.join(
|
||||
os.path.dirname(__file__),
|
||||
"..", "ui", "ressources", filename
|
||||
)
|
||||
)
|
||||
#def _path_file(self, filename):
|
||||
#return os.path.abspath(
|
||||
#os.path.join(
|
||||
#os.path.dirname(__file__),
|
||||
#"..", "ui", "ressources", filename
|
||||
#)
|
||||
#)
|
||||
|
||||
def __init__(self, study=None, config=None,
|
||||
solver=None, results=None,
|
||||
parent=None):
|
||||
self._solver = solver
|
||||
self._results = results
|
||||
#def __init__(self, study=None, config=None,
|
||||
#solver=None, results=None,
|
||||
#parent=None):
|
||||
#self._solvers[0] = solver
|
||||
#self._results = results
|
||||
|
||||
trad = CompareResultsTranslate()
|
||||
name = (
|
||||
trad[self._pamhyr_name] + " - "
|
||||
+ study.name + " - "
|
||||
+ self._solver.name
|
||||
)
|
||||
#trad = CompareResultsTranslate()
|
||||
#name = (
|
||||
#trad[self._pamhyr_name] + " - "
|
||||
#+ study.name + " - "
|
||||
#+ self._solvers[0].name
|
||||
#)
|
||||
|
||||
super(CompareResultsWindow, self).__init__(
|
||||
study=study,
|
||||
config=config,
|
||||
solver=solver,
|
||||
results=results,
|
||||
parent=parent,
|
||||
trad=trad
|
||||
)
|
||||
#super(CompareResultsWindow, self).__init__(
|
||||
#study=study,
|
||||
#config=config,
|
||||
#solver=solver,
|
||||
#results=results,
|
||||
#parent=parent,
|
||||
#trad=trad
|
||||
#)
|
||||
|
|
|
|||
|
|
@ -60,10 +60,14 @@ class ResultsTranslate(MainTranslate):
|
|||
}
|
||||
|
||||
self._sub_dict["table_headers_profile"] = {
|
||||
"name": self._dict["name"],
|
||||
"name": _translate("Results", "Profile name"),
|
||||
"rk": self._dict["unit_rk"],
|
||||
}
|
||||
|
||||
self._sub_dict["table_headers_solver"] = {
|
||||
"solver": _translate("Results", "Solver"),
|
||||
}
|
||||
|
||||
self._sub_dict["table_headers_pollutants"] = {
|
||||
"name": _translate("Results", "Pollutant name"),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,6 +41,13 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="horizontalLayoutWidget">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QTableView" name="tableView_solver"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
|
|
|
|||
|
|
@ -46,9 +46,6 @@
|
|||
<item>
|
||||
<widget class="QTableView" name="tableView_pollutants"/>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_tot_left"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
|
|
@ -457,7 +454,7 @@
|
|||
<resources/>
|
||||
<connections/>
|
||||
<buttongroups>
|
||||
<buttongroup name="buttonGroup"/>
|
||||
<buttongroup name="buttonGroup_2"/>
|
||||
<buttongroup name="buttonGroup"/>
|
||||
</buttongroups>
|
||||
</ui>
|
||||
|
|
|
|||
Loading…
Reference in New Issue