From d6f152958f45859dfcbd9ea705c4291e179d0e1d Mon Sep 17 00:00:00 2001 From: Theophile Terraz Date: Wed, 4 Dec 2024 11:59:02 +0100 Subject: [PATCH] work on results adis --- src/View/Results/PlotSedAdisDt.py | 3 + src/View/Results/PlotSedAdisDx.py | 7 ++ src/View/Results/WindowAdisTS.py | 164 +++++++++++++++++------------- src/View/Results/translate.py | 6 ++ src/View/Translate.py | 2 + src/View/ui/ResultsAdisTS.ui | 104 +++++++++++++++---- 6 files changed, 192 insertions(+), 94 deletions(-) diff --git a/src/View/Results/PlotSedAdisDt.py b/src/View/Results/PlotSedAdisDt.py index bbc1f2df..83a0e906 100644 --- a/src/View/Results/PlotSedAdisDt.py +++ b/src/View/Results/PlotSedAdisDt.py @@ -53,6 +53,7 @@ class PlotAdis_dt(PamhyrPlot): self._key = key self.label_x = self._trad["unit_time_s"] + self._available_values_y = self._trad.get_dict("values_y_pol") self.label = {} self.label["C"] = _translate("Results", "Concentration") @@ -64,6 +65,8 @@ class PlotAdis_dt(PamhyrPlot): self.sed_id["C"] = 0 self.sed_id["M"] = 1 + self.label_y = self._available_values_y["unit_"+self._key] + self._isometric_axis = False @property diff --git a/src/View/Results/PlotSedAdisDx.py b/src/View/Results/PlotSedAdisDx.py index b1b872c8..7ec8cadc 100644 --- a/src/View/Results/PlotSedAdisDx.py +++ b/src/View/Results/PlotSedAdisDx.py @@ -53,6 +53,7 @@ class PlotAdis_dx(PamhyrPlot): self._key = key self.label_x = self._trad["unit_pk"] + self._available_values_y = self._trad.get_dict("values_y_pol") self.label = {} self.label["C"] = _translate("Results", "Concentration") @@ -64,6 +65,8 @@ class PlotAdis_dx(PamhyrPlot): self.sed_id["C"] = 0 self.sed_id["M"] = 1 + self.label_y = self._available_values_y["unit_"+self._key] + self._isometric_axis = False @property @@ -259,4 +262,8 @@ class PlotAdis_dx(PamhyrPlot): self.y_max = np.max(y) self.y_min = np.min(y) + if self.y_max - self.y_min < 1: + self.y_min = (self.y_max + self.y_min)/2 - 0.5 + self.y_max = (self.y_max + self.y_min)/2 + 0.5 + self.canvas.axes.set_ylim(self.y_min, self.y_max) diff --git a/src/View/Results/WindowAdisTS.py b/src/View/Results/WindowAdisTS.py index fd163e8a..f4647115 100644 --- a/src/View/Results/WindowAdisTS.py +++ b/src/View/Results/WindowAdisTS.py @@ -107,7 +107,7 @@ class ResultsWindowAdisTS(PamhyrWindow): self._hash_data.append(self._results) self._additional_plot = {} - self._pol_id = 0 + self._pol_id = 1 self._reach_id = 0 self._profile_id = 0 @@ -178,95 +178,114 @@ class ResultsWindowAdisTS(PamhyrWindow): self._timer = QTimer(self) def setup_plots(self): - self.canvas_dt = MplCanvas(width=5, height=4, dpi=100) - self.canvas_dt.setObjectName("canvas_dt") - self.toolbar_dt = PamhyrPlotToolbar( - self.canvas_dt, self, items=[ + self.canvas_cdt = MplCanvas(width=5, height=4, dpi=100) + self.canvas_cdt.setObjectName("canvas_cdt") + self.toolbar_cdt = PamhyrPlotToolbar( + self.canvas_cdt, self, items=[ "home", "move", "zoom", "save", "iso", "back/forward" ] ) - self.plot_layout_dt = self.find( + self.plot_layout_cdt = self.find( QVBoxLayout, "verticalLayout_concentration_dt") - self.plot_layout_dt.addWidget(self.toolbar_dt) - self.plot_layout_dt.addWidget(self.canvas_dt) + #self.plot_layout_cdt = self.find( + #QVBoxLayout, "verticalLayout_cdt") + self.plot_layout_cdt.addWidget(self.toolbar_cdt) + self.plot_layout_cdt.addWidget(self.canvas_cdt) - self.plot_c_dt = PlotAdis_dt( - canvas=self.canvas_dt, + self.plot_cdt = PlotAdis_dt( + canvas=self.canvas_cdt, results=self._results, reach_id=self._reach_id, profile_id=self._profile_id, pol_id=self._pol_id, key="C", trad=self._trad, - toolbar=self.toolbar_dt + toolbar=self.toolbar_cdt ) - self.plot_c_dt.draw() + self.plot_cdt.draw() - self.canvas_dx = MplCanvas(width=5, height=4, dpi=100) - self.canvas_dx.setObjectName("canvas_dx") - self.toolbar_dx = PamhyrPlotToolbar( - self.canvas_dt, self, items=[ + self.canvas_cdx = MplCanvas(width=5, height=4, dpi=100) + self.canvas_cdx.setObjectName("canvas_cdx") + self.toolbar_cdx = PamhyrPlotToolbar( + self.canvas_cdx, self, items=[ "home", "move", "zoom", "save", "iso", "back/forward" ] ) - self.plot_layout_dx = self.find( + self.plot_layout_cdx = self.find( QVBoxLayout, "verticalLayout_concentration_dx") - self.plot_layout_dx.addWidget(self.toolbar_dx) - self.plot_layout_dx.addWidget(self.canvas_dx) + #self.plot_layout_cdx = self.find( + #QVBoxLayout, "verticalLayout_cdx") + self.plot_layout_cdx.addWidget(self.toolbar_cdx) + self.plot_layout_cdx.addWidget(self.canvas_cdx) - self.plot_c_dx = PlotAdis_dx( - canvas=self.canvas_dx, + self.plot_cdx = PlotAdis_dx( + canvas=self.canvas_cdx, results=self._results, reach_id=self._reach_id, profile_id=self._profile_id, pol_id=self._pol_id, key="C", trad=self._trad, - toolbar=self.toolbar_dx + toolbar=self.toolbar_cdx ) - self.plot_c_dx.draw() + self.plot_cdx.draw() - self.canvas_3 = MplCanvas(width=5, height=4, dpi=100) - self.canvas_3.setObjectName("canvas_3") - self.toolbar_3 = PamhyrPlotToolbar( - self.canvas_3, self, items=[ + self.canvas_mdx = MplCanvas(width=5, height=4, dpi=100) + self.canvas_mdx.setObjectName("canvas_mdx") + self.toolbar_mdx = PamhyrPlotToolbar( + self.canvas_mdx, self, items=[ "home", "move", "zoom", "save", "iso", "back/forward" ] ) - self.plot_layout_3 = self.find( - QVBoxLayout, "verticalLayout_mass") - self.plot_layout_3.addWidget(self.toolbar_3) - self.plot_layout_3.addWidget(self.canvas_3) + self.plot_layout_mdx = self.find( + QVBoxLayout, "verticalLayout_mass_dx2") + self.plot_layout_mdx.addWidget(self.toolbar_mdx) + self.plot_layout_mdx.addWidget(self.canvas_mdx) - #self.plot_m = PlotM( - #canvas=self.canvas_3, - #results=self._results, - #reach_id=self._reach_id, - #profile_id=self._profile_id, - #pol_id=self._pol_id, - #trad=self._trad, - #toolbar=self.toolbar_3 - #) - - - self.plot_m = PlotAdis_dx( - canvas=self.canvas_3, + self.plot_mdx = PlotAdis_dx( + canvas=self.canvas_mdx, results=self._results, reach_id=self._reach_id, profile_id=self._profile_id, pol_id=self._pol_id, key="M", trad=self._trad, - toolbar=self.toolbar_3 + toolbar=self.toolbar_mdx ) - self.plot_m.draw() + self.plot_mdx.draw() + + self.canvas_mdt = MplCanvas(width=5, height=4, dpi=100) + self.canvas_mdt.setObjectName("canvas_mdt") + self.toolbar_mdt = PamhyrPlotToolbar( + self.canvas_mdt, self, items=[ + "home", "move", "zoom", "save", + "iso", "back/forward" + ] + ) + self.plot_layout_mdt = self.find( + QVBoxLayout, "verticalLayout_mass_dt2") + self.plot_layout_mdt.addWidget(self.toolbar_mdt) + self.plot_layout_mdt.addWidget(self.canvas_mdt) + + self.plot_mdt = PlotAdis_dt( + canvas=self.canvas_mdt, + results=self._results, + reach_id=self._reach_id, + profile_id=self._profile_id, + pol_id=self._pol_id, + key="M", + trad=self._trad, + toolbar=self.toolbar_mdt + ) + + self.plot_mdt.draw() if self._type_pol[self._pol_id] != 7: - self.find(QTabWidget, "tabWidget").setTabVisible(3, False) + self.find(QTabWidget, "tabWidget").setTabVisible(2, False) self.canvas_2 = MplCanvas(width=5, height=4, dpi=100) self.canvas_2.setObjectName("canvas_2") @@ -511,10 +530,11 @@ class ResultsWindowAdisTS(PamhyrWindow): def update(self, reach_id=None, profile_id=None, pol_id=None, timestamp=None): if reach_id is not None: - self.plot_c_dt.set_reach(reach_id) - self.plot_c_dx.set_reach(reach_id) + self.plot_cdt.set_reach(reach_id) + self.plot_cdx.set_reach(reach_id) if self._type_pol[self._pol_id] == 7: - self.plot_m.set_reach(reach_id) + self.plot_mdx.set_reach(reach_id) + self.plot_mdt.set_reach(reach_id) self.plot_tot_c.set_reach(reach_id) self.plot_tot_eg.set_reach(reach_id) self.plot_tot_em.set_reach(reach_id) @@ -525,10 +545,11 @@ class ResultsWindowAdisTS(PamhyrWindow): self.update_table_selection_pol(0) if profile_id is not None: - self.plot_c_dt.set_profile(profile_id) - self.plot_c_dx.set_profile(profile_id) + self.plot_cdt.set_profile(profile_id) + self.plot_cdx.set_profile(profile_id) if self._type_pol[self._pol_id] == 7: - self.plot_m.set_profile(profile_id) + self.plot_mdx.set_profile(profile_id) + self.plot_mdt.set_profile(profile_id) self.plot_tot_c.set_profile(profile_id) self.plot_tot_eg.set_profile(profile_id) self.plot_tot_em.set_profile(profile_id) @@ -538,21 +559,23 @@ class ResultsWindowAdisTS(PamhyrWindow): if pol_id is not None: self._pol_id = pol_id - self.plot_c_dt.set_pollutant(self._pol_id) - self.plot_c_dx.set_pollutant(self._pol_id) + self.plot_cdt.set_pollutant(self._pol_id) + self.plot_cdx.set_pollutant(self._pol_id) if self._type_pol[self._pol_id] == 7: - self.find(QTabWidget, "tabWidget").setTabVisible(3, True) - self.plot_m.set_pollutant(self._pol_id) + self.find(QTabWidget, "tabWidget").setTabVisible(2, True) + self.plot_mdx.set_pollutant(self._pol_id) + self.plot_mdt.set_pollutant(self._pol_id) else: - self.find(QTabWidget, "tabWidget").setTabVisible(3, False) + self.find(QTabWidget, "tabWidget").setTabVisible(2, False) self.update_table_selection_pol(self._pol_id) if timestamp is not None: - self.plot_c_dt.set_timestamp(timestamp) - self.plot_c_dx.set_timestamp(timestamp) + self.plot_cdt.set_timestamp(timestamp) + self.plot_cdx.set_timestamp(timestamp) if self._type_pol[self._pol_id] == 7: - self.plot_m.set_timestamp(timestamp) + self.plot_mdx.set_timestamp(timestamp) + self.plot_mdt.set_timestamp(timestamp) #self.plot_tot_c.set_timestamp(timestamp) #self.plot_tot_eg.set_timestamp(timestamp) #self.plot_tot_em.set_timestamp(timestamp) @@ -582,7 +605,6 @@ class ResultsWindowAdisTS(PamhyrWindow): return self.update(profile_id=indexes[0].row()) - ###self._slider_profile.setValue(ind) def _set_current_pol(self): table = self.find(QTableView, f"tableView_pollutants") @@ -602,28 +624,26 @@ class ResultsWindowAdisTS(PamhyrWindow): self.update(profile_id=ind) self._slider_profile.setValue(ind) - def _set_current_profile_slider(self): - pid = self._slider_profile.value() - self.update(profile_id=pid) - def _set_current_timestamp(self): timestamp = self._timestamps[self._slider_time.value()] self.update(timestamp=timestamp) def _reload_plots(self): - self.plot_c_dt.results = self._results - self.plot_c_dx.results = self._results + self.plot_cdt.results = self._results + self.plot_cdx.results = self._results if self._type_pol[self._pol_id] == 7: - self.plot_m.results = self._results + self.plot_mdx.results = self._results + self.plot_mdt.results = self._results self.plot_tot_c.results = self._results self.plot_tot_eg.results = self._results self.plot_tot_em.results = self._results self.plot_tot_ed.results = self._results - self.plot_c_dt.draw() - self.plot_c_dx.draw() + self.plot_cdt.draw() + self.plot_cdx.draw() if self._type_pol[self._pol_id] == 7: - self.plot_m.draw() + self.plot_mdx.draw() + self.plot_mdt.draw() self.plot_tot_c.draw() self.plot_tot_eg.draw() self.plot_tot_em.draw() diff --git a/src/View/Results/translate.py b/src/View/Results/translate.py index b0573be9..f74fc2d1 100644 --- a/src/View/Results/translate.py +++ b/src/View/Results/translate.py @@ -125,3 +125,9 @@ class ResultsTranslate(MainTranslate): "min_depth": self._dict["unit_min_depth"], "max_depth": self._dict["unit_max_depth"], } + + self._sub_dict["values_y_pol"] = { + "unit_C": self._dict["unit_concentration"], + "unit_M": self._dict["unit_mass"], + } + diff --git a/src/View/Translate.py b/src/View/Translate.py index 72341d0e..b8413791 100644 --- a/src/View/Translate.py +++ b/src/View/Translate.py @@ -144,6 +144,8 @@ class UnitTranslate(CommonWordTranslate): "Unit", "Hydraulic Radius (m)" ) self._dict["unit_froude"] = _translate("Unit", "Froude number") + self._dict["unit_mass"] = _translate("Unit", "Mass (kg)") + self._dict["unit_concentration"] = _translate("Unit", "Concentration (kg/m^3)") class MainTranslate(UnitTranslate): diff --git a/src/View/ui/ResultsAdisTS.ui b/src/View/ui/ResultsAdisTS.ui index 4416961f..51fe837c 100644 --- a/src/View/ui/ResultsAdisTS.ui +++ b/src/View/ui/ResultsAdisTS.ui @@ -6,8 +6,8 @@ 0 0 - 1097 - 720 + 1410 + 821 @@ -129,8 +129,11 @@ + + true + - 1 + 3 @@ -149,39 +152,96 @@ - + true - Concentration dt + Concentration - + + + + + 0 + + + + Concentration dx + + + + + + + + + + Concentration dt + + + + + + + + + + - - - Concentration dx - - - - - - - - + + + true + Mass - + - + + + + + true + + + 1 + + + + Mass dx + + + + + + + + + + Mass dt + + + + + + + + + + + + + Page + + Total Sediments @@ -190,9 +250,9 @@ - + - 3 + 0 @@ -253,7 +313,7 @@ 0 0 - 1097 + 1410 22