Compare commits

..

7 Commits

Author SHA1 Message Date
Theophile Terraz 7ef41ad886 optimize results visu 2026-03-06 11:12:43 +01:00
Theophile Terraz ada396f26d debug 2026-03-05 16:46:22 +01:00
Theophile Terraz 674247db09 add talweg in update_rk 2026-03-04 11:14:05 +01:00
Theophile Terraz 5fecd29666 Claude François 2026-02-26 16:57:42 +01:00
Theophile Terraz 71e1324a0f debug open results from file 2026-02-24 17:19:59 +01:00
Theophile Terraz 07cae542b0 pep8 2026-02-24 09:18:47 +01:00
Theophile Terraz b693f67b99 debug RubarBE 2026-02-24 09:15:31 +01:00
13 changed files with 230 additions and 145 deletions

View File

@ -102,7 +102,7 @@ class InternalMeshing(AMeshingTool):
# calcul number of intermediate profiles # calcul number of intermediate profiles
np = [] np = []
for i in range(limites[0], limites[1]): for i in range(limites[0], limites[1]):
np.append(int((reach.profiles[i+1].rk - np.append(int(abs(reach.profiles[i+1].rk -
reach.profiles[i].rk) / step) - 1) reach.profiles[i].rk) / step) - 1)
if np[-1] < 0: if np[-1] < 0:
np[-1] = 0 np[-1] = 0

View File

@ -93,6 +93,9 @@ class Profile(object):
return self.points[0] return self.points[0]
elif name == "np": elif name == "np":
return self.points[-1] return self.points[-1]
elif name == "talweg":
zm = self.z_min()
return next((p for p in self.points if p.z == zm), None)
else: else:
return next((p for p in self.points if p.name == name), None) return next((p for p in self.points if p.name == name), None)
@ -101,6 +104,12 @@ class Profile(object):
return 0 return 0
elif name == "np": elif name == "np":
return len(self.points) - 1 return len(self.points) - 1
elif name == "talweg":
zm = self.z_min()
return next(
(p for p in enumerate(self.points) if p[1].z == zm),
None
)[0]
else: else:
return next( return next(
(p for p in enumerate(self.points) if p[1].name == name), (p for p in enumerate(self.points) if p[1].name == name),

View File

@ -58,12 +58,12 @@ class Rubar3(CommandLineSolver):
("rubarbe_iovis", "n"), ("rubarbe_iovis", "n"),
("rubarbe_rep", "n"), ("rubarbe_rep", "n"),
("rubarbe_tinit", "000:00:00:00"), ("rubarbe_tinit", "000:00:00:00"),
("rubarbe_tmax", "999:99:99:00"), ("rubarbe_tmax", "000:01:00:00"), # 1 day
("rubarbe_tiopdt", "000:00:00:00"), ("rubarbe_tiopdt", "000:00:00:00"),
("rubarbe_dt", "5.0"), ("rubarbe_dt", "5.0"),
("rubarbe_ts", "999:99:99:00"), ("rubarbe_ts", "999:99:99:00"),
("rubarbe_dtsauv", "00:00:00:05"), ("rubarbe_dtsauv", "00:00:05:00"),
("rubarbe_psave", "00:00:00:05"), ("rubarbe_psave", "00:00:05:00"),
("rubarbe_fdeb1", "1"), ("rubarbe_fdeb1", "1"),
("rubarbe_fdeb2", "10"), ("rubarbe_fdeb2", "10"),
("rubarbe_fdeb3", "100"), ("rubarbe_fdeb3", "100"),

View File

@ -55,7 +55,7 @@ class AboutWindow(PamhyrDialog):
label = self.get_label_text("label_version") label = self.get_label_text("label_version")
label = label.replace("@version", version) label = label.replace("@version", version)
label = label.replace("@codename", "(Le Coz)") label = label.replace("@codename", "(Claude François)")
self.set_label_text("label_version", label) self.set_label_text("label_version", label)
# Authors # Authors

View File

@ -119,8 +119,8 @@ class UpdateRKDialog(PamhyrDialog):
return name return name
def _init_default_values_guidelines(self): def _init_default_values_guidelines(self):
bgl = ['un'] + self._gl + ['np'] bgl = ['un'] + self._gl + ['np', 'talweg']
egl = ['un'] + self._gl + ['np'] egl = ['un'] + self._gl + ['np', 'talweg']
self.combobox_add_items("comboBox_begin_gl", bgl) self.combobox_add_items("comboBox_begin_gl", bgl)
self.combobox_add_items("comboBox_end_gl", egl) self.combobox_add_items("comboBox_end_gl", egl)

View File

@ -195,10 +195,10 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
title = "(dbg) " if self.conf.debug else "" title = "(dbg) " if self.conf.debug else ""
if self._study is not None: if self._study is not None:
title += f"Pamhyr2 (Le Coz) - {self._study.name}" title += f"Pamhyr2 (Claude François) - {self._study.name}"
self.setWindowTitle(title) self.setWindowTitle(title)
else: else:
title += "Pamhyr2 (Le Coz)" title += "Pamhyr2 (Claude François)"
self.setWindowTitle(title) self.setWindowTitle(title)
def setup_tab(self): def setup_tab(self):
@ -1563,10 +1563,10 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
if dialog.exec_(): if dialog.exec_():
file_name = dialog.selectedFiles() file_name = dialog.selectedFiles()
logger.info(f"Select results: {file_name}") logger.info(f"Select results: {file_name[0]}")
solver = None solver = None
if ".BIN" in file_name: if ".BIN" in file_name[0]:
solver = Mage8("Mage8") solver = Mage8("Mage8")
else: else:
solver = Rubar3("Rubar3") solver = Rubar3("Rubar3")
@ -1741,7 +1741,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
path = os.path.normpath(dir_path) path = os.path.normpath(dir_path)
solver_name = path.split(os.sep)[-2] solver_name = path.split(os.sep)[-2]
solver_results = next(filter(lambda x: x.name == solver_name, solver_results = next(filter(lambda x: x.name == solver_name,
self.conf.solvers)) self.conf.solvers), None)
solver_results_adists = solver_results.results( solver_results_adists = solver_results.results(
self._study, self._study,
repertory=dir_path, qlog=None) # self._output) repertory=dir_path, qlog=None) # self._output)

View File

@ -62,9 +62,9 @@ class CustomPlot(PamhyrPlot):
self._x = x self._x = x
self._y = y self._y = y
self._envelop = envelop self._envelop = envelop
self._reach = reach self._current_reach = reach
self._profile = profile self._current_profile_id = profile
self._timestamp = timestamp self._current_timestamp = timestamp
self._current_res_id = res_id[0] self._current_res_id = res_id[0]
self._parent = parent self._parent = parent
@ -133,7 +133,7 @@ class CustomPlot(PamhyrPlot):
""" """
Get SL list for profile p at initial time (initial data) Get SL list for profile p at initial time (initial data)
""" """
t0 = min(list(self.data[self._current_res_id[0]].get("timestamps"))) t0 = min(list(self.data[self._current_res_id].get("timestamps")))
return map( return map(
lambda p: p.get_ts_key(t0, "sl")[0], lambda p: p.get_ts_key(t0, "sl")[0],
reach.profiles reach.profiles
@ -144,14 +144,14 @@ class CustomPlot(PamhyrPlot):
Get SL list for profile p at current time Get SL list for profile p at current time
""" """
return map( return map(
lambda p: p.get_ts_key(self._timestamp, "sl")[0], lambda p: p.get_ts_key(self._current_timestamp, "sl")[0],
reach.profiles reach.profiles
) )
def get_ts_zmin(self, profile, res_id): def get_ts_zmin(self, profile, res_id):
results = self.data[res_id] results = self.data[res_id]
nt = len(list(results.get("timestamps"))) nt = len(list(results.get("timestamps")))
reach = results.river.reach(self._reach) reach = results.river.reach(self._current_reach)
berdrock = self.sl_compute_bedrock(reach) berdrock = self.sl_compute_bedrock(reach)
sl = reach.profile(profile).get_key("sl") sl = reach.profile(profile).get_key("sl")
@ -171,10 +171,10 @@ class CustomPlot(PamhyrPlot):
def _draw_rk(self): def _draw_rk(self):
results = self.data[self._current_res_id] results = self.data[self._current_res_id]
reach = results.river.reach(self._reach) reach = results.river.reach(self._current_reach)
if self._current_res_id == 2: # compare results if self._current_res_id == 2: # compare results
reach1 = self.data[0].river.reach(self._reach) reach1 = self.data[0].river.reach(self._current_reach)
reach2 = self.data[1].river.reach(self._reach) reach2 = self.data[1].river.reach(self._current_reach)
rk = reach.geometry.get_rk() rk = reach.geometry.get_rk()
if reach.has_sediment(): if reach.has_sediment():
z_min = self.draw_bottom_with_bedload(reach) z_min = self.draw_bottom_with_bedload(reach)
@ -183,19 +183,19 @@ class CustomPlot(PamhyrPlot):
q = list( q = list(
map( map(
lambda p: p.get_ts_key(self._timestamp, "Q"), lambda p: p.get_ts_key(self._current_timestamp, "Q"),
reach.profiles reach.profiles
) )
) )
z = list( z = list(
map( map(
lambda p: p.get_ts_key(self._timestamp, "Z"), lambda p: p.get_ts_key(self._current_timestamp, "Z"),
reach.profiles reach.profiles
) )
) )
v = list( v = list(
map( map(
lambda p: p.get_ts_key(self._timestamp, "V"), lambda p: p.get_ts_key(self._current_timestamp, "V"),
reach.profiles reach.profiles
) )
) )
@ -248,7 +248,8 @@ class CustomPlot(PamhyrPlot):
e = list( e = list(
map( map(
lambda p: max(self.get_ts_zmin(p, res_id)), lambda p: max(self.get_ts_zmin(
p, self._current_res_id)),
range(len(reach)) range(len(reach))
) )
) )
@ -261,7 +262,8 @@ class CustomPlot(PamhyrPlot):
e = list( e = list(
map( map(
lambda p: min(self.get_ts_zmin(p, res_id)), lambda p: min(self.get_ts_zmin(
p, self._current_res_id)),
range(len(reach)) range(len(reach))
) )
) )
@ -402,7 +404,7 @@ class CustomPlot(PamhyrPlot):
d = list( d = list(
map( map(
lambda p: p.geometry.max_water_depth( lambda p: p.geometry.max_water_depth(
p.get_ts_key(self._timestamp, "Z")), p.get_ts_key(self._current_timestamp, "Z")),
reach.profiles reach.profiles
) )
) )
@ -410,14 +412,14 @@ class CustomPlot(PamhyrPlot):
d1 = list( d1 = list(
map( map(
lambda p: p.geometry.max_water_depth( lambda p: p.geometry.max_water_depth(
p.get_ts_key(self._timestamp, "Z")), p.get_ts_key(self._current_timestamp, "Z")),
reach1.profiles reach1.profiles
) )
) )
d2 = list( d2 = list(
map( map(
lambda p: p.geometry.max_water_depth( lambda p: p.geometry.max_water_depth(
p.get_ts_key(self._timestamp, "Z")), p.get_ts_key(self._current_timestamp, "Z")),
reach2.profiles reach2.profiles
) )
) )
@ -471,7 +473,7 @@ class CustomPlot(PamhyrPlot):
d = list( d = list(
map( map(
lambda p: p.geometry.mean_water_depth( lambda p: p.geometry.mean_water_depth(
p.get_ts_key(self._timestamp, "Z")), p.get_ts_key(self._current_timestamp, "Z")),
reach.profiles reach.profiles
) )
) )
@ -479,14 +481,14 @@ class CustomPlot(PamhyrPlot):
d1 = list( d1 = list(
map( map(
lambda p: p.geometry.mean_water_depth( lambda p: p.geometry.mean_water_depth(
p.get_ts_key(self._timestamp, "Z")), p.get_ts_key(self._current_timestamp, "Z")),
reach1.profiles reach1.profiles
) )
) )
d2 = list( d2 = list(
map( map(
lambda p: p.geometry.mean_water_depth( lambda p: p.geometry.mean_water_depth(
p.get_ts_key(self._timestamp, "Z")), p.get_ts_key(self._current_timestamp, "Z")),
reach2.profiles reach2.profiles
) )
) )
@ -510,12 +512,12 @@ class CustomPlot(PamhyrPlot):
fr = list( fr = list(
map( map(
lambda p: lambda p:
p.get_ts_key(self._timestamp, "V") / p.get_ts_key(self._current_timestamp, "V") /
sqrt(9.81 * ( sqrt(9.81 * (
p.geometry.wet_area( p.geometry.wet_area(p.get_ts_key(
p.get_ts_key(self._timestamp, "Z")) / self._current_timestamp, "Z")) /
p.geometry.wet_width( p.geometry.wet_width(p.get_ts_key(
p.get_ts_key(self._timestamp, "Z")) self._current_timestamp, "Z"))
)), )),
reach.profiles reach.profiles
) )
@ -524,12 +526,12 @@ class CustomPlot(PamhyrPlot):
fr1 = list( fr1 = list(
map( map(
lambda p: lambda p:
p.get_ts_key(self._timestamp, "V") / p.get_ts_key(self._current_timestamp, "V") /
sqrt(9.81 * ( sqrt(9.81 * (
p.geometry.wet_area( p.geometry.wet_area(p.get_ts_key(
p.get_ts_key(self._timestamp, "Z")) / self._current_timestamp, "Z")) /
p.geometry.wet_width( p.geometry.wet_width(p.get_ts_key(
p.get_ts_key(self._timestamp, "Z")) self._current_timestamp, "Z"))
)), )),
reach1.profiles reach1.profiles
) )
@ -537,12 +539,12 @@ class CustomPlot(PamhyrPlot):
fr2 = list( fr2 = list(
map( map(
lambda p: lambda p:
p.get_ts_key(self._timestamp, "V") / p.get_ts_key(self._current_timestamp, "V") /
sqrt(9.81 * ( sqrt(9.81 * (
p.geometry.wet_area( p.geometry.wet_area(p.get_ts_key(
p.get_ts_key(self._timestamp, "Z")) / self._current_timestamp, "Z")) /
p.geometry.wet_width( p.geometry.wet_width(p.get_ts_key(
p.get_ts_key(self._timestamp, "Z")) self._current_timestamp, "Z"))
)), )),
reach2.profiles reach2.profiles
) )
@ -566,7 +568,7 @@ class CustomPlot(PamhyrPlot):
d = list( d = list(
map( map(
lambda p: p.geometry.wet_area( lambda p: p.geometry.wet_area(
p.get_ts_key(self._timestamp, "Z")), p.get_ts_key(self._current_timestamp, "Z")),
reach.profiles reach.profiles
) )
) )
@ -574,14 +576,14 @@ class CustomPlot(PamhyrPlot):
d1 = list( d1 = list(
map( map(
lambda p: p.geometry.wet_area( lambda p: p.geometry.wet_area(
p.get_ts_key(self._timestamp, "Z")), p.get_ts_key(self._current_timestamp, "Z")),
reach1.profiles reach1.profiles
) )
) )
d2 = list( d2 = list(
map( map(
lambda p: p.geometry.wet_area( lambda p: p.geometry.wet_area(
p.get_ts_key(self._timestamp, "Z")), p.get_ts_key(self._current_timestamp, "Z")),
reach2.profiles reach2.profiles
) )
) )
@ -609,10 +611,10 @@ class CustomPlot(PamhyrPlot):
def _redraw_rk(self): def _redraw_rk(self):
results = self.data[self._current_res_id] results = self.data[self._current_res_id]
reach = results.river.reach(self._reach) reach = results.river.reach(self._current_reach)
if self._current_res_id == 2: # compare results if self._current_res_id == 2: # compare results
reach1 = self.data[0].river.reach(self._reach) reach1 = self.data[0].river.reach(self._current_reach)
reach2 = self.data[1].river.reach(self._reach) reach2 = self.data[1].river.reach(self._current_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()
@ -623,19 +625,19 @@ class CustomPlot(PamhyrPlot):
q = list( q = list(
map( map(
lambda p: p.get_ts_key(self._timestamp, "Q"), lambda p: p.get_ts_key(self._current_timestamp, "Q"),
reach.profiles reach.profiles
) )
) )
z = list( z = list(
map( map(
lambda p: p.get_ts_key(self._timestamp, "Z"), lambda p: p.get_ts_key(self._current_timestamp, "Z"),
reach.profiles reach.profiles
) )
) )
v = list( v = list(
map( map(
lambda p: p.get_ts_key(self._timestamp, "V"), lambda p: p.get_ts_key(self._current_timestamp, "V"),
reach.profiles reach.profiles
) )
) )
@ -679,7 +681,7 @@ class CustomPlot(PamhyrPlot):
d = list( d = list(
map( map(
lambda p: p.geometry.max_water_depth( lambda p: p.geometry.max_water_depth(
p.get_ts_key(self._timestamp, "Z")), p.get_ts_key(self._current_timestamp, "Z")),
reach.profiles reach.profiles
) )
) )
@ -687,14 +689,14 @@ class CustomPlot(PamhyrPlot):
d1 = list( d1 = list(
map( map(
lambda p: p.geometry.max_water_depth( lambda p: p.geometry.max_water_depth(
p.get_ts_key(self._timestamp, "Z")), p.get_ts_key(self._current_timestamp, "Z")),
reach1.profiles reach1.profiles
) )
) )
d2 = list( d2 = list(
map( map(
lambda p: p.geometry.max_water_depth( lambda p: p.geometry.max_water_depth(
p.get_ts_key(self._timestamp, "Z")), p.get_ts_key(self._current_timestamp, "Z")),
reach2.profiles reach2.profiles
) )
) )
@ -712,7 +714,7 @@ class CustomPlot(PamhyrPlot):
d = list( d = list(
map( map(
lambda p: p.geometry.mean_water_depth( lambda p: p.geometry.mean_water_depth(
p.get_ts_key(self._timestamp, "Z")), p.get_ts_key(self._current_timestamp, "Z")),
reach.profiles reach.profiles
) )
) )
@ -720,14 +722,14 @@ class CustomPlot(PamhyrPlot):
d1 = list( d1 = list(
map( map(
lambda p: p.geometry.mean_water_depth( lambda p: p.geometry.mean_water_depth(
p.get_ts_key(self._timestamp, "Z")), p.get_ts_key(self._current_timestamp, "Z")),
reach1.profiles reach1.profiles
) )
) )
d2 = list( d2 = list(
map( map(
lambda p: p.geometry.mean_water_depth( lambda p: p.geometry.mean_water_depth(
p.get_ts_key(self._timestamp, "Z")), p.get_ts_key(self._current_timestamp, "Z")),
reach2.profiles reach2.profiles
) )
) )
@ -745,12 +747,12 @@ class CustomPlot(PamhyrPlot):
fr = list( fr = list(
map( map(
lambda p: lambda p:
p.get_ts_key(self._timestamp, "V") / p.get_ts_key(self._current_timestamp, "V") /
sqrt(9.81 * ( sqrt(9.81 * (
p.geometry.wet_area( p.geometry.wet_area(p.get_ts_key(
p.get_ts_key(self._timestamp, "Z")) / self._current_timestamp, "Z")) /
p.geometry.wet_width( p.geometry.wet_width(p.get_ts_key(
p.get_ts_key(self._timestamp, "Z")) self._current_timestamp, "Z"))
)), )),
reach.profiles reach.profiles
) )
@ -759,12 +761,12 @@ class CustomPlot(PamhyrPlot):
fr1 = list( fr1 = list(
map( map(
lambda p: lambda p:
p.get_ts_key(self._timestamp, "V") / p.get_ts_key(self._current_timestamp, "V") /
sqrt(9.81 * ( sqrt(9.81 * (
p.geometry.wet_area( p.geometry.wet_area(p.get_ts_key(
p.get_ts_key(self._timestamp, "Z")) / self._current_timestamp, "Z")) /
p.geometry.wet_width( p.geometry.wet_width(p.get_ts_key(
p.get_ts_key(self._timestamp, "Z")) self._current_timestamp, "Z"))
)), )),
reach1.profiles reach1.profiles
) )
@ -772,12 +774,12 @@ class CustomPlot(PamhyrPlot):
fr2 = list( fr2 = list(
map( map(
lambda p: lambda p:
p.get_ts_key(self._timestamp, "V") / p.get_ts_key(self._current_timestamp, "V") /
sqrt(9.81 * ( sqrt(9.81 * (
p.geometry.wet_area( p.geometry.wet_area(p.get_ts_key(
p.get_ts_key(self._timestamp, "Z")) / self._current_timestamp, "Z")) /
p.geometry.wet_width( p.geometry.wet_width(p.get_ts_key(
p.get_ts_key(self._timestamp, "Z")) self._current_timestamp, "Z"))
)), )),
reach2.profiles reach2.profiles
) )
@ -796,7 +798,7 @@ class CustomPlot(PamhyrPlot):
d = list( d = list(
map( map(
lambda p: p.geometry.wet_area( lambda p: p.geometry.wet_area(
p.get_ts_key(self._timestamp, "Z")), p.get_ts_key(self._current_timestamp, "Z")),
reach.profiles reach.profiles
) )
) )
@ -804,14 +806,14 @@ class CustomPlot(PamhyrPlot):
d1 = list( d1 = list(
map( map(
lambda p: p.geometry.wet_area( lambda p: p.geometry.wet_area(
p.get_ts_key(self._timestamp, "Z")), p.get_ts_key(self._current_timestamp, "Z")),
reach1.profiles reach1.profiles
) )
) )
d2 = list( d2 = list(
map( map(
lambda p: p.geometry.wet_area( lambda p: p.geometry.wet_area(
p.get_ts_key(self._timestamp, "Z")), p.get_ts_key(self._current_timestamp, "Z")),
reach2.profiles reach2.profiles
) )
) )
@ -868,8 +870,8 @@ class CustomPlot(PamhyrPlot):
def _draw_time(self): def _draw_time(self):
results = self.data[self._current_res_id] results = self.data[self._current_res_id]
reach = results.river.reach(self._reach) reach = results.river.reach(self._current_reach)
profile = reach.profile(self._profile) profile = reach.profile(self._current_profile_id)
shift = 0 shift = 0
compt = 0 compt = 0
@ -884,10 +886,10 @@ class CustomPlot(PamhyrPlot):
ts = self._parent._timestamps ts = self._parent._timestamps
if self._current_res_id == 2: # compare results if self._current_res_id == 2: # compare results
reach1 = self.data[0].river.reach(self._reach) reach1 = self.data[0].river.reach(self._current_reach)
reach2 = self.data[1].river.reach(self._reach) reach2 = self.data[1].river.reach(self._current_reach)
profile1 = reach1.profile(self._profile) profile1 = reach1.profile(self._current_profile_id)
profile2 = reach2.profile(self._profile) profile2 = reach2.profile(self._current_profile_id)
q1 = profile1.get_key("Q") q1 = profile1.get_key("Q")
z1 = profile1.get_key("Z") z1 = profile1.get_key("Z")
@ -903,7 +905,8 @@ class CustomPlot(PamhyrPlot):
z_min = profile.geometry.z_min() z_min = profile.geometry.z_min()
if self._current_res_id < 2: if self._current_res_id < 2:
if reach.has_sediment(): if reach.has_sediment():
ts_z_min = self.get_ts_zmin(self._profile, res_id) ts_z_min = self.get_ts_zmin(
self._current_profile_id, self._current_res_id)
else: else:
ts_z_min = list( ts_z_min = list(
map( map(
@ -920,8 +923,8 @@ class CustomPlot(PamhyrPlot):
if self._current_res_id == 2: if self._current_res_id == 2:
if reach.has_sediment(): if reach.has_sediment():
ts_z_min1 = self.get_ts_zmin(self._profile1, 0) ts_z_min1 = self.get_ts_zmin(self._current_profile_id1, 0)
ts_z_min2 = self.get_ts_zmin(self._profile2, 1) ts_z_min2 = self.get_ts_zmin(self._current_profile_id2, 1)
ts_z_min = list( ts_z_min = list(
map( map(
lambda x, y: x - y, lambda x, y: x - y,
@ -1114,16 +1117,16 @@ class CustomPlot(PamhyrPlot):
def _redraw_time(self): def _redraw_time(self):
results = self.data[self._current_res_id] results = self.data[self._current_res_id]
reach = results.river.reach(self._reach) reach = results.river.reach(self._current_reach)
profile = reach.profile(self._profile) profile = reach.profile(self._current_profile_id)
ts = list(results.get("timestamps")) ts = list(results.get("timestamps"))
ts.sort() ts.sort()
if self._current_res_id == 2: # compare results if self._current_res_id == 2: # compare results
reach1 = self.data[0].river.reach(self._reach) reach1 = self.data[0].river.reach(self._current_reach)
reach2 = self.data[1].river.reach(self._reach) reach2 = self.data[1].river.reach(self._current_reach)
profile1 = reach1.profile(self._profile) profile1 = reach1.profile(self._current_profile_id)
profile2 = reach2.profile(self._profile) profile2 = reach2.profile(self._current_profile_id)
q1 = profile1.get_key("Q") q1 = profile1.get_key("Q")
z1 = profile1.get_key("Z") z1 = profile1.get_key("Z")
@ -1138,7 +1141,8 @@ class CustomPlot(PamhyrPlot):
v = profile.get_key("V") v = profile.get_key("V")
if self._current_res_id < 2: if self._current_res_id < 2:
if reach.has_sediment(): if reach.has_sediment():
ts_z_min = self.get_ts_zmin(self._profile) ts_z_min = self.get_ts_zmin(
self._current_profile_id, self._current_res_id)
else: else:
z_min = profile.geometry.z_min() z_min = profile.geometry.z_min()
ts_z_min = list( ts_z_min = list(
@ -1150,8 +1154,8 @@ class CustomPlot(PamhyrPlot):
if "bed_elevation" in self._y: if "bed_elevation" in self._y:
if self._current_res_id == 2: if self._current_res_id == 2:
if reach.has_sediment(): if reach.has_sediment():
ts_z_min1 = self.get_ts_zmin(self._profile1, 0) ts_z_min1 = self.get_ts_zmin(self._current_profile_id1, 0)
ts_z_min2 = self.get_ts_zmin(self._profile2, 1) ts_z_min2 = self.get_ts_zmin(self._current_profile_id2, 1)
ts_z_min = list( ts_z_min = list(
map( map(
lambda x, y: x - y, lambda x, y: x - y,
@ -1358,11 +1362,12 @@ class CustomPlot(PamhyrPlot):
elif self._x == "time": elif self._x == "time":
self._draw_time() self._draw_time()
if self._x == "rk": if self._x == "rk":
reach = self.data[self._current_res_id].river.reach(self._reach) reach = self.data[self._current_res_id].river.reach(
profile = reach.profile(self._profile) self._current_reach)
profile = reach.profile(self._current_profile_id)
x = profile.rk x = profile.rk
elif self._x == "time": elif self._x == "time":
x = self._timestamp x = self._current_timestamp
self._current, = self.canvas.axes.plot( self._current, = self.canvas.axes.plot(
[x, x], [x, x],
@ -1385,13 +1390,13 @@ class CustomPlot(PamhyrPlot):
return return
def set_reach(self, reach_id): def set_reach(self, reach_id):
self._reach = reach_id self._current_reach = reach_id
self._profile = 0 self._current_profile_id = 0
self.draw() self.draw()
def set_profile(self, profile_id): def set_profile(self, profile_id):
self._profile = profile_id self._current_profile_id = profile_id
if self._x != "rk": if self._x != "rk":
self.update() self.update()
@ -1403,19 +1408,27 @@ class CustomPlot(PamhyrPlot):
self.draw() self.draw()
def set_timestamp(self, timestamp): def set_timestamp(self, timestamp):
self._timestamp = timestamp self._current_timestamp = timestamp
if self._x != "time": if self._x != "time":
self.update() self.update()
else: else:
self.draw_current() self.draw_current()
def update_all(self):
self._current_reach_id = self._parent._get_current_reach()
self._current_profile_id = self._parent._get_current_profile()
self._current_res_id = self._parent._get_current_results()[0]
self._current_timestamp = self._parent._get_current_timestamp()
self.draw()
def draw_current(self): def draw_current(self):
if self._x == "rk": if self._x == "rk":
reach = self.data[self._current_res_id].river.reach(self._reach) reach = self.data[self._current_res_id].river.reach(
profile = reach.profile(self._profile) self._current_reach)
profile = reach.profile(self._current_profile_id)
x = profile.rk x = profile.rk
elif self._x == "time": elif self._x == "time":
x = self._timestamp x = self._current_timestamp
self._current.set_data([x, x], self.canvas.axes.get_ylim()) self._current.set_data([x, x], self.canvas.axes.get_ylim())
self.canvas.draw_idle() self.canvas.draw_idle()

View File

@ -39,6 +39,7 @@ class PlotAC(PamhyrPlot):
parent=parent parent=parent
) )
self._parent = parent
self._current_reach_id = reach_id self._current_reach_id = reach_id
self._current_profile_id = profile_id self._current_profile_id = profile_id
self._current_res_id = res_id[0] self._current_res_id = res_id[0]
@ -243,6 +244,14 @@ class PlotAC(PamhyrPlot):
self.update_idle() self.update_idle()
def update_all(self):
self._current_reach_id = self._parent._get_current_reach()
self._current_profile_id = self._parent._get_current_profile()
self._current_res_id = self._parent._get_current_results()[0]
self._current_timestamp = self._parent._get_current_timestamp()
self._init = False
self.update()
def update_gl(self): def update_gl(self):
for a in self.annotation: for a in self.annotation:
a.remove() a.remove()

View File

@ -47,6 +47,7 @@ class PlotH(PamhyrPlot):
self._mode = "time" self._mode = "time"
self._parent = parent
self._current_reach_id = reach_id self._current_reach_id = reach_id
self._current_profile_id = profile_id self._current_profile_id = profile_id
self._current_res_id = res_id self._current_res_id = res_id
@ -216,20 +217,16 @@ class PlotH(PamhyrPlot):
if not self._init: if not self._init:
self.draw() self.draw()
self.update_data()
self.update_current() self.update_current()
self.update_idle() self.update_idle()
def update_data(self): def update_all(self):
for res, res_id in enumerate(self._current_res_id): self._current_reach_id = self._parent._get_current_reach()
results = self.results[res_id] self._current_profile_id = self._parent._get_current_profiles_list()
reach = results.river.reach(self._current_reach_id) self._current_res_id = self._parent._get_current_results()
profile = reach.profile(self._current_profile_id) self._current_timestamp = self._parent._get_current_timestamp()
self._init = False
x = self._timestamps self.update()
y = profile.get_key("Q")
self._line[res].set_data(x, y)
def update_current(self): def update_current(self):
y = self._current.get_ydata() y = self._current.get_ydata()

View File

@ -42,6 +42,7 @@ class PlotRKC(PamhyrPlot):
parent=parent parent=parent
) )
self._parent = parent
self._current_reach_id = reach_id self._current_reach_id = reach_id
self._current_profile_id = profile_id self._current_profile_id = profile_id
self._current_res_id = res_id[0] self._current_res_id = res_id[0]
@ -343,6 +344,14 @@ class PlotRKC(PamhyrPlot):
self.update_idle() self.update_idle()
def update_all(self):
self._current_reach_id = self._parent._get_current_reach()
self._current_profile_id = self._parent._get_current_profile()
self._current_res_id = self._parent._get_current_results()[0]
self._current_timestamp = self._parent._get_current_timestamp()
self._init = False
self.update()
def update_water_elevation(self): def update_water_elevation(self):
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)

View File

@ -52,6 +52,7 @@ class PlotXY(PamhyrPlot):
self.line_gl = [] self.line_gl = []
self.overflow = [] self.overflow = []
self._parent = parent
self._timestamps = parent._timestamps self._timestamps = parent._timestamps
self._current_timestamp = max(self._timestamps) self._current_timestamp = max(self._timestamps)
self._current_reach_id = reach_id self._current_reach_id = reach_id
@ -332,6 +333,14 @@ class PlotXY(PamhyrPlot):
self.update_idle() self.update_idle()
def update_all(self):
self._current_reach_id = self._parent._get_current_reach()
self._current_profile_id = self._parent._get_current_profile()
self._current_res_id = self._parent._get_current_results()[0]
self._current_timestamp = self._parent._get_current_timestamp()
self._init = False
self.update()
def update_profile(self): def update_profile(self):
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)

View File

@ -445,49 +445,69 @@ class ResultsWindow(PamhyrWindow):
solver_id=None, solver_id=None,
timestamp=None): timestamp=None):
tab_widget = self.find(QTabWidget, f"tabWidget")
tab_index = tab_widget.currentIndex()
name = tab_widget.tabText(tab_index)
if reach_id is not None: if reach_id is not None:
if tab_index == 1:
self.plot_xy.set_reach(reach_id) self.plot_xy.set_reach(reach_id)
self.plot_ac.set_reach(reach_id) self.plot_ac.set_reach(reach_id)
self.plot_rkc.set_reach(reach_id) self.plot_rkc.set_reach(reach_id)
elif tab_index == 2:
self.plot_h.set_reach(reach_id) self.plot_h.set_reach(reach_id)
elif tab_index > 2:
self._additional_plot[name].set_reach(reach_id)
for plot in self._additional_plot: # for plot in self._additional_plot:
self._additional_plot[plot].set_reach(reach_id) # self._additional_plot[plot].set_reach(reach_id)
self.update_table_selection_reach(reach_id) self.update_table_selection_reach(reach_id)
self.update_table_selection_profile(0) self.update_table_selection_profile(0)
if profile_id is not None: if profile_id is not None:
if tab_index == 1:
self.plot_xy.set_profile(profile_id[0]) self.plot_xy.set_profile(profile_id[0])
self.plot_ac.set_profile(profile_id[0]) self.plot_ac.set_profile(profile_id[0])
self.plot_rkc.set_profile(profile_id[0]) self.plot_rkc.set_profile(profile_id[0])
elif tab_index == 2:
self.plot_h.set_profile(profile_id) self.plot_h.set_profile(profile_id)
elif tab_widget.currentIndex() > 2:
self._additional_plot[name].set_profile(profile_id[0])
for plot in self._additional_plot: # for plot in self._additional_plot:
self._additional_plot[plot].set_profile(profile_id[0]) # self._additional_plot[plot].set_profile(profile_id[0])
tab_widget = self.find(QTabWidget, f"tabWidget") tab_widget = self.find(QTabWidget, f"tabWidget")
if tab_widget.currentIndex() != 2: if tab_widget.currentIndex() != 2:
self.update_table_selection_profile(profile_id[0]) self.update_table_selection_profile(profile_id[0])
if solver_id is not None: if solver_id is not None:
if tab_index == 1:
self._current_results = solver_id self._current_results = solver_id
self.plot_xy.set_result(solver_id) self.plot_xy.set_result(solver_id)
self.plot_ac.set_result(solver_id) self.plot_ac.set_result(solver_id)
self.plot_rkc.set_result(solver_id) self.plot_rkc.set_result(solver_id)
elif tab_index == 2:
self.plot_h.set_result(solver_id) self.plot_h.set_result(solver_id)
elif tab_widget.currentIndex() > 2:
self._additional_plot[name].set_result(solver_id)
for plot in self._additional_plot: # for plot in self._additional_plot:
self._additional_plot[plot].set_result(solver_id) # self._additional_plot[plot].set_result(solver_id)
if timestamp is not None: if timestamp is not None:
self.plot_xy.set_timestamp(timestamp) self.plot_xy.set_timestamp(timestamp)
self.plot_ac.set_timestamp(timestamp) self.plot_ac.set_timestamp(timestamp)
self.plot_rkc.set_timestamp(timestamp) self.plot_rkc.set_timestamp(timestamp)
if tab_index == 2:
self.plot_h.set_timestamp(timestamp) self.plot_h.set_timestamp(timestamp)
for plot in self._additional_plot: if tab_widget.currentIndex() > 2:
self._additional_plot[plot].set_timestamp(timestamp) self._additional_plot[name].set_timestamp(timestamp)
# for plot in self._additional_plot:
# self._additional_plot[plot].set_timestamp(timestamp)
self._table["raw_data"].timestamp = timestamp self._table["raw_data"].timestamp = timestamp
@ -522,6 +542,14 @@ class ResultsWindow(PamhyrWindow):
self._slider_time.value() self._slider_time.value()
] ]
def _get_current_results(self):
table = self.find(QTableView, f"tableView_solver")
indexes = table.selectedIndexes()
if len(indexes) == 0:
return
return [i.row() for i in indexes]
def _set_current_reach(self): def _set_current_reach(self):
table = self.find(QTableView, f"tableView_reach") table = self.find(QTableView, f"tableView_reach")
indexes = table.selectedIndexes() indexes = table.selectedIndexes()
@ -1200,6 +1228,17 @@ class ResultsWindow(PamhyrWindow):
# unselect all profiles but the first one # unselect all profiles but the first one
profile_id = self._get_current_profile() profile_id = self._get_current_profile()
self.update_table_selection_profile(profile_id) self.update_table_selection_profile(profile_id)
tab_widget = self.find(QTabWidget, f"tabWidget")
tab_index = tab_widget.currentIndex()
name = tab_widget.tabText(tab_index)
if tab_index == 1:
self.plot_xy.update_all()
self.plot_ac.update_all()
self.plot_rkc.update_all()
elif tab_index == 2:
self.plot_h.update_all()
elif tab_index > 2:
self._additional_plot[name].update_all()
def import_geotiff(self): def import_geotiff(self):
return return

View File

@ -173,7 +173,7 @@ class Config(SQL):
posix = os.name == 'posix' posix = os.name == 'posix'
ext = "" if posix else ".exe" ext = "" if posix else ".exe"
path = os.path.join("@install_dir", path = os.path.join("@install_dir",
"rubar", f"rubar3{ext}") "rubar", f"rubarbe{ext}")
self.execute(f""" self.execute(f"""
INSERT INTO solver VALUES ( INSERT INTO solver VALUES (
@ -372,7 +372,7 @@ class Config(SQL):
ctor = solver_type_list["rubar3"] ctor = solver_type_list["rubar3"]
new = ctor("default-Rubar3") new = ctor("default-Rubar3")
new._description = "Default Pamhyr2 Rubar 3 version" new._description = "Default Pamhyr2 Rubar 3 version"
path = os.path.join("@install_dir", "rubar", f"rubar3{ext}") path = os.path.join("@install_dir", "rubar", f"rubarbe{ext}")
new._cmd_solver = f""""{path}" @args @input""" new._cmd_solver = f""""{path}" @args @input"""
self._solvers.append(new) self._solvers.append(new)