mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
Compare commits
43
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7eb39e5896 | ||
|
|
28cc88b4b8 | ||
|
|
c9925cd03c | ||
|
|
40f9465929 | ||
|
|
359805b713 | ||
|
|
31565b9170 | ||
|
|
9c2a0541df | ||
|
|
38d7d587fa | ||
|
|
f19ab9455a | ||
|
|
cadffe40d6 | ||
|
|
5a195e2822 | ||
|
|
63592b91a9 | ||
|
|
88345c58a7 | ||
|
|
7124b2b61c | ||
|
|
f93e6a7d7c | ||
|
|
5d46401b85 | ||
|
|
97867080d9 | ||
|
|
93a4b44143 | ||
|
|
5e3e5628d2 | ||
|
|
4a6349cd9c | ||
|
|
e9c998fec8 | ||
|
|
290b8918fc | ||
|
|
0e6de5d0f0 | ||
|
|
98d30a326e | ||
|
|
5f64499984 | ||
|
|
6e32c740ae | ||
|
|
e0721715d0 | ||
|
|
10edc00973 | ||
|
|
f8829ce82c | ||
|
|
ac91b712a3 | ||
|
|
4bccbbac33 | ||
|
|
5c8b7290ba | ||
|
|
288713ce5b | ||
|
|
ff3b5a320c | ||
|
|
a2e0f6a517 | ||
|
|
7356e5dd30 | ||
|
|
933c6c1952 | ||
|
|
d8fd4488e2 | ||
|
|
fef2a2e979 | ||
|
|
f001dffb68 | ||
|
|
2818644b7f | ||
|
|
86d93fd702 | ||
|
|
593cc0c91b |
No files matched your search
@@ -1069,6 +1069,12 @@ gitlab-ci.
|
||||
sudo python3 -m pip install pyinstaller
|
||||
#+end_src
|
||||
|
||||
In addition, you must install Glab[fn:glab] to allow the runner to
|
||||
proceed with the publication.
|
||||
|
||||
[fn:glab] The Gitlab cli releases page:
|
||||
https://gitlab.com/gitlab-org/cli/-/releases
|
||||
|
||||
*** Windows (Wine) {{{windows}}}
|
||||
|
||||
The ci-runner environment for Wine need at least wine version 8, let
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 30 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 127 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
@@ -4,7 +4,7 @@ PyQt5-sip==12.18.0
|
||||
PyQtWebEngine==5.15.6
|
||||
QScintilla>=2.14.1
|
||||
pyqtgraph>=0.12.1
|
||||
matplotlib==3.8.3
|
||||
matplotlib==3.10.8
|
||||
numpy>=1.24.2
|
||||
colorama>=0.4.3
|
||||
pyinstaller>=5.11.0
|
||||
@@ -14,3 +14,4 @@ platformdirs>=4.2.0
|
||||
pyshp>=2.3.1
|
||||
rasterio==1.3.11
|
||||
#fortranformat==2.0.3
|
||||
psutil>=7.2.2
|
||||
+1
-1
@@ -4,7 +4,7 @@ PyQt5-sip==12.18.0
|
||||
#PyQtWebEngine==5.15.6
|
||||
QScintilla>=2.14.1
|
||||
pyqtgraph>=0.12.1
|
||||
matplotlib==3.8.3
|
||||
matplotlib==3.10.8
|
||||
numpy>=1.24.2
|
||||
colorama>=0.4.3
|
||||
pyinstaller>=5.11.0
|
||||
|
||||
@@ -45,6 +45,9 @@ class Distribution(SQLSubModel):
|
||||
self._type = "generic"
|
||||
self._script = script
|
||||
self._labels = []
|
||||
self._default_values = []
|
||||
self._params_checkers = []
|
||||
self._params_tips = []
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
@@ -54,6 +57,10 @@ class Distribution(SQLSubModel):
|
||||
def labels(self):
|
||||
return self._labels
|
||||
|
||||
@property
|
||||
def default_values(self):
|
||||
return self._default_values
|
||||
|
||||
@classmethod
|
||||
def _db_create(cls, execute, ext=""):
|
||||
execute(f"""
|
||||
@@ -140,13 +147,28 @@ class Distribution(SQLSubModel):
|
||||
if predicate(self, data):
|
||||
modifier(self, data)
|
||||
|
||||
def is_valid_parameters(self, parameters):
|
||||
valid = True
|
||||
tips = []
|
||||
|
||||
for i, checker in enumerate(self._params_checkers):
|
||||
ok = checker(parameters)
|
||||
if not ok:
|
||||
tips.append(self._params_tips[i])
|
||||
valid = False
|
||||
|
||||
return (valid, tips)
|
||||
|
||||
def check_params(self, params):
|
||||
return True
|
||||
|
||||
def random(self, r):
|
||||
raise NotImplementedMethodeError(cls, cls._load)
|
||||
|
||||
|
||||
###########################
|
||||
###############################
|
||||
# DISTRIBUTION IMPLEMENTATION #
|
||||
###########################
|
||||
###############################
|
||||
|
||||
class Uniform(Distribution):
|
||||
_sub_classes = []
|
||||
@@ -160,6 +182,12 @@ class Uniform(Distribution):
|
||||
)
|
||||
|
||||
self._labels = ["low", "high"]
|
||||
self._default_values = [20.0, 40.0]
|
||||
self._params_checkers = [self.check_params, self.check_params]
|
||||
self._params_tips = ["uniform_low_tips", "uniform_high_tips"]
|
||||
|
||||
def check_params(self, params):
|
||||
return (params[0] < params[1])
|
||||
|
||||
def random(self, params, nb):
|
||||
lst = params.copy()
|
||||
@@ -180,6 +208,12 @@ class Normal(Distribution):
|
||||
)
|
||||
|
||||
self._labels = ["loc", "scale"]
|
||||
self._default_values = [30.0, 5.0]
|
||||
self._params_checkers = [self.check_params, self.check_scale]
|
||||
self._params_tips = ["normal_loc_tips", "normal_scale_tips"]
|
||||
|
||||
def check_scale(self, params):
|
||||
return 0 <= params[1]
|
||||
|
||||
def random(self, params, nb):
|
||||
lst = params.copy()
|
||||
@@ -188,6 +222,37 @@ class Normal(Distribution):
|
||||
return np.random.normal(*lst)
|
||||
|
||||
|
||||
class Binomial(Distribution):
|
||||
_sub_classes = []
|
||||
|
||||
def __init__(self, id: int = -1,
|
||||
name: str = "binomial", script: str = "",
|
||||
status=None):
|
||||
super(Binomial, self).__init__(
|
||||
id=id, status=status,
|
||||
name=name, script=script
|
||||
)
|
||||
|
||||
self._labels = ["binomial_n", "binomial_p"]
|
||||
self._default_values = [100.0, 0.3]
|
||||
self._params_checkers = [self.check_n, self.check_p]
|
||||
self._params_tips = ["binomial_n_tips", "binomial_p_tips"]
|
||||
|
||||
def check_n(self, params):
|
||||
n = params[0]
|
||||
return (0 <= n) and (n == round(n))
|
||||
|
||||
def check_p(self, params):
|
||||
p = params[1]
|
||||
return 0 <= p <= 1
|
||||
|
||||
def random(self, params, nb):
|
||||
lst = params.copy()
|
||||
lst.append(nb)
|
||||
|
||||
return np.random.binomial(*lst)
|
||||
|
||||
|
||||
class Poisson(Distribution):
|
||||
_sub_classes = []
|
||||
|
||||
@@ -199,7 +264,14 @@ class Poisson(Distribution):
|
||||
name=name, script=script
|
||||
)
|
||||
|
||||
self._labels = ["lam"]
|
||||
self._labels = ["poisson_lam"]
|
||||
self._default_values = [5.0]
|
||||
self._params_checkers = [self.check_lam]
|
||||
self._params_tips = ["poisson_lam_tips"]
|
||||
|
||||
def check_lam(self, params):
|
||||
lam = params[0]
|
||||
return 0 <= lam
|
||||
|
||||
def random(self, params, nb):
|
||||
lst = params.copy()
|
||||
@@ -221,6 +293,9 @@ class Custom(Distribution):
|
||||
|
||||
self._labels = ["custom"]
|
||||
self._type = "custom"
|
||||
self._default_values = [""]
|
||||
self._params_checkers = [self.check_params]
|
||||
self._params_tips = ["custom_params_tips"]
|
||||
|
||||
def random(self, params, nb):
|
||||
try:
|
||||
|
||||
@@ -30,10 +30,12 @@ class DistributionList(PamhyrModelList):
|
||||
new = cls(status=data['status'])
|
||||
|
||||
# Default distributions
|
||||
d = {"status": data['status']}
|
||||
new._lst = [
|
||||
Uniform(status=data['status']),
|
||||
Normal(status=data['status']),
|
||||
Poisson(status=data['status']),
|
||||
Uniform(**d),
|
||||
Normal(**d),
|
||||
Binomial(**d),
|
||||
Poisson(**d),
|
||||
]
|
||||
|
||||
# DB custom distributions
|
||||
|
||||
@@ -252,3 +252,28 @@ class Ensemble(SQLSubModel):
|
||||
def target_data(self, target_data):
|
||||
self._target_data = target_data
|
||||
self._status.modified()
|
||||
|
||||
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 {
|
||||
"name": self.name,
|
||||
"data_type": self.data_type,
|
||||
"target_data": target_data,
|
||||
"distribution": distribution,
|
||||
"params": self.params,
|
||||
}
|
||||
|
||||
def set_data_dict(self, data):
|
||||
self.name = data["name"]
|
||||
self.data_type = data["data_type"]
|
||||
self.target_data = data["target_data"]
|
||||
self.distribution = data["distribution"]
|
||||
self.params = data["params"]
|
||||
@@ -51,3 +51,12 @@ class EnsembleList(PamhyrModelList):
|
||||
self._lst.insert(index, r)
|
||||
self._status.modified()
|
||||
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
|
||||
@@ -826,6 +826,13 @@ class ProfileXYZ(Profile, SQLSubModel):
|
||||
|
||||
return n_zones
|
||||
|
||||
def froude(self, z, v):
|
||||
return v / np.sqrt(
|
||||
9.81 * (
|
||||
self.wet_area(z) / self.wet_width(z)
|
||||
)
|
||||
)
|
||||
|
||||
@timer
|
||||
def get_all_water_limits_ac(self, z):
|
||||
"""
|
||||
|
||||
@@ -436,9 +436,11 @@ class Results(SQLSubModel):
|
||||
solver_name TEXT NOT NULL,
|
||||
solver_type TEXT NOT NULL,
|
||||
study_revision INTEGER NOT NULL,
|
||||
creation_data DATE NOT NULL,
|
||||
creation_date DATE NOT NULL,
|
||||
nb_timestamps INTEGER NOT NULL,
|
||||
timestamps BLOB NOT NULL,
|
||||
seed INTEGER,
|
||||
number_of_run INTEGER,
|
||||
{Scenario.create_db_add_scenario()},
|
||||
{Scenario.create_db_add_scenario_fk()},
|
||||
PRIMARY KEY(pamhyr_id, scenario)
|
||||
@@ -464,6 +466,21 @@ class Results(SQLSubModel):
|
||||
cls._db_create(execute)
|
||||
create = True
|
||||
|
||||
if major == "0" and int(minor) <= 2:
|
||||
if int(release) < 9 and not create:
|
||||
execute(
|
||||
"ALTER TABLE results ADD COLUMN " +
|
||||
"seed INTEGER"
|
||||
)
|
||||
execute(
|
||||
"ALTER TABLE results ADD COLUMN " +
|
||||
"number_of_run INTEGER"
|
||||
)
|
||||
execute(
|
||||
"ALTER TABLE results RENAME COLUMN " +
|
||||
"creation_data TO creation_date"
|
||||
)
|
||||
|
||||
return cls._update_submodel(execute, version, data)
|
||||
|
||||
@classmethod
|
||||
@@ -476,7 +493,9 @@ class Results(SQLSubModel):
|
||||
|
||||
table = execute(
|
||||
"SELECT pamhyr_id, solver_name, solver_type, " +
|
||||
"study_revision, creation_data, nb_timestamps, timestamps, " +
|
||||
"study_revision, creation_date, " +
|
||||
"seed, number_of_run, " +
|
||||
"nb_timestamps, timestamps, " +
|
||||
"scenario " +
|
||||
"FROM results " +
|
||||
f"WHERE scenario = {scenario.id}"
|
||||
@@ -496,6 +515,8 @@ class Results(SQLSubModel):
|
||||
solver_type = next(it)
|
||||
revision = next(it)
|
||||
creation_date = next(it)
|
||||
seed = next(it)
|
||||
number_of_run = next(it)
|
||||
nb_timestamps = next(it)
|
||||
timestamps_bytes = next(it)
|
||||
owner_scenario = next(it)
|
||||
@@ -506,6 +527,9 @@ class Results(SQLSubModel):
|
||||
new_results.set("solver_type", solver_type)
|
||||
new_results.set("study_revision", revision)
|
||||
new_results.set("creation_date", creation_date)
|
||||
if seed is not None:
|
||||
new_results.set("seed", seed)
|
||||
new_results.set("number_of_run", number_of_run)
|
||||
|
||||
data["result_pid"] = pid
|
||||
data["result"] = new_results
|
||||
@@ -598,15 +622,25 @@ class Results(SQLSubModel):
|
||||
ts = sorted(self.get("timestamps"))
|
||||
sf = ">" + ''.join(itertools.repeat("d", len(ts)))
|
||||
|
||||
if "seed" in self._meta_data:
|
||||
seed = int(self.get("seed"))
|
||||
number_of_run = int(self.get("number_of_run"))
|
||||
else:
|
||||
seed = None
|
||||
number_of_run = None
|
||||
|
||||
execute(
|
||||
"INSERT INTO " +
|
||||
"results (pamhyr_id, solver_name, solver_type, " +
|
||||
"study_revision, creation_data, " +
|
||||
"study_revision, creation_date, " +
|
||||
"seed, number_of_run, " +
|
||||
"nb_timestamps, timestamps, " +
|
||||
"scenario) VALUES (?, ?, ?, ?, ?, ?, ?, ?)",
|
||||
"scenario) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||
self._pamhyr_id, solver_name, solver_type,
|
||||
self._status.version, self.get("creation_date"),
|
||||
len(ts), struct.pack(sf, *ts), self._owner_scenario
|
||||
seed, number_of_run,
|
||||
len(ts), struct.pack(sf, *ts),
|
||||
self._owner_scenario
|
||||
)
|
||||
|
||||
data["result"] = self._pamhyr_id
|
||||
|
||||
@@ -393,7 +393,7 @@ class Reach(SQLSubModel):
|
||||
class River(SQLSubModel):
|
||||
_sub_classes = [Reach]
|
||||
|
||||
def __init__(self, study, parent):
|
||||
def __init__(self, study, parent, init=True):
|
||||
super(River, self).__init__(
|
||||
id=-1, status=study.status,
|
||||
owner_scenario=study.status.scenario.id
|
||||
@@ -404,8 +404,9 @@ class River(SQLSubModel):
|
||||
|
||||
# Dict with timestamps as key
|
||||
self._reachs = []
|
||||
for i, _ in enumerate(self._study.river.enable_edges()):
|
||||
self.add(i)
|
||||
if init:
|
||||
for i, _ in enumerate(self._study.river.enable_edges()):
|
||||
self.add(i)
|
||||
|
||||
def __len__(self):
|
||||
return len(self._reachs)
|
||||
@@ -458,7 +459,7 @@ class River(SQLSubModel):
|
||||
study = data["study"]
|
||||
parent = data["parent"]
|
||||
|
||||
new_river = cls(study, parent)
|
||||
new_river = cls(study, parent, init=False)
|
||||
|
||||
for reach in study.river.reachs():
|
||||
data["reach"] = reach.reach
|
||||
|
||||
+9
-5
@@ -47,7 +47,7 @@ logger = logging.getLogger()
|
||||
|
||||
|
||||
class Study(SQLModel):
|
||||
_version = "0.2.8"
|
||||
_version = "0.2.9"
|
||||
|
||||
_sub_classes = [
|
||||
Scenario,
|
||||
@@ -679,6 +679,7 @@ class Study(SQLModel):
|
||||
self.status.scenario.y + 100)
|
||||
|
||||
new.name = self.status.scenario.name + " (copy)"
|
||||
new.is_ensemble = self.status.scenario.is_ensemble
|
||||
|
||||
self.status.scenario = new
|
||||
self.river._data_traversal(
|
||||
@@ -690,20 +691,23 @@ class Study(SQLModel):
|
||||
self.status.set_as_editable()
|
||||
return new
|
||||
|
||||
def create_ensemble_scenario(self, switch=True):
|
||||
def create_ensemble_scenario(self, pos=None, switch=True):
|
||||
new = self.scenarios.new(
|
||||
self.status.scenario,
|
||||
is_ensemble=True
|
||||
)
|
||||
|
||||
new.name = self.status.scenario.name + " (ensemble)"
|
||||
new.set_pos(self.status.scenario.x + 100,
|
||||
self.status.scenario.y)
|
||||
if pos is not None:
|
||||
new.set_pos(pos.x(), pos.y())
|
||||
else:
|
||||
new.set_pos(self.status.scenario.x + 100,
|
||||
self.status.scenario.y)
|
||||
|
||||
if switch:
|
||||
self.status.scenario = new
|
||||
|
||||
self.status.set_as_editable()
|
||||
self.status.set_as_read_only()
|
||||
return new
|
||||
|
||||
@property
|
||||
|
||||
@@ -185,6 +185,13 @@ class SQLSubModel(PamhyrID):
|
||||
else:
|
||||
self._owner_scenario = owner_scenario
|
||||
|
||||
def __str__(self):
|
||||
t = type(self)
|
||||
return (
|
||||
f"'{t.__module__}.{t.__name__}" +
|
||||
f"@{self._pamhyr_id}.{self._owner_scenario}'"
|
||||
)
|
||||
|
||||
def must_be_saved(self):
|
||||
"""Return True if this object MUST be save in the save file.
|
||||
|
||||
|
||||
+20
-21
@@ -1621,25 +1621,33 @@ class Mage8(Mage):
|
||||
res["z_mean"] = z
|
||||
res["q_mean"] = q
|
||||
|
||||
res["z_tmp_M2"] = np.zeros(z.shape)
|
||||
res["q_tmp_M2"] = np.zeros(q.shape)
|
||||
|
||||
res["z_std_derivation"] = np.zeros(z.shape)
|
||||
res["q_std_derivation"] = np.zeros(q.shape)
|
||||
|
||||
res["z_min"] = z
|
||||
res["z_max"] = z
|
||||
|
||||
res["q_min"] = q
|
||||
res["q_max"] = q
|
||||
|
||||
res["res_z_min"] = []
|
||||
res["res_z_mean"] = []
|
||||
res["res_z_max"] = []
|
||||
|
||||
res["res_q_min"] = []
|
||||
res["res_q_mean"] = []
|
||||
res["res_q_max"] = []
|
||||
|
||||
res["traces"] = []
|
||||
else:
|
||||
# Get mean results for Z and Q
|
||||
res["z_mean"] = (res["z_mean"] + z) / 2
|
||||
res["q_mean"] = (res["q_mean"] + q) / 2
|
||||
n = run_number
|
||||
for x, txt in [(z, "z"), (q, "q")]:
|
||||
t_mean = f"{txt}_mean"
|
||||
t_M2 = f"{txt}_tmp_M2"
|
||||
t_std_deriv = f"{txt}_std_derivation"
|
||||
|
||||
delta = x - res[t_mean]
|
||||
|
||||
res[t_mean] += delta / n
|
||||
|
||||
delta_2 = x - res[t_mean]
|
||||
|
||||
res[t_M2] += delta * delta_2
|
||||
res[t_std_deriv] = np.sqrt(res[t_M2] / n)
|
||||
|
||||
# Z and Q min max values
|
||||
res["z_min"] = np.minimum(z, res["z_min"])
|
||||
@@ -1647,15 +1655,6 @@ class Mage8(Mage):
|
||||
res["q_min"] = np.minimum(q, res["q_min"])
|
||||
res["q_max"] = np.maximum(q, res["q_max"])
|
||||
|
||||
# Keep results min, mean and max
|
||||
# res["res_z_min"].append((run_number, np.min(z, axis=0)))
|
||||
# res["res_z_mean"].append((run_number, np.mean(z, axis=0)))
|
||||
# res["res_z_max"].append((run_number, np.max(z, axis=0)))
|
||||
|
||||
# res["res_q_min"].append((run_number, np.min(q, axis=0)))
|
||||
# res["res_q_mean"].append((run_number, np.mean(q, axis=0)))
|
||||
# res["res_q_max"].append((run_number, np.max(q, axis=0)))
|
||||
|
||||
@timer
|
||||
def results_ensemble(self, study, repertory,
|
||||
tables, run_number,
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
# Translate.py -- Pamhyr
|
||||
# Copyright (C) 2023-2026 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
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from PyQt5.QtCore import QCoreApplication
|
||||
|
||||
from View.Ensembles.Translate import EnsemblesTranslate
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
|
||||
class EnsembleEditTranslate(EnsemblesTranslate):
|
||||
def __init__(self):
|
||||
super(EnsembleEditTranslate, self).__init__()
|
||||
|
||||
self._dict["binomial_n"] = _translate("Ensemble", "n")
|
||||
self._dict["binomial_p"] = _translate("Ensemble", "p")
|
||||
|
||||
self._dict["poisson_lam"] = _translate("Ensemble", "Lam")
|
||||
|
||||
self._dict["checker_failed_title"] = _translate(
|
||||
"Ensemble",
|
||||
"Invalid parameter"
|
||||
)
|
||||
self._dict["checker_failed_text"] = _translate(
|
||||
"Ensemble",
|
||||
"This parameter is not valid for selected distribution: "
|
||||
)
|
||||
|
||||
uniform = _translate(
|
||||
"Ensemble", "(High - Low) must be non-negative."
|
||||
)
|
||||
self._dict["uniform_low_tips"] = uniform
|
||||
self._dict["uniform_high_tips"] = uniform
|
||||
|
||||
self._dict["normal_scale_tips"] = _translate(
|
||||
"Ensemble", "Scale must be non-negative."
|
||||
)
|
||||
|
||||
self._dict["binomial_n_tips"] = _translate(
|
||||
"Ensemble", "N must be non-negative and must be an integers."
|
||||
)
|
||||
|
||||
self._dict["binomial_p_tips"] = _translate(
|
||||
"Ensemble", "P must be >= 0 and <=1."
|
||||
)
|
||||
|
||||
self._dict["poisson_lam_tips"] = _translate(
|
||||
"Ensemble", "Lam must be >= 0."
|
||||
)
|
||||
@@ -0,0 +1,320 @@
|
||||
# Window.py -- Pamhyr
|
||||
# Copyright (C) 2023-2026 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
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import logging
|
||||
|
||||
from tools import trace, timer, logger_exception
|
||||
|
||||
from View.Tools.PamhyrWindow import PamhyrWindow, PamhyrDialog
|
||||
from View.Tools.PamhyrWidget import PamhyrWidget
|
||||
from View.Tools.PamhyrTree import (
|
||||
PamhyrModelItem, PamhyrModelListItem,
|
||||
)
|
||||
|
||||
from PyQt5.QtGui import (
|
||||
QKeySequence,
|
||||
)
|
||||
|
||||
from PyQt5 import QtWidgets
|
||||
from PyQt5.QtCore import (
|
||||
Qt, QVariant, QAbstractTableModel,
|
||||
QCoreApplication, QModelIndex, pyqtSlot,
|
||||
QRect, QSettings,
|
||||
)
|
||||
|
||||
from PyQt5.QtWidgets import (
|
||||
QDialogButtonBox, QPushButton, QLineEdit,
|
||||
QFileDialog, QTableView, QAbstractItemView,
|
||||
QUndoStack, QShortcut, QAction, QItemDelegate,
|
||||
QComboBox, QVBoxLayout, QHeaderView, QTabWidget,
|
||||
QGroupBox, QTreeWidget,
|
||||
)
|
||||
|
||||
from View.Ensembles.Edit.Translate import EnsembleEditTranslate
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
class StricklersCoefModelItem(PamhyrModelItem):
|
||||
def get_value(self):
|
||||
return (self._data, self.parent()._data)
|
||||
|
||||
|
||||
class StricklersModelItem(PamhyrModelItem):
|
||||
def __init__(self, data=None, trad=None, parent=None):
|
||||
super(StricklersModelItem, self).__init__(
|
||||
data=data, trad=trad, parent=parent,
|
||||
)
|
||||
|
||||
def _setup_children(self):
|
||||
for coef in ["strickler_minor", "strickler_medium"]:
|
||||
self.addChild(
|
||||
StricklersCoefModelItem(data=coef, parent=self)
|
||||
)
|
||||
|
||||
def get_value(self):
|
||||
return self._data
|
||||
|
||||
|
||||
class EnsembleEditDialog(PamhyrDialog):
|
||||
_pamhyr_ui = "EnsembleEditDialog"
|
||||
_pamhyr_name = "Parameters"
|
||||
|
||||
def __init__(self, study=None, ensemble=None,
|
||||
parent=None):
|
||||
trad = EnsembleEditTranslate()
|
||||
|
||||
super(EnsembleEditDialog, self).__init__(
|
||||
title=trad[self._pamhyr_name],
|
||||
trad=trad,
|
||||
options=[],
|
||||
parent=parent
|
||||
)
|
||||
|
||||
self._study = study
|
||||
self._ensemble = ensemble
|
||||
self._target_data = None
|
||||
|
||||
self._tree = self.find(QTreeWidget, "treeWidget_target_data")
|
||||
self._tg_group_box = self.find(QGroupBox, "groupBox_target_data")
|
||||
|
||||
self._init_tree()
|
||||
self._init_default_values()
|
||||
self._init_connection()
|
||||
|
||||
def _init_tree(self):
|
||||
self._tree.setColumnCount(1)
|
||||
self._tree.setHeaderLabels(["Name"])
|
||||
|
||||
stricklers = PamhyrModelListItem(
|
||||
name="Stricklers",
|
||||
lst=self._study.river.stricklers,
|
||||
child_item_ctor=StricklersModelItem,
|
||||
parent=self._tree
|
||||
)
|
||||
|
||||
self._target_data = (
|
||||
self._ensemble.data_type,
|
||||
self._ensemble.target_data
|
||||
)
|
||||
|
||||
self._tg_group_box.setTitle(
|
||||
self._format_target_data(self._target_data)
|
||||
)
|
||||
|
||||
item = stricklers.find_item_by_value(self._target_data)
|
||||
if item:
|
||||
self._tree.setCurrentItem(item)
|
||||
|
||||
def _init_default_values(self):
|
||||
self.set_line_edit_text("lineEdit_name", self._ensemble.name)
|
||||
|
||||
self.combobox_add_items(
|
||||
"comboBox_distribution",
|
||||
[self._trad["not_defined"]] +
|
||||
list(
|
||||
map(
|
||||
lambda d: d.name,
|
||||
self._study._ens_distributions.lst
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
self._params_widget = None
|
||||
if self._ensemble.distribution is not None:
|
||||
self.set_combobox_text("comboBox_distribution",
|
||||
self._ensemble.distribution.name)
|
||||
|
||||
self._set_widget(self._ensemble.distribution)
|
||||
|
||||
def _init_connection(self):
|
||||
self.find(QComboBox, "comboBox_distribution")\
|
||||
.currentTextChanged.connect(self.update_distribution)
|
||||
|
||||
self._tree.itemClicked.connect(self._tree_item_select)
|
||||
|
||||
def _tree_item_select(self, item):
|
||||
if type(item) is StricklersCoefModelItem:
|
||||
self._target_data = item.get_value()
|
||||
|
||||
self._tg_group_box.setTitle(
|
||||
self._format_target_data(self._target_data)
|
||||
)
|
||||
|
||||
def _format_target_data(self, data):
|
||||
return f" Selection: {str(data[1])}, {data[0]}"
|
||||
|
||||
def update_distribution(self, txt):
|
||||
# txt = self.get_combobox_text("comboBox_distribution")
|
||||
distribution = next(
|
||||
filter(
|
||||
lambda d: d.name == txt,
|
||||
self._study._ens_distributions.lst
|
||||
),
|
||||
None
|
||||
)
|
||||
|
||||
self._set_widget(distribution)
|
||||
|
||||
def _set_widget(self, distribution):
|
||||
box = self.find(QGroupBox, "groupBox_params")
|
||||
vbox = self.find(QVBoxLayout, "verticalLayout_params")
|
||||
|
||||
if self._params_widget is not None:
|
||||
vbox.removeWidget(self._params_widget)
|
||||
self._params_widget.setParent(None)
|
||||
|
||||
if distribution is None:
|
||||
return
|
||||
|
||||
size = len(distribution._labels)
|
||||
if size == 1:
|
||||
self._params_widget = Ensemble1ParamsWidget(
|
||||
ensemble=self._ensemble,
|
||||
distribution=distribution,
|
||||
trad=self._trad, parent=box,
|
||||
)
|
||||
vbox.addWidget(self._params_widget)
|
||||
elif size == 2:
|
||||
self._params_widget = Ensemble2ParamsWidget(
|
||||
ensemble=self._ensemble,
|
||||
distribution=distribution,
|
||||
trad=self._trad, parent=box,
|
||||
)
|
||||
vbox.addWidget(self._params_widget)
|
||||
else:
|
||||
self._params_widget = None
|
||||
|
||||
@property
|
||||
def values(self):
|
||||
return self._values
|
||||
|
||||
def accept(self):
|
||||
txt = self.get_combobox_text("comboBox_distribution")
|
||||
distribution = next(
|
||||
filter(
|
||||
lambda d: d.name == txt,
|
||||
self._study._ens_distributions.lst
|
||||
),
|
||||
None
|
||||
)
|
||||
parameters = self._params_widget.values
|
||||
|
||||
if distribution is not None:
|
||||
ok, tips = distribution.is_valid_parameters(parameters)
|
||||
if not ok:
|
||||
self.message_box(
|
||||
text=self._trad["checker_failed_text"],
|
||||
informative_text="\n".join(
|
||||
map(lambda t: " - " + self._trad[t], tips)
|
||||
),
|
||||
window_title=self._trad["checker_failed_title"],
|
||||
)
|
||||
return
|
||||
|
||||
self._values = {
|
||||
"name": self.get_line_edit_text("lineEdit_name"),
|
||||
"data_type": self._target_data[0],
|
||||
"target_data": self._target_data[1],
|
||||
"distribution": distribution,
|
||||
"params": parameters,
|
||||
}
|
||||
|
||||
super().accept()
|
||||
|
||||
def reject(self):
|
||||
self.close()
|
||||
|
||||
|
||||
class Ensemble1ParamsWidget(PamhyrWidget):
|
||||
_pamhyr_ui = "Ensemble1ParamsWidget"
|
||||
_pamhyr_name = "Parameters"
|
||||
|
||||
def __init__(self, ensemble=None,
|
||||
distribution=None,
|
||||
trad=None, parent=None):
|
||||
super(Ensemble1ParamsWidget, self).__init__(
|
||||
parent=parent
|
||||
)
|
||||
self._trad = trad
|
||||
|
||||
self._ensemble = ensemble
|
||||
self._distribution = distribution
|
||||
self._labels = distribution.labels
|
||||
|
||||
self._init_default_labels()
|
||||
self._init_default_values()
|
||||
|
||||
def _init_default_labels(self):
|
||||
self.set_label_text("label_0", self._trad[self._labels[0]])
|
||||
|
||||
def _init_default_values(self):
|
||||
self._values = self._ensemble.params
|
||||
if len(self._values) != 1:
|
||||
self._values = self._distribution.default_values.copy()
|
||||
|
||||
self.set_double_spin_box("doubleSpinBox_0", self._values[0])
|
||||
|
||||
@property
|
||||
def values(self):
|
||||
self._values = [
|
||||
self.get_double_spin_box("doubleSpinBox_0"),
|
||||
]
|
||||
|
||||
return self._values
|
||||
|
||||
|
||||
class Ensemble2ParamsWidget(PamhyrWidget):
|
||||
_pamhyr_ui = "Ensemble2ParamsWidget"
|
||||
_pamhyr_name = "Parameters"
|
||||
|
||||
def __init__(self, ensemble=None,
|
||||
distribution=None,
|
||||
trad=None, parent=None):
|
||||
super(Ensemble2ParamsWidget, self).__init__(
|
||||
parent=parent
|
||||
)
|
||||
self._trad = trad
|
||||
|
||||
self._ensemble = ensemble
|
||||
self._distribution = distribution
|
||||
self._labels = distribution.labels
|
||||
|
||||
self._init_default_labels()
|
||||
self._init_default_values()
|
||||
|
||||
def _init_default_labels(self):
|
||||
self.set_label_text("label_0", self._trad[self._labels[0]])
|
||||
self.set_label_text("label_1", self._trad[self._labels[1]])
|
||||
|
||||
def _init_default_values(self):
|
||||
self._values = self._ensemble.params
|
||||
if len(self._values) != 2:
|
||||
self._values = self._distribution.default_values.copy()
|
||||
|
||||
self.set_double_spin_box("doubleSpinBox_0", self._values[0])
|
||||
self.set_double_spin_box("doubleSpinBox_1", self._values[1])
|
||||
|
||||
@property
|
||||
def values(self):
|
||||
self._values = [
|
||||
self.get_double_spin_box("doubleSpinBox_0"),
|
||||
self.get_double_spin_box("doubleSpinBox_1")
|
||||
]
|
||||
|
||||
return self._values
|
||||
@@ -1,4 +1,4 @@
|
||||
# translate.py -- Pamhyr
|
||||
# Translate.py -- Pamhyr
|
||||
# Copyright (C) 2023-2026 INRAE
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -84,13 +84,17 @@ class SetDistributionCommand(QUndoCommand):
|
||||
self._ensembles = ensembles
|
||||
self._index = index
|
||||
self._old = self._ensembles.get(self._index).distribution
|
||||
self._old_params = self._ensembles.get(self._index).params
|
||||
self._new = distribution
|
||||
|
||||
def undo(self):
|
||||
self._ensembles.get(self._index).distribution = self._old
|
||||
self._ensembles.get(self._index).params = self._old_params
|
||||
|
||||
def redo(self):
|
||||
self._ensembles.get(self._index).distribution = self._new
|
||||
if self._new is not None:
|
||||
self._ensembles.get(self._index).params = self._new.default_values
|
||||
|
||||
|
||||
class AddCommand(QUndoCommand):
|
||||
@@ -111,6 +115,34 @@ class AddCommand(QUndoCommand):
|
||||
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):
|
||||
def __init__(self, ensembles, rows):
|
||||
QUndoCommand.__init__(self)
|
||||
@@ -129,3 +161,18 @@ class DelCommand(QUndoCommand):
|
||||
|
||||
def redo(self):
|
||||
self._ensembles.delete_i(self._rows)
|
||||
|
||||
|
||||
class SetAllCommand(QUndoCommand):
|
||||
def __init__(self, ensemble, data):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
self._ensemble = ensemble
|
||||
self._old = self._ensemble.get_data_dict()
|
||||
self._new = data
|
||||
|
||||
def undo(self):
|
||||
self._ensemble.set_data_dict(self._old)
|
||||
|
||||
def redo(self):
|
||||
self._ensemble.set_data_dict(self._new)
|
||||
@@ -17,6 +17,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import logging
|
||||
import json
|
||||
|
||||
from tools import trace, timer, logger_exception
|
||||
|
||||
@@ -42,10 +43,12 @@ from PyQt5.QtWidgets import (
|
||||
|
||||
from Modules import Modules
|
||||
|
||||
from View.Ensembles.Edit.Window import EnsembleEditDialog
|
||||
from View.Ensembles.Table import (
|
||||
EnsembleTableModel, ComboBoxDelegate
|
||||
)
|
||||
from View.Ensembles.Translate import EnsemblesTranslate
|
||||
from View.Ensembles.UndoCommand import SetAllCommand, ImportCommand
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
@@ -114,7 +117,7 @@ class EnsemblesWindow(PamhyrWindow):
|
||||
delegates = self.setup_table_delegate()
|
||||
|
||||
editable_headers = [
|
||||
"name", "type", "distribution", "target_data"
|
||||
"name",
|
||||
]
|
||||
|
||||
table = self.find(QTableView, f"tableView")
|
||||
@@ -138,6 +141,12 @@ class EnsemblesWindow(PamhyrWindow):
|
||||
self.find(QAction, "action_add").triggered.connect(self.add)
|
||||
self.find(QAction, "action_del").triggered.connect(self.delete)
|
||||
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.selectionModel()\
|
||||
@@ -185,110 +194,87 @@ class EnsemblesWindow(PamhyrWindow):
|
||||
for row in rows:
|
||||
try:
|
||||
ens = self._ensembles.get(row)
|
||||
len_params = len(ens.distribution.labels)
|
||||
|
||||
if len_params == 1:
|
||||
dlg = Ensemble1ParamsDialog(
|
||||
ensemble=ens,
|
||||
trad=self._trad,
|
||||
parent=self
|
||||
)
|
||||
else:
|
||||
dlg = Ensemble2ParamsDialog(
|
||||
ensemble=ens,
|
||||
trad=self._trad,
|
||||
parent=self
|
||||
)
|
||||
dlg = EnsembleEditDialog(
|
||||
study=self._study,
|
||||
ensemble=ens,
|
||||
parent=self
|
||||
)
|
||||
|
||||
if dlg.exec():
|
||||
self._ensembles.get(row).params = dlg._values
|
||||
self._undo_stack.push(
|
||||
SetAllCommand(
|
||||
ens, dlg.values
|
||||
)
|
||||
)
|
||||
except Exception as e:
|
||||
logger_exception(e)
|
||||
return
|
||||
|
||||
def export_to_json(self):
|
||||
ens = []
|
||||
for e in self._ensembles.lst:
|
||||
ens.append(e.get_data_dict(use_ids=True))
|
||||
|
||||
class Ensemble1ParamsDialog(PamhyrDialog):
|
||||
_pamhyr_ui = "Ensemble1ParamsDialog"
|
||||
_pamhyr_name = "Parameters"
|
||||
data = {"ensembles": ens}
|
||||
|
||||
def __init__(self, ensemble=None,
|
||||
trad=None, parent=None):
|
||||
super(Ensemble1ParamsDialog, self).__init__(
|
||||
title=trad[self._pamhyr_name],
|
||||
trad=trad,
|
||||
options=[],
|
||||
parent=parent
|
||||
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"]]
|
||||
)
|
||||
|
||||
self._ensemble = ensemble
|
||||
self._labels = ensemble.distribution.labels
|
||||
def import_from_json(self):
|
||||
def aux(filename):
|
||||
with open(filename[0], 'r') as f:
|
||||
return json.load(f)
|
||||
|
||||
self._init_default_labels()
|
||||
self._init_default_values()
|
||||
|
||||
def _init_default_labels(self):
|
||||
self.set_label_text("label_0", self._trad[self._labels[0]])
|
||||
|
||||
|
||||
def _init_default_values(self):
|
||||
self._values = self._ensemble.params
|
||||
if len(self._values) > 0:
|
||||
self.set_double_spin_box("doubleSpinBox_0", self._values[0])
|
||||
|
||||
@property
|
||||
def values(self):
|
||||
return self._values
|
||||
|
||||
def accept(self):
|
||||
self._values = [
|
||||
self.get_double_spin_box("doubleSpinBox_0"),
|
||||
]
|
||||
super().accept()
|
||||
|
||||
def reject(self):
|
||||
self.close()
|
||||
|
||||
|
||||
class Ensemble2ParamsDialog(PamhyrDialog):
|
||||
_pamhyr_ui = "Ensemble2ParamsDialog"
|
||||
_pamhyr_name = "Parameters"
|
||||
|
||||
def __init__(self, ensemble=None,
|
||||
trad=None, parent=None):
|
||||
super(Ensemble2ParamsDialog, self).__init__(
|
||||
title=trad[self._pamhyr_name],
|
||||
trad=trad,
|
||||
options=[],
|
||||
parent=parent
|
||||
data = self.file_dialog(
|
||||
select_file=None,
|
||||
callback=aux,
|
||||
default_suffix='.json',
|
||||
file_filter=[self._trad["file_json"]]
|
||||
)
|
||||
|
||||
self._ensemble = ensemble
|
||||
self._labels = ensemble.distribution.labels
|
||||
dtarget = dict(
|
||||
map(
|
||||
lambda s: (s.pamhyr_id, s),
|
||||
self._study.river.stricklers.stricklers
|
||||
)
|
||||
)
|
||||
|
||||
self._init_default_labels()
|
||||
self._init_default_values()
|
||||
ddistr = dict(
|
||||
map(
|
||||
lambda d: (d.name, d),
|
||||
self._study._ens_distributions.lst
|
||||
)
|
||||
)
|
||||
|
||||
def _init_default_labels(self):
|
||||
self.set_label_text("label_0", self._trad[self._labels[0]])
|
||||
self.set_label_text("label_1", self._trad[self._labels[1]])
|
||||
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"]
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
def _init_default_values(self):
|
||||
self._values = self._ensemble.params
|
||||
if len(self._values) > 0:
|
||||
self.set_double_spin_box("doubleSpinBox_0", self._values[0])
|
||||
self.set_double_spin_box("doubleSpinBox_1", self._values[1])
|
||||
|
||||
@property
|
||||
def values(self):
|
||||
return self._values
|
||||
|
||||
def accept(self):
|
||||
self._values = [
|
||||
self.get_double_spin_box("doubleSpinBox_0"),
|
||||
self.get_double_spin_box("doubleSpinBox_1")
|
||||
]
|
||||
super().accept()
|
||||
|
||||
def reject(self):
|
||||
self.close()
|
||||
self._undo_stack.push(
|
||||
ImportCommand(
|
||||
self._ensembles, updated, 0
|
||||
)
|
||||
)
|
||||
self._table.update()
|
||||
@@ -26,10 +26,13 @@ from View.Results.translate import ResultsTranslate
|
||||
|
||||
|
||||
class CustomExportDialog(PamhyrDialog):
|
||||
_pamhyr_ui = "CustomExportAdisDialog"
|
||||
_pamhyr_name = "Custom Plot Selection"
|
||||
_pamhyr_ui = "CustomExportDialog"
|
||||
_pamhyr_name = "Custom Export"
|
||||
|
||||
def __init__(self, parent=None):
|
||||
def __init__(self,
|
||||
tag_x="values_x",
|
||||
tag_y="values_y",
|
||||
parent=None):
|
||||
trad = ResultsTranslate()
|
||||
super(CustomExportDialog, self).__init__(
|
||||
title=trad[self._pamhyr_name],
|
||||
@@ -38,8 +41,8 @@ class CustomExportDialog(PamhyrDialog):
|
||||
parent=parent
|
||||
)
|
||||
|
||||
self._available_values_x = self._trad.get_dict("values_x")
|
||||
self._available_values_y = self._trad.get_dict("values_y")
|
||||
self._available_values_x = self._trad.get_dict(tag_x)
|
||||
self._available_values_y = self._trad.get_dict(tag_y)
|
||||
|
||||
self.setup_radio_buttons_x()
|
||||
self.setup_radio_buttons_res()
|
||||
@@ -66,8 +69,8 @@ class CustomExportDialog(PamhyrDialog):
|
||||
|
||||
def setup_radio_buttons_res(self):
|
||||
self._radio2 = []
|
||||
layout = self.find(QVBoxLayout, "verticalLayout_pol")
|
||||
label = self.find(QLabel, "label_3")
|
||||
layout = self.find(QVBoxLayout, "verticalLayout_solv")
|
||||
label = self.find(QLabel, "label_solv")
|
||||
label.setText(self._trad["solver"])
|
||||
|
||||
for solver in self.parent._solvers:
|
||||
@@ -89,7 +92,7 @@ class CustomExportDialog(PamhyrDialog):
|
||||
layout.addStretch()
|
||||
|
||||
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.setStyleSheet('background-color: white')
|
||||
self.set_label()
|
||||
@@ -163,6 +166,15 @@ class CustomExportDialog(PamhyrDialog):
|
||||
res = i
|
||||
break
|
||||
|
||||
self.value = x, y, self._envelop.isChecked(), res
|
||||
self.value = (x, y, self._envelop.isChecked(), res)
|
||||
|
||||
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
|
||||
)
|
||||
@@ -102,6 +102,7 @@ class PlotHEnsemble(PamhyrPlot):
|
||||
return
|
||||
|
||||
self.draw_data(res_id)
|
||||
self.draw_data_std_derivation(res_id)
|
||||
|
||||
self.canvas.axes.set_xlabel(
|
||||
self._trad["unit_time_s"],
|
||||
@@ -159,6 +160,29 @@ class PlotHEnsemble(PamhyrPlot):
|
||||
|
||||
self._line.append(line)
|
||||
|
||||
@timer
|
||||
def draw_data_std_derivation(self, res_id):
|
||||
results = self.results[res_id]
|
||||
reach = results.river.reach(self._current_reach_id)
|
||||
|
||||
q = results.get("table")["q_mean"]
|
||||
std_deriv = results.get("table")["q_std_derivation"]
|
||||
profile = reach.profile(self._current_profile_id[0])
|
||||
|
||||
x = self._timestamps
|
||||
y = q[:, profile.global_index]
|
||||
std = std_deriv[:, profile.global_index]
|
||||
|
||||
y_b = y - std
|
||||
y_t = y + std
|
||||
|
||||
plot = self.canvas.axes.fill_between(
|
||||
x, y_b, y_t,
|
||||
label=f"Standard derivation {profile.name}",
|
||||
color=self.color_plot_ensemble_std_deriv,
|
||||
alpha=0.3,
|
||||
)
|
||||
|
||||
def draw_additional_data(self, res_id):
|
||||
results = self.results[res_id]
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ class PlotRKC(PamhyrPlot):
|
||||
ts = results.get_timestamp_id(self._current_timestamp)
|
||||
|
||||
gi_0, gi_1 = reach.global_index
|
||||
water_z = table[ts, gi_0 : gi_1 + 1]
|
||||
zfd = table[ts, gi_0:gi_1 + 1]
|
||||
|
||||
self.line_bottom, = self.canvas.axes.plot(
|
||||
rk, zfd,
|
||||
@@ -175,7 +175,7 @@ class PlotRKC(PamhyrPlot):
|
||||
ts = result.get_timestamp_id(self._current_timestamp)
|
||||
|
||||
gi_0, gi_1 = reach.global_index
|
||||
water_z = table[ts, gi_0 : gi_1 + 1]
|
||||
water_z = table[ts, gi_0:gi_1 + 1]
|
||||
|
||||
self.water = self.canvas.axes.plot(
|
||||
rk, water_z,
|
||||
@@ -200,7 +200,7 @@ class PlotRKC(PamhyrPlot):
|
||||
ts = result.get_timestamp_id(self._current_timestamp)
|
||||
|
||||
gi_0, gi_1 = reach.global_index
|
||||
water_z = table[ts, gi_0 : gi_1 + 1]
|
||||
water_z = table[ts, gi_0:gi_1 + 1]
|
||||
|
||||
self.canvas.axes.plot(
|
||||
rk, water_z, lw=1.,
|
||||
@@ -337,7 +337,7 @@ class PlotRKC(PamhyrPlot):
|
||||
ts = result.get_timestamp_id(self._current_timestamp)
|
||||
|
||||
gi_0, gi_1 = reach.global_index
|
||||
water_z = table[ts, gi_0 : gi_1 + 1]
|
||||
water_z = table[ts, gi_0:gi_1 + 1]
|
||||
|
||||
self.water[0].set_data(
|
||||
rk, water_z
|
||||
@@ -378,7 +378,8 @@ class PlotRKC(PamhyrPlot):
|
||||
table = results.get("table")["zfd"]
|
||||
ts = results.get_timestamp_id(self._current_timestamp)
|
||||
|
||||
zfd = table[ts, reach.global_index]
|
||||
gi_0, gi_1 = reach.global_index
|
||||
zfd = table[ts, gi_0:gi_1 + 1]
|
||||
|
||||
self.line_bottom.remove()
|
||||
|
||||
|
||||
@@ -88,6 +88,7 @@ class PlotRKCEnsemble(PamhyrPlot):
|
||||
reach = results.river.reach(self._current_reach_id)
|
||||
|
||||
self.draw_bottom(reach)
|
||||
self.draw_std_derivation(reach)
|
||||
self.draw_water_elevation(reach)
|
||||
self.draw_current(reach)
|
||||
self.draw_profiles_hs(reach)
|
||||
@@ -149,7 +150,6 @@ class PlotRKCEnsemble(PamhyrPlot):
|
||||
if len(reach.geometry.profiles) != 0:
|
||||
result = self.results[0]
|
||||
rk = reach.geometry.get_rk()
|
||||
z_min = reach.geometry.get_z_min()
|
||||
|
||||
self.water = []
|
||||
|
||||
@@ -164,17 +164,45 @@ class PlotRKCEnsemble(PamhyrPlot):
|
||||
ts = result.get_timestamp_id(self._current_timestamp)
|
||||
|
||||
gi_0, gi_1 = reach.global_index
|
||||
water_z = table[ts, gi_0 : gi_1 + 1]
|
||||
water_z = table[ts, gi_0:gi_1 + 1]
|
||||
|
||||
plot, = self.canvas.axes.plot(
|
||||
rk, water_z,
|
||||
lw=1., color=color,
|
||||
linestyle='dotted',
|
||||
label=f"Elevation: {t} (m)",
|
||||
)
|
||||
|
||||
self.water.append(plot)
|
||||
|
||||
def draw_std_derivation(self, reach):
|
||||
if len(reach.geometry.profiles) != 0:
|
||||
result = self.results[0]
|
||||
rk = reach.geometry.get_rk()
|
||||
z_min = reach.geometry.get_z_min()
|
||||
|
||||
color = self.color_plot_ensemble_std_deriv
|
||||
|
||||
table = result.get("table")["z_mean"]
|
||||
std_deriv = result.get("table")["z_std_derivation"]
|
||||
|
||||
ts = result.get_timestamp_id(self._current_timestamp)
|
||||
|
||||
gi_0, gi_1 = reach.global_index
|
||||
|
||||
water_z = table[ts, gi_0:gi_1 + 1]
|
||||
std = std_deriv[ts, gi_0:gi_1 + 1]
|
||||
|
||||
water_z_b = water_z - std
|
||||
water_z_t = water_z + std
|
||||
|
||||
plot = self.canvas.axes.fill_between(
|
||||
rk, water_z_b, water_z_t,
|
||||
lw=1., color=color, alpha=0.3,
|
||||
label=f"Standard derivation",
|
||||
)
|
||||
|
||||
self.water_std_deriv = plot
|
||||
|
||||
def draw_additional_data(self):
|
||||
results = self.results[0]
|
||||
|
||||
@@ -248,6 +276,7 @@ class PlotRKCEnsemble(PamhyrPlot):
|
||||
reach = results.river.reach(self._current_reach_id)
|
||||
|
||||
self.update_water_elevation()
|
||||
self.update_std_derivation()
|
||||
|
||||
self.update_idle()
|
||||
|
||||
@@ -267,7 +296,7 @@ class PlotRKCEnsemble(PamhyrPlot):
|
||||
ts = result.get_timestamp_id(self._current_timestamp)
|
||||
|
||||
gi_0, gi_1 = reach.global_index
|
||||
water_z = table[ts, gi_0 : gi_1 + 1]
|
||||
water_z = table[ts, gi_0:gi_1 + 1]
|
||||
|
||||
colors = [
|
||||
(0, "z_min", self.color_plot_ensemble_min),
|
||||
@@ -280,10 +309,31 @@ class PlotRKCEnsemble(PamhyrPlot):
|
||||
ts = result.get_timestamp_id(self._current_timestamp)
|
||||
|
||||
gi_0, gi_1 = reach.global_index
|
||||
water_z = table[ts, gi_0 : gi_1 + 1]
|
||||
water_z = table[ts, gi_0:gi_1 + 1]
|
||||
|
||||
self.water[i].set_data(rk, water_z)
|
||||
|
||||
def update_std_derivation(self):
|
||||
result = self.results[0]
|
||||
reach = result.river.reach(self._current_reach_id)
|
||||
|
||||
rk = reach.geometry.get_rk()
|
||||
|
||||
table = result.get("table")["z_mean"]
|
||||
std_deriv = result.get("table")["z_std_derivation"]
|
||||
|
||||
ts = result.get_timestamp_id(self._current_timestamp)
|
||||
|
||||
gi_0, gi_1 = reach.global_index
|
||||
|
||||
water_z = table[ts, gi_0:gi_1 + 1]
|
||||
std = std_deriv[ts, gi_0:gi_1 + 1]
|
||||
|
||||
water_z_b = water_z - std
|
||||
water_z_t = water_z + std
|
||||
|
||||
self.water_std_deriv.set_data(rk, water_z_b, water_z_t)
|
||||
|
||||
def update_additional_data(self):
|
||||
self.draw_additional_data()
|
||||
self.update_idle()
|
||||
|
||||
@@ -97,7 +97,7 @@ class TableModel(PamhyrTableModel):
|
||||
return str(v)
|
||||
elif self._opt_data == "runs":
|
||||
if self._headers[column] == "runs":
|
||||
p = self._lst[row,:]
|
||||
p = self._lst[row, :]
|
||||
return f"{row}: {p}"
|
||||
elif self._opt_data == "raw_data":
|
||||
table = self._data[0].get("table")
|
||||
|
||||
+456
-371
@@ -79,7 +79,9 @@ from View.Results.CustomPlot.Plot import CustomPlot
|
||||
from View.Results.CustomPlot.CustomPlotValuesSelectionDialog import (
|
||||
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.translate import (
|
||||
@@ -786,34 +788,47 @@ class ResultsWindow(PamhyrWindow):
|
||||
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}"]
|
||||
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, 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, solver_id)
|
||||
|
||||
try:
|
||||
with open(filename, 'w', newline='') as csvfile:
|
||||
writer = csv.writer(csvfile, delimiter=',',
|
||||
quotechar='|', quoting=csv.QUOTE_MINIMAL)
|
||||
quotechar='|',
|
||||
quoting=csv.QUOTE_MINIMAL)
|
||||
dict_x = self._trad.get_dict("values_x")
|
||||
header = []
|
||||
|
||||
writer.writerow(first_line)
|
||||
|
||||
for text in val_dict.keys():
|
||||
header.append(text)
|
||||
|
||||
writer.writerow(header)
|
||||
|
||||
for row in range(len(val_dict[dict_x[x]])):
|
||||
line = []
|
||||
|
||||
for var in val_dict.keys():
|
||||
line.append(val_dict[var][row])
|
||||
|
||||
writer.writerow(line)
|
||||
|
||||
self._timer.stop()
|
||||
except Exception as e:
|
||||
self.message_box(
|
||||
@@ -876,266 +891,174 @@ class ResultsWindow(PamhyrWindow):
|
||||
dict_x = self._trad.get_dict("values_x")
|
||||
dict_y = self._trad.get_dict("values_y")
|
||||
|
||||
if self._current_results == 2:
|
||||
envelop = False
|
||||
reach1 = results[0].river.reachs[self._get_current_reach()]
|
||||
reach2 = results[1].river.reachs[self._get_current_reach()]
|
||||
|
||||
if envelop:
|
||||
dict_y.update(self._trad.get_dict("values_y_envelop"))
|
||||
|
||||
my_dict = {}
|
||||
my_dict[dict_x["rk"]] = reach.geometry.get_rk()
|
||||
|
||||
table = results.get("table")
|
||||
id_ts = results.get_timestamp_id(timestamp)
|
||||
|
||||
z = table["Z"]
|
||||
q = table["Q"]
|
||||
v = table["V"]
|
||||
zfd = table["zfd"]
|
||||
ind = reach.global_index
|
||||
|
||||
if "bed_elevation" in y:
|
||||
if reach.has_bedload():
|
||||
zmin = list(map(
|
||||
lambda p: zfd[id_ts, p.global_index],
|
||||
reach.profiles
|
||||
))
|
||||
else:
|
||||
zmin = reach.geometry.get_z_min()
|
||||
my_dict[dict_y["bed_elevation"]] = zmin
|
||||
# if envelop and reach.has_sediment():
|
||||
if "discharge" in y:
|
||||
my_dict[dict_y["discharge"]] = list(
|
||||
map(
|
||||
lambda p: q[id_ts, p.global_index],
|
||||
reach.profiles
|
||||
)
|
||||
my_dict = {}
|
||||
data = {
|
||||
"z": table["Z"][:, ind[0]:ind[1]+1],
|
||||
"q": table["Q"][:, ind[0]:ind[1]+1],
|
||||
"v": table["V"][:, ind[0]:ind[1]+1],
|
||||
"zfd": table["zfd"][:, ind[0]:ind[1]+1],
|
||||
|
||||
"reach": reach,
|
||||
"id_ts": id_ts, "envelop": envelop,
|
||||
"my_dict": my_dict,
|
||||
}
|
||||
|
||||
func = {
|
||||
"bed_elevation": self._export_rk_compute_elevation,
|
||||
"discharge": self._export_rk_compute_discharge,
|
||||
"water_elevation": self._export_rk_compute_water_elevation,
|
||||
"velocity": self._export_rk_compute_velocity,
|
||||
"depth": self._export_rk_compute_depth,
|
||||
"mean_depth": self._export_rk_compute_mean_depth,
|
||||
"froude": self._export_rk_compute_froude,
|
||||
"wet_area": self._export_rk_compute_wet_area,
|
||||
}
|
||||
|
||||
# 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_compute_elevation(self, data):
|
||||
my_dict = data["my_dict"]
|
||||
reach = data["reach"]
|
||||
id_ts = data["id_ts"]
|
||||
|
||||
if reach.has_bedload():
|
||||
zfd = data["zfd"]
|
||||
zmin = zfd[id_ts, :]
|
||||
else:
|
||||
zmin = reach.geometry.get_z_min()
|
||||
|
||||
my_dict["bed_elevation"] = zmin
|
||||
|
||||
def _export_rk_compute_discharge(self, data):
|
||||
my_dict = data["my_dict"]
|
||||
envelop = data["envelop"]
|
||||
id_ts = data["id_ts"]
|
||||
|
||||
q = data["q"]
|
||||
|
||||
my_dict["discharge"] = q[id_ts, :]
|
||||
|
||||
if envelop:
|
||||
my_dict["min_discharge"] = np.min(q, axis=0)
|
||||
my_dict["max_discharge"] = np.max(q, axis=0)
|
||||
|
||||
def _export_rk_compute_water_elevation(self, data):
|
||||
my_dict = data["my_dict"]
|
||||
envelop = data["envelop"]
|
||||
id_ts = data["id_ts"]
|
||||
|
||||
z = data["z"]
|
||||
|
||||
my_dict["water_elevation"] = z[id_ts, :]
|
||||
|
||||
if envelop:
|
||||
my_dict["min_water_elevation"] = np.min(z, axis=0)
|
||||
my_dict["max_water_elevation"] = np.max(z, axis=0)
|
||||
|
||||
def _export_rk_compute_velocity(self, data):
|
||||
my_dict = data["my_dict"]
|
||||
envelop = data["envelop"]
|
||||
id_ts = data["id_ts"]
|
||||
|
||||
v = data["v"]
|
||||
|
||||
my_dict["velocity"] = v[id_ts, :]
|
||||
|
||||
if envelop:
|
||||
my_dict["min_velocity"] = np.min(v, axis=0)
|
||||
my_dict["max_velocity"] = np.max(v, axis=0)
|
||||
|
||||
def _export_rk_compute_depth(self, data):
|
||||
my_dict = data["my_dict"]
|
||||
envelop = data["envelop"]
|
||||
reach = data["reach"]
|
||||
id_ts = data["id_ts"]
|
||||
|
||||
z = data["z"]
|
||||
|
||||
my_dict["depth"] = list(
|
||||
map(
|
||||
lambda p: p.geometry.max_water_depth(
|
||||
z[id_ts, p.global_index]
|
||||
),
|
||||
reach.profiles
|
||||
)
|
||||
if envelop:
|
||||
my_dict[dict_y["min_discharge"]] = list(
|
||||
map(
|
||||
lambda p: np.min(q[:, p.global_index]),
|
||||
reach.profiles
|
||||
)
|
||||
)
|
||||
my_dict[dict_y["max_discharge"]] = list(
|
||||
map(
|
||||
lambda p: np.max(q[:, p.global_index]),
|
||||
reach.profiles
|
||||
)
|
||||
)
|
||||
if "water_elevation" in y:
|
||||
my_dict[dict_y["water_elevation"]] = list(
|
||||
map(
|
||||
lambda p: z[id_ts, p.global_index],
|
||||
reach.profiles
|
||||
)
|
||||
)
|
||||
|
||||
if envelop:
|
||||
z_min = reach.geometry.get_z_min()
|
||||
|
||||
my_dict["min_depth"] = np.min(z, axis=0) - z_min
|
||||
my_dict["max_depth"] = np.max(z, axis=0) - z_min
|
||||
|
||||
def _export_rk_compute_mean_depth(self, data):
|
||||
my_dict = data["my_dict"]
|
||||
reach = data["reach"]
|
||||
id_ts = data["id_ts"]
|
||||
|
||||
z = data["z"]
|
||||
|
||||
my_dict["mean_depth"] = list(
|
||||
map(
|
||||
lambda p: p.geometry.mean_water_depth(
|
||||
z[id_ts, p.global_index]
|
||||
),
|
||||
reach.profiles
|
||||
)
|
||||
if envelop:
|
||||
my_dict[dict_y["min_water_elevation"]] = list(
|
||||
map(
|
||||
lambda p: np.min(z[:, p.global_index]),
|
||||
reach.profiles
|
||||
)
|
||||
)
|
||||
my_dict[dict_y["max_water_elevation"]] = list(
|
||||
map(
|
||||
lambda p: np.max(z[:, p.global_index]),
|
||||
reach.profiles
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
if "velocity" in y:
|
||||
my_dict[dict_y["velocity"]] = list(
|
||||
map(
|
||||
lambda p: v[id_ts, p.global_index],
|
||||
reach.profiles
|
||||
)
|
||||
def _export_rk_compute_froude(self, data):
|
||||
my_dict = data["my_dict"]
|
||||
reach = data["reach"]
|
||||
id_ts = data["id_ts"]
|
||||
|
||||
z = data["z"]
|
||||
v = data["v"]
|
||||
|
||||
my_dict["froude"] = list(
|
||||
map(
|
||||
lambda p: p.geometry.froude(
|
||||
z[id_ts, p.global_index],
|
||||
v[id_ts, p.global_index]
|
||||
),
|
||||
reach.profiles
|
||||
)
|
||||
if envelop:
|
||||
velocities = list(map(
|
||||
lambda p: v[:, p.global_index],
|
||||
reach.profiles
|
||||
))
|
||||
my_dict[dict_y["min_velocity"]] = [min(v) for v in velocities]
|
||||
my_dict[dict_y["max_velocity"]] = [max(v) for v in velocities]
|
||||
)
|
||||
|
||||
if "depth" in y:
|
||||
if self._current_results != 2:
|
||||
d = my_dict[dict_y["depth"]] = list(
|
||||
map(
|
||||
lambda p: p.geometry.max_water_depth(
|
||||
z[id_ts, p.global_index]
|
||||
),
|
||||
reach.profiles
|
||||
)
|
||||
)
|
||||
else:
|
||||
d1 = list(
|
||||
map(
|
||||
lambda p: p.geometry.max_water_depth(
|
||||
z[id_ts, p.global_index]
|
||||
),
|
||||
reach1.profiles
|
||||
)
|
||||
)
|
||||
d2 = list(
|
||||
map(
|
||||
lambda p: p.geometry.max_water_depth(
|
||||
z[id_ts, p.global_index]
|
||||
),
|
||||
reach2.profiles
|
||||
)
|
||||
)
|
||||
d = list(
|
||||
map(
|
||||
lambda x, y: x - y,
|
||||
d1, d2
|
||||
)
|
||||
)
|
||||
my_dict[dict_y["depth"]] = d
|
||||
if envelop:
|
||||
my_dict[dict_y["min_depth"]] = list(map(
|
||||
lambda p1, p2: p1 - p2, map(
|
||||
lambda p: np.min(z[:, p.global_index]),
|
||||
reach.profiles
|
||||
), reach.geometry.get_z_min()
|
||||
)
|
||||
)
|
||||
my_dict[dict_y["max_depth"]] = list(map(
|
||||
lambda p1, p2: p1 - p2, map(
|
||||
lambda p: np.max(z[:, p.global_index]),
|
||||
reach.profiles
|
||||
), reach.geometry.get_z_min()
|
||||
)
|
||||
)
|
||||
def _export_rk_compute_wet_area(self, data):
|
||||
my_dict = data["my_dict"]
|
||||
reach = data["reach"]
|
||||
id_ts = data["id_ts"]
|
||||
|
||||
if "mean_depth" in y:
|
||||
if self._current_results != 2:
|
||||
d = list(
|
||||
map(
|
||||
lambda p: p.geometry.mean_water_depth(
|
||||
z[id_ts, p.global_index]
|
||||
),
|
||||
reach.profiles
|
||||
)
|
||||
)
|
||||
else:
|
||||
d1 = list(
|
||||
map(
|
||||
lambda p: p.geometry.mean_water_depth(
|
||||
z[id_ts, p.global_index]
|
||||
),
|
||||
reach1.profiles
|
||||
)
|
||||
)
|
||||
d2 = list(
|
||||
map(
|
||||
lambda p: p.geometry.mean_water_depth(
|
||||
z[id_ts, p.global_index]
|
||||
),
|
||||
reach2.profiles
|
||||
)
|
||||
)
|
||||
d = list(
|
||||
map(
|
||||
lambda x, y: x - y,
|
||||
d1, d2
|
||||
)
|
||||
)
|
||||
my_dict[dict_y["mean_depth"]] = d
|
||||
if "froude" in y:
|
||||
if self._current_results != 2:
|
||||
fr = my_dict[dict_y["froude"]] = list(
|
||||
map(
|
||||
lambda p: (
|
||||
v[id_ts, p.global_index] /
|
||||
sqrt(9.81 * (
|
||||
p.geometry.wet_area(
|
||||
z[id_ts, p.global_index]
|
||||
) /
|
||||
p.geometry.wet_width(
|
||||
z[id_ts, p.global_index]
|
||||
)
|
||||
))
|
||||
),
|
||||
reach.profiles
|
||||
)
|
||||
)
|
||||
else:
|
||||
fr1 = list(
|
||||
map(
|
||||
lambda p: (
|
||||
v[id_ts, p.global_index] /
|
||||
sqrt(9.81 * (
|
||||
p.geometry.wet_area(
|
||||
z[id_ts, p.global_index]
|
||||
) /
|
||||
p.geometry.wet_width(
|
||||
z[id_ts, p.global_index]
|
||||
)
|
||||
))
|
||||
),
|
||||
reach1.profiles
|
||||
)
|
||||
)
|
||||
fr2 = list(
|
||||
map(
|
||||
lambda p: (
|
||||
v[id_ts, p.global_index] /
|
||||
sqrt(9.81 * (
|
||||
p.geometry.wet_area(
|
||||
z[id_ts, p.global_index]
|
||||
) /
|
||||
p.geometry.wet_width(
|
||||
z[id_ts, p.global_index]
|
||||
)
|
||||
))
|
||||
),
|
||||
reach2.profiles
|
||||
)
|
||||
)
|
||||
fr = list(map(
|
||||
lambda x, y: x - y,
|
||||
fr1, fr2
|
||||
))
|
||||
my_dict[dict_y["froude"]] = fr
|
||||
if "wet_area" in y:
|
||||
if self._current_results != 2:
|
||||
wa = list(
|
||||
map(
|
||||
lambda p: p.geometry.wet_area(
|
||||
z[id_ts, p.global_index]
|
||||
),
|
||||
reach.profiles
|
||||
)
|
||||
)
|
||||
else:
|
||||
wa1 = list(
|
||||
map(
|
||||
lambda p: p.geometry.wet_area(
|
||||
z[id_ts, p.global_index]
|
||||
),
|
||||
reach1.profiles
|
||||
)
|
||||
)
|
||||
wa2 = list(
|
||||
map(
|
||||
lambda p: p.geometry.wet_area(
|
||||
z[id_ts, p.global_index]
|
||||
),
|
||||
reach2.profiles
|
||||
)
|
||||
)
|
||||
wa = list(map(
|
||||
lambda x, y: x - y,
|
||||
wa1, wa2
|
||||
))
|
||||
z = data["z"]
|
||||
|
||||
my_dict[dict_y["wet_area"]] = wa
|
||||
|
||||
return my_dict
|
||||
my_dict["wet_area"] = list(
|
||||
map(
|
||||
lambda p: p.geometry.wet_area(
|
||||
z[id_ts, p.global_index]
|
||||
),
|
||||
reach.profiles
|
||||
)
|
||||
)
|
||||
|
||||
def _export_time(self, profile, y, solver_id):
|
||||
results = self._results[solver_id]
|
||||
@@ -1144,134 +1067,105 @@ class ResultsWindow(PamhyrWindow):
|
||||
dict_x = self._trad.get_dict("values_x")
|
||||
dict_y = self._trad.get_dict("values_y")
|
||||
|
||||
my_dict = {}
|
||||
my_dict[dict_x["time"]] = self._timestamps
|
||||
|
||||
table = results.get("table")
|
||||
ind = profile.global_index
|
||||
|
||||
z = table["Z"][:, profile.global_index]
|
||||
q = table["Q"][:, profile.global_index]
|
||||
v = table["V"][:, profile.global_index]
|
||||
zfd = table["zfd"][:, profile.global_index]
|
||||
my_dict = {}
|
||||
data = {
|
||||
"z": table["Z"][:, ind],
|
||||
"q": table["Q"][:, ind],
|
||||
"v": table["V"][:, ind],
|
||||
"zfd": table["zfd"][:, ind],
|
||||
|
||||
if self._current_results == 2:
|
||||
reach1 = self._results[0].river.reach(self._reach)
|
||||
reach2 = self._results[1].river.reach(self._reach)
|
||||
reach3 = self._results[2].river.reach(self._reach)
|
||||
profile1 = reach1.profile(self._profile)
|
||||
profile2 = reach2.profile(self._profile)
|
||||
# profile3 = reach3.profile(self._profile)
|
||||
"reach": reach,
|
||||
"profile": profile,
|
||||
"my_dict": my_dict,
|
||||
}
|
||||
|
||||
z1 = table["Z"][:, profile1.global_index]
|
||||
q1 = table["Q"][:, profile1.global_index]
|
||||
v1 = table["V"][:, profile1.global_index]
|
||||
def set_dict(k, v):
|
||||
my_dict[k] = v
|
||||
|
||||
z2 = table["Z"][:, profile2.global_index]
|
||||
q2 = table["Q"][:, profile2.global_index]
|
||||
v2 = table["V"][:, profile2.global_index]
|
||||
func = {
|
||||
"bed_elevation": self._export_time_compute_elevation,
|
||||
"discharge": lambda d: set_dict("discharge", d["q"]),
|
||||
"water_elevation": lambda d: set_dict("water_elevation", d["z"]),
|
||||
"velocity": lambda d: set_dict("velocity", d["v"]),
|
||||
"depth": self._export_time_compute_depth,
|
||||
"mean_depth": self._export_time_compute_mean_depth,
|
||||
"froude": self._export_time_compute_froude,
|
||||
"wet_area": self._export_time_compute_wet_area,
|
||||
}
|
||||
|
||||
if "bed_elevation" in y:
|
||||
if reach.has_bedload():
|
||||
z_min = zfd
|
||||
else:
|
||||
z_min = [profile.geometry.z_min()] * len(self._timestamps)
|
||||
# Compute values
|
||||
for key in y:
|
||||
func[key](data)
|
||||
|
||||
my_dict[dict_y["bed_elevation"]] = z_min
|
||||
if "discharge" in y:
|
||||
my_dict[dict_y["discharge"]] = q
|
||||
if "water_elevation" in y:
|
||||
my_dict[dict_y["water_elevation"]] = z
|
||||
if "velocity" in y:
|
||||
my_dict[dict_y["velocity"]] = v
|
||||
if "depth" in y:
|
||||
if self._current_results != 2:
|
||||
d = list(
|
||||
map(lambda x: profile.geometry.max_water_depth(x), z)
|
||||
)
|
||||
else:
|
||||
d1 = list(
|
||||
map(lambda x: profile1.geometry.max_water_depth(x), z1)
|
||||
)
|
||||
d2 = list(
|
||||
map(lambda x: profile2.geometry.max_water_depth(x), z2)
|
||||
)
|
||||
d = list(
|
||||
map(
|
||||
lambda x, y: x - y,
|
||||
d1, d2
|
||||
)
|
||||
)
|
||||
my_dict[dict_y["depth"]] = d
|
||||
if "mean_depth" in y:
|
||||
if self._current_results != 2:
|
||||
d = list(
|
||||
map(lambda x: profile.geometry.mean_water_depth(x), z)
|
||||
)
|
||||
else:
|
||||
d1 = list(
|
||||
map(lambda x: profile1.geometry.mean_water_depth(x), z1)
|
||||
)
|
||||
d2 = list(
|
||||
map(lambda x: profile2.geometry.mean_water_depth(x), z2)
|
||||
)
|
||||
d = list(map(
|
||||
lambda x, y: x - y,
|
||||
d1, d2
|
||||
))
|
||||
my_dict[dict_y["mean_depth"]] = d
|
||||
if "froude" in y:
|
||||
if self._current_results != 2:
|
||||
fr = my_dict[dict_y["froude"]] = list(
|
||||
map(lambda z, v:
|
||||
v / sqrt(9.81 * (
|
||||
profile.geometry.wet_area(z) /
|
||||
profile.geometry.wet_width(z))
|
||||
),
|
||||
z, v)
|
||||
)
|
||||
else:
|
||||
fr1 = list(
|
||||
map(lambda z, v:
|
||||
v /
|
||||
sqrt(9.81 * (
|
||||
profile1.geometry.wet_area(z) /
|
||||
profile1.geometry.wet_width(z))
|
||||
),
|
||||
z1, v1)
|
||||
)
|
||||
fr2 = list(
|
||||
map(lambda z, v:
|
||||
v /
|
||||
sqrt(9.81 * (
|
||||
profile2.geometry.wet_area(z) /
|
||||
profile2.geometry.wet_width(z))
|
||||
),
|
||||
z2, v2)
|
||||
)
|
||||
fr = list(map(
|
||||
lambda x, y: x - y,
|
||||
fr1, fr2
|
||||
))
|
||||
my_dict[dict_y["froude"]] = fr
|
||||
if "wet_area" in y:
|
||||
if self._current_results != 2:
|
||||
wa = list(
|
||||
map(lambda x: profile.geometry.wet_area(x), z)
|
||||
)
|
||||
else:
|
||||
wa1 = list(
|
||||
map(lambda x: profile1.geometry.wet_area(x), z1)
|
||||
)
|
||||
wa2 = list(
|
||||
map(lambda x: profile2.geometry.wet_area(x), z2)
|
||||
)
|
||||
wa = list(map(
|
||||
lambda x, y: x - y,
|
||||
wa1, wa2
|
||||
))
|
||||
my_dict[dict_y["wet_area"]] = wa
|
||||
# Translate dictionary keys
|
||||
translated_dict = {}
|
||||
translated_dict[dict_x["time"]] = self._timestamps
|
||||
|
||||
return my_dict
|
||||
for key in my_dict:
|
||||
translated_dict[dict_y[key]] = my_dict[key]
|
||||
|
||||
return translated_dict
|
||||
|
||||
def _export_time_compute_elevation(self, data):
|
||||
my_dict = data["my_dict"]
|
||||
profile = data["profile"]
|
||||
|
||||
if reach.has_bedload():
|
||||
z_min = data["zfd"]
|
||||
else:
|
||||
z_min = [profile.geometry.z_min()] * len(self._timestamps)
|
||||
|
||||
my_dict["bed_elevation"] = z_min
|
||||
|
||||
def _export_time_compute_depth(self, data):
|
||||
my_dict = data["my_dict"]
|
||||
profile = data["profile"]
|
||||
|
||||
z = data["z"]
|
||||
|
||||
my_dict["depth"] = list(
|
||||
map(lambda x: profile.geometry.max_water_depth(x), z)
|
||||
)
|
||||
|
||||
def _export_time_compute_mean_depth(self, data):
|
||||
my_dict = data["my_dict"]
|
||||
profile = data["profile"]
|
||||
|
||||
z = data["z"]
|
||||
|
||||
my_dict["mean_depth"] = list(
|
||||
map(lambda x: profile.geometry.mean_water_depth(x), z)
|
||||
)
|
||||
|
||||
def _export_time_compute_froude(self, data):
|
||||
my_dict = data["my_dict"]
|
||||
profile = data["profile"]
|
||||
|
||||
z = data["z"]
|
||||
v = data["v"]
|
||||
|
||||
my_dict["froude"] = list(
|
||||
map(
|
||||
lambda z, v: profile.geometry.froude(z, v),
|
||||
z, v
|
||||
)
|
||||
)
|
||||
|
||||
def _export_time_compute_wet_area(self, data):
|
||||
my_dict = data["my_dict"]
|
||||
profile = data["profile"]
|
||||
|
||||
z = data["z"]
|
||||
|
||||
my_dict["wet_area"] = list(
|
||||
map(
|
||||
lambda x: profile.geometry.wet_area(x),
|
||||
z
|
||||
)
|
||||
)
|
||||
|
||||
def get_timestamps(self):
|
||||
self._timestamps = sorted(list(self._results[0].get("timestamps")))
|
||||
@@ -1526,7 +1420,6 @@ class ResultsEnsembleWindow(ResultsWindow):
|
||||
def setup_connections(self):
|
||||
# Action
|
||||
actions = {
|
||||
"action_add": self._add_custom_plot,
|
||||
"action_export": self._export,
|
||||
# "action_export": self.export_current,
|
||||
"action_import_data": self.import_data
|
||||
@@ -1568,6 +1461,15 @@ class ResultsEnsembleWindow(ResultsWindow):
|
||||
tab_widget = self.find(QTabWidget, f"tabWidget")
|
||||
tab_widget.currentChanged.connect(self.tab_changed)
|
||||
|
||||
def _compute_status_label(self):
|
||||
return (self.text_bief() + " | " +
|
||||
self.text_profile() + " | " +
|
||||
self.text_time() + " | " +
|
||||
self.text_seed())
|
||||
|
||||
def text_seed(self):
|
||||
return f"Seed: {self._results[0].get("seed")}"
|
||||
|
||||
def update(self,
|
||||
reach_id=None,
|
||||
profile_id=None,
|
||||
@@ -1650,3 +1552,186 @@ class ResultsEnsembleWindow(ResultsWindow):
|
||||
|
||||
def update_table_selection_solver(self, ind):
|
||||
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"],
|
||||
}
|
||||
|
||||
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:
|
||||
self._sub_dict["table_headers_raw_data"] = {
|
||||
"name": _translate("Results", "Profile"),
|
||||
@@ -157,7 +176,7 @@ class ResultsTranslate(MainTranslate):
|
||||
"max_velocity": self._dict["unit_max_velocity"],
|
||||
"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"],
|
||||
|
||||
@@ -576,30 +576,15 @@ class SolverLogEnsWindow(SolverLogWindow):
|
||||
table = {}
|
||||
|
||||
for key in ["z", "q"]:
|
||||
for func in ["min", "mean", "max"]:
|
||||
for func in ["min", "mean", "max", "std_derivation"]:
|
||||
name = f"{key}_{func}"
|
||||
table[name] = results.new_table_data(name, tables[name])
|
||||
|
||||
name = f"res_{name}"
|
||||
table[name] = results.new_table_data(
|
||||
name,
|
||||
np.array(
|
||||
list(map(lambda e: e[1], tables[name]))
|
||||
)
|
||||
)
|
||||
|
||||
# for nb, data in tables["traces"]:
|
||||
# name = f"{nb}_"
|
||||
# table[name + "z"] = results.new_table_data(name + "z",
|
||||
# data["Z"])
|
||||
# table[name + "q"] = results.new_table_data(name + "q",
|
||||
# data["Q"])
|
||||
|
||||
table["samples"] = results.new_table_data(
|
||||
"samples", np.array(self._run_samples)
|
||||
)
|
||||
results.set("number_of_run", self._number_of_run)
|
||||
results.set("seed", self._seed) # Keep random seed
|
||||
results.set("seed", self._seed) # Keep random seed
|
||||
|
||||
results.set("table", table)
|
||||
|
||||
|
||||
@@ -47,11 +47,19 @@ class AbstractMenu(object):
|
||||
|
||||
class DefaultMenu(AbstractMenu):
|
||||
def run(self):
|
||||
current_scenario = self._graph.status.scenario
|
||||
|
||||
if current_scenario.is_ensemble():
|
||||
return
|
||||
|
||||
add_node = self._menu.addAction(self._trad["menu_add_scenario"])
|
||||
ensemble = self._menu.addAction(self._trad["menu_ens_scenario"])
|
||||
|
||||
action = self._exec()
|
||||
if action == add_node:
|
||||
self._parent.new_scenario(self._pos)
|
||||
if action == ensemble:
|
||||
self._parent.create_new_ensemble_scenario(self._pos)
|
||||
|
||||
|
||||
class ScenarioMenu(AbstractMenu):
|
||||
@@ -59,17 +67,16 @@ class ScenarioMenu(AbstractMenu):
|
||||
item = self._items[0]
|
||||
scenarios = item.graph._study.scenarios
|
||||
|
||||
if len(scenarios) == 1:
|
||||
return
|
||||
|
||||
current_scenario = item.graph._study.status.scenario.id
|
||||
|
||||
select = self._menu.addAction(self._trad["menu_select_scenario"])
|
||||
select = None
|
||||
duplicate = None
|
||||
delete = None
|
||||
ensemble = None
|
||||
edit_ens = None
|
||||
|
||||
if len(scenarios) > 1:
|
||||
select = self._menu.addAction(self._trad["menu_select_scenario"])
|
||||
|
||||
if item.scenario.id != 0:
|
||||
if scenarios.is_leaf(item.scenario):
|
||||
delete = self._menu.addAction(self._trad["menu_del_scenario"])
|
||||
@@ -79,17 +86,11 @@ class ScenarioMenu(AbstractMenu):
|
||||
self._trad["menu_dup_scenario"]
|
||||
)
|
||||
|
||||
if not item.scenario.is_ensemble():
|
||||
if item.scenario.id == current_scenario:
|
||||
ensemble = self._menu.addAction(
|
||||
self._trad["menu_ens_scenario"]
|
||||
if item.scenario.is_ensemble():
|
||||
edit_ens = self._menu.addAction(
|
||||
self._trad["menu_edit_ens_scenario"]
|
||||
)
|
||||
|
||||
if item.scenario.is_ensemble():
|
||||
edit_ens = self._menu.addAction(
|
||||
self._trad["menu_edit_ens_scenario"]
|
||||
)
|
||||
|
||||
action = self._exec()
|
||||
if action is None:
|
||||
return
|
||||
@@ -99,7 +100,5 @@ class ScenarioMenu(AbstractMenu):
|
||||
self._parent.delete_scenario(item)
|
||||
elif action == duplicate:
|
||||
self._parent.duplicate_scenario(item)
|
||||
elif action == ensemble:
|
||||
self._parent.create_ensemble_scenario(item)
|
||||
elif action == edit_ens:
|
||||
self._parent.edit_ensemble_scenario(item)
|
||||
@@ -550,6 +550,26 @@ class GraphWidget(QGraphicsView):
|
||||
self.exec_with_waiting_window(fn, "create_ensemble_scenario")
|
||||
self.changeScenario.emit(self.sender())
|
||||
|
||||
def create_new_ensemble_scenario(self, pos):
|
||||
must_save = self.dialog_save()
|
||||
if must_save == "Cancel":
|
||||
return
|
||||
|
||||
def fn():
|
||||
self._close_other_window()
|
||||
|
||||
if must_save == "Save":
|
||||
self._study.save()
|
||||
|
||||
self._undo.push(
|
||||
CreateEnsembleScenarioCommand(
|
||||
self._study, pos=pos,
|
||||
)
|
||||
)
|
||||
|
||||
self.exec_with_waiting_window(fn, "create_ensemble_scenario")
|
||||
self.changeScenario.emit(self.sender())
|
||||
|
||||
def edit_ensemble_scenario(self, item):
|
||||
self.parent\
|
||||
.parent\
|
||||
|
||||
@@ -99,11 +99,12 @@ class DuplicateScenariosCommand(QUndoCommand):
|
||||
|
||||
|
||||
class CreateEnsembleScenarioCommand(QUndoCommand):
|
||||
def __init__(self, study):
|
||||
def __init__(self, study, pos=None):
|
||||
QUndoCommand.__init__(self)
|
||||
|
||||
self._study = study
|
||||
self._new = None
|
||||
self._pos = pos
|
||||
|
||||
def undo(self):
|
||||
self._study.scenarios.delete(self._new.id)
|
||||
@@ -111,7 +112,7 @@ class CreateEnsembleScenarioCommand(QUndoCommand):
|
||||
|
||||
def redo(self):
|
||||
if self._new is None:
|
||||
self._new = self._study.create_ensemble_scenario()
|
||||
self._new = self._study.create_ensemble_scenario(self._pos)
|
||||
else:
|
||||
self._new.set_as_not_deleted()
|
||||
self._study.reload_from_scenario(self._new)
|
||||
|
||||
@@ -44,7 +44,7 @@ class ScenariosTranslate(MainTranslate):
|
||||
"Scenarios", "Duplicate this scenario"
|
||||
)
|
||||
self._dict["menu_ens_scenario"] = _translate(
|
||||
"Scenarios", "Create ensemble scenario from this scenario"
|
||||
"Scenarios", "Create ensemble scenario from current scenario"
|
||||
)
|
||||
self._dict["menu_edit_ens_scenario"] = _translate(
|
||||
"Scenarios", "Edit this ensemble scenario"
|
||||
|
||||
@@ -107,7 +107,7 @@ class WindowToolKit(object):
|
||||
|
||||
dialog = QFileDialog(self, options=options)
|
||||
|
||||
if select_file == "Existing_file":
|
||||
if select_file == "ExistingFile":
|
||||
mode = QFileDialog.FileMode.ExistingFile
|
||||
elif select_file == "Directory":
|
||||
mode = QFileDialog.FileMode.Directory
|
||||
@@ -390,7 +390,6 @@ class ASubWindowFeatures(object):
|
||||
"""
|
||||
return self.find(QSpinBox, name).value()
|
||||
|
||||
|
||||
def set_spin_box_enable(self, name: str, value: bool):
|
||||
"""Set status of spinbox component
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ class PamhyrPlot(APlot):
|
||||
color_plot_ensemble_min = "green"
|
||||
color_plot_ensemble_mean = "black"
|
||||
color_plot_ensemble_max = "red"
|
||||
color_plot_ensemble_std_deriv = "black"
|
||||
|
||||
colors = list(mplcolors.TABLEAU_COLORS)
|
||||
linestyle = ['solid', 'dashed', 'dashdot', 'dotted']
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
# PamhyrTree.py -- Pamhyr abstract table model
|
||||
# Copyright (C) 2023-2026 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
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import logging
|
||||
import traceback
|
||||
|
||||
from tools import trace, timer
|
||||
|
||||
from Model.Except import NotImplementedMethodeError
|
||||
|
||||
from PyQt5.QtCore import (
|
||||
Qt, QVariant, QAbstractItemModel,
|
||||
QCoreApplication, QModelIndex, pyqtSlot,
|
||||
)
|
||||
|
||||
from PyQt5.QtWidgets import (
|
||||
QTreeWidget, QTreeWidgetItem,
|
||||
)
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
class PamhyrModelItem(QTreeWidgetItem):
|
||||
def __init__(self, data=None, trad=None, parent=None):
|
||||
self._data = data
|
||||
self._name = self._get_name()
|
||||
|
||||
super(PamhyrModelItem, self).__init__(
|
||||
parent, [self._name],
|
||||
)
|
||||
|
||||
self._setup_children()
|
||||
|
||||
def _get_name(self):
|
||||
return str(self._data)
|
||||
|
||||
def _setup_children(self):
|
||||
return
|
||||
|
||||
def get_value(self):
|
||||
return self._data
|
||||
|
||||
def find_item_by_value(self, data):
|
||||
if self.get_value() == data:
|
||||
return self
|
||||
|
||||
for i in range(self.childCount()):
|
||||
item = self.child(i)
|
||||
if item.get_value() == data:
|
||||
return item
|
||||
|
||||
found = item.find_item_by_value(data)
|
||||
if found:
|
||||
return found
|
||||
|
||||
return None
|
||||
|
||||
|
||||
class PamhyrModelListItem(QTreeWidgetItem):
|
||||
def __init__(self, name=None, lst=None,
|
||||
child_item_ctor=PamhyrModelItem,
|
||||
trad=None, parent=None):
|
||||
super(PamhyrModelListItem, self).__init__(
|
||||
parent, [name],
|
||||
)
|
||||
|
||||
self._name = name
|
||||
self._lst = lst
|
||||
self._trad = trad
|
||||
self._child_item_ctor = child_item_ctor
|
||||
|
||||
self._setup_children()
|
||||
|
||||
def _setup_children(self):
|
||||
for el in self._lst.lst:
|
||||
self.addChild(
|
||||
self._child_item_ctor(
|
||||
data=el, trad=self._trad, parent=self
|
||||
)
|
||||
)
|
||||
|
||||
def get_value(self):
|
||||
return None
|
||||
|
||||
def find_item_by_value(self, data):
|
||||
if self.get_value() == data:
|
||||
return self
|
||||
|
||||
for i in range(self.childCount()):
|
||||
item = self.child(i)
|
||||
if item.get_value() == data:
|
||||
return item
|
||||
|
||||
found = item.find_item_by_value(data)
|
||||
if found:
|
||||
return found
|
||||
|
||||
return None
|
||||
+19
-3
@@ -45,7 +45,6 @@ class CommonWordTranslate(PamhyrTranslate):
|
||||
|
||||
self._dict["loc"] = _translate("CommonWord", "Loc")
|
||||
self._dict["scale"] = _translate("CommonWord", "Scale")
|
||||
self._dict["lam"] = _translate("CommonWord", "Lam")
|
||||
|
||||
self._dict["reach"] = _translate("CommonWord", "Reach")
|
||||
self._dict["reaches"] = _translate("CommonWord", "Reaches")
|
||||
@@ -72,6 +71,9 @@ class CommonWordTranslate(PamhyrTranslate):
|
||||
self._dict["file_csv"] = _translate(
|
||||
"CommonWord", "CSV file (*.csv)"
|
||||
)
|
||||
self._dict["file_json"] = _translate(
|
||||
"CommonWord", "JSON file (*.json)"
|
||||
)
|
||||
|
||||
|
||||
class UnitTranslate(CommonWordTranslate):
|
||||
@@ -110,6 +112,12 @@ class UnitTranslate(CommonWordTranslate):
|
||||
self._dict["unit_water_elevation"] = _translate(
|
||||
"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(
|
||||
"Unit", "Water Elevation Envelop (m)"
|
||||
)
|
||||
@@ -129,8 +137,16 @@ class UnitTranslate(CommonWordTranslate):
|
||||
self._dict["unit_min_velocity"] = _translate(
|
||||
"Unit", "Min Velocity (m/s)"
|
||||
)
|
||||
self._dict["unit_discharge"] = _translate(
|
||||
"Unit", "Discharge") + f" (m³/s)"
|
||||
self._dict["unit_discharge"] = (
|
||||
_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(
|
||||
"Unit", "Discharge Envelop") + " (m³/s)"
|
||||
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>
|
||||
@@ -0,0 +1,157 @@
|
||||
<?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>875</width>
|
||||
<height>415</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_name"/>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Distribution</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QComboBox" name="comboBox_distribution"/>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>313</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0" rowspan="2" colspan="2">
|
||||
<widget class="QGroupBox" name="groupBox_target_data">
|
||||
<property name="title">
|
||||
<string>Target data</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTreeWidget" name="treeWidget_target_data">
|
||||
<column>
|
||||
<property name="text">
|
||||
<string notr="true">1</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2" colspan="3">
|
||||
<widget class="QGroupBox" name="groupBox_params">
|
||||
<property name="title">
|
||||
<string>Parameters</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_params"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2" colspan="3">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="2" colspan="3">
|
||||
<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>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<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>
|
||||
<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>
|
||||
</connections>
|
||||
</ui>
|
||||
@@ -57,7 +57,7 @@
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox">
|
||||
<property name="text">
|
||||
<string>Custom random seed</string>
|
||||
<string>Custom seed</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -33,6 +33,9 @@
|
||||
<addaction name="action_add"/>
|
||||
<addaction name="action_del"/>
|
||||
<addaction name="action_edit"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="action_export"/>
|
||||
<addaction name="action_import"/>
|
||||
</widget>
|
||||
<action name="action_add">
|
||||
<property name="icon">
|
||||
@@ -79,6 +82,30 @@
|
||||
<enum>QAction::NoRole</enum>
|
||||
</property>
|
||||
</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>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
||||
@@ -196,22 +196,9 @@
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="action_add"/>
|
||||
<addaction name="action_export"/>
|
||||
<addaction name="action_import_data"/>
|
||||
</widget>
|
||||
<action name="action_add">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>ressources/add.png</normaloff>ressources/add.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Add customized visualization</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_export">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Form</class>
|
||||
<widget class="QWidget" name="Form">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>482</width>
|
||||
<height>48</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_0">
|
||||
<property name="text">
|
||||
<string>Parameter 1</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_0">
|
||||
<property name="minimum">
|
||||
<double>-10000000000.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>10000000000.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Form</class>
|
||||
<widget class="QWidget" name="Form">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>416</width>
|
||||
<height>80</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_0">
|
||||
<property name="text">
|
||||
<string>Parameter 1</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_0">
|
||||
<property name="minimum">
|
||||
<double>-10000000000.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>10000000000.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_1">
|
||||
<property name="text">
|
||||
<string>Parameter 2</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_1">
|
||||
<property name="minimum">
|
||||
<double>-10000000000.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>10000000000.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Binary file not shown.
Reference in new issue
Block a user