more work on compare results

scenarios
Theophile Terraz 2025-10-24 16:36:06 +02:00
parent 84486c03ed
commit e6dd983f97
3 changed files with 40 additions and 67 deletions

View File

@ -841,11 +841,6 @@ class ProfileXYZ(Profile, SQLSubModel):
if zz[i] > z and zz[i+1] <= z: if zz[i] > z and zz[i+1] <= z:
fact = (z - zz[i]) / (zz[i+1] - zz[i]) fact = (z - zz[i]) / (zz[i+1] - zz[i])
y = station[i] + fact * (station[i+1] - station[i]) y = station[i] + fact * (station[i+1] - station[i])
#y = np.interp(
#z,
#[zz[i+1], zz[i]],
#[station[i+1], station[i]]
#)
start.append(y) start.append(y)
end = [] end = []
@ -856,11 +851,6 @@ class ProfileXYZ(Profile, SQLSubModel):
if zz[i] <= z and zz[i+1] > z: if zz[i] <= z and zz[i+1] > z:
fact = (z - zz[i]) / (zz[i+1] - zz[i]) fact = (z - zz[i]) / (zz[i+1] - zz[i])
y = station[i] + fact * (station[i+1] - station[i]) y = station[i] + fact * (station[i+1] - station[i])
#y = np.interp(
#z,
#[zz[i], zz[i+1]],
#[station[i], station[i+1]]
#)
end.append(y) end.append(y)
if len(start) != len(end): if len(start) != len(end):
@ -891,38 +881,24 @@ class ProfileXYZ(Profile, SQLSubModel):
# Interpolate points at river left side # Interpolate points at river left side
if (i_left > 0): if (i_left > 0):
fact = (z - self.point(i_left).z) / (self.point(i_left - 1).z - self.point(i_left).z) fact = (z - self.point(i_left).z) / (self.point(i_left - 1).z
x = self.point(i_left).x + fact * (self.point(i_left - 1).x - self.point(i_left).x) - self.point(i_left).z)
y = self.point(i_left).y + fact * (self.point(i_left - 1).y - self.point(i_left).y) x = self.point(i_left).x + fact * (self.point(i_left - 1).x
#x = np.interp( - self.point(i_left).x)
#z, y = self.point(i_left).y + fact * (self.point(i_left - 1).y
#[self.point(i_left - 1).z, self.point(i_left).z], - self.point(i_left).y)
#[self.point(i_left - 1).x, self.point(i_left).x]
#)
#y = np.interp(
#z,
#[self.point(i_left).z, self.point(i_left - 1).z],
#[self.point(i_left).y, self.point(i_left - 1).y]
#)
pt_left = PointXYZ(x=x, y=y, z=z, name="wl_left") pt_left = PointXYZ(x=x, y=y, z=z, name="wl_left")
else: else:
pt_left = self.point(0) pt_left = self.point(0)
# Interpolate points at river right side # Interpolate points at river right side
if (i_right < self.number_points - 1): if (i_right < self.number_points - 1):
fact = (z - self.point(i_right).z) / (self.point(i_right + 1).z - self.point(i_right).z) fact = (z - self.point(i_right).z) / (self.point(i_right + 1).z -
x = self.point(i_right).x + fact * (self.point(i_right + 1).x - self.point(i_right).x) self.point(i_right).z)
y = self.point(i_right).y + fact * (self.point(i_right + 1).y - self.point(i_right).y) x = self.point(i_right).x + fact * (self.point(i_right + 1).x -
#x = np.interp( self.point(i_right).x)
#z, y = self.point(i_right).y + fact * (self.point(i_right + 1).y -
#[self.point(i_right).z, self.point(i_right + 1).z], self.point(i_right).y)
#[self.point(i_right).x, self.point(i_right + 1).x]
#)
#y = np.interp(
#z,
#[self.point(i_right).z, self.point(i_right + 1).z],
#[self.point(i_right).y, self.point(i_right + 1).y]
#)
pt_right = PointXYZ(x=x, y=y, z=z, name="wl_right") pt_right = PointXYZ(x=x, y=y, z=z, name="wl_right")
else: else:
pt_right = self.point(self.number_points - 1) pt_right = self.point(self.number_points - 1)

View File

@ -1416,3 +1416,16 @@ class CustomPlot(PamhyrPlot):
) )
labs = list(map(lambda line: self._trad[line], self.lines)) labs = list(map(lambda line: self._trad[line], self.lines))
self.canvas.axes.legend(lns, labs, loc="best") self.canvas.axes.legend(lns, labs, loc="best")
def add_imported_plot(self, data):
if (data["type_x"] == self._x and
data["type_y"] in self._y):
while data["legend"] in self.lines:
data["legend"] += '*'
self._trad._dict[data["legend"]] = data["legend"] + data["unit"]
self.lines[data["legend"]] = self.canvas.axes.plot(data["x"],
data["y"],
marker="+",
linestyle="--")
self.update_legend()
self.idle()

View File

@ -1243,24 +1243,12 @@ class ResultsWindow(PamhyrWindow):
for line in lines: for line in lines:
if line[0] != "*" and line[0] != "#" and line[0] != "$": if line[0] != "*" and line[0] != "#" and line[0] != "$":
row = line.split(sep) row = line.split(sep)
print(row)
if len(row) >= 2: if len(row) >= 2:
try: try:
x.append(float(row[0])) x.append(float(row[0]))
y.append(float(row[1])) y.append(float(row[1]))
except: except:
pass pass
print(x)
print(y)
# with open(filename, 'r', newline='') as f:
# reader = csv.reader(f, delimiter=sep, quotechar='|',
# quoting=csv.QUOTE_NONNUMERIC)
# for row in reader:
# print(row)
# if len(row) == 2:
# x.append(float(row[0]))
# y.append(float(row[1]))
data_type_lst = ['Q(t)', 'Z(t)', 'Z(x)'] data_type_lst = ['Q(t)', 'Z(t)', 'Z(x)']
data_type, ok = QInputDialog.getItem( data_type, ok = QInputDialog.getItem(
@ -1269,8 +1257,7 @@ class ResultsWindow(PamhyrWindow):
if not ok: if not ok:
return return
legend, ok = QInputDialog.getText( legend, ok = QInputDialog.getText(self, 'Legend', 'Legend:')
self, 'Legend','Legend:' )
if not ok: if not ok:
return return
@ -1286,28 +1273,25 @@ class ResultsWindow(PamhyrWindow):
tmp_unit = {'Z': ' (m)', tmp_unit = {'Z': ' (m)',
'Q': ' (m³/s)'} 'Q': ' (m³/s)'}
data = {'type_x': tmp_dict[data_type[2]],
'type_y': tmp_dict[data_type[0]],
'legend': legend,
'unit': tmp_unit[data_type[0]],
'x': x,
'y': y}
if data_type == 'Z(x)': if data_type == 'Z(x)':
line = self.canvas_2.axes.plot(x, y, marker="+", line = self.canvas_2.axes.plot(x, y, marker="+",
label = legend + ' (m)') label=legend + ' (m)')
self.plot_rkc.canvas.draw_idle() self.plot_rkc.canvas.draw_idle()
self.plot_rkc.update_idle() self.plot_rkc.update_idle()
if data_type == 'Q(t)': if data_type == 'Q(t)':
line = self.canvas_4.axes.plot(x, y, line = self.canvas_4.axes.plot(x, y, marker="+",
marker="+", label=legend + ' (m³/s)')
label = legend + ' (m³/s)')
self.plot_h._line.append(line) self.plot_h._line.append(line)
self.plot_h.enable_legend() self.plot_h.enable_legend()
self.plot_h.canvas.draw_idle()
self.plot_h.update_idle
for p in self._additional_plot: for p in self._additional_plot:
plot = self._additional_plot[p] self._additional_plot[p].add_imported_plot(data)
x_key = p.split(": ")[0]
y_key = p.split(": ")[1].split(",")
if (tmp_dict[data_type[2]] in x_key and
tmp_dict[data_type[0]] in y_key):
while legend in plot.lines:
legend += '*'
plot._trad._dict[legend] = legend + tmp_unit[data_type[0]]
plot.lines[legend] = plot.canvas.axes.plot(x, y,
marker="+",
linestyle="--")
plot.update_legend()
plot.idle()