mirror of https://gitlab.com/pamhyr/pamhyr2
work on export CSV compare results
parent
e4a31b3497
commit
ca8dc19c83
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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"] = {
|
||||
|
|
|
|||
Loading…
Reference in New Issue