mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
Compare commits
4
Commits
f93e6a7d7c
...
5a195e2822
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5a195e2822 | ||
|
|
63592b91a9 | ||
|
|
88345c58a7 | ||
|
|
7124b2b61c |
No files matched your search
@@ -253,12 +253,21 @@ class Ensemble(SQLSubModel):
|
|||||||
self._target_data = target_data
|
self._target_data = target_data
|
||||||
self._status.modified()
|
self._status.modified()
|
||||||
|
|
||||||
def get_data_dict(self):
|
def get_data_dict(self, use_ids=False):
|
||||||
|
target_data = self.target_data
|
||||||
|
distribution = self.distribution
|
||||||
|
|
||||||
|
if use_ids:
|
||||||
|
if self.target_data:
|
||||||
|
target_data = self.target_data.pamhyr_id
|
||||||
|
if self.distribution:
|
||||||
|
distribution = self.distribution.name
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"name": self.name,
|
"name": self.name,
|
||||||
"data_type": self.data_type,
|
"data_type": self.data_type,
|
||||||
"target_data": self.target_data,
|
"target_data": target_data,
|
||||||
"distribution": self.distribution,
|
"distribution": distribution,
|
||||||
"params": self.params,
|
"params": self.params,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,3 +51,12 @@ class EnsembleList(PamhyrModelList):
|
|||||||
self._lst.insert(index, r)
|
self._lst.insert(index, r)
|
||||||
self._status.modified()
|
self._status.modified()
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
def new_with_data(self, index, data):
|
||||||
|
r = Ensemble(status=self._status)
|
||||||
|
|
||||||
|
r.set_data_dict(data)
|
||||||
|
|
||||||
|
self._lst.insert(index, r)
|
||||||
|
self._status.modified()
|
||||||
|
return r
|
||||||
+1
-1
@@ -707,7 +707,7 @@ class Study(SQLModel):
|
|||||||
if switch:
|
if switch:
|
||||||
self.status.scenario = new
|
self.status.scenario = new
|
||||||
|
|
||||||
self.status.set_as_editable()
|
self.status.set_as_read_only()
|
||||||
return new
|
return new
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|||||||
@@ -114,6 +114,33 @@ class AddCommand(QUndoCommand):
|
|||||||
else:
|
else:
|
||||||
self._ensembles.insert(self._index, self._new)
|
self._ensembles.insert(self._index, self._new)
|
||||||
|
|
||||||
|
class ImportCommand(QUndoCommand):
|
||||||
|
def __init__(self, ensembles, data, index):
|
||||||
|
QUndoCommand.__init__(self)
|
||||||
|
|
||||||
|
self._ensembles = ensembles
|
||||||
|
self._index = index
|
||||||
|
self._data = data
|
||||||
|
self._news = None
|
||||||
|
|
||||||
|
def undo(self):
|
||||||
|
for new in self._news:
|
||||||
|
new.set_as_deleted()
|
||||||
|
|
||||||
|
def redo(self):
|
||||||
|
if self._news is None:
|
||||||
|
self._news = list(
|
||||||
|
map(
|
||||||
|
lambda d: self._ensembles.new_with_data(
|
||||||
|
self._index, d
|
||||||
|
),
|
||||||
|
self._data,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
for new in self._news:
|
||||||
|
new.set_as_not_deleted()
|
||||||
|
|
||||||
|
|
||||||
class DelCommand(QUndoCommand):
|
class DelCommand(QUndoCommand):
|
||||||
def __init__(self, ensembles, rows):
|
def __init__(self, ensembles, rows):
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
import json
|
||||||
|
|
||||||
from tools import trace, timer, logger_exception
|
from tools import trace, timer, logger_exception
|
||||||
|
|
||||||
@@ -47,7 +48,7 @@ from View.Ensembles.Table import (
|
|||||||
EnsembleTableModel, ComboBoxDelegate
|
EnsembleTableModel, ComboBoxDelegate
|
||||||
)
|
)
|
||||||
from View.Ensembles.Translate import EnsemblesTranslate
|
from View.Ensembles.Translate import EnsemblesTranslate
|
||||||
from View.Ensembles.UndoCommand import SetAllCommand
|
from View.Ensembles.UndoCommand import SetAllCommand, ImportCommand
|
||||||
|
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
|
|
||||||
@@ -140,6 +141,12 @@ class EnsemblesWindow(PamhyrWindow):
|
|||||||
self.find(QAction, "action_add").triggered.connect(self.add)
|
self.find(QAction, "action_add").triggered.connect(self.add)
|
||||||
self.find(QAction, "action_del").triggered.connect(self.delete)
|
self.find(QAction, "action_del").triggered.connect(self.delete)
|
||||||
self.find(QAction, "action_edit").triggered.connect(self.edit)
|
self.find(QAction, "action_edit").triggered.connect(self.edit)
|
||||||
|
self.find(QAction, "action_export").triggered.connect(
|
||||||
|
self.export_to_json
|
||||||
|
)
|
||||||
|
self.find(QAction, "action_import").triggered.connect(
|
||||||
|
self.import_from_json
|
||||||
|
)
|
||||||
|
|
||||||
table = self.find(QTableView, f"tableView")
|
table = self.find(QTableView, f"tableView")
|
||||||
table.selectionModel()\
|
table.selectionModel()\
|
||||||
@@ -204,6 +211,75 @@ class EnsemblesWindow(PamhyrWindow):
|
|||||||
logger_exception(e)
|
logger_exception(e)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def export_to_json(self):
|
||||||
|
ens = []
|
||||||
|
for e in self._ensembles.lst:
|
||||||
|
ens.append(e.get_data_dict(use_ids=True))
|
||||||
|
|
||||||
|
data = {"ensembles" : ens}
|
||||||
|
|
||||||
|
def aux(filename):
|
||||||
|
with open(filename[0], 'w') as f:
|
||||||
|
f.write(json.dumps(data))
|
||||||
|
|
||||||
|
self.file_dialog(
|
||||||
|
select_file=None,
|
||||||
|
callback=aux,
|
||||||
|
default_suffix='.json',
|
||||||
|
file_filter=[self._trad["file_json"]]
|
||||||
|
)
|
||||||
|
|
||||||
|
def import_from_json(self):
|
||||||
|
def aux(filename):
|
||||||
|
with open(filename[0], 'r') as f:
|
||||||
|
return json.load(f)
|
||||||
|
|
||||||
|
data = self.file_dialog(
|
||||||
|
select_file=None,
|
||||||
|
callback=aux,
|
||||||
|
default_suffix='.json',
|
||||||
|
file_filter=[self._trad["file_json"]]
|
||||||
|
)
|
||||||
|
|
||||||
|
dtarget = dict(
|
||||||
|
map(
|
||||||
|
lambda s: (s.pamhyr_id, s),
|
||||||
|
self._study.river.stricklers.stricklers
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
ddistr = dict(
|
||||||
|
map(
|
||||||
|
lambda d: (d.name, d),
|
||||||
|
self._study._ens_distributions.lst
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
def update(d, values):
|
||||||
|
d.update(values)
|
||||||
|
return d
|
||||||
|
|
||||||
|
updated = list(
|
||||||
|
map(
|
||||||
|
lambda d: update(
|
||||||
|
d, {"target_data": dtarget[d["target_data"]]}
|
||||||
|
),
|
||||||
|
map(
|
||||||
|
lambda d: update(
|
||||||
|
d, {"distribution": ddistr[d["distribution"]]}
|
||||||
|
),
|
||||||
|
data["ensembles"]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
self._undo_stack.push(
|
||||||
|
ImportCommand(
|
||||||
|
self._ensembles, updated, 0
|
||||||
|
)
|
||||||
|
)
|
||||||
|
self._table.update()
|
||||||
|
|
||||||
|
|
||||||
class Ensemble1ParamsDialog(PamhyrDialog):
|
class Ensemble1ParamsDialog(PamhyrDialog):
|
||||||
_pamhyr_ui = "Ensemble1ParamsDialog"
|
_pamhyr_ui = "Ensemble1ParamsDialog"
|
||||||
|
|||||||
@@ -26,10 +26,13 @@ from View.Results.translate import ResultsTranslate
|
|||||||
|
|
||||||
|
|
||||||
class CustomExportDialog(PamhyrDialog):
|
class CustomExportDialog(PamhyrDialog):
|
||||||
_pamhyr_ui = "CustomExportAdisDialog"
|
_pamhyr_ui = "CustomExportDialog"
|
||||||
_pamhyr_name = "Custom Plot Selection"
|
_pamhyr_name = "Custom Export"
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self,
|
||||||
|
tag_x="values_x",
|
||||||
|
tag_y="values_y",
|
||||||
|
parent=None):
|
||||||
trad = ResultsTranslate()
|
trad = ResultsTranslate()
|
||||||
super(CustomExportDialog, self).__init__(
|
super(CustomExportDialog, self).__init__(
|
||||||
title=trad[self._pamhyr_name],
|
title=trad[self._pamhyr_name],
|
||||||
@@ -38,8 +41,8 @@ class CustomExportDialog(PamhyrDialog):
|
|||||||
parent=parent
|
parent=parent
|
||||||
)
|
)
|
||||||
|
|
||||||
self._available_values_x = self._trad.get_dict("values_x")
|
self._available_values_x = self._trad.get_dict(tag_x)
|
||||||
self._available_values_y = self._trad.get_dict("values_y")
|
self._available_values_y = self._trad.get_dict(tag_y)
|
||||||
|
|
||||||
self.setup_radio_buttons_x()
|
self.setup_radio_buttons_x()
|
||||||
self.setup_radio_buttons_res()
|
self.setup_radio_buttons_res()
|
||||||
@@ -66,8 +69,8 @@ class CustomExportDialog(PamhyrDialog):
|
|||||||
|
|
||||||
def setup_radio_buttons_res(self):
|
def setup_radio_buttons_res(self):
|
||||||
self._radio2 = []
|
self._radio2 = []
|
||||||
layout = self.find(QVBoxLayout, "verticalLayout_pol")
|
layout = self.find(QVBoxLayout, "verticalLayout_solv")
|
||||||
label = self.find(QLabel, "label_3")
|
label = self.find(QLabel, "label_solv")
|
||||||
label.setText(self._trad["solver"])
|
label.setText(self._trad["solver"])
|
||||||
|
|
||||||
for solver in self.parent._solvers:
|
for solver in self.parent._solvers:
|
||||||
@@ -89,7 +92,7 @@ class CustomExportDialog(PamhyrDialog):
|
|||||||
layout.addStretch()
|
layout.addStretch()
|
||||||
|
|
||||||
def setup_label(self):
|
def setup_label(self):
|
||||||
self._label = self.find(QLabel, "label_4")
|
self._label = self.find(QLabel, "label_data")
|
||||||
self._label.setFrameStyle(QFrame.StyledPanel)
|
self._label.setFrameStyle(QFrame.StyledPanel)
|
||||||
self._label.setStyleSheet('background-color: white')
|
self._label.setStyleSheet('background-color: white')
|
||||||
self.set_label()
|
self.set_label()
|
||||||
@@ -163,6 +166,15 @@ class CustomExportDialog(PamhyrDialog):
|
|||||||
res = i
|
res = i
|
||||||
break
|
break
|
||||||
|
|
||||||
self.value = x, y, self._envelop.isChecked(), res
|
self.value = (x, y, self._envelop.isChecked(), res)
|
||||||
|
|
||||||
super().accept()
|
super().accept()
|
||||||
|
|
||||||
|
|
||||||
|
class CustomExportEnsembleDialog(CustomExportDialog):
|
||||||
|
def __init__(self, parent=None):
|
||||||
|
super(CustomExportEnsembleDialog, self).__init__(
|
||||||
|
tag_x="values_x_ens",
|
||||||
|
tag_y="values_y_ens",
|
||||||
|
parent=parent
|
||||||
|
)
|
||||||
+207
-9
@@ -79,7 +79,9 @@ from View.Results.CustomPlot.Plot import CustomPlot
|
|||||||
from View.Results.CustomPlot.CustomPlotValuesSelectionDialog import (
|
from View.Results.CustomPlot.CustomPlotValuesSelectionDialog import (
|
||||||
CustomPlotValuesSelectionDialog,
|
CustomPlotValuesSelectionDialog,
|
||||||
)
|
)
|
||||||
from View.Results.CustomExport.CustomExport import CustomExportDialog
|
from View.Results.CustomExport.CustomExport import (
|
||||||
|
CustomExportDialog, CustomExportEnsembleDialog,
|
||||||
|
)
|
||||||
|
|
||||||
from View.Results.Table import TableModel
|
from View.Results.Table import TableModel
|
||||||
from View.Results.translate import (
|
from View.Results.translate import (
|
||||||
@@ -786,34 +788,47 @@ class ResultsWindow(PamhyrWindow):
|
|||||||
def export_to(self, filename, x, y, envelop, solver_id):
|
def export_to(self, filename, x, y, envelop, solver_id):
|
||||||
results = self._results[solver_id]
|
results = self._results[solver_id]
|
||||||
reach = results.river.reachs[self._get_current_reach()]
|
reach = results.river.reachs[self._get_current_reach()]
|
||||||
first_line = [f"Study: {results.study.name}",
|
first_line = [
|
||||||
f"Reach: {reach.name}"]
|
f"Study: {results.study.name}",
|
||||||
|
f"Reach: {reach.name}"
|
||||||
|
]
|
||||||
|
|
||||||
if x == "rk":
|
if x == "rk":
|
||||||
timestamp = self._get_current_timestamp()
|
timestamp = self._get_current_timestamp()
|
||||||
|
|
||||||
first_line.append(f"Time: {timestamp}s")
|
first_line.append(f"Time: {timestamp}s")
|
||||||
val_dict = self._export_rk(timestamp, y, envelop, solver_id)
|
val_dict = self._export_rk(timestamp, y, envelop, solver_id)
|
||||||
elif x == "time":
|
elif x == "time":
|
||||||
profile_id = self._get_current_profile()
|
profile_id = self._get_current_profile()
|
||||||
profile = reach.profile(profile_id)
|
profile = reach.profile(profile_id)
|
||||||
pname = profile.name if profile.name != "" else profile.rk
|
pname = profile.name if profile.name != "" else profile.rk
|
||||||
|
|
||||||
first_line.append(f"Profile: {pname}")
|
first_line.append(f"Profile: {pname}")
|
||||||
val_dict = self._export_time(profile_id, y, solver_id)
|
val_dict = self._export_time(profile_id, y, solver_id)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(filename, 'w', newline='') as csvfile:
|
with open(filename, 'w', newline='') as csvfile:
|
||||||
writer = csv.writer(csvfile, delimiter=',',
|
writer = csv.writer(csvfile, delimiter=',',
|
||||||
quotechar='|', quoting=csv.QUOTE_MINIMAL)
|
quotechar='|',
|
||||||
|
quoting=csv.QUOTE_MINIMAL)
|
||||||
dict_x = self._trad.get_dict("values_x")
|
dict_x = self._trad.get_dict("values_x")
|
||||||
header = []
|
header = []
|
||||||
|
|
||||||
writer.writerow(first_line)
|
writer.writerow(first_line)
|
||||||
|
|
||||||
for text in val_dict.keys():
|
for text in val_dict.keys():
|
||||||
header.append(text)
|
header.append(text)
|
||||||
|
|
||||||
writer.writerow(header)
|
writer.writerow(header)
|
||||||
|
|
||||||
for row in range(len(val_dict[dict_x[x]])):
|
for row in range(len(val_dict[dict_x[x]])):
|
||||||
line = []
|
line = []
|
||||||
|
|
||||||
for var in val_dict.keys():
|
for var in val_dict.keys():
|
||||||
line.append(val_dict[var][row])
|
line.append(val_dict[var][row])
|
||||||
|
|
||||||
writer.writerow(line)
|
writer.writerow(line)
|
||||||
|
|
||||||
self._timer.stop()
|
self._timer.stop()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.message_box(
|
self.message_box(
|
||||||
@@ -913,11 +928,11 @@ class ResultsWindow(PamhyrWindow):
|
|||||||
|
|
||||||
# Translate dictionary keys
|
# Translate dictionary keys
|
||||||
translated_dict = {}
|
translated_dict = {}
|
||||||
|
translated_dict[dict_x["rk"]] = reach.geometry.get_rk()
|
||||||
|
|
||||||
for key in my_dict:
|
for key in my_dict:
|
||||||
translated_dict[dict_y[key]] = my_dict[key]
|
translated_dict[dict_y[key]] = my_dict[key]
|
||||||
|
|
||||||
translated_dict[dict_x["rk"]] = reach.geometry.get_rk()
|
|
||||||
|
|
||||||
return translated_dict
|
return translated_dict
|
||||||
|
|
||||||
def _export_rk_compute_elevation(self, data):
|
def _export_rk_compute_elevation(self, data):
|
||||||
@@ -1087,16 +1102,16 @@ class ResultsWindow(PamhyrWindow):
|
|||||||
|
|
||||||
# Translate dictionary keys
|
# Translate dictionary keys
|
||||||
translated_dict = {}
|
translated_dict = {}
|
||||||
|
translated_dict[dict_x["time"]] = self._timestamps
|
||||||
|
|
||||||
for key in my_dict:
|
for key in my_dict:
|
||||||
translated_dict[dict_y[key]] = my_dict[key]
|
translated_dict[dict_y[key]] = my_dict[key]
|
||||||
|
|
||||||
translated_dict[dict_x["time"]] = self._timestamps
|
|
||||||
|
|
||||||
return translated_dict
|
return translated_dict
|
||||||
|
|
||||||
def _export_time_compute_elevation(self, data):
|
def _export_time_compute_elevation(self, data):
|
||||||
my_dict = data["my_dict"]
|
my_dict = data["my_dict"]
|
||||||
reach = data["reach"]
|
profile = data["profile"]
|
||||||
|
|
||||||
if reach.has_bedload():
|
if reach.has_bedload():
|
||||||
z_min = data["zfd"]
|
z_min = data["zfd"]
|
||||||
@@ -1537,3 +1552,186 @@ class ResultsEnsembleWindow(ResultsWindow):
|
|||||||
|
|
||||||
def update_table_selection_solver(self, ind):
|
def update_table_selection_solver(self, ind):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def _export(self):
|
||||||
|
profile_id = self._get_current_profile()
|
||||||
|
self.update_table_selection_profile(profile_id)
|
||||||
|
|
||||||
|
dlg = CustomExportEnsembleDialog(parent=self)
|
||||||
|
if dlg.exec():
|
||||||
|
x, y, envelop, solver_id = dlg.value
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
|
logger.debug(
|
||||||
|
"Export custom plot for: " +
|
||||||
|
f"{x} -> {','.join(y)}"
|
||||||
|
)
|
||||||
|
self.file_dialog(
|
||||||
|
select_file="AnyFile",
|
||||||
|
callback=lambda f: self.export_to(f[0], x, y, envelop, solver_id),
|
||||||
|
default_suffix=".csv",
|
||||||
|
file_filter=[self._trad["file_csv"]],
|
||||||
|
)
|
||||||
|
|
||||||
|
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_ens")
|
||||||
|
dict_y = self._trad.get_dict("values_y_ens")
|
||||||
|
|
||||||
|
if envelop:
|
||||||
|
dict_y.update(self._trad.get_dict("values_y_envelop_ens"))
|
||||||
|
|
||||||
|
table = results.get("table")
|
||||||
|
id_ts = results.get_timestamp_id(timestamp)
|
||||||
|
|
||||||
|
ind = reach.global_index
|
||||||
|
|
||||||
|
my_dict = {}
|
||||||
|
data = {
|
||||||
|
"z_min": table["z_min"][:, ind[0]:ind[1]+1],
|
||||||
|
"q_min": table["q_min"][:, ind[0]:ind[1]+1],
|
||||||
|
"z": table["z_mean"][:, ind[0]:ind[1]+1],
|
||||||
|
"q": table["q_mean"][:, ind[0]:ind[1]+1],
|
||||||
|
"z_max": table["z_max"][:, ind[0]:ind[1]+1],
|
||||||
|
"q_max": table["q_max"][:, ind[0]:ind[1]+1],
|
||||||
|
|
||||||
|
"z_std_deriv": table["z_std_derivation"][:, ind[0]:ind[1]+1],
|
||||||
|
"q_std_deriv": table["q_std_derivation"][:, ind[0]:ind[1]+1],
|
||||||
|
|
||||||
|
"reach": reach,
|
||||||
|
"id_ts": id_ts, "envelop": envelop,
|
||||||
|
"my_dict": my_dict,
|
||||||
|
}
|
||||||
|
|
||||||
|
func = {
|
||||||
|
"z_mean": self._export_rk_z,
|
||||||
|
"q_mean": self._export_rk_q,
|
||||||
|
"z_standard_derivation": self._export_rk_z_std_deriv,
|
||||||
|
"q_standard_derivation": self._export_rk_q_std_deriv,
|
||||||
|
}
|
||||||
|
|
||||||
|
# Compute values
|
||||||
|
for key in y:
|
||||||
|
func[key](data)
|
||||||
|
|
||||||
|
# Translate dictionary keys
|
||||||
|
translated_dict = {}
|
||||||
|
translated_dict[dict_x["rk"]] = reach.geometry.get_rk()
|
||||||
|
|
||||||
|
for key in my_dict:
|
||||||
|
translated_dict[dict_y[key]] = my_dict[key]
|
||||||
|
|
||||||
|
return translated_dict
|
||||||
|
|
||||||
|
def _export_rk_z(self, data):
|
||||||
|
my_dict = data["my_dict"]
|
||||||
|
envelop = data["envelop"]
|
||||||
|
reach = data["reach"]
|
||||||
|
id_ts = data["id_ts"]
|
||||||
|
|
||||||
|
my_dict["z_mean"] = data["z"][id_ts, :]
|
||||||
|
|
||||||
|
if envelop:
|
||||||
|
my_dict["z_min"] = data["z_min"][id_ts, :]
|
||||||
|
my_dict["z_max"] = data["z_max"][id_ts, :]
|
||||||
|
|
||||||
|
def _export_rk_z_std_deriv(self, data):
|
||||||
|
my_dict = data["my_dict"]
|
||||||
|
envelop = data["envelop"]
|
||||||
|
reach = data["reach"]
|
||||||
|
id_ts = data["id_ts"]
|
||||||
|
|
||||||
|
my_dict["z_standard_derivation"] = data["z_std_deriv"][id_ts, :]
|
||||||
|
|
||||||
|
def _export_rk_q(self, data):
|
||||||
|
my_dict = data["my_dict"]
|
||||||
|
envelop = data["envelop"]
|
||||||
|
reach = data["reach"]
|
||||||
|
id_ts = data["id_ts"]
|
||||||
|
|
||||||
|
my_dict["q_mean"] = data["q"][id_ts, :]
|
||||||
|
|
||||||
|
if envelop:
|
||||||
|
my_dict["q_min"] = data["q_min"][id_ts, :]
|
||||||
|
my_dict["q_max"] = data["q_max"][id_ts, :]
|
||||||
|
|
||||||
|
def _export_rk_q_std_deriv(self, data):
|
||||||
|
my_dict = data["my_dict"]
|
||||||
|
envelop = data["envelop"]
|
||||||
|
reach = data["reach"]
|
||||||
|
id_ts = data["id_ts"]
|
||||||
|
|
||||||
|
my_dict["q_standard_derivation"] = data["q_std_deriv"][id_ts, :]
|
||||||
|
|
||||||
|
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")
|
||||||
|
dict_y = self._trad.get_dict("values_y")
|
||||||
|
|
||||||
|
table = results.get("table")
|
||||||
|
ind = profile.global_index
|
||||||
|
|
||||||
|
my_dict = {}
|
||||||
|
data = {
|
||||||
|
"z_min": table["z_min"][:, ind],
|
||||||
|
"q_min": table["q_min"][:, ind],
|
||||||
|
"z": table["z_mean"][:, ind],
|
||||||
|
"q": table["q_mean"][:, ind],
|
||||||
|
"z_max": table["z_max"][:, ind],
|
||||||
|
"q_max": table["q_max"][:, ind],
|
||||||
|
|
||||||
|
"z": table["z_std_derivation"][:, ind],
|
||||||
|
"q": table["q_std_derivation"][:, ind],
|
||||||
|
|
||||||
|
"reach": reach,
|
||||||
|
"profile": profile,
|
||||||
|
"my_dict": my_dict,
|
||||||
|
}
|
||||||
|
|
||||||
|
func = {
|
||||||
|
"z_mean": self._export_time_z,
|
||||||
|
"q_mean": self._export_time_q,
|
||||||
|
"z_standard_derivation": self._export_time_z_std_deriv,
|
||||||
|
"q_standard_derivation": self._export_time_q_std_deriv,
|
||||||
|
}
|
||||||
|
|
||||||
|
# Compute values
|
||||||
|
for key in y:
|
||||||
|
func[key](data)
|
||||||
|
|
||||||
|
# Translate dictionary keys
|
||||||
|
translated_dict = {}
|
||||||
|
translated_dict[dict_x["time"]] = self._timestamps
|
||||||
|
|
||||||
|
for key in my_dict:
|
||||||
|
translated_dict[dict_y[key]] = my_dict[key]
|
||||||
|
|
||||||
|
return translated_dict
|
||||||
|
|
||||||
|
def _export_time_z(self, data):
|
||||||
|
my_dict = data["my_dict"]
|
||||||
|
|
||||||
|
my_dict["z_mean"] = data["z"]
|
||||||
|
my_dict["z_min"] = data["z_min"]
|
||||||
|
my_dict["z_max"] = data["z_max"]
|
||||||
|
|
||||||
|
def _export_time_z_std_deriv(self, data):
|
||||||
|
my_dict = data["my_dict"]
|
||||||
|
|
||||||
|
my_dict["z_standard_derivation"] = data["z_std_deriv"]
|
||||||
|
|
||||||
|
def _export_time_q(self, data):
|
||||||
|
my_dict = data["my_dict"]
|
||||||
|
|
||||||
|
my_dict["q_mean"] = data["q"]
|
||||||
|
my_dict["q_min"] = data["q_min"]
|
||||||
|
my_dict["q_max"] = data["q_max"]
|
||||||
|
|
||||||
|
def _export_time_q_std_deriv(self, data):
|
||||||
|
my_dict = data["my_dict"]
|
||||||
|
|
||||||
|
my_dict["q_standard_derivation"] = data["q_std_deriv"]
|
||||||
@@ -130,6 +130,25 @@ class ResultsTranslate(MainTranslate):
|
|||||||
"wet_area": self._dict["unit_wet_area"],
|
"wet_area": self._dict["unit_wet_area"],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self._sub_dict["values_x_ens"] = {
|
||||||
|
"rk": self._dict["unit_rk"],
|
||||||
|
"time": self._dict["unit_time_s"],
|
||||||
|
}
|
||||||
|
|
||||||
|
self._sub_dict["values_y_ens"] = {
|
||||||
|
"z_mean": self._dict["unit_mean_water_elevation"],
|
||||||
|
"q_mean": self._dict["unit_mean_discharge"],
|
||||||
|
"z_standard_derivation": self._dict["unit_std_deriv_elevation"],
|
||||||
|
"q_standard_derivation": self._dict["unit_std_deriv_discharge"],
|
||||||
|
}
|
||||||
|
|
||||||
|
self._sub_dict["values_y_envelop_ens"] = {
|
||||||
|
"z_min": self._dict["unit_min_water_elevation"],
|
||||||
|
"z_max": self._dict["unit_max_water_elevation"],
|
||||||
|
"q_min": self._dict["unit_min_discharge"],
|
||||||
|
"q_max": self._dict["unit_max_discharge"],
|
||||||
|
}
|
||||||
|
|
||||||
if self.pollutants is not None:
|
if self.pollutants is not None:
|
||||||
self._sub_dict["table_headers_raw_data"] = {
|
self._sub_dict["table_headers_raw_data"] = {
|
||||||
"name": _translate("Results", "Profile"),
|
"name": _translate("Results", "Profile"),
|
||||||
@@ -157,7 +176,7 @@ class ResultsTranslate(MainTranslate):
|
|||||||
"max_velocity": self._dict["unit_max_velocity"],
|
"max_velocity": self._dict["unit_max_velocity"],
|
||||||
"min_depth": self._dict["unit_min_depth"],
|
"min_depth": self._dict["unit_min_depth"],
|
||||||
"max_depth": self._dict["unit_max_depth"],
|
"max_depth": self._dict["unit_max_depth"],
|
||||||
}
|
}
|
||||||
|
|
||||||
self._sub_dict["values_y_pol"] = {
|
self._sub_dict["values_y_pol"] = {
|
||||||
"unit_C": self._dict["unit_concentration"],
|
"unit_C": self._dict["unit_concentration"],
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ class WindowToolKit(object):
|
|||||||
|
|
||||||
dialog = QFileDialog(self, options=options)
|
dialog = QFileDialog(self, options=options)
|
||||||
|
|
||||||
if select_file == "Existing_file":
|
if select_file == "ExistingFile":
|
||||||
mode = QFileDialog.FileMode.ExistingFile
|
mode = QFileDialog.FileMode.ExistingFile
|
||||||
elif select_file == "Directory":
|
elif select_file == "Directory":
|
||||||
mode = QFileDialog.FileMode.Directory
|
mode = QFileDialog.FileMode.Directory
|
||||||
|
|||||||
+19
-2
@@ -72,6 +72,9 @@ class CommonWordTranslate(PamhyrTranslate):
|
|||||||
self._dict["file_csv"] = _translate(
|
self._dict["file_csv"] = _translate(
|
||||||
"CommonWord", "CSV file (*.csv)"
|
"CommonWord", "CSV file (*.csv)"
|
||||||
)
|
)
|
||||||
|
self._dict["file_json"] = _translate(
|
||||||
|
"CommonWord", "JSON file (*.json)"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class UnitTranslate(CommonWordTranslate):
|
class UnitTranslate(CommonWordTranslate):
|
||||||
@@ -110,6 +113,12 @@ class UnitTranslate(CommonWordTranslate):
|
|||||||
self._dict["unit_water_elevation"] = _translate(
|
self._dict["unit_water_elevation"] = _translate(
|
||||||
"Unit", "Water Elevation (m)"
|
"Unit", "Water Elevation (m)"
|
||||||
)
|
)
|
||||||
|
self._dict["unit_mean_water_elevation"] = _translate(
|
||||||
|
"Unit", "Mean water elevation (m)"
|
||||||
|
)
|
||||||
|
self._dict["unit_std_deriv_elevation"] = _translate(
|
||||||
|
"Unit", "Elevation standard derivation (m)"
|
||||||
|
)
|
||||||
self._dict["unit_water_elevation_envelop"] = _translate(
|
self._dict["unit_water_elevation_envelop"] = _translate(
|
||||||
"Unit", "Water Elevation Envelop (m)"
|
"Unit", "Water Elevation Envelop (m)"
|
||||||
)
|
)
|
||||||
@@ -129,8 +138,16 @@ class UnitTranslate(CommonWordTranslate):
|
|||||||
self._dict["unit_min_velocity"] = _translate(
|
self._dict["unit_min_velocity"] = _translate(
|
||||||
"Unit", "Min Velocity (m/s)"
|
"Unit", "Min Velocity (m/s)"
|
||||||
)
|
)
|
||||||
self._dict["unit_discharge"] = _translate(
|
self._dict["unit_discharge"] = (
|
||||||
"Unit", "Discharge") + f" (m³/s)"
|
_translate("Unit", "Discharge") + f" (m³/s)"
|
||||||
|
)
|
||||||
|
self._dict["unit_mean_discharge"] = (
|
||||||
|
_translate("Unit", "Mean discharge") + f" (m³/s)"
|
||||||
|
)
|
||||||
|
self._dict["unit_std_deriv_discharge"] = (
|
||||||
|
_translate("Unit", "Discharge standard derivation")
|
||||||
|
+ f" (m³/s)"
|
||||||
|
)
|
||||||
self._dict["unit_discharge_envelop"] = _translate(
|
self._dict["unit_discharge_envelop"] = _translate(
|
||||||
"Unit", "Discharge Envelop") + " (m³/s)"
|
"Unit", "Discharge Envelop") + " (m³/s)"
|
||||||
self._dict["unit_max_discharge"] = _translate(
|
self._dict["unit_max_discharge"] = _translate(
|
||||||
|
|||||||
@@ -0,0 +1,111 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>Dialog</class>
|
||||||
|
<widget class="QDialog" name="Dialog">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>418</width>
|
||||||
|
<height>220</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Dialog</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QSplitter" name="splitter">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="verticalLayoutWidget">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_x">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_x">
|
||||||
|
<property name="text">
|
||||||
|
<string>X axis:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="verticalLayoutWidget_2">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_y">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_y">
|
||||||
|
<property name="text">
|
||||||
|
<string>Y axis:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="verticalLayoutWidget_3">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_solv">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_solv">
|
||||||
|
<property name="text">
|
||||||
|
<string>Solver:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="0">
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="0">
|
||||||
|
<widget class="QLabel" name="label_data">
|
||||||
|
<property name="text">
|
||||||
|
<string>TextLabel</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>Dialog</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>316</x>
|
||||||
|
<y>260</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>286</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>Dialog</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>248</x>
|
||||||
|
<y>254</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>157</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
||||||
@@ -33,6 +33,9 @@
|
|||||||
<addaction name="action_add"/>
|
<addaction name="action_add"/>
|
||||||
<addaction name="action_del"/>
|
<addaction name="action_del"/>
|
||||||
<addaction name="action_edit"/>
|
<addaction name="action_edit"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
|
<addaction name="action_export"/>
|
||||||
|
<addaction name="action_import"/>
|
||||||
</widget>
|
</widget>
|
||||||
<action name="action_add">
|
<action name="action_add">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
@@ -79,6 +82,30 @@
|
|||||||
<enum>QAction::NoRole</enum>
|
<enum>QAction::NoRole</enum>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="action_export">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset>
|
||||||
|
<normaloff>ressources/export.png</normaloff>ressources/export.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Export</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Export all ensemble configuration into json file</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="action_import">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset>
|
||||||
|
<normaloff>ressources/import.png</normaloff>ressources/import.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Import</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Import ensemble configuration from json file</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
|||||||
Reference in new issue
Block a user