From ca8dc19c839748bec781f8797aec2d4c861ee94c Mon Sep 17 00:00:00 2001 From: Theophile Terraz <theophile.terraz@inrae.fr> Date: Tue, 4 Feb 2025 16:24:42 +0100 Subject: [PATCH] work on export CSV compare results --- .../Results/CustomExport/CustomExportAdis.py | 4 ++-- src/View/Results/Window.py | 23 ++++++++++--------- src/View/Results/translate.py | 5 ++-- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/View/Results/CustomExport/CustomExportAdis.py b/src/View/Results/CustomExport/CustomExportAdis.py index d8b845f3..d2364ac6 100644 --- a/src/View/Results/CustomExport/CustomExportAdis.py +++ b/src/View/Results/CustomExport/CustomExportAdis.py @@ -1,5 +1,5 @@ -# CustomPlotValuesSelectionDialog.py -- Pamhyr -# Copyright (C) 2023-2024 INRAE +# CustomExportAdis.py -- Pamhyr +# Copyright (C) 2023-2025 INRAE # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/src/View/Results/Window.py b/src/View/Results/Window.py index ccdd131c..ab3d58e9 100644 --- a/src/View/Results/Window.py +++ b/src/View/Results/Window.py @@ -59,6 +59,7 @@ from View.Results.CustomPlot.Plot import CustomPlot from View.Results.CustomPlot.CustomPlotValuesSelectionDialog import ( CustomPlotValuesSelectionDialog, ) +from View.Results.CustomExport.CustomExport import CustomExportDialog from View.Results.Table import TableModel from View.Results.translate import ( @@ -665,9 +666,9 @@ class ResultsWindow(PamhyrWindow): def _export(self): - dlg = CustomPlotValuesSelectionDialog(parent=self) + dlg = CustomExportDialog(parent=self) if dlg.exec(): - x, y, envelop = dlg.value + x, y, envelop, solver_id = dlg.value else: return @@ -677,26 +678,26 @@ class ResultsWindow(PamhyrWindow): ) self.file_dialog( select_file="AnyFile", - callback=lambda f: self.export_to(f[0], x, y, envelop), + callback=lambda f: self.export_to(f[0], x, y, envelop, solver_id), default_suffix=".csv", file_filter=["CSV (*.csv)"], ) - def export_to(self, filename, x, y, envelop): - results = self._results[self._current_results[0]] + def export_to(self, filename, x, y, envelop, solver_id): + results = self._results[solver_id] reach = results.river.reachs[self._get_current_reach()] first_line = [f"Study: {results.study.name}", f"Reach: {reach.name}"] if x == "rk": timestamp = self._get_current_timestamp() first_line.append(f"Time: {timestamp}s") - val_dict = self._export_rk(timestamp, y, envelop) + val_dict = self._export_rk(timestamp, y, envelop, solver_id) elif x == "time": profile_id = self._get_current_profile() profile = reach.profile(profile_id) pname = profile.name if profile.name != "" else profile.rk first_line.append(f"Profile: {pname}") - val_dict = self._export_time(profile_id, y) + val_dict = self._export_time(profile_id, y, solver_id) with open(filename, 'w', newline='') as csvfile: writer = csv.writer(csvfile, delimiter=',', @@ -752,8 +753,8 @@ class ResultsWindow(PamhyrWindow): self._additional_plot.pop(tab_widget.tabText(index)) tab_widget.removeTab(index) - def _export_rk(self, timestamp, y, envelop): - results = self._results[self._current_results[0]] + def _export_rk(self, timestamp, y, envelop, solver_id): + results = self._results[solver_id] reach = results.river.reachs[self._get_current_reach()] dict_x = self._trad.get_dict("values_x") dict_y = self._trad.get_dict("values_y") @@ -997,8 +998,8 @@ class ResultsWindow(PamhyrWindow): return my_dict - def _export_time(self, profile, y): - results = self._results[self._current_results[0]] + def _export_time(self, profile, y, solver_id): + results = self._results[solver_id] reach = results.river.reachs[self._get_current_reach()] profile = reach.profile(profile) dict_x = self._trad.get_dict("values_x") diff --git a/src/View/Results/translate.py b/src/View/Results/translate.py index a2903b96..834369dc 100644 --- a/src/View/Results/translate.py +++ b/src/View/Results/translate.py @@ -42,7 +42,8 @@ class ResultsTranslate(MainTranslate): self._dict['day'] = _translate("Results", "day") self._dict['days'] = _translate("Results", "days") - self._dict['envelop'] = _translate("Results", "envelop") + self._dict['envelop'] = _translate("Results", "Envelop") + self._dict['solver'] = _translate("Results", "Solver") self._dict['x'] = _translate("Results", "X (m)") @@ -67,7 +68,7 @@ class ResultsTranslate(MainTranslate): } self._sub_dict["table_headers_solver"] = { - "solver": _translate("Results", "Solver"), + "solver": self._dict['solver'], } self._sub_dict["table_headers_pollutants"] = { -- GitLab