mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
Compare commits
124
Commits
v2.0.0rc1
...
5a195e2822
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 | ||
|
|
32a316589b | ||
|
|
d4bc9bdf75 | ||
|
|
3325ba935b | ||
|
|
345f24996f | ||
|
|
4040b2456c | ||
|
|
8e77d31a5a | ||
|
|
6e029beafc | ||
|
|
f5a7cd5984 | ||
|
|
d4d5e26a2b | ||
|
|
92990948ad | ||
|
|
bf6d40f398 | ||
|
|
03299db99a | ||
|
|
a0886d900e | ||
|
|
97fe038d9b | ||
|
|
58e3da8942 | ||
|
|
b7c3793a66 | ||
|
|
2498466a51 | ||
|
|
ef36eba039 | ||
|
|
c40e28ed0f | ||
|
|
b21846a513 | ||
|
|
3532f75c2b | ||
|
|
6c59919972 | ||
|
|
77d56b8bec | ||
|
|
7ef7bc13dc | ||
|
|
a1d85274b9 | ||
|
|
e7b9bc92a2 | ||
|
|
7d8e414fe2 | ||
|
|
476bcc9c55 | ||
|
|
ae006f52f4 | ||
|
|
3583a93ae0 | ||
|
|
212a00a43c | ||
|
|
e5dbba362a | ||
|
|
bdc09addfa | ||
|
|
51b3987a4a | ||
|
|
e7290fa81b | ||
|
|
b5432498c6 | ||
|
|
807592eab2 | ||
|
|
394c0779fc | ||
|
|
5b3f777100 | ||
|
|
8b36905842 | ||
|
|
b203e8e062 | ||
|
|
4d4df1bde2 | ||
|
|
876780a349 | ||
|
|
3b83377f3c | ||
|
|
e64c45b621 | ||
|
|
70dae9ab1b | ||
|
|
0bb3c5bc65 | ||
|
|
54f5c7c548 | ||
|
|
56217186ff | ||
|
|
82fb2bcc48 | ||
|
|
6dc42b637a | ||
|
|
e6d12713e3 | ||
|
|
9456cf32fc | ||
|
|
9b1fb4e7d2 | ||
|
|
c09c62f077 | ||
|
|
7a2e93a995 | ||
|
|
5327c29641 | ||
|
|
be865102a8 | ||
|
|
37f1b43b93 | ||
|
|
16f0775783 | ||
|
|
f2c4285b4c | ||
|
|
ee95f0e89e | ||
|
|
1306977954 | ||
|
|
476fa81bc2 | ||
|
|
e8f1f0ac43 | ||
|
|
1adf24ce77 | ||
|
|
a61d130baa | ||
|
|
0a1760cee6 | ||
|
|
3e094af325 | ||
|
|
762e4d70a0 | ||
|
|
6c4f863b96 | ||
|
|
b87f82f74d | ||
|
|
ffad53a331 | ||
|
|
662a218e41 | ||
|
|
0501ae9bec | ||
|
|
7fd38eec00 | ||
|
|
4bab4580ad | ||
|
|
21d2e6ad20 | ||
|
|
d0a8f369ef | ||
|
|
fef2e1a40c | ||
|
|
20c2cb7ea4 | ||
|
|
ecb2544cab | ||
|
|
9c66021b53 | ||
|
|
8255fc3c1b | ||
|
|
32e7413aad | ||
|
|
d87db5fd48 | ||
|
|
388368adad | ||
|
|
4d014d5a1d | ||
|
|
181a6c226f | ||
|
|
1975ed7eaa | ||
|
|
565a7530fb |
No files matched your search
@@ -1,4 +1,4 @@
|
|||||||
Sylvain COULIBALY, INRAE, 2020 - 2022
|
Sylvain COULIBALY, INRAE, 2020 - 2022
|
||||||
Théophile TERRAZ, INRAE, 2022 - 2024
|
Théophile TERRAZ, INRAE, 2022 - 2024
|
||||||
Pierre-Antoine ROUBY, INRAE, 2023 - 2025
|
Pierre-Antoine ROUBY, INRAE, 2023 - 2026
|
||||||
Dylan JEANNIN, INRAE, 2026
|
Dylan JEANNIN, INRAE, 2026
|
||||||
@@ -1069,6 +1069,12 @@ gitlab-ci.
|
|||||||
sudo python3 -m pip install pyinstaller
|
sudo python3 -m pip install pyinstaller
|
||||||
#+end_src
|
#+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}}}
|
*** Windows (Wine) {{{windows}}}
|
||||||
|
|
||||||
The ci-runner environment for Wine need at least wine version 8, let
|
The ci-runner environment for Wine need at least wine version 8, let
|
||||||
|
|||||||
+1
-1
@@ -20,4 +20,4 @@
|
|||||||
"python-pyqtgraph" "python-qscintilla"
|
"python-pyqtgraph" "python-qscintilla"
|
||||||
"python-numpy@1" "python-shapely" "python-pyshp"
|
"python-numpy@1" "python-shapely" "python-pyshp"
|
||||||
"python-matplotlib" "python-colorama"
|
"python-matplotlib" "python-colorama"
|
||||||
"python-rasterio"))
|
"python-rasterio" "python-psutil"))
|
||||||
+2
-2
@@ -4,7 +4,7 @@ PyQt5-sip==12.18.0
|
|||||||
#PyQtWebEngine==5.15.6
|
#PyQtWebEngine==5.15.6
|
||||||
QScintilla>=2.14.1
|
QScintilla>=2.14.1
|
||||||
pyqtgraph>=0.12.1
|
pyqtgraph>=0.12.1
|
||||||
matplotlib==3.8.3
|
matplotlib==3.10.8
|
||||||
numpy>=1.24.2
|
numpy>=1.24.2
|
||||||
colorama>=0.4.3
|
colorama>=0.4.3
|
||||||
pyinstaller>=5.11.0
|
pyinstaller>=5.11.0
|
||||||
@@ -14,4 +14,4 @@ platformdirs>=4.2.0
|
|||||||
pyshp>=2.3.1
|
pyshp>=2.3.1
|
||||||
rasterio==1.3.11
|
rasterio==1.3.11
|
||||||
#fortranformat==2.0.3
|
#fortranformat==2.0.3
|
||||||
|
psutil>=7.2.2
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
# Adists.py -- Pamhyr study checkers
|
# Adists.py -- Pamhyr study checkers
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Checker.py -- Pamhyr abstract checker class
|
# Checker.py -- Pamhyr abstract checker class
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
# Mage.py -- Pamhyr MAGE checkers
|
# Mage.py -- Pamhyr MAGE checkers
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Study.py -- Pamhyr study checkers
|
# Study.py -- Pamhyr study checkers
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# AMeshingTool.py -- Pamhyr
|
# AMeshingTool.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Internal.py -- Pamhyr
|
# Internal.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
# Mage.py -- Pamhyr
|
# Mage.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# __init__.py -- Pamhyr
|
# __init__.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# test_Model.py -- Pamhyr
|
# test_Model.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# BoundaryCondition.py -- Pamhyr
|
# BoundaryCondition.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# BoundaryConditionList.py -- Pamhyr
|
# BoundaryConditionList.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# BoundaryConditionTypes.py -- Pamhyr
|
# BoundaryConditionTypes.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# BoundaryConditionsAdisTS.py -- Pamhyr
|
# BoundaryConditionsAdisTS.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# BoundaryConditionsAdisTSList.py -- Pamhyr
|
# BoundaryConditionsAdisTSList.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# D90AdisTS.py -- Pamhyr
|
# D90AdisTS.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# D90AdisTSList.py -- Pamhyr
|
# D90AdisTSList.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# D90AdisTSSpec.py -- Pamhyr
|
# D90AdisTSSpec.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# DIFAdisTS.py -- Pamhyr
|
# DIFAdisTS.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# DIFAdisTSList.py -- Pamhyr
|
# DIFAdisTSList.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# DIFAdisTSSpec.py -- Pamhyr
|
# DIFAdisTSSpec.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -0,0 +1,241 @@
|
|||||||
|
# Distribution.py -- Pamhyr
|
||||||
|
# Copyright (C) 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 struct
|
||||||
|
import logging
|
||||||
|
import itertools
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
from tools import logger_exception
|
||||||
|
|
||||||
|
from Model.Except import NotImplementedMethodeError
|
||||||
|
from Model.Tools.PamhyrDB import SQLSubModel
|
||||||
|
from Model.Scenario import Scenario
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
|
|
||||||
|
class Distribution(SQLSubModel):
|
||||||
|
_sub_classes = []
|
||||||
|
|
||||||
|
def __init__(self, id: int = -1,
|
||||||
|
name: str = "", script: str = "",
|
||||||
|
status=None):
|
||||||
|
super(Distribution, self).__init__(
|
||||||
|
id=id, status=status,
|
||||||
|
owner_scenario=0
|
||||||
|
)
|
||||||
|
|
||||||
|
self._name = name
|
||||||
|
self._type = "generic"
|
||||||
|
self._script = script
|
||||||
|
self._labels = []
|
||||||
|
self._default_values = []
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self):
|
||||||
|
return self._name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def labels(self):
|
||||||
|
return self._labels
|
||||||
|
|
||||||
|
@property
|
||||||
|
def default_values(self):
|
||||||
|
return self._default_values
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _db_create(cls, execute, ext=""):
|
||||||
|
execute(f"""
|
||||||
|
CREATE TABLE ensemble_distribution{ext} (
|
||||||
|
{cls.create_db_add_pamhyr_id()},
|
||||||
|
deleted BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
name TEXT NOT NULL,
|
||||||
|
script TEXT NOT NULL,
|
||||||
|
PRIMARY KEY(pamhyr_id)
|
||||||
|
)
|
||||||
|
""")
|
||||||
|
|
||||||
|
if ext == "_tmp":
|
||||||
|
return True
|
||||||
|
|
||||||
|
return cls._create_submodel(execute)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _db_update(cls, execute, version, data=None):
|
||||||
|
major, minor, release = version.strip().split(".")
|
||||||
|
if major == "0" and int(minor) < 2:
|
||||||
|
cls._db_create(execute)
|
||||||
|
elif major == "0" and int(minor) == 2:
|
||||||
|
if int(release) < 8:
|
||||||
|
cls._db_create(execute)
|
||||||
|
|
||||||
|
return cls._update_submodel(execute, version, data)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _db_load(cls, execute, data=None):
|
||||||
|
new = []
|
||||||
|
scenario = data["scenario"]
|
||||||
|
loaded = data['loaded_pid']
|
||||||
|
|
||||||
|
table = execute(
|
||||||
|
"SELECT pamhyr_id, deleted, name, script " +
|
||||||
|
"FROM ensemble_distribution " +
|
||||||
|
f"WHERE pamhyr_id NOT IN ({', '.join(map(str, loaded))})"
|
||||||
|
)
|
||||||
|
|
||||||
|
for row in table:
|
||||||
|
it = iter(row)
|
||||||
|
|
||||||
|
id = next(it)
|
||||||
|
deleted = (next(it) == 1)
|
||||||
|
name = next(it)
|
||||||
|
script = next(it)
|
||||||
|
|
||||||
|
new_distribution = cls(
|
||||||
|
id, name=name, script=script,
|
||||||
|
status=data["status"]
|
||||||
|
)
|
||||||
|
if deleted:
|
||||||
|
new_distribution.set_as_deleted()
|
||||||
|
|
||||||
|
loaded.add(id)
|
||||||
|
new.append(new_distribution)
|
||||||
|
|
||||||
|
return new
|
||||||
|
|
||||||
|
def _db_save(self, execute, data=None):
|
||||||
|
# Only save custom distribution
|
||||||
|
if self._type != "custom":
|
||||||
|
return True
|
||||||
|
|
||||||
|
if not self.must_be_saved():
|
||||||
|
return True
|
||||||
|
|
||||||
|
execute(
|
||||||
|
"INSERT INTO " +
|
||||||
|
"ensemble_distribution(pamhyr_id, deleted, " +
|
||||||
|
" name, script) " +
|
||||||
|
"VALUES (?, ?, ?, ?)",
|
||||||
|
self.pamhyr_id, self.is_deleted(),
|
||||||
|
self._name, self._script
|
||||||
|
)
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
def _data_traversal(self,
|
||||||
|
predicate=lambda obj, data: True,
|
||||||
|
modifier=lambda obj, data: None,
|
||||||
|
data={}):
|
||||||
|
if predicate(self, data):
|
||||||
|
modifier(self, data)
|
||||||
|
|
||||||
|
def random(self, r):
|
||||||
|
raise NotImplementedMethodeError(cls, cls._load)
|
||||||
|
|
||||||
|
|
||||||
|
###########################
|
||||||
|
# DISTRIBUTION IMPLEMENTATION #
|
||||||
|
###########################
|
||||||
|
|
||||||
|
class Uniform(Distribution):
|
||||||
|
_sub_classes = []
|
||||||
|
|
||||||
|
def __init__(self, id: int = -1,
|
||||||
|
name: str = "uniform", script: str = "",
|
||||||
|
status=None):
|
||||||
|
super(Uniform, self).__init__(
|
||||||
|
id=id, status=status,
|
||||||
|
name=name, script=script
|
||||||
|
)
|
||||||
|
|
||||||
|
self._labels = ["low", "high"]
|
||||||
|
self._default_values = [20.0, 40.0]
|
||||||
|
|
||||||
|
def random(self, params, nb):
|
||||||
|
lst = params.copy()
|
||||||
|
lst.append(nb)
|
||||||
|
|
||||||
|
return np.random.uniform(*lst)
|
||||||
|
|
||||||
|
|
||||||
|
class Normal(Distribution):
|
||||||
|
_sub_classes = []
|
||||||
|
|
||||||
|
def __init__(self, id: int = -1,
|
||||||
|
name: str = "normal", script: str = "",
|
||||||
|
status=None):
|
||||||
|
super(Normal, self).__init__(
|
||||||
|
id=id, status=status,
|
||||||
|
name=name, script=script
|
||||||
|
)
|
||||||
|
|
||||||
|
self._labels = ["loc", "scale"]
|
||||||
|
self._default_values = [30.0, 5.0]
|
||||||
|
|
||||||
|
def random(self, params, nb):
|
||||||
|
lst = params.copy()
|
||||||
|
lst.append(nb)
|
||||||
|
|
||||||
|
return np.random.normal(*lst)
|
||||||
|
|
||||||
|
|
||||||
|
class Poisson(Distribution):
|
||||||
|
_sub_classes = []
|
||||||
|
|
||||||
|
def __init__(self, id: int = -1,
|
||||||
|
name: str = "poisson", script: str = "",
|
||||||
|
status=None):
|
||||||
|
super(Poisson, self).__init__(
|
||||||
|
id=id, status=status,
|
||||||
|
name=name, script=script
|
||||||
|
)
|
||||||
|
|
||||||
|
self._labels = ["lam"]
|
||||||
|
self._default_values = [5.0]
|
||||||
|
|
||||||
|
def random(self, params, nb):
|
||||||
|
lst = params.copy()
|
||||||
|
lst.append(nb)
|
||||||
|
|
||||||
|
return np.random.poisson(*lst)
|
||||||
|
|
||||||
|
|
||||||
|
class Custom(Distribution):
|
||||||
|
_sub_classes = []
|
||||||
|
|
||||||
|
def __init__(self, id: int = -1,
|
||||||
|
name: str = "", script: str = "",
|
||||||
|
status=None):
|
||||||
|
super(Custom, self).__init__(
|
||||||
|
id=id, status=status,
|
||||||
|
name=name, script=script
|
||||||
|
)
|
||||||
|
|
||||||
|
self._labels = ["custom"]
|
||||||
|
self._type = "custom"
|
||||||
|
self._default_values = ""
|
||||||
|
|
||||||
|
def random(self, params, nb):
|
||||||
|
try:
|
||||||
|
# Run script to (re)define the sample distribution
|
||||||
|
f = eval(self._script)
|
||||||
|
return f(params, nb)
|
||||||
|
except Exception as e:
|
||||||
|
logger_exception(e)
|
||||||
|
return None # TODO: Raise helpful exception
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
# DistributionList.py -- Pamhyr
|
||||||
|
# Copyright (C) 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 tools import trace, timer
|
||||||
|
|
||||||
|
from Model.Tools.PamhyrListExt import PamhyrModelList
|
||||||
|
from Model.Ensembles.Distribution import *
|
||||||
|
|
||||||
|
|
||||||
|
class DistributionList(PamhyrModelList):
|
||||||
|
_sub_classes = [Distribution]
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _db_load(cls, execute, data=None):
|
||||||
|
new = cls(status=data['status'])
|
||||||
|
|
||||||
|
# Default distributions
|
||||||
|
new._lst = [
|
||||||
|
Uniform(status=data['status']),
|
||||||
|
Normal(status=data['status']),
|
||||||
|
Poisson(status=data['status']),
|
||||||
|
]
|
||||||
|
|
||||||
|
# DB custom distributions
|
||||||
|
new._lst += Distribution._db_load(
|
||||||
|
execute, data
|
||||||
|
)
|
||||||
|
|
||||||
|
return new
|
||||||
|
|
||||||
|
def _db_save(self, execute, data={}):
|
||||||
|
execute(
|
||||||
|
"DELETE FROM ensemble_distribution"
|
||||||
|
)
|
||||||
|
|
||||||
|
for fun in self._lst:
|
||||||
|
fun._db_save(execute, data)
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
def new(self, index):
|
||||||
|
r = Custom(status=self._status)
|
||||||
|
self._lst.insert(index, r)
|
||||||
|
self._status.modified()
|
||||||
|
return r
|
||||||
@@ -0,0 +1,279 @@
|
|||||||
|
# Ensemble.py -- Pamhyr
|
||||||
|
# Copyright (C) 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 struct
|
||||||
|
import logging
|
||||||
|
import itertools
|
||||||
|
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
from Model.Tools.PamhyrDB import SQLSubModel
|
||||||
|
from Model.Scenario import Scenario
|
||||||
|
from Model.Ensembles.Distribution import Uniform
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
|
|
||||||
|
class Ensemble(SQLSubModel):
|
||||||
|
_sub_classes = []
|
||||||
|
|
||||||
|
def __init__(self, id: int = -1, name: str = "",
|
||||||
|
distribution=None, params=[0., 100.],
|
||||||
|
data_type=None, target_data=None,
|
||||||
|
status=None, owner_scenario=-1):
|
||||||
|
super(Ensemble, self).__init__(
|
||||||
|
id=id, status=status,
|
||||||
|
owner_scenario=owner_scenario
|
||||||
|
)
|
||||||
|
|
||||||
|
self._name = name
|
||||||
|
self._data_type = data_type
|
||||||
|
self._distribution = distribution
|
||||||
|
self._params = params
|
||||||
|
self._target_data = target_data
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _db_create(cls, execute, ext=""):
|
||||||
|
execute(f"""
|
||||||
|
CREATE TABLE ensemble{ext} (
|
||||||
|
{cls.create_db_add_pamhyr_id()},
|
||||||
|
deleted BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
name TEXT NOT NULL,
|
||||||
|
type VARCHAR(8) NOT NULL,
|
||||||
|
distribution INTEGER NOT NULL,
|
||||||
|
distribution_name VARCHAR(32) NOT NULL,
|
||||||
|
params BLOB NOT NULL,
|
||||||
|
params_len INTEGER NOT NULL,
|
||||||
|
data_pid INTEGER NOT NULL,
|
||||||
|
{Scenario.create_db_add_scenario()},
|
||||||
|
{Scenario.create_db_add_scenario_fk()},
|
||||||
|
PRIMARY KEY(pamhyr_id, scenario)
|
||||||
|
)
|
||||||
|
""")
|
||||||
|
|
||||||
|
if ext == "_tmp":
|
||||||
|
return True
|
||||||
|
|
||||||
|
return cls._create_submodel(execute)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _db_update(cls, execute, version, data=None):
|
||||||
|
major, minor, release = version.strip().split(".")
|
||||||
|
if major == "0" and int(minor) < 2:
|
||||||
|
cls._db_create(execute)
|
||||||
|
elif major == "0" and int(minor) == 2:
|
||||||
|
if int(release) < 8:
|
||||||
|
cls._db_create(execute)
|
||||||
|
|
||||||
|
return cls._update_submodel(execute, version, data)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _db_load(cls, execute, data=None):
|
||||||
|
new = []
|
||||||
|
scenario = data["scenario"]
|
||||||
|
distributions = data["ens_distributions"]
|
||||||
|
stricklers = data["stricklers"]
|
||||||
|
loaded = data['loaded_pid']
|
||||||
|
|
||||||
|
table = execute(
|
||||||
|
"SELECT pamhyr_id, deleted, name, type, " +
|
||||||
|
"distribution, distribution_name, params, params_len, data_pid, " +
|
||||||
|
"scenario " +
|
||||||
|
"FROM ensemble " +
|
||||||
|
f"WHERE scenario = {scenario.id} " +
|
||||||
|
f"AND pamhyr_id NOT IN ({', '.join(map(str, loaded))})"
|
||||||
|
)
|
||||||
|
|
||||||
|
for row in table:
|
||||||
|
it = iter(row)
|
||||||
|
|
||||||
|
id = next(it)
|
||||||
|
deleted = (next(it) == 1)
|
||||||
|
name = next(it)
|
||||||
|
data_type = next(it)
|
||||||
|
fid = next(it)
|
||||||
|
fname = next(it)
|
||||||
|
params = next(it)
|
||||||
|
params_len = next(it)
|
||||||
|
data_pid = next(it)
|
||||||
|
owner_scenario = next(it)
|
||||||
|
|
||||||
|
def fn(f): return f._name == fname
|
||||||
|
if fid != -1:
|
||||||
|
def fn(f): return f._pamhyr_id == fid
|
||||||
|
|
||||||
|
distribution = next(
|
||||||
|
filter(fn, distributions.lst),
|
||||||
|
None
|
||||||
|
)
|
||||||
|
|
||||||
|
target_data = next(
|
||||||
|
filter(
|
||||||
|
lambda s: s._pamhyr_id == data_pid,
|
||||||
|
stricklers.lst
|
||||||
|
),
|
||||||
|
None
|
||||||
|
)
|
||||||
|
|
||||||
|
rdata = list(cls._decode_params(params, params_len))
|
||||||
|
|
||||||
|
new_ensemble = cls(
|
||||||
|
id, name=name,
|
||||||
|
distribution=distribution,
|
||||||
|
params=rdata,
|
||||||
|
data_type=data_type,
|
||||||
|
target_data=target_data,
|
||||||
|
status=data["status"],
|
||||||
|
owner_scenario=owner_scenario
|
||||||
|
)
|
||||||
|
if deleted:
|
||||||
|
new_ensemble.set_as_deleted()
|
||||||
|
|
||||||
|
loaded.add(id)
|
||||||
|
new.append(new_ensemble)
|
||||||
|
|
||||||
|
return new
|
||||||
|
|
||||||
|
def _db_save(self, execute, data=None):
|
||||||
|
if not self.must_be_saved():
|
||||||
|
return True
|
||||||
|
|
||||||
|
execute(
|
||||||
|
"DELETE FROM ensemble " +
|
||||||
|
f"WHERE pamhyr_id = {self.pamhyr_id} " +
|
||||||
|
f"AND scenario = {self._status.scenario_id}"
|
||||||
|
)
|
||||||
|
|
||||||
|
bparams, length = self._encode_params()
|
||||||
|
|
||||||
|
if self._distribution is None:
|
||||||
|
fid = -1
|
||||||
|
fname = "NULL"
|
||||||
|
else:
|
||||||
|
fid = self._distribution._pamhyr_id
|
||||||
|
fname = self._distribution._name
|
||||||
|
|
||||||
|
if self._distribution._type == "generic":
|
||||||
|
fid = -1
|
||||||
|
|
||||||
|
data_pid = -1
|
||||||
|
if self._target_data is not None:
|
||||||
|
data_pid = self._target_data._pamhyr_id
|
||||||
|
|
||||||
|
execute(
|
||||||
|
"INSERT INTO " +
|
||||||
|
"ensemble(pamhyr_id, deleted, name, type, " +
|
||||||
|
" distribution, distribution_name, params, params_len, " +
|
||||||
|
" data_pid, scenario) " +
|
||||||
|
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||||
|
self.pamhyr_id, self.is_deleted(),
|
||||||
|
self._name, self._data_type,
|
||||||
|
fid, fname, bparams, length,
|
||||||
|
data_pid, self._status.scenario_id
|
||||||
|
)
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
def _encode_params(self):
|
||||||
|
length = len(self._params)
|
||||||
|
data_format = ">" + ''.join(itertools.repeat("d", length))
|
||||||
|
|
||||||
|
return struct.pack(data_format, *self._params), length
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _decode_params(cls, bparams, length):
|
||||||
|
data_format = ">" + ''.join(itertools.repeat("d", length))
|
||||||
|
|
||||||
|
return struct.unpack(data_format, bparams)
|
||||||
|
|
||||||
|
def random(self, nb):
|
||||||
|
return np.nditer(
|
||||||
|
self._distribution.random(
|
||||||
|
self._params, nb
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self):
|
||||||
|
return self._name
|
||||||
|
|
||||||
|
@name.setter
|
||||||
|
def name(self, name):
|
||||||
|
self._name = name
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def distribution(self):
|
||||||
|
return self._distribution
|
||||||
|
|
||||||
|
@distribution.setter
|
||||||
|
def distribution(self, distribution):
|
||||||
|
self._distribution = distribution
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def params(self):
|
||||||
|
return self._params
|
||||||
|
|
||||||
|
@params.setter
|
||||||
|
def params(self, params):
|
||||||
|
self._params = params
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def data_type(self):
|
||||||
|
return self._data_type
|
||||||
|
|
||||||
|
@data_type.setter
|
||||||
|
def data_type(self, data_type):
|
||||||
|
self._data_type = data_type
|
||||||
|
self._status.modified()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def target_data(self):
|
||||||
|
return self._target_data
|
||||||
|
|
||||||
|
@target_data.setter
|
||||||
|
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"]
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
# EnsembleList.py -- Pamhyr
|
||||||
|
# Copyright (C) 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 tools import trace, timer
|
||||||
|
|
||||||
|
from Model.Tools.PamhyrListExt import PamhyrModelList
|
||||||
|
from Model.Ensembles.Ensemble import Ensemble
|
||||||
|
|
||||||
|
|
||||||
|
class EnsembleList(PamhyrModelList):
|
||||||
|
_sub_classes = [Ensemble]
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _db_load(cls, execute, data=None):
|
||||||
|
new = cls(status=data['status'])
|
||||||
|
|
||||||
|
new._lst = Ensemble._db_load(
|
||||||
|
execute, data
|
||||||
|
)
|
||||||
|
|
||||||
|
return new
|
||||||
|
|
||||||
|
def _db_save(self, execute, data=None):
|
||||||
|
execute(
|
||||||
|
"DELETE FROM ensemble " +
|
||||||
|
f"WHERE scenario = {self._status.scenario_id}"
|
||||||
|
)
|
||||||
|
|
||||||
|
for ens in self._lst:
|
||||||
|
ens._db_save(execute, data=data)
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
def new(self, index):
|
||||||
|
r = Ensemble(status=self._status)
|
||||||
|
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
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
# Except.py -- Pamhyr model exceptions
|
# Except.py -- Pamhyr model exceptions
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Friction.py -- Pamhyr
|
# Friction.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# FrictionList.py -- Pamhyr
|
# FrictionList.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Point.py -- Pamhyr
|
# Point.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# PointXY.py -- Pamhyr
|
# PointXY.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# PointXYZ.py -- Pamhyr
|
# PointXYZ.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -95,12 +95,11 @@ class PointXYZ(Point):
|
|||||||
"ADD COLUMN deleted BOOLEAN NOT NULL DEFAULT FALSE"
|
"ADD COLUMN deleted BOOLEAN NOT NULL DEFAULT FALSE"
|
||||||
)
|
)
|
||||||
|
|
||||||
if major == "0" and minor == "2":
|
# Try to create index at each update
|
||||||
if int(release) < 5:
|
execute(
|
||||||
execute(
|
"CREATE INDEX IF NOT EXISTS idx_point " +
|
||||||
"CREATE INDEX idx_point " +
|
"ON geometry_pointXYZ(profile, scenario);"
|
||||||
"ON geometry_pointXYZ(profile, scenario);"
|
)
|
||||||
)
|
|
||||||
|
|
||||||
return cls._update_submodel(execute, version, data)
|
return cls._update_submodel(execute, version, data)
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Profile.py -- Pamhyr
|
# Profile.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ProfileXYZ.py -- Pamhyr
|
# ProfileXYZ.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -91,6 +91,9 @@ class ProfileXYZ(Profile, SQLSubModel):
|
|||||||
self._station = []
|
self._station = []
|
||||||
self.station_up_to_date = False
|
self.station_up_to_date = False
|
||||||
|
|
||||||
|
self._get_water_limits_cache = {}
|
||||||
|
self._get_water_limits_ac_cache = {}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _db_create(cls, execute, ext=""):
|
def _db_create(cls, execute, ext=""):
|
||||||
execute(f"""
|
execute(f"""
|
||||||
@@ -619,6 +622,7 @@ class ProfileXYZ(Profile, SQLSubModel):
|
|||||||
"""
|
"""
|
||||||
return [x for x in lst if not np.isnan(x)]
|
return [x for x in lst if not np.isnan(x)]
|
||||||
|
|
||||||
|
@timer
|
||||||
def speed(self, q, z):
|
def speed(self, q, z):
|
||||||
area = self.wet_area(z)
|
area = self.wet_area(z)
|
||||||
|
|
||||||
@@ -670,6 +674,7 @@ class ProfileXYZ(Profile, SQLSubModel):
|
|||||||
length += line.length
|
length += line.length
|
||||||
return length
|
return length
|
||||||
|
|
||||||
|
@timer
|
||||||
def compute_wet_area(self, z):
|
def compute_wet_area(self, z):
|
||||||
area = 0.0
|
area = 0.0
|
||||||
if len(self.tab.L) > 0:
|
if len(self.tab.L) > 0:
|
||||||
@@ -710,6 +715,7 @@ class ProfileXYZ(Profile, SQLSubModel):
|
|||||||
if len(line.coords) > 2:
|
if len(line.coords) > 2:
|
||||||
poly = geometry.Polygon(line)
|
poly = geometry.Polygon(line)
|
||||||
area += poly.area
|
area += poly.area
|
||||||
|
|
||||||
return area
|
return area
|
||||||
|
|
||||||
def wet_radius(self, z):
|
def wet_radius(self, z):
|
||||||
@@ -732,6 +738,7 @@ class ProfileXYZ(Profile, SQLSubModel):
|
|||||||
line = geometry.LineString(list(zip(station, zz)))
|
line = geometry.LineString(list(zip(station, zz)))
|
||||||
return line
|
return line
|
||||||
|
|
||||||
|
@timer
|
||||||
def wet_lines(self, z):
|
def wet_lines(self, z):
|
||||||
points = self._points
|
points = self._points
|
||||||
if len(points) < 3:
|
if len(points) < 3:
|
||||||
@@ -808,7 +815,6 @@ class ProfileXYZ(Profile, SQLSubModel):
|
|||||||
return points
|
return points
|
||||||
|
|
||||||
def get_nb_wet_areas(self, z):
|
def get_nb_wet_areas(self, z):
|
||||||
|
|
||||||
n_zones = 0
|
n_zones = 0
|
||||||
points = self._points
|
points = self._points
|
||||||
if points[0].z <= z:
|
if points[0].z <= z:
|
||||||
@@ -820,10 +826,20 @@ class ProfileXYZ(Profile, SQLSubModel):
|
|||||||
|
|
||||||
return n_zones
|
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):
|
def get_all_water_limits_ac(self, z):
|
||||||
"""
|
"""
|
||||||
Determine all water limits for z elevation.
|
Determine all water limits for z elevation.
|
||||||
"""
|
"""
|
||||||
|
if z in self._get_water_limits_ac_cache:
|
||||||
|
return self._get_water_limits_ac_cache[z]
|
||||||
|
|
||||||
points = self._points
|
points = self._points
|
||||||
if len(points) < 3:
|
if len(points) < 3:
|
||||||
@@ -856,69 +872,94 @@ class ProfileXYZ(Profile, SQLSubModel):
|
|||||||
logger.error(f"ERROR in get_all_water_limits_ac")
|
logger.error(f"ERROR in get_all_water_limits_ac")
|
||||||
return [], []
|
return [], []
|
||||||
|
|
||||||
return start, list(reversed(end))
|
res = start, list(reversed(end))
|
||||||
|
self._get_water_limits_ac_cache[z] = res
|
||||||
|
|
||||||
|
return res
|
||||||
|
|
||||||
|
@timer
|
||||||
def get_water_limits(self, z):
|
def get_water_limits(self, z):
|
||||||
|
if z in self._get_water_limits_cache:
|
||||||
|
return self._get_water_limits_cache[z]
|
||||||
|
|
||||||
|
v = self.get_water_limits_compute(z)
|
||||||
|
|
||||||
|
return v
|
||||||
|
|
||||||
|
def get_water_limits_compute(self, z):
|
||||||
"""
|
"""
|
||||||
Determine left and right limits of water elevation.
|
Determine left and right limits of water elevation.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Get the index of first point with elevation lesser than water
|
# Get the index of first point with elevation lesser than water
|
||||||
# elevation (for the right and left river side)
|
# elevation (for the right and left river side)
|
||||||
i_left = -1
|
i_left = next(
|
||||||
i_right = -1
|
filter(
|
||||||
|
lambda i: self.point(i).z <= z,
|
||||||
|
range(self.number_points)
|
||||||
|
),
|
||||||
|
-1
|
||||||
|
)
|
||||||
|
|
||||||
for i in range(self.number_points):
|
i_right = next(
|
||||||
if self.point(i).z <= z:
|
filter(
|
||||||
i_left = i
|
lambda i: self.point(i).z <= z,
|
||||||
break
|
reversed(range(self.number_points))
|
||||||
|
),
|
||||||
for i in reversed(range(self.number_points)):
|
-1
|
||||||
if self.point(i).z <= z:
|
)
|
||||||
i_right = i
|
|
||||||
break
|
|
||||||
|
|
||||||
# Interpolate points at river left side
|
# Interpolate points at river left side
|
||||||
if (i_left > 0):
|
if (i_left > 0):
|
||||||
if abs(self.point(i_left - 1).z - self.point(i_left).z) < 1e-20:
|
pi = self.point(i_left)
|
||||||
pt_left = self.point(i_left)
|
pim1 = self.point(i_left - 1)
|
||||||
|
|
||||||
|
if abs(pim1.z - pi.z) < 1e-20:
|
||||||
|
pt_left = pi
|
||||||
else:
|
else:
|
||||||
fact = (z - self.point(i_left).z) / \
|
fact = (z - pi.z) / (pim1.z - pi.z)
|
||||||
(self.point(i_left - 1).z - self.point(i_left).z)
|
x = pi.x + fact * (pim1.x - pi.x)
|
||||||
x = self.point(i_left).x + fact * \
|
y = pi.y + fact * (pim1.y - pi.y)
|
||||||
(self.point(i_left - 1).x - self.point(i_left).x)
|
|
||||||
y = self.point(i_left).y + fact * \
|
|
||||||
(self.point(i_left - 1).y - self.point(i_left).y)
|
|
||||||
pt_left = PointXYZ(x=x, y=y, z=z, name="wl_left")
|
pt_left = PointXYZ(x=x, y=y, z=z, name="wl_left")
|
||||||
else:
|
else:
|
||||||
pt_left = self.point(0)
|
pt_left = self.point(0)
|
||||||
|
|
||||||
# Interpolate points at river right side
|
# Interpolate points at river right side
|
||||||
if (i_right < self.number_points - 1):
|
if (i_right < self.number_points - 1):
|
||||||
if abs(self.point(i_right + 1).z - self.point(i_right).z) < 1e-20:
|
pi = self.point(i_right)
|
||||||
pt_right = self.point(i_right)
|
pip1 = self.point(i_right + 1)
|
||||||
|
|
||||||
|
if abs(pip1.z - pi.z) < 1e-20:
|
||||||
|
pt_right = pi
|
||||||
else:
|
else:
|
||||||
fact = (z - self.point(i_right).z) / \
|
fact = (z - pi.z) / (pip1.z - pi.z)
|
||||||
(self.point(i_right + 1).z - self.point(i_right).z)
|
x = pi.x + fact * (pip1.x - pi.x)
|
||||||
x = self.point(i_right).x + fact * \
|
y = pi.y + fact * (pip1.y - pi.y)
|
||||||
(self.point(i_right + 1).x - self.point(i_right).x)
|
|
||||||
y = self.point(i_right).y + fact * \
|
|
||||||
(self.point(i_right + 1).y - self.point(i_right).y)
|
|
||||||
pt_right = PointXYZ(x=x, y=y, z=z, name="wl_right")
|
pt_right = PointXYZ(x=x, y=y, z=z, name="wl_right")
|
||||||
else:
|
else:
|
||||||
pt_right = self.point(self.number_points - 1)
|
pt_right = self.point(self.number_points - 1)
|
||||||
|
|
||||||
return pt_left, pt_right
|
v = (pt_left, pt_right)
|
||||||
|
|
||||||
|
# Put results in cache
|
||||||
|
self._get_water_limits_cache[z] = v
|
||||||
|
|
||||||
|
# Create a generator to improve results data reading speed
|
||||||
|
yield v
|
||||||
|
|
||||||
|
@timer
|
||||||
def compute_tabulation(self):
|
def compute_tabulation(self):
|
||||||
sorted_points = sorted(self._points, key=lambda p: p.z)
|
sorted_points = sorted(self._points, key=lambda p: p.z)
|
||||||
|
|
||||||
self.tab.z = np.array([p.z for p in sorted_points], np.float64)
|
self.tab.z = np.array([p.z for p in sorted_points], np.float64)
|
||||||
self.tab.L = np.zeros(len(self.tab.z), np.float64)
|
self.tab.L = np.zeros(len(self.tab.z), np.float64)
|
||||||
self.tab.A = np.zeros(len(self.tab.z), np.float64)
|
self.tab.A = np.zeros(len(self.tab.z), np.float64)
|
||||||
|
|
||||||
for i in range(1, len(self.tab.z)):
|
for i in range(1, len(self.tab.z)):
|
||||||
self.tab.L[i] = self.compute_wet_width(self.tab.z[i])
|
self.tab.L[i] = self.compute_wet_width(self.tab.z[i])
|
||||||
|
|
||||||
dx = (self.tab.L[i] + self.tab.L[i-1])/2
|
dx = (self.tab.L[i] + self.tab.L[i-1])/2
|
||||||
dz = self.tab.z[i] - self.tab.z[i-1]
|
dz = self.tab.z[i] - self.tab.z[i-1]
|
||||||
|
|
||||||
self.tab.A[i] = self.tab.A[i-1] + dz * dx
|
self.tab.A[i] = self.tab.A[i-1] + dz * dx
|
||||||
|
|
||||||
self.tab_up_to_date = True
|
self.tab_up_to_date = True
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Reach.py -- Pamhyr
|
# Reach.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Vector_1d.py -- Pamhyr
|
# Vector_1d.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# HydraulicStructures.py -- Pamhyr
|
# HydraulicStructures.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Types.py -- Pamhyr
|
# Types.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Value.py -- Pamhyr
|
# Value.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# HydraulicStructures.py -- Pamhyr
|
# HydraulicStructures.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# HydraulicStructuresList.py -- Pamhyr
|
# HydraulicStructuresList.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# InitialConditions.py -- Pamhyr
|
# InitialConditions.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# InitialConditionsDict.py -- Pamhyr
|
# InitialConditionsDict.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# InitialConditionsAdisTS.py -- Pamhyr
|
# InitialConditionsAdisTS.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# InitialConditionsAdisTSList.py -- Pamhyr
|
# InitialConditionsAdisTSList.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# InitialConditionsAdisTSSpec.py -- Pamhyr
|
# InitialConditionsAdisTSSpec.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# LateralContribution.py -- Pamhyr
|
# LateralContribution.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# LateralContributionList.py -- Pamhyr
|
# LateralContributionList.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# LateralContributionTypes.py -- Pamhyr
|
# LateralContributionTypes.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# LateralContributionAdisTS.py -- Pamhyr
|
# LateralContributionAdisTS.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# LateralContributionsAdisTSList.py -- Pamhyr
|
# LateralContributionsAdisTSList.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Edge.py -- Pamhyr
|
# Edge.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Graph.py -- Pamhyr
|
# Graph.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Node.py -- Pamhyr
|
# Node.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Point.py -- Pamhyr
|
# Point.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# __init__.py -- Pamhyr
|
# __init__.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# test_Network.py -- Pamhyr
|
# test_Network.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# OutputRKAdists.py -- Pamhyr
|
# OutputRKAdists.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Pollutants.py -- Pamhyr
|
# Pollutants.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Reservoir.py -- Pamhyr
|
# Reservoir.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ReservoirList.py -- Pamhyr
|
# ReservoirList.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Results.py -- Pamhyr
|
# Results.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -22,6 +22,8 @@ import numpy as np
|
|||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
from tools import timer
|
||||||
|
|
||||||
from Model.Scenario import Scenario
|
from Model.Scenario import Scenario
|
||||||
from Model.Tools.PamhyrDB import SQLSubModel
|
from Model.Tools.PamhyrDB import SQLSubModel
|
||||||
from Model.Results.River.River import River
|
from Model.Results.River.River import River
|
||||||
@@ -155,11 +157,188 @@ class AdditionalData(SQLSubModel):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
class TableData(SQLSubModel):
|
||||||
|
_sub_classes = []
|
||||||
|
|
||||||
|
def __init__(self, id=-1, study=None,
|
||||||
|
legend="", data=None,
|
||||||
|
owner_scenario=-1):
|
||||||
|
super(TableData, self).__init__(
|
||||||
|
id=id, status=study.status,
|
||||||
|
owner_scenario=owner_scenario
|
||||||
|
)
|
||||||
|
|
||||||
|
self._study = study
|
||||||
|
self._legend = legend
|
||||||
|
self._data = data
|
||||||
|
|
||||||
|
@property
|
||||||
|
def data(self):
|
||||||
|
return self._data
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _db_create(cls, execute, ext=""):
|
||||||
|
execute(f"""
|
||||||
|
CREATE TABLE results_table_data{ext} (
|
||||||
|
{cls.create_db_add_pamhyr_id()},
|
||||||
|
result INTEGER NOT NULL,
|
||||||
|
legend TEXT NOT NULL,
|
||||||
|
unit TEXT NOT NULL,
|
||||||
|
data_shape_x INTEGER NOT NULL,
|
||||||
|
data_shape_y INTEGER NOT NULL,
|
||||||
|
data_shape_z INTEGER DEFAULT -1,
|
||||||
|
data BLOB NOT NULL,
|
||||||
|
{Scenario.create_db_add_scenario()},
|
||||||
|
{Scenario.create_db_add_scenario_fk()},
|
||||||
|
FOREIGN KEY(result) REFERENCES results(pamhyr_id),
|
||||||
|
PRIMARY KEY(pamhyr_id, result, legend, scenario)
|
||||||
|
)
|
||||||
|
""")
|
||||||
|
|
||||||
|
if ext != "":
|
||||||
|
return True
|
||||||
|
|
||||||
|
return cls._create_submodel(execute)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _db_update(cls, execute, version, data=None):
|
||||||
|
major, minor, release = version.strip().split(".")
|
||||||
|
create = False
|
||||||
|
|
||||||
|
if major == "0" and int(minor) == 2:
|
||||||
|
if int(release) < 7 and not create:
|
||||||
|
cls._db_create(execute)
|
||||||
|
create = True
|
||||||
|
|
||||||
|
return cls._update_submodel(execute, version, data)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _db_load(cls, execute, data=None):
|
||||||
|
res = {}
|
||||||
|
|
||||||
|
study = data['study']
|
||||||
|
status = data['status']
|
||||||
|
scenario = data["scenario"]
|
||||||
|
result = data["result"]
|
||||||
|
rid = data["result_pid"]
|
||||||
|
|
||||||
|
table = execute(
|
||||||
|
"SELECT pamhyr_id, " +
|
||||||
|
"legend, unit, " +
|
||||||
|
"data_shape_x, data_shape_y, data_shape_z, " +
|
||||||
|
"data, " +
|
||||||
|
"scenario " +
|
||||||
|
"FROM results_table_data " +
|
||||||
|
f"WHERE scenario = {scenario.id} " +
|
||||||
|
f"AND result = {rid}"
|
||||||
|
)
|
||||||
|
|
||||||
|
for v in table:
|
||||||
|
it = iter(v)
|
||||||
|
|
||||||
|
pid = next(it)
|
||||||
|
legend = next(it)
|
||||||
|
unit = next(it)
|
||||||
|
data_shape_x = next(it)
|
||||||
|
data_shape_y = next(it)
|
||||||
|
data_shape_z = next(it)
|
||||||
|
data = next(it)
|
||||||
|
owner_scenario = next(it)
|
||||||
|
|
||||||
|
dtype = cls._unit_to_dtype(unit)
|
||||||
|
|
||||||
|
np_data = np.frombuffer(data, dtype=dtype)
|
||||||
|
if data_shape_y == -1:
|
||||||
|
np_data = np.reshape(np_data, data_shape_x)
|
||||||
|
elif data_shape_z == -1:
|
||||||
|
np_data = np.reshape(np_data, (data_shape_x,
|
||||||
|
data_shape_y))
|
||||||
|
else:
|
||||||
|
np_data = np.reshape(np_data, (data_shape_x,
|
||||||
|
data_shape_y,
|
||||||
|
data_shape_z))
|
||||||
|
|
||||||
|
new_table = cls(study=study,
|
||||||
|
legend=legend, data=np_data,
|
||||||
|
owner_scenario=owner_scenario)
|
||||||
|
|
||||||
|
res[legend] = new_table
|
||||||
|
|
||||||
|
return res
|
||||||
|
|
||||||
|
def _db_save(self, execute, data=None):
|
||||||
|
if self._status.scenario.id != self._owner_scenario:
|
||||||
|
return
|
||||||
|
|
||||||
|
shape_x = -1
|
||||||
|
shape_y = -1
|
||||||
|
shape_z = -1
|
||||||
|
shape = self._data.shape
|
||||||
|
|
||||||
|
if len(shape) == 2:
|
||||||
|
shape_x, shape_y = shape
|
||||||
|
elif len(shape) == 1:
|
||||||
|
shape_x, = shape
|
||||||
|
elif len(shape) == 3:
|
||||||
|
shape_x, shape_y, shape_z = shape
|
||||||
|
else:
|
||||||
|
logger.error(
|
||||||
|
f"Failed to parse numpy shape: {shape}"
|
||||||
|
)
|
||||||
|
|
||||||
|
execute(
|
||||||
|
"INSERT INTO " +
|
||||||
|
"results_table_data (pamhyr_id, result, " +
|
||||||
|
"legend, unit, " +
|
||||||
|
"data_shape_x, data_shape_y, data_shape_z, " +
|
||||||
|
"data, " +
|
||||||
|
"scenario) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||||
|
self._pamhyr_id, data["result"],
|
||||||
|
self._legend, self._dtype_to_unit(self._data.dtype),
|
||||||
|
shape_x, shape_y, shape_z,
|
||||||
|
self._data,
|
||||||
|
self._owner_scenario
|
||||||
|
)
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _unit_to_dtype(cls, unit):
|
||||||
|
t = {
|
||||||
|
"i32": np.int32, "i64": np.int64,
|
||||||
|
"u32": np.uint32, "u64": np.uint64,
|
||||||
|
"f32": np.float32, "f64": np.float64,
|
||||||
|
}
|
||||||
|
|
||||||
|
return t[unit]
|
||||||
|
|
||||||
|
def _dtype_to_unit(self, dtype):
|
||||||
|
t = {
|
||||||
|
np.dtype(np.int32): "i32", np.dtype(np.int64): "i64",
|
||||||
|
np.dtype(np.uint32): "u32", np.dtype(np.uint64): "u64",
|
||||||
|
np.dtype(np.float32): "f32", np.dtype(np.float64): "f64",
|
||||||
|
}
|
||||||
|
|
||||||
|
return t[dtype]
|
||||||
|
|
||||||
|
def table(self):
|
||||||
|
return self._data
|
||||||
|
|
||||||
|
def __len__(self):
|
||||||
|
return len(self._data)
|
||||||
|
|
||||||
|
def __getitem__(self, key):
|
||||||
|
if isinstance(key, tuple):
|
||||||
|
return self._data[key[0], key[1]]
|
||||||
|
|
||||||
|
self._data[key]
|
||||||
|
|
||||||
|
|
||||||
class Results(SQLSubModel):
|
class Results(SQLSubModel):
|
||||||
_sub_classes = [River, AdditionalData]
|
_sub_classes = [River, TableData, AdditionalData]
|
||||||
|
|
||||||
def __init__(self, id=-1, study=None, solver=None,
|
def __init__(self, id=-1, study=None, solver=None,
|
||||||
repertory="", name="0"):
|
repertory="", name="0", is_ensemble=False):
|
||||||
super(Results, self).__init__(
|
super(Results, self).__init__(
|
||||||
id=id, status=study.status,
|
id=id, status=study.status,
|
||||||
owner_scenario=study.status.scenario.id
|
owner_scenario=study.status.scenario.id
|
||||||
@@ -167,21 +346,29 @@ class Results(SQLSubModel):
|
|||||||
|
|
||||||
self._name = name
|
self._name = name
|
||||||
self._study = study
|
self._study = study
|
||||||
self._river = River(self._study)
|
self._river = River(self._study, self)
|
||||||
|
|
||||||
self._solver = solver
|
self._solver = solver
|
||||||
self._repertory = repertory
|
self._repertory = repertory
|
||||||
|
|
||||||
|
self._is_ensemble = is_ensemble
|
||||||
|
|
||||||
self._meta_data = {
|
self._meta_data = {
|
||||||
# Keep results creation date
|
# Keep results creation date
|
||||||
"creation_date": datetime.now(),
|
"creation_date": datetime.now(),
|
||||||
"study_revision": study.status.version,
|
"study_revision": study.status.version,
|
||||||
"additional_data": [],
|
"additional_data": [],
|
||||||
|
"table": {},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self._ts_index = {}
|
||||||
|
|
||||||
if solver is not None:
|
if solver is not None:
|
||||||
self.set("solver_type", solver._type)
|
self.set("solver_type", solver._type)
|
||||||
|
|
||||||
|
def is_ensemble(self):
|
||||||
|
return self._is_ensemble
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def date(self):
|
def date(self):
|
||||||
date = self._meta_data["creation_date"]
|
date = self._meta_data["creation_date"]
|
||||||
@@ -195,6 +382,7 @@ class Results(SQLSubModel):
|
|||||||
def study(self):
|
def study(self):
|
||||||
return self._study
|
return self._study
|
||||||
|
|
||||||
|
@timer
|
||||||
def set(self, key, value):
|
def set(self, key, value):
|
||||||
self._meta_data[key] = value
|
self._meta_data[key] = value
|
||||||
|
|
||||||
@@ -212,6 +400,16 @@ class Results(SQLSubModel):
|
|||||||
def get(self, key):
|
def get(self, key):
|
||||||
return self._meta_data[key]
|
return self._meta_data[key]
|
||||||
|
|
||||||
|
def set_timestamp_index(self, index):
|
||||||
|
self._ts_index = index
|
||||||
|
|
||||||
|
def get_timestamp_id(self, ts):
|
||||||
|
return self._ts_index[ts]
|
||||||
|
|
||||||
|
def compute_timestamp_index(self):
|
||||||
|
for i, ts in enumerate(self._meta_data["timestamps"]):
|
||||||
|
self._ts_index[ts] = i
|
||||||
|
|
||||||
def reload(self):
|
def reload(self):
|
||||||
return self._solver.results(
|
return self._solver.results(
|
||||||
self._study,
|
self._study,
|
||||||
@@ -238,9 +436,11 @@ class Results(SQLSubModel):
|
|||||||
solver_name TEXT NOT NULL,
|
solver_name TEXT NOT NULL,
|
||||||
solver_type TEXT NOT NULL,
|
solver_type TEXT NOT NULL,
|
||||||
study_revision INTEGER NOT NULL,
|
study_revision INTEGER NOT NULL,
|
||||||
creation_data DATE NOT NULL,
|
creation_date DATE NOT NULL,
|
||||||
nb_timestamps INTEGER NOT NULL,
|
nb_timestamps INTEGER NOT NULL,
|
||||||
timestamps BLOB NOT NULL,
|
timestamps BLOB NOT NULL,
|
||||||
|
seed INTEGER,
|
||||||
|
number_of_run INTEGER,
|
||||||
{Scenario.create_db_add_scenario()},
|
{Scenario.create_db_add_scenario()},
|
||||||
{Scenario.create_db_add_scenario_fk()},
|
{Scenario.create_db_add_scenario_fk()},
|
||||||
PRIMARY KEY(pamhyr_id, scenario)
|
PRIMARY KEY(pamhyr_id, scenario)
|
||||||
@@ -266,6 +466,21 @@ class Results(SQLSubModel):
|
|||||||
cls._db_create(execute)
|
cls._db_create(execute)
|
||||||
create = True
|
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)
|
return cls._update_submodel(execute, version, data)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -278,7 +493,9 @@ class Results(SQLSubModel):
|
|||||||
|
|
||||||
table = execute(
|
table = execute(
|
||||||
"SELECT pamhyr_id, solver_name, solver_type, " +
|
"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 " +
|
"scenario " +
|
||||||
"FROM results " +
|
"FROM results " +
|
||||||
f"WHERE scenario = {scenario.id}"
|
f"WHERE scenario = {scenario.id}"
|
||||||
@@ -298,6 +515,8 @@ class Results(SQLSubModel):
|
|||||||
solver_type = next(it)
|
solver_type = next(it)
|
||||||
revision = next(it)
|
revision = next(it)
|
||||||
creation_date = next(it)
|
creation_date = next(it)
|
||||||
|
seed = next(it)
|
||||||
|
number_of_run = next(it)
|
||||||
nb_timestamps = next(it)
|
nb_timestamps = next(it)
|
||||||
timestamps_bytes = next(it)
|
timestamps_bytes = next(it)
|
||||||
owner_scenario = next(it)
|
owner_scenario = next(it)
|
||||||
@@ -308,12 +527,24 @@ class Results(SQLSubModel):
|
|||||||
new_results.set("solver_type", solver_type)
|
new_results.set("solver_type", solver_type)
|
||||||
new_results.set("study_revision", revision)
|
new_results.set("study_revision", revision)
|
||||||
new_results.set("creation_date", creation_date)
|
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
|
||||||
|
|
||||||
|
table_data = TableData._db_load(execute, data)
|
||||||
|
new_results.set("table", table_data)
|
||||||
|
|
||||||
sf = ">" + ''.join(itertools.repeat("d", nb_timestamps))
|
sf = ">" + ''.join(itertools.repeat("d", nb_timestamps))
|
||||||
ts = struct.unpack(sf, timestamps_bytes)
|
ts = struct.unpack(sf, timestamps_bytes)
|
||||||
new_results.set("timestamps", ts)
|
new_results.set("timestamps", ts)
|
||||||
|
|
||||||
data["timestamps"] = sorted(ts)
|
data["timestamps"] = sorted(ts)
|
||||||
|
new_results.compute_timestamp_index()
|
||||||
|
|
||||||
|
data["parent"] = new_results
|
||||||
new_results._river = River._db_load(execute, data)
|
new_results._river = River._db_load(execute, data)
|
||||||
|
|
||||||
new_results.set(
|
new_results.set(
|
||||||
@@ -321,6 +552,20 @@ class Results(SQLSubModel):
|
|||||||
AdditionalData._db_load(execute, data)
|
AdditionalData._db_load(execute, data)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Update global index
|
||||||
|
i = 0
|
||||||
|
for reach in new_results._river.reachs:
|
||||||
|
nb = len(reach.profiles)
|
||||||
|
reach.set_global_index(range(i, i + nb + 1))
|
||||||
|
i += nb
|
||||||
|
|
||||||
|
if "Z" in table_data:
|
||||||
|
for ts in data["timestamps"]:
|
||||||
|
new_results._river.update_water_limits(
|
||||||
|
ts,
|
||||||
|
table_data["Z"][new_results.get_timestamp_id(ts), :]
|
||||||
|
)
|
||||||
|
|
||||||
yield (solver_type, new_results)
|
yield (solver_type, new_results)
|
||||||
|
|
||||||
def _db_save_clear(self, execute, solver_type, data=None):
|
def _db_save_clear(self, execute, solver_type, data=None):
|
||||||
@@ -343,6 +588,11 @@ class Results(SQLSubModel):
|
|||||||
f"WHERE scenario = {self._owner_scenario} " +
|
f"WHERE scenario = {self._owner_scenario} " +
|
||||||
f"AND result = {pid}"
|
f"AND result = {pid}"
|
||||||
)
|
)
|
||||||
|
execute(
|
||||||
|
"DELETE FROM results_table_data " +
|
||||||
|
f"WHERE scenario = {self._owner_scenario} " +
|
||||||
|
f"AND result = {pid}"
|
||||||
|
)
|
||||||
execute(
|
execute(
|
||||||
"DELETE FROM results_add_data " +
|
"DELETE FROM results_add_data " +
|
||||||
f"WHERE scenario = {self._owner_scenario} " +
|
f"WHERE scenario = {self._owner_scenario} " +
|
||||||
@@ -372,21 +622,43 @@ class Results(SQLSubModel):
|
|||||||
ts = sorted(self.get("timestamps"))
|
ts = sorted(self.get("timestamps"))
|
||||||
sf = ">" + ''.join(itertools.repeat("d", len(ts)))
|
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(
|
execute(
|
||||||
"INSERT INTO " +
|
"INSERT INTO " +
|
||||||
"results (pamhyr_id, solver_name, solver_type, " +
|
"results (pamhyr_id, solver_name, solver_type, " +
|
||||||
"study_revision, creation_data, " +
|
"study_revision, creation_date, " +
|
||||||
|
"seed, number_of_run, " +
|
||||||
"nb_timestamps, timestamps, " +
|
"nb_timestamps, timestamps, " +
|
||||||
"scenario) VALUES (?, ?, ?, ?, ?, ?, ?, ?)",
|
"scenario) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||||
self._pamhyr_id, solver_name, solver_type,
|
self._pamhyr_id, solver_name, solver_type,
|
||||||
self._status.version, self.get("creation_date"),
|
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
|
data["result"] = self._pamhyr_id
|
||||||
self._river._db_save(execute, data)
|
self._river._db_save(execute, data)
|
||||||
|
|
||||||
|
tables = self.get("table")
|
||||||
|
for legend in tables:
|
||||||
|
tables[legend]._db_save(execute, data)
|
||||||
|
|
||||||
for add_data in self.get("additional_data"):
|
for add_data in self.get("additional_data"):
|
||||||
add_data._db_save(execute, data)
|
add_data._db_save(execute, data)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def new_table_data(self, legend, data):
|
||||||
|
return TableData(
|
||||||
|
study=self._study,
|
||||||
|
legend=legend,
|
||||||
|
data=data,
|
||||||
|
owner_scenario=self._owner_scenario
|
||||||
|
)
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
# Results.py -- Pamhyr
|
# Results.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# River.py -- Pamhyr
|
# River.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,12 +14,13 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import types
|
||||||
import struct
|
import struct
|
||||||
import logging
|
import logging
|
||||||
import itertools
|
import itertools
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
from tools import flatten
|
from tools import flatten, timer
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
@@ -30,15 +31,17 @@ logger = logging.getLogger()
|
|||||||
|
|
||||||
|
|
||||||
class Profile(SQLSubModel):
|
class Profile(SQLSubModel):
|
||||||
def __init__(self, profile, study):
|
def __init__(self, profile, study, parent):
|
||||||
super(Profile, self).__init__(
|
super(Profile, self).__init__(
|
||||||
id=-1, status=study.status,
|
id=-1, status=study.status,
|
||||||
owner_scenario=study.status.scenario.id
|
owner_scenario=study.status.scenario.id
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self._parent = parent
|
||||||
self._study = study
|
self._study = study
|
||||||
self._profile = profile # Source profile in the study
|
self._profile = profile # Source profile in the study
|
||||||
self._data = {} # Dict of dict {<ts>: {<key>: <value>, ...}, ...}
|
self._data = {} # Dict of dict {<ts>: {<key>: <value>, ...}, ...}
|
||||||
|
self._global_index = -1
|
||||||
|
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
return len(self._data)
|
return len(self._data)
|
||||||
@@ -55,15 +58,26 @@ class Profile(SQLSubModel):
|
|||||||
def geometry(self):
|
def geometry(self):
|
||||||
return self._profile
|
return self._profile
|
||||||
|
|
||||||
|
@property
|
||||||
|
def global_index(self):
|
||||||
|
return self._global_index
|
||||||
|
|
||||||
|
@global_index.setter
|
||||||
|
def global_index(self, id):
|
||||||
|
self._global_index = id
|
||||||
|
|
||||||
|
@timer
|
||||||
def set(self, timestamp, key, data):
|
def set(self, timestamp, key, data):
|
||||||
if timestamp not in self._data:
|
if timestamp not in self._data:
|
||||||
self._data[timestamp] = {}
|
self._data[timestamp] = {}
|
||||||
|
|
||||||
self._data[timestamp][key] = data
|
self._data[timestamp][key] = data
|
||||||
|
|
||||||
|
@timer
|
||||||
def get_ts(self, timestamp):
|
def get_ts(self, timestamp):
|
||||||
return self._data[timestamp]
|
return self._data[timestamp]
|
||||||
|
|
||||||
|
@timer
|
||||||
def get_key(self, key):
|
def get_key(self, key):
|
||||||
res = list(
|
res = list(
|
||||||
map(lambda ts: self._data[ts][key],
|
map(lambda ts: self._data[ts][key],
|
||||||
@@ -71,17 +85,26 @@ class Profile(SQLSubModel):
|
|||||||
)
|
)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
@timer
|
||||||
def get_ts_key(self, timestamp, key):
|
def get_ts_key(self, timestamp, key):
|
||||||
if timestamp in self._data:
|
if timestamp in self._data:
|
||||||
if key in self._data[timestamp]:
|
if key in self._data[timestamp]:
|
||||||
return self._data[timestamp][key]
|
v = self._data[timestamp][key]
|
||||||
|
|
||||||
|
# If is a generator, compute value(s)
|
||||||
|
if isinstance(v, types.GeneratorType):
|
||||||
|
v = next(v)
|
||||||
|
self._data[timestamp][key] = v
|
||||||
|
|
||||||
|
return v
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def has_sediment_layers(self):
|
def has_sediment_layers(self):
|
||||||
return any(map(lambda ts: "sl" in self._data[ts], self._data))
|
return any(map(lambda ts: "sl" in self._data[ts], self._data))
|
||||||
|
|
||||||
def has_bedload(self):
|
def has_bedload(self):
|
||||||
return any(map(lambda ts: "zfd" in self._data[ts], self._data))
|
return any(map(lambda ts: "sl" in self._data[ts], self._data))
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _db_create(cls, execute, ext=""):
|
def _db_create(cls, execute, ext=""):
|
||||||
@@ -114,9 +137,9 @@ class Profile(SQLSubModel):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _db_load(cls, execute, data=None):
|
def _db_load(cls, execute, data=None):
|
||||||
new = {}
|
|
||||||
status = data['status']
|
status = data['status']
|
||||||
|
|
||||||
|
parent = data['parent']
|
||||||
study = data['study']
|
study = data['study']
|
||||||
reach = data['reach']
|
reach = data['reach']
|
||||||
profile = data['profile']
|
profile = data['profile']
|
||||||
@@ -124,6 +147,8 @@ class Profile(SQLSubModel):
|
|||||||
loaded = data['loaded_pid']
|
loaded = data['loaded_pid']
|
||||||
timestamps = data['timestamps']
|
timestamps = data['timestamps']
|
||||||
|
|
||||||
|
new = cls(profile, study, parent)
|
||||||
|
|
||||||
values = execute(
|
values = execute(
|
||||||
"SELECT pamhyr_id, result, key, " +
|
"SELECT pamhyr_id, result, key, " +
|
||||||
"len_data, data, scenario " +
|
"len_data, data, scenario " +
|
||||||
@@ -143,12 +168,6 @@ class Profile(SQLSubModel):
|
|||||||
data = next(it)
|
data = next(it)
|
||||||
owner_scenario = next(it)
|
owner_scenario = next(it)
|
||||||
|
|
||||||
if profile not in new:
|
|
||||||
new_data = cls(profile, study)
|
|
||||||
new[profile] = new_data
|
|
||||||
else:
|
|
||||||
new_data = new[profile]
|
|
||||||
|
|
||||||
if key in ["Z", "Q", "V"]:
|
if key in ["Z", "Q", "V"]:
|
||||||
sf = ">" + ''.join(itertools.repeat("f", len_data))
|
sf = ">" + ''.join(itertools.repeat("f", len_data))
|
||||||
len_values = len(values)
|
len_values = len(values)
|
||||||
@@ -161,11 +180,11 @@ class Profile(SQLSubModel):
|
|||||||
)
|
)
|
||||||
|
|
||||||
for timestamp, value in zip(timestamps, values):
|
for timestamp, value in zip(timestamps, values):
|
||||||
new_data.set(timestamp, key, value)
|
new.set(timestamp, key, value)
|
||||||
if key == "Z":
|
if key == "Z":
|
||||||
new_data.update_water_limits(timestamp, value)
|
new.update_water_limits(timestamp, value)
|
||||||
|
|
||||||
return list(new.values())
|
return new
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _db_load_data_sl_format(cls, values, len_data, timestamps):
|
def _db_load_data_sl_format(cls, values, len_data, timestamps):
|
||||||
@@ -257,19 +276,20 @@ class Profile(SQLSubModel):
|
|||||||
class Reach(SQLSubModel):
|
class Reach(SQLSubModel):
|
||||||
_sub_classes = [Profile]
|
_sub_classes = [Profile]
|
||||||
|
|
||||||
def __init__(self, reach, study, with_init=True):
|
def __init__(self, reach, study, parent, with_init=True):
|
||||||
super(Reach, self).__init__(
|
super(Reach, self).__init__(
|
||||||
id=-1, status=study.status,
|
id=-1, status=study.status,
|
||||||
owner_scenario=study.status.scenario.id
|
owner_scenario=study.status.scenario.id
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self._parent = parent
|
||||||
self._study = study
|
self._study = study
|
||||||
self._reach = reach # Source reach in the study
|
self._reach = reach # Source reach in the study
|
||||||
self._profiles = []
|
self._profiles = []
|
||||||
if with_init:
|
if with_init:
|
||||||
self._profiles = list(
|
self._profiles = list(
|
||||||
map(
|
map(
|
||||||
lambda p: Profile(p, self._study),
|
lambda p: Profile(p, self._study, self._parent),
|
||||||
reach.profiles
|
reach.profiles
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -279,6 +299,9 @@ class Reach(SQLSubModel):
|
|||||||
lambda p: p.name[0:8] != 'interpol', self._profiles
|
lambda p: p.name[0:8] != 'interpol', self._profiles
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self._global_index = (-1, -1)
|
||||||
|
|
||||||
self._buffers = {}
|
self._buffers = {}
|
||||||
|
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
@@ -307,6 +330,17 @@ class Reach(SQLSubModel):
|
|||||||
def profile(self, id):
|
def profile(self, id):
|
||||||
return self._profiles[id]
|
return self._profiles[id]
|
||||||
|
|
||||||
|
def set_global_index(self, indexs):
|
||||||
|
self._global_index = (indexs[0], indexs[-1])
|
||||||
|
|
||||||
|
for profile, ind in zip(self._profiles, indexs):
|
||||||
|
profile.global_index = ind
|
||||||
|
|
||||||
|
@property
|
||||||
|
def global_index(self):
|
||||||
|
return self._global_index
|
||||||
|
|
||||||
|
@timer
|
||||||
def set(self, profile_id, timestamp, key, data):
|
def set(self, profile_id, timestamp, key, data):
|
||||||
self._profiles[profile_id].set(timestamp, key, data)
|
self._profiles[profile_id].set(timestamp, key, data)
|
||||||
|
|
||||||
@@ -322,6 +356,10 @@ class Reach(SQLSubModel):
|
|||||||
for i, p in enumerate(self._profiles):
|
for i, p in enumerate(self._profiles):
|
||||||
self._buffers[key][:, i] = p.get_key(key)
|
self._buffers[key][:, i] = p.get_key(key)
|
||||||
|
|
||||||
|
def update_water_limits(self, timestamp, z_data):
|
||||||
|
for profile, z in zip(self._profiles, z_data):
|
||||||
|
profile.update_water_limits(timestamp, z)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _db_create(cls, execute, ext=""):
|
def _db_create(cls, execute, ext=""):
|
||||||
return cls._create_submodel(execute)
|
return cls._create_submodel(execute)
|
||||||
@@ -335,12 +373,13 @@ class Reach(SQLSubModel):
|
|||||||
reach = data["reach"]
|
reach = data["reach"]
|
||||||
|
|
||||||
new_reach = cls(
|
new_reach = cls(
|
||||||
data["reach"], data["study"], with_init=False
|
data["reach"], data["study"], data["parent"],
|
||||||
|
with_init=False
|
||||||
)
|
)
|
||||||
|
|
||||||
for i, profile in enumerate(reach.profiles):
|
for i, profile in enumerate(reach.profiles):
|
||||||
data["profile"] = profile
|
data["profile"] = profile
|
||||||
new_reach._profiles += Profile._db_load(execute, data)
|
new_reach._profiles += [Profile._db_load(execute, data)]
|
||||||
|
|
||||||
return new_reach
|
return new_reach
|
||||||
|
|
||||||
@@ -354,16 +393,20 @@ class Reach(SQLSubModel):
|
|||||||
class River(SQLSubModel):
|
class River(SQLSubModel):
|
||||||
_sub_classes = [Reach]
|
_sub_classes = [Reach]
|
||||||
|
|
||||||
def __init__(self, study):
|
def __init__(self, study, parent, init=True):
|
||||||
super(River, self).__init__(
|
super(River, self).__init__(
|
||||||
id=-1, status=study.status,
|
id=-1, status=study.status,
|
||||||
owner_scenario=study.status.scenario.id
|
owner_scenario=study.status.scenario.id
|
||||||
)
|
)
|
||||||
|
|
||||||
self._study = study
|
self._study = study
|
||||||
|
self._parent = parent
|
||||||
|
|
||||||
# Dict with timestamps as key
|
# Dict with timestamps as key
|
||||||
self._reachs = []
|
self._reachs = []
|
||||||
|
if init:
|
||||||
|
for i, _ in enumerate(self._study.river.enable_edges()):
|
||||||
|
self.add(i)
|
||||||
|
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
return len(self._reachs)
|
return len(self._reachs)
|
||||||
@@ -381,7 +424,7 @@ class River(SQLSubModel):
|
|||||||
def add(self, reach_id):
|
def add(self, reach_id):
|
||||||
reachs = self._study.river.enable_edges()
|
reachs = self._study.river.enable_edges()
|
||||||
|
|
||||||
new = Reach(reachs[reach_id].reach, self._study)
|
new = Reach(reachs[reach_id].reach, self._study, self._parent)
|
||||||
|
|
||||||
self._reachs.append(new)
|
self._reachs.append(new)
|
||||||
return new
|
return new
|
||||||
@@ -394,6 +437,15 @@ class River(SQLSubModel):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def update_water_limits(self, timestamp, data):
|
||||||
|
for reach in self._reachs:
|
||||||
|
ind = reach.global_index
|
||||||
|
|
||||||
|
reach.update_water_limits(
|
||||||
|
timestamp,
|
||||||
|
data[ind[0]:ind[1]]
|
||||||
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _db_create(cls, execute, ext=""):
|
def _db_create(cls, execute, ext=""):
|
||||||
return cls._create_submodel(execute)
|
return cls._create_submodel(execute)
|
||||||
@@ -405,7 +457,9 @@ class River(SQLSubModel):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def _db_load(cls, execute, data=None):
|
def _db_load(cls, execute, data=None):
|
||||||
study = data["study"]
|
study = data["study"]
|
||||||
new_river = cls(study)
|
parent = data["parent"]
|
||||||
|
|
||||||
|
new_river = cls(study, parent, init=False)
|
||||||
|
|
||||||
for reach in study.river.reachs():
|
for reach in study.river.reachs():
|
||||||
data["reach"] = reach.reach
|
data["reach"] = reach.reach
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# River.py -- Pamhyr
|
# River.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
+11
-2
@@ -1,5 +1,5 @@
|
|||||||
# River.py -- Pamhyr river model
|
# River.py -- Pamhyr river model
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -60,6 +60,7 @@ from Model.LateralContributionsAdisTS.LateralContributionsAdisTSList \
|
|||||||
from Model.D90AdisTS.D90AdisTSList import D90AdisTSList
|
from Model.D90AdisTS.D90AdisTSList import D90AdisTSList
|
||||||
from Model.DIFAdisTS.DIFAdisTSList import DIFAdisTSList
|
from Model.DIFAdisTS.DIFAdisTSList import DIFAdisTSList
|
||||||
from Model.GeoTIFF.GeoTIFFList import GeoTIFFList
|
from Model.GeoTIFF.GeoTIFFList import GeoTIFFList
|
||||||
|
from Model.Ensembles.EnsembleList import EnsembleList
|
||||||
from Model.Results.Results import Results
|
from Model.Results.Results import Results
|
||||||
|
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
@@ -476,6 +477,7 @@ class River(Graph):
|
|||||||
D90AdisTSList,
|
D90AdisTSList,
|
||||||
DIFAdisTSList,
|
DIFAdisTSList,
|
||||||
GeoTIFFList,
|
GeoTIFFList,
|
||||||
|
EnsembleList,
|
||||||
Results
|
Results
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -515,6 +517,9 @@ class River(Graph):
|
|||||||
|
|
||||||
self._geotiff = GeoTIFFList(status=self._status)
|
self._geotiff = GeoTIFFList(status=self._status)
|
||||||
|
|
||||||
|
# Scenario ensemble
|
||||||
|
self._ensembles = EnsembleList(status=self._status)
|
||||||
|
|
||||||
self._results = {}
|
self._results = {}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -629,6 +634,8 @@ class River(Graph):
|
|||||||
|
|
||||||
new._geotiff = GeoTIFFList._db_load(execute, data)
|
new._geotiff = GeoTIFFList._db_load(execute, data)
|
||||||
|
|
||||||
|
new._ensembles = EnsembleList._db_load(execute, data)
|
||||||
|
|
||||||
return new
|
return new
|
||||||
|
|
||||||
def _db_load_results(self, execute, data=None):
|
def _db_load_results(self, execute, data=None):
|
||||||
@@ -664,6 +671,8 @@ class River(Graph):
|
|||||||
|
|
||||||
objs.append(self._geotiff)
|
objs.append(self._geotiff)
|
||||||
|
|
||||||
|
objs.append(self._ensembles)
|
||||||
|
|
||||||
for solv_type in self.results:
|
for solv_type in self.results:
|
||||||
objs.append(self.results[solv_type])
|
objs.append(self.results[solv_type])
|
||||||
|
|
||||||
@@ -740,7 +749,7 @@ class River(Graph):
|
|||||||
self._BoundaryConditionsAdisTS,
|
self._BoundaryConditionsAdisTS,
|
||||||
self._LateralContributionsAdisTS,
|
self._LateralContributionsAdisTS,
|
||||||
self._D90AdisTS, self._DIFAdisTS,
|
self._D90AdisTS, self._DIFAdisTS,
|
||||||
self._geotiff,
|
self._geotiff, self._ensembles,
|
||||||
]
|
]
|
||||||
|
|
||||||
for solver in self._parameters:
|
for solver in self._parameters:
|
||||||
|
|||||||
+29
-12
@@ -53,6 +53,7 @@ class Scenario(SQLSubModel):
|
|||||||
"geometry_pointXYZ", "geometry_profileXYZ",
|
"geometry_pointXYZ", "geometry_profileXYZ",
|
||||||
"river_reach", "river_node",
|
"river_reach", "river_node",
|
||||||
"geotiff", "reservoir", "reservoir_data",
|
"geotiff", "reservoir", "reservoir_data",
|
||||||
|
"ensemble",
|
||||||
]
|
]
|
||||||
|
|
||||||
related_tables = tables_with_deleted_column + [
|
related_tables = tables_with_deleted_column + [
|
||||||
@@ -67,6 +68,7 @@ class Scenario(SQLSubModel):
|
|||||||
name: str = "",
|
name: str = "",
|
||||||
description: str = "",
|
description: str = "",
|
||||||
x: int = 1000.0, y: int = 1000.0,
|
x: int = 1000.0, y: int = 1000.0,
|
||||||
|
is_ensemble: bool = False,
|
||||||
revision: int = 0,
|
revision: int = 0,
|
||||||
parent=None):
|
parent=None):
|
||||||
super(Scenario, self).__init__()
|
super(Scenario, self).__init__()
|
||||||
@@ -76,6 +78,7 @@ class Scenario(SQLSubModel):
|
|||||||
self._x, self._y = x, y
|
self._x, self._y = x, y
|
||||||
self._name = name
|
self._name = name
|
||||||
self._description = description
|
self._description = description
|
||||||
|
self._is_ensemble = is_ensemble
|
||||||
self._revision = revision
|
self._revision = revision
|
||||||
self._parent = parent
|
self._parent = parent
|
||||||
|
|
||||||
@@ -98,6 +101,7 @@ class Scenario(SQLSubModel):
|
|||||||
y REAL NOT NULL DEFAULT 1000,
|
y REAL NOT NULL DEFAULT 1000,
|
||||||
name TEXT NOT NULL,
|
name TEXT NOT NULL,
|
||||||
description TEXT NOT NULL,
|
description TEXT NOT NULL,
|
||||||
|
is_ensemble BOOL DEFAULT FALSE,
|
||||||
revision INTEGER NOT NULL,
|
revision INTEGER NOT NULL,
|
||||||
parent_id INTEGER REFERENCES scenario(id)
|
parent_id INTEGER REFERENCES scenario(id)
|
||||||
)
|
)
|
||||||
@@ -133,6 +137,13 @@ class Scenario(SQLSubModel):
|
|||||||
cls._db_create(execute)
|
cls._db_create(execute)
|
||||||
cls._db_add_default(execute)
|
cls._db_add_default(execute)
|
||||||
|
|
||||||
|
if major == "0" and int(minor) == 2:
|
||||||
|
if int(release) < 8:
|
||||||
|
execute(
|
||||||
|
f"ALTER TABLE scenario " +
|
||||||
|
"ADD COLUMN is_ensemble BOOL DEFAULT FALSE"
|
||||||
|
)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -153,7 +164,8 @@ class Scenario(SQLSubModel):
|
|||||||
scenarios = {}
|
scenarios = {}
|
||||||
|
|
||||||
table = execute(
|
table = execute(
|
||||||
"SELECT id, x, y, name, description, revision, parent_id " +
|
"SELECT id, x, y, name, description, " +
|
||||||
|
" is_ensemble, revision, parent_id " +
|
||||||
"FROM scenario " +
|
"FROM scenario " +
|
||||||
"ORDER BY id ASC"
|
"ORDER BY id ASC"
|
||||||
)
|
)
|
||||||
@@ -165,6 +177,7 @@ class Scenario(SQLSubModel):
|
|||||||
x, y = next(it), next(it)
|
x, y = next(it), next(it)
|
||||||
name = next(it)
|
name = next(it)
|
||||||
desc = next(it)
|
desc = next(it)
|
||||||
|
is_ens = next(it)
|
||||||
revi = next(it)
|
revi = next(it)
|
||||||
parent = next(it)
|
parent = next(it)
|
||||||
|
|
||||||
@@ -174,7 +187,9 @@ class Scenario(SQLSubModel):
|
|||||||
new = cls(
|
new = cls(
|
||||||
id=id, x=x, y=y,
|
id=id, x=x, y=y,
|
||||||
name=name, description=desc,
|
name=name, description=desc,
|
||||||
revision=revi, parent=parent
|
is_ensemble=is_ens,
|
||||||
|
revision=revi,
|
||||||
|
parent=parent
|
||||||
)
|
)
|
||||||
scenarios[id] = new
|
scenarios[id] = new
|
||||||
|
|
||||||
@@ -184,21 +199,18 @@ class Scenario(SQLSubModel):
|
|||||||
if self.is_deleted():
|
if self.is_deleted():
|
||||||
return self.drop_all(execute)
|
return self.drop_all(execute)
|
||||||
|
|
||||||
parent = 'NULL'
|
parent = None
|
||||||
if self.parent is not None:
|
if self.parent is not None:
|
||||||
parent = self.parent._id
|
parent = self.parent._id
|
||||||
|
|
||||||
execute(
|
execute(
|
||||||
"INSERT OR REPLACE INTO " +
|
"INSERT OR REPLACE INTO " +
|
||||||
"scenario(id, x, y, name, description, revision, parent_id) " +
|
"scenario(id, x, y, name, description, " +
|
||||||
"VALUES (" +
|
" is_ensemble, revision, parent_id) " +
|
||||||
f"{self._id}, " +
|
"VALUES (?, ?, ?, ?, ?, ?, ?, ?)",
|
||||||
f"{self.x}, {self.y}, " +
|
self._id, self.x, self.y,
|
||||||
f"'{self._db_format(self.name)}', " +
|
self.name, self.description, self._is_ensemble,
|
||||||
f"'{self._db_format(self.description)}', " +
|
self._revision, parent
|
||||||
f"{self._revision}, " +
|
|
||||||
f"{parent}" +
|
|
||||||
")"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
@@ -323,6 +335,9 @@ class Scenario(SQLSubModel):
|
|||||||
def parent(self):
|
def parent(self):
|
||||||
return self._parent
|
return self._parent
|
||||||
|
|
||||||
|
def is_ensemble(self):
|
||||||
|
return self._is_ensemble
|
||||||
|
|
||||||
def set_pos(self, x, y):
|
def set_pos(self, x, y):
|
||||||
self._x = x
|
self._x = x
|
||||||
self._y = y
|
self._y = y
|
||||||
@@ -340,6 +355,8 @@ class Scenario(SQLSubModel):
|
|||||||
return self.name
|
return self.name
|
||||||
if key == "description":
|
if key == "description":
|
||||||
return self.description
|
return self.description
|
||||||
|
if key == "is_ensemble":
|
||||||
|
return self.is_ensemble()
|
||||||
if key == "parent":
|
if key == "parent":
|
||||||
return self.parent
|
return self.parent
|
||||||
|
|
||||||
|
|||||||
@@ -57,8 +57,11 @@ class Scenarios(PamhyrModelDict):
|
|||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def new(self, parent):
|
def new(self, parent, is_ensemble=False):
|
||||||
new = Scenario(parent=parent)
|
new = Scenario(
|
||||||
|
parent=parent,
|
||||||
|
is_ensemble=is_ensemble
|
||||||
|
)
|
||||||
self.set(new._id, new)
|
self.set(new._id, new)
|
||||||
return new
|
return new
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Serializable.py -- Pamhyr pickle abstract class
|
# Serializable.py -- Pamhyr pickle abstract class
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# SolverParametersList.py -- Pamhyr
|
# SolverParametersList.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
# Status.py -- Pamhyr model status class
|
# Status.py -- Pamhyr model status class
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Stricklers.py -- Pamhyr
|
# Stricklers.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# StricklersList.py -- Pamhyr
|
# StricklersList.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
+57
-5
@@ -1,5 +1,5 @@
|
|||||||
# Study.py -- Pamhyr Study class
|
# Study.py -- Pamhyr Study class
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -33,6 +33,7 @@ from Model.Status import StudyStatus
|
|||||||
from Model.Except import NotImplementedMethodeError
|
from Model.Except import NotImplementedMethodeError
|
||||||
from Model.River import River
|
from Model.River import River
|
||||||
from Model.Geometry.Reach import Reach
|
from Model.Geometry.Reach import Reach
|
||||||
|
from Model.Ensembles.DistributionList import DistributionList
|
||||||
from Model.HydraulicStructures.HydraulicStructures import (
|
from Model.HydraulicStructures.HydraulicStructures import (
|
||||||
HydraulicStructure
|
HydraulicStructure
|
||||||
)
|
)
|
||||||
@@ -46,10 +47,11 @@ logger = logging.getLogger()
|
|||||||
|
|
||||||
|
|
||||||
class Study(SQLModel):
|
class Study(SQLModel):
|
||||||
_version = "0.2.6"
|
_version = "0.2.9"
|
||||||
|
|
||||||
_sub_classes = [
|
_sub_classes = [
|
||||||
Scenario,
|
Scenario,
|
||||||
|
DistributionList,
|
||||||
River,
|
River,
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -84,6 +86,9 @@ class Study(SQLModel):
|
|||||||
self.scenarios = Scenarios(status=self.status)
|
self.scenarios = Scenarios(status=self.status)
|
||||||
self.scenarios[0] = s0
|
self.scenarios[0] = s0
|
||||||
self.status.scenario = s0
|
self.status.scenario = s0
|
||||||
|
|
||||||
|
self._ens_distributions = DistributionList(status=self.status)
|
||||||
|
|
||||||
self._river = River(status=self.status)
|
self._river = River(status=self.status)
|
||||||
else:
|
else:
|
||||||
self._init_db_file(filename, is_new=False)
|
self._init_db_file(filename, is_new=False)
|
||||||
@@ -388,12 +393,19 @@ class Study(SQLModel):
|
|||||||
lambda a, s: a or (s.parent is scenario),
|
lambda a, s: a or (s.parent is scenario),
|
||||||
new.scenarios.lst,
|
new.scenarios.lst,
|
||||||
False
|
False
|
||||||
):
|
) or scenario.is_ensemble():
|
||||||
new.status.set_as_read_only()
|
new.status.set_as_read_only()
|
||||||
|
|
||||||
data["scenario"] = scenario
|
data["scenario"] = scenario
|
||||||
data["loaded_pid"] = set()
|
data["loaded_pid"] = set()
|
||||||
|
|
||||||
|
# Get ensemble distribution
|
||||||
|
new._ens_distributions = DistributionList._db_load(
|
||||||
|
sql_exec, data=data
|
||||||
|
)
|
||||||
|
|
||||||
|
data["ens_distributions"] = new._ens_distributions
|
||||||
|
|
||||||
# Load river data
|
# Load river data
|
||||||
new._river = River._db_load(
|
new._river = River._db_load(
|
||||||
sql_exec, data=data
|
sql_exec, data=data
|
||||||
@@ -454,8 +466,27 @@ class Study(SQLModel):
|
|||||||
)
|
)
|
||||||
progress()
|
progress()
|
||||||
|
|
||||||
|
if self.status.scenario.is_ensemble():
|
||||||
|
lst = [
|
||||||
|
self.scenarios, self._ens_distributions,
|
||||||
|
self._river._ensembles,
|
||||||
|
]
|
||||||
|
for solv in self._river._results:
|
||||||
|
lst.append(self._river._results[solv])
|
||||||
|
|
||||||
|
self._save_submodel(
|
||||||
|
lst, data=progress
|
||||||
|
)
|
||||||
|
progress()
|
||||||
|
self.commit()
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
self._save_submodel(
|
self._save_submodel(
|
||||||
[self.scenarios, self._river],
|
[
|
||||||
|
self.scenarios, self._ens_distributions,
|
||||||
|
self._river
|
||||||
|
],
|
||||||
data=progress
|
data=progress
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -573,7 +604,8 @@ class Study(SQLModel):
|
|||||||
data = {
|
data = {
|
||||||
"status": self.status,
|
"status": self.status,
|
||||||
"loaded_pid": set(),
|
"loaded_pid": set(),
|
||||||
"scenario": scenario
|
"scenario": scenario,
|
||||||
|
"ens_distributions": self._ens_distributions,
|
||||||
}
|
}
|
||||||
|
|
||||||
self.status.start_loading()
|
self.status.start_loading()
|
||||||
@@ -647,6 +679,7 @@ class Study(SQLModel):
|
|||||||
self.status.scenario.y + 100)
|
self.status.scenario.y + 100)
|
||||||
|
|
||||||
new.name = self.status.scenario.name + " (copy)"
|
new.name = self.status.scenario.name + " (copy)"
|
||||||
|
new.is_ensemble = self.status.scenario.is_ensemble
|
||||||
|
|
||||||
self.status.scenario = new
|
self.status.scenario = new
|
||||||
self.river._data_traversal(
|
self.river._data_traversal(
|
||||||
@@ -658,6 +691,25 @@ class Study(SQLModel):
|
|||||||
self.status.set_as_editable()
|
self.status.set_as_editable()
|
||||||
return new
|
return new
|
||||||
|
|
||||||
|
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)"
|
||||||
|
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_read_only()
|
||||||
|
return new
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def results(self):
|
def results(self):
|
||||||
return self._river.results
|
return self._river.results
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# PamhyrDB.py -- Pamhyr abstract model database classes
|
# PamhyrDB.py -- Pamhyr abstract model database classes
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -185,6 +185,13 @@ class SQLSubModel(PamhyrID):
|
|||||||
else:
|
else:
|
||||||
self._owner_scenario = owner_scenario
|
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):
|
def must_be_saved(self):
|
||||||
"""Return True if this object MUST be save in the save file.
|
"""Return True if this object MUST be save in the save file.
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# PamhyrDict.py -- Pamhyr abstract dict for model classes
|
# PamhyrDict.py -- Pamhyr abstract dict for model classes
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# PamhyrList.py -- Pamhyr Abstract List object for the Model
|
# PamhyrList.py -- Pamhyr Abstract List object for the Model
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# PamhyrList.py -- Pamhyr Abstract List object for the Model
|
# PamhyrList.py -- Pamhyr Abstract List object for the Model
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# __init__.py -- Pamhyr
|
# __init__.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# test_Model.py -- Pamhyr
|
# test_Model.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
# SQL.py -- Pamhyr
|
# SQL.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# AScript.py -- Pamhyr abstract script class
|
# AScript.py -- Pamhyr abstract script class
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Hello.py -- Pamhyr
|
# Hello.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ListSolver.py -- Pamhyr
|
# ListSolver.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# MageMesh.py -- Pamhyr
|
# MageMesh.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# P3DST.py -- Pamhyr
|
# P3DST.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
# Run.py -- Pamhyr
|
# Run.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,3 +1,20 @@
|
|||||||
|
# mage_to_mascaret.py -- Pamhyr
|
||||||
|
# Copyright (C) 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 -*-
|
||||||
#!/bin/env python3
|
#!/bin/env python3
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
@@ -336,6 +353,3 @@ if __name__ == "__main__":
|
|||||||
print( 'Number of arguments:', len(sys.argv), 'arguments.')
|
print( 'Number of arguments:', len(sys.argv), 'arguments.')
|
||||||
print( 'Argument List:', str(sys.argv))
|
print( 'Argument List:', str(sys.argv))
|
||||||
mage_to_mascaret(sys.argv[1])
|
mage_to_mascaret(sys.argv[1])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,3 +1,20 @@
|
|||||||
|
# mascaret_to_mage.py -- Pamhyr
|
||||||
|
# Copyright (C) 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 -*-
|
||||||
#!/bin/env python3
|
#!/bin/env python3
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# ASolver.py -- Pamhyr
|
# ASolver.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# AdisTS.py -- Pamhyr
|
# AdisTS.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# CommandLine.py -- Pamhyr
|
# CommandLine.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# GenericSolver.py -- Pamhyr
|
# GenericSolver.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
+316
-53
@@ -1,5 +1,5 @@
|
|||||||
# Mage.py -- Pamhyr
|
# Mage.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -1027,6 +1027,75 @@ class Mage8(Mage):
|
|||||||
logger_exception(e)
|
logger_exception(e)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def export_ensemble_variation(self, study, repertory,
|
||||||
|
qlog=None, name="0",
|
||||||
|
samples=None):
|
||||||
|
self._study = study
|
||||||
|
name = study.name.replace(" ", "_")
|
||||||
|
|
||||||
|
var_samples = self._export_ensemble_RUG(
|
||||||
|
study, repertory,
|
||||||
|
qlog, name=name,
|
||||||
|
samples=samples,
|
||||||
|
)
|
||||||
|
|
||||||
|
return var_samples
|
||||||
|
|
||||||
|
def _export_ensemble_RUG(self, study, repertory,
|
||||||
|
qlog, name="0",
|
||||||
|
samples={}):
|
||||||
|
files = []
|
||||||
|
var_samples = []
|
||||||
|
|
||||||
|
for ens in samples:
|
||||||
|
if ens.target_data is None:
|
||||||
|
continue
|
||||||
|
|
||||||
|
x = next(samples[ens])
|
||||||
|
var_samples.append(x)
|
||||||
|
|
||||||
|
qlog.put(f"*** Variation " +
|
||||||
|
f"'{ens.target_data}' - {ens.data_type} x {x}")
|
||||||
|
|
||||||
|
if ens.data_type == "strickler_minor":
|
||||||
|
ens.target_data.minor = x
|
||||||
|
elif ens.data_type == "strickler_medium":
|
||||||
|
ens.target_data.medium = x
|
||||||
|
|
||||||
|
if qlog is not None:
|
||||||
|
qlog.put("Export variation of RUG file")
|
||||||
|
|
||||||
|
# Write header
|
||||||
|
with mage_file_open(os.path.join(repertory, f"{name}.RUG"), "w+") as f:
|
||||||
|
files.append(f"{name}.RUG")
|
||||||
|
|
||||||
|
edges = study.river.enable_edges()
|
||||||
|
|
||||||
|
id = 1
|
||||||
|
for edge in edges:
|
||||||
|
frictions = edge.frictions
|
||||||
|
|
||||||
|
for friction in frictions.frictions:
|
||||||
|
if friction.begin_strickler is None:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if friction.is_deleted():
|
||||||
|
continue
|
||||||
|
|
||||||
|
num = f"{id:>3}"
|
||||||
|
brk = f"{friction.begin_rk:>10.3f}"
|
||||||
|
erk = f"{friction.end_rk:>10.3f}"
|
||||||
|
|
||||||
|
strickler = friction.begin_strickler
|
||||||
|
coef_1 = f"{strickler.minor:>10.3f}"
|
||||||
|
coef_2 = f"{strickler.medium:>10.3f}"
|
||||||
|
|
||||||
|
f.write(f"K{num} {brk}{erk}{coef_1}{coef_2}\n")
|
||||||
|
|
||||||
|
id += 1
|
||||||
|
|
||||||
|
return var_samples
|
||||||
|
|
||||||
###########
|
###########
|
||||||
# RESULTS #
|
# RESULTS #
|
||||||
###########
|
###########
|
||||||
@@ -1083,7 +1152,7 @@ class Mage8(Mage):
|
|||||||
newline()
|
newline()
|
||||||
|
|
||||||
reachs = []
|
reachs = []
|
||||||
iprofiles = {}
|
iprofiles = []
|
||||||
profile_len = []
|
profile_len = []
|
||||||
reach_offset = {}
|
reach_offset = {}
|
||||||
|
|
||||||
@@ -1091,22 +1160,25 @@ class Mage8(Mage):
|
|||||||
|
|
||||||
for i in range(nb_reach):
|
for i in range(nb_reach):
|
||||||
# Add results reach to reach list
|
# Add results reach to reach list
|
||||||
r = results.river.add(i)
|
r = results.river.reach(i)
|
||||||
reachs.append(r)
|
reachs.append(r)
|
||||||
|
|
||||||
# ID of first and last reach profiles
|
# ID of first and last reach profiles
|
||||||
i1 = data[2*i] - 1
|
i1 = data[2*i] - 1
|
||||||
i2 = data[2*i+1] - 1
|
i2 = data[2*i+1] - 1
|
||||||
|
|
||||||
|
# Keep profiles index of all river
|
||||||
|
r.set_global_index(range(i1, i2 + 1))
|
||||||
|
|
||||||
# Add profile id correspondance to reach
|
# Add profile id correspondance to reach
|
||||||
key = (i1, i2)
|
for key in range(i1, i2 + 1):
|
||||||
iprofiles[key] = r
|
iprofiles.append(i)
|
||||||
|
|
||||||
# Profile ID offset
|
# Profile ID offset
|
||||||
reach_offset[r] = i1
|
reach_offset[r] = i1
|
||||||
profile_len.append(i2-i1+1)
|
profile_len.append(i2 - i1 + 1)
|
||||||
|
|
||||||
logger.debug(f"read_bin: iprofiles = {iprofiles}")
|
logger.debug(f"read_bin: iprofiles = {len(iprofiles)}")
|
||||||
|
|
||||||
endline()
|
endline()
|
||||||
|
|
||||||
@@ -1124,16 +1196,6 @@ class Mage8(Mage):
|
|||||||
# Data
|
# Data
|
||||||
newline()
|
newline()
|
||||||
|
|
||||||
def ip_to_r(i): return iprofiles[
|
|
||||||
next(
|
|
||||||
filter(
|
|
||||||
lambda k: k[0] <= i <= k[1],
|
|
||||||
iprofiles
|
|
||||||
)
|
|
||||||
)
|
|
||||||
]
|
|
||||||
def ip_to_ri(r, i): return i - reach_offset[r]
|
|
||||||
|
|
||||||
# check results and geometry consistency
|
# check results and geometry consistency
|
||||||
for i, r in enumerate(reachs):
|
for i, r in enumerate(reachs):
|
||||||
lp = len(r.profiles)
|
lp = len(r.profiles)
|
||||||
@@ -1144,6 +1206,8 @@ class Mage8(Mage):
|
|||||||
return
|
return
|
||||||
|
|
||||||
ts = set()
|
ts = set()
|
||||||
|
tmp_table = {}
|
||||||
|
|
||||||
end = False
|
end = False
|
||||||
while not end:
|
while not end:
|
||||||
n = read_int(1)[0]
|
n = read_int(1)[0]
|
||||||
@@ -1152,18 +1216,21 @@ class Mage8(Mage):
|
|||||||
f, dtype=np.byte, count=1)).decode()
|
f, dtype=np.byte, count=1)).decode()
|
||||||
data = read_float(n)
|
data = read_float(n)
|
||||||
|
|
||||||
# logger.debug(f"read_bin: timestamp = {timestamp} sec")
|
if key not in tmp_table:
|
||||||
|
tmp_table[key] = []
|
||||||
|
|
||||||
|
tmp_table[key].append(data)
|
||||||
ts.add(timestamp)
|
ts.add(timestamp)
|
||||||
|
|
||||||
if key in ["Z", "Q"]:
|
if key in ["Z", "Q"]:
|
||||||
for i, d in enumerate(data):
|
for i, d in enumerate(data):
|
||||||
# Get reach corresponding to profile ID
|
# Get reach corresponding to profile ID
|
||||||
reach = ip_to_r(i)
|
reach = reachs[iprofiles[i]]
|
||||||
# Get profile id in reach
|
# Get profile id in reach
|
||||||
ri = ip_to_ri(reach, i)
|
ri = i - reach_offset[reach]
|
||||||
|
|
||||||
# Set data for profile RI
|
# Set data for profile RI
|
||||||
reach.set(ri, timestamp, key, d)
|
# reach.set(ri, timestamp, key, d)
|
||||||
if key == "Z":
|
if key == "Z":
|
||||||
profile = reach.profile(ri)
|
profile = reach.profile(ri)
|
||||||
limits = profile.geometry.get_water_limits(d)
|
limits = profile.geometry.get_water_limits(d)
|
||||||
@@ -1176,6 +1243,15 @@ class Mage8(Mage):
|
|||||||
endline()
|
endline()
|
||||||
end = newline().size <= 0
|
end = newline().size <= 0
|
||||||
|
|
||||||
|
ts_index = {}
|
||||||
|
for i, t in enumerate(sorted(ts)):
|
||||||
|
ts_index[t] = i
|
||||||
|
results.set_timestamp_index(ts_index)
|
||||||
|
|
||||||
|
table = {}
|
||||||
|
for k in tmp_table:
|
||||||
|
table[k] = np.array(tmp_table[k])
|
||||||
|
|
||||||
results.set("timestamps", ts)
|
results.set("timestamps", ts)
|
||||||
ts_list = sorted(ts)
|
ts_list = sorted(ts)
|
||||||
logger.info(f"compute tab...")
|
logger.info(f"compute tab...")
|
||||||
@@ -1185,19 +1261,33 @@ class Mage8(Mage):
|
|||||||
|
|
||||||
logger.info(f"compute velocity...")
|
logger.info(f"compute velocity...")
|
||||||
|
|
||||||
for r in reachs:
|
velocity_arr = np.zeros((len(ts), len(iprofiles)))
|
||||||
for t in ts_list:
|
for ti, t in enumerate(ts_list):
|
||||||
for i, p in enumerate(r.profiles):
|
j = 0
|
||||||
|
for r in reachs:
|
||||||
|
for pi, p in enumerate(r.profiles):
|
||||||
v = p.geometry.speed(
|
v = p.geometry.speed(
|
||||||
p.get_ts_key(t, "Q"),
|
table["Q"][ti, p.global_index],
|
||||||
p.get_ts_key(t, "Z")
|
table["Z"][ti, p.global_index],
|
||||||
)
|
)
|
||||||
r.set(i, t, "V", v)
|
# r.set(pi, t, "V", v)
|
||||||
|
velocity_arr[ti, j] = v
|
||||||
|
j += 1
|
||||||
|
|
||||||
|
table["V"] = velocity_arr
|
||||||
|
|
||||||
|
for legend in table:
|
||||||
|
table[legend] = results.new_table_data(
|
||||||
|
legend, table[legend]
|
||||||
|
)
|
||||||
|
|
||||||
|
results.set("table", table)
|
||||||
|
|
||||||
logger.info(f"read_bin: ... end with {len(ts)} timestamp read")
|
logger.info(f"read_bin: ... end with {len(ts)} timestamp read")
|
||||||
|
|
||||||
results.bufferize("Z")
|
# results.bufferize("Z")
|
||||||
results.bufferize("Q")
|
# results.bufferize("Q")
|
||||||
results.bufferize("V")
|
# results.bufferize("V")
|
||||||
logger.info(f"reading time: '{time.time() - start}'")
|
logger.info(f"reading time: '{time.time() - start}'")
|
||||||
|
|
||||||
@timer
|
@timer
|
||||||
@@ -1267,8 +1357,8 @@ class Mage8(Mage):
|
|||||||
reachs.append(r)
|
reachs.append(r)
|
||||||
|
|
||||||
# ID of first and last reach profiles
|
# ID of first and last reach profiles
|
||||||
i1 = data[2*i] - 1
|
i1 = data[2 * i] - 1
|
||||||
i2 = data[2*i+1] - 1
|
i2 = data[2 * i + 1] - 1
|
||||||
|
|
||||||
# Add profile id correspondance to reach
|
# Add profile id correspondance to reach
|
||||||
key = (i1, i2)
|
key = (i1, i2)
|
||||||
@@ -1322,6 +1412,7 @@ class Mage8(Mage):
|
|||||||
newline()
|
newline()
|
||||||
npts = read_int(n)
|
npts = read_int(n)
|
||||||
endline()
|
endline()
|
||||||
|
|
||||||
sum_npts = sum(npts)
|
sum_npts = sum(npts)
|
||||||
logger.debug(f"read_gra: Number of points: {sum_npts}")
|
logger.debug(f"read_gra: Number of points: {sum_npts}")
|
||||||
|
|
||||||
@@ -1371,35 +1462,42 @@ class Mage8(Mage):
|
|||||||
|
|
||||||
logger.info(f"compute river bed elevation...")
|
logger.info(f"compute river bed elevation...")
|
||||||
|
|
||||||
|
zfd_lst = []
|
||||||
|
|
||||||
for r in reachs:
|
for r in reachs:
|
||||||
z_min = r.geometry.get_z_min()
|
z_min = r.geometry.get_z_min()
|
||||||
sls = list(map(
|
sls = map(
|
||||||
lambda p: p.get_ts_key(ts_list[0], "sl")[0],
|
lambda p: p.get_ts_key(ts_list[0], "sl")[0],
|
||||||
r.profiles
|
r.profiles
|
||||||
))
|
)
|
||||||
z_br = list(map(
|
z_br = list(map(
|
||||||
lambda z, sl: reduce(
|
lambda z, sl: reduce(
|
||||||
lambda z, h: z - h[0],
|
lambda z, h: z - h[0],
|
||||||
sl, z
|
sl, z
|
||||||
),
|
),
|
||||||
z_min, # Original geometry
|
z_min, # Original geometry
|
||||||
sls # Original sediment layers
|
sls # Original sediment layers
|
||||||
))
|
))
|
||||||
for t in ts_list:
|
for its, t in enumerate(ts_list):
|
||||||
sls = list(map(
|
sls = map(
|
||||||
lambda p: p.get_ts_key(t, "sl")[0],
|
lambda p: p.get_ts_key(t, "sl")[0],
|
||||||
r.profiles
|
r.profiles
|
||||||
))
|
)
|
||||||
zfd = list(map(
|
zfd = list(map(
|
||||||
lambda z, sl: reduce(
|
lambda z, sl: reduce(
|
||||||
lambda z, h: z + h[0],
|
lambda z, h: z + h[0],
|
||||||
sl, z
|
sl, z
|
||||||
),
|
),
|
||||||
z_br, # bedrock
|
z_br, # bedrock
|
||||||
sls # Original sediment layers
|
sls # Original sediment layers
|
||||||
))
|
))
|
||||||
for i, p in enumerate(r.profiles):
|
|
||||||
r.set(i, t, "zfd", zfd[i])
|
zfd_lst.append(np.array(zfd))
|
||||||
|
|
||||||
|
table = results.get("table")
|
||||||
|
table["zfd"] = results.new_table_data(
|
||||||
|
"zfd", np.array(zfd_lst)
|
||||||
|
)
|
||||||
|
|
||||||
results.set("sediment_timestamps", ts)
|
results.set("sediment_timestamps", ts)
|
||||||
logger.info(f"read_gra: ... end with {len(ts)} timestamp read")
|
logger.info(f"read_gra: ... end with {len(ts)} timestamp read")
|
||||||
@@ -1422,6 +1520,171 @@ class Mage8(Mage):
|
|||||||
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
@timer
|
||||||
|
def read_ensemble_bin(self, study, fname, tables, run_number, qlog=None):
|
||||||
|
logger.info(f"read_ensemble_bin: Start reading '{fname}' ...")
|
||||||
|
start = time.time()
|
||||||
|
|
||||||
|
with mage_file_open(fname, "r") as f:
|
||||||
|
def newline(): return np.fromfile(f, dtype=np.int32, count=1)
|
||||||
|
def endline(): return np.fromfile(f, dtype=np.int32, count=1)
|
||||||
|
|
||||||
|
def read_int(size): return np.fromfile(
|
||||||
|
f, dtype=np.int32, count=size)
|
||||||
|
|
||||||
|
def read_float(size): return np.fromfile(
|
||||||
|
f, dtype=np.float32, count=size)
|
||||||
|
|
||||||
|
def read_float64(size): return np.fromfile(
|
||||||
|
f, dtype=np.float64, count=size)
|
||||||
|
|
||||||
|
# Meta data (1st line)
|
||||||
|
newline()
|
||||||
|
data = read_int(3)
|
||||||
|
|
||||||
|
nb_reach = data[0]
|
||||||
|
nb_profile = data[1]
|
||||||
|
mage_version = data[2]
|
||||||
|
|
||||||
|
if mage_version <= 80:
|
||||||
|
msg = (
|
||||||
|
"Read BIN files: " +
|
||||||
|
f"Possible incompatible mage version '{mage_version}', " +
|
||||||
|
"please check your solver configuration..."
|
||||||
|
)
|
||||||
|
logger.warning(msg)
|
||||||
|
|
||||||
|
if qlog is not None:
|
||||||
|
qlog.put("[WARNING] " + msg)
|
||||||
|
|
||||||
|
endline()
|
||||||
|
|
||||||
|
# Reach information (2nd line)
|
||||||
|
newline()
|
||||||
|
_ = read_int(2*nb_reach)
|
||||||
|
endline()
|
||||||
|
|
||||||
|
# X (3rd line)
|
||||||
|
newline()
|
||||||
|
_ = read_float(nb_profile)
|
||||||
|
endline()
|
||||||
|
|
||||||
|
# Z and Y (4th line)
|
||||||
|
newline()
|
||||||
|
_ = read_float(3*nb_profile)
|
||||||
|
endline()
|
||||||
|
|
||||||
|
# Data
|
||||||
|
newline()
|
||||||
|
|
||||||
|
ts = set()
|
||||||
|
|
||||||
|
tmp_table = {}
|
||||||
|
end = False
|
||||||
|
while not end:
|
||||||
|
n = read_int(1)[0]
|
||||||
|
timestamp = read_float64(1)[0]
|
||||||
|
key = bytearray(
|
||||||
|
np.fromfile(
|
||||||
|
f, dtype=np.byte, count=1
|
||||||
|
)
|
||||||
|
).decode()
|
||||||
|
data = read_float(n)
|
||||||
|
|
||||||
|
if key not in tmp_table:
|
||||||
|
tmp_table[key] = []
|
||||||
|
|
||||||
|
tmp_table[key].append(data)
|
||||||
|
|
||||||
|
ts.add(timestamp)
|
||||||
|
|
||||||
|
endline()
|
||||||
|
end = newline().size <= 0
|
||||||
|
|
||||||
|
table = {}
|
||||||
|
for k in tmp_table:
|
||||||
|
table[k] = np.array(tmp_table[k])
|
||||||
|
|
||||||
|
self.read_ensemble_bin_agregate_data(
|
||||||
|
table, tables, run_number
|
||||||
|
)
|
||||||
|
|
||||||
|
tables["timestamps"] = ts
|
||||||
|
|
||||||
|
logger.info(f"reading time: '{time.time() - start}'")
|
||||||
|
|
||||||
|
def read_ensemble_bin_agregate_data(self, tables, res, run_number):
|
||||||
|
z = tables["Z"]
|
||||||
|
q = tables["Q"]
|
||||||
|
|
||||||
|
if "z_mean" not in res:
|
||||||
|
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
|
||||||
|
else:
|
||||||
|
# Get mean results for Z and Q
|
||||||
|
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"])
|
||||||
|
res["z_max"] = np.maximum(z, res["z_max"])
|
||||||
|
res["q_min"] = np.minimum(q, res["q_min"])
|
||||||
|
res["q_max"] = np.maximum(q, res["q_max"])
|
||||||
|
|
||||||
|
@timer
|
||||||
|
def results_ensemble(self, study, repertory,
|
||||||
|
tables, run_number,
|
||||||
|
qlog=None, name=None):
|
||||||
|
self._study = study
|
||||||
|
if name is None:
|
||||||
|
name = study.name.replace(" ", "_")
|
||||||
|
|
||||||
|
fname = os.path.join(repertory, f"{name}.BIN".replace(" ", "_"))
|
||||||
|
if not os.path.isfile(fname):
|
||||||
|
logger.info(f"Result file {name}.BIN does not exist")
|
||||||
|
return None
|
||||||
|
try:
|
||||||
|
self.read_ensemble_bin(study, fname, tables, run_number, qlog)
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Failed to read results")
|
||||||
|
logger_exception(e)
|
||||||
|
return None
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
def get_ensemble_empty_results(self, study, repertory, name=None):
|
||||||
|
return Results(
|
||||||
|
study=study,
|
||||||
|
solver=self,
|
||||||
|
repertory=repertory,
|
||||||
|
name=name,
|
||||||
|
is_ensemble=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class MageFake7(Mage8):
|
class MageFake7(Mage8):
|
||||||
_type = "mage_fake7"
|
_type = "mage_fake7"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Solvers.py -- Pamhyr
|
# Solvers.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Window.py -- Pamhyr
|
# Window.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# GenerateDialog.py -- Pamhyr
|
# GenerateDialog.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Plot.py -- Pamhyr
|
# Plot.py -- Pamhyr
|
||||||
# Copyright (C) 2023-2025 INRAE
|
# Copyright (C) 2023-2026 INRAE
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
Loaded 100 of 315 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user