Results: Add additional data to SQL study save.

This commit is contained in:
parouby committed 2025-11-03 16:55:36 +01:00
1 parent 2487bec6d6
commit 14549330b9
3 files changed
+187 -32

No files matched your search

+51 -30
View File
@@ -59,6 +59,8 @@ from PyQt5.QtWidgets import (
QSlider, QLabel, QWidget, QGridLayout, QTabBar, QInputDialog
)
from Model.Results.Results import AdditionalData
from View.Tools.Plot.PamhyrCanvas import MplCanvas
from View.Tools.Plot.PamhyrToolbar import PamhyrPlotToolbar
@@ -1249,7 +1251,17 @@ class ResultsWindow(PamhyrWindow):
x, y = self.read_csv_file_data(filename)
data = self.read_csv_file_format(x, y)
self.read_csv_file_update_plot(data)
results = self._results[self._current_results[0]]
data_lst = results.get("additional_data")
data_lst.append(
AdditionalData(
study=self._study,
data=data
)
)
self.update_plot_additional_data()
def read_csv_file_data(self, filename):
sep = ","
@@ -1262,13 +1274,15 @@ class ResultsWindow(PamhyrWindow):
if line[0] != "*" and line[0] != "#" and line[0] != "$":
row = line.split(sep)
if len(row) >= 2:
try:
fx, fy = float(row[0]), float(row[1])
x.append(fx)
y.append(fy)
except:
continue
if len(row) < 2:
continue
try:
fx, fy = float(row[0]), float(row[1])
x.append(fx)
y.append(fy)
except Exception as e:
continue
return x, y
@@ -1309,28 +1323,35 @@ class ResultsWindow(PamhyrWindow):
return data
def read_csv_file_update_plot(self, data):
x, y = data['x'], data['y']
legend = data['legend']
unit = data['unit']
def update_plot_additional_data(self):
results = self._results[self._current_results[0]]
if data['type_x'] == 'water_elevation' and data['type_y'] == 'time':
line = self.canvas_2.axes.plot(
x, y, marker="+",
label=legend + ' ' + unit
)
self.plot_rkc.canvas.draw_idle()
self.plot_rkc.update_idle()
for data in results.get("additional_data"):
data = data._data
x, y = data['x'], data['y']
legend = data['legend']
unit = data['unit']
if data['type_x'] == 'discharge' and data['type_y'] == 'time':
line = self.canvas_4.axes.plot(
x, y, marker="+",
label=legend + ' ' + unit
)
self.plot_h._line.append(line)
self.plot_h.enable_legend()
self.plot_h.canvas.draw_idle()
self.plot_h.update_idle()
if (
data['type_x'] == 'water_elevation' and
data['type_y'] == 'time'
):
line = self.canvas_2.axes.plot(
x, y, marker="+",
label=legend + ' ' + unit
)
self.plot_rkc.canvas.draw_idle()
self.plot_rkc.update_idle()
for p in self._additional_plot:
self._additional_plot[p].add_imported_plot(data)
if data['type_x'] == 'discharge' and data['type_y'] == 'time':
line = self.canvas_4.axes.plot(
x, y, marker="+",
label=legend + ' ' + unit
)
self.plot_h._line.append(line)
self.plot_h.enable_legend()
self.plot_h.canvas.draw_idle()
self.plot_h.update_idle()
for p in self._additional_plot:
self._additional_plot[p].add_imported_plot(data)