mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
Compare commits
No files matched your search
+1
-1
@@ -29,7 +29,7 @@ stages:
|
||||
#############
|
||||
|
||||
variables:
|
||||
MAGE_VERSION: "v8.3.3"
|
||||
MAGE_VERSION: "v8.3.4"
|
||||
|
||||
dl-mage-doc:
|
||||
stage: downloads
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
Sylvain COULIBALY, INRAE, 2020 - 2022
|
||||
Théophile TERRAZ, INRAE, 2022 - 2023
|
||||
Pierre-Antoine ROUBY, INRAE, 2023
|
||||
Théophile TERRAZ, INRAE, 2022 - 2024
|
||||
Pierre-Antoine ROUBY, INRAE, 2023 - 2024
|
||||
@@ -25,21 +25,11 @@ for more details.
|
||||
|
||||
### GNU/Linux
|
||||
|
||||
Downloads the [last
|
||||
realease](https://gitlab.irstea.fr/theophile.terraz/pamhyr/-/releases/permalink/latest)
|
||||
GNU/Linux binary archive.
|
||||
|
||||
```shell
|
||||
tar xf pamhyr-gnulinux.tar.xz
|
||||
cd pamhyr
|
||||
./Pamhyr2
|
||||
```
|
||||
[See documentation](https://gitlab.irstea.fr/theophile.terraz/pamhyr/-/wikis/home/en/Install%20on%20GNULinux)
|
||||
|
||||
### Windows
|
||||
|
||||
Downloads the [last
|
||||
realease](https://gitlab.irstea.fr/theophile.terraz/pamhyr/-/releases/permalink/latest)
|
||||
Windows installer or ZIP archive.
|
||||
[See documentation](https://gitlab.irstea.fr/theophile.terraz/pamhyr/-/wikis/home/en/Install%20on%20Windows)
|
||||
|
||||
### From source code
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 19 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 20 KiB |
@@ -4,7 +4,7 @@ PyQt5-sip==12.12.2
|
||||
PyQtWebEngine==5.15.6
|
||||
QScintilla>=2.14.1
|
||||
pyqtgraph>=0.12.1
|
||||
matplotlib>=3.4.1
|
||||
matplotlib>=3.7.1
|
||||
numpy>=1.24.2
|
||||
colorama>=0.4.3
|
||||
pyinstaller>=5.11.0
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ PyQt5-sip==12.12.2
|
||||
#PyQtWebEngine==5.15.6
|
||||
QScintilla>=2.14.1
|
||||
pyqtgraph>=0.12.1
|
||||
matplotlib>=3.4.1
|
||||
matplotlib>=3.7.1
|
||||
numpy>=1.24.2
|
||||
colorama>=0.4.3
|
||||
pyinstaller>=5.11.0
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Checker.py -- Pamhyr abstract checker class
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
# Mage.py -- Pamhyr MAGE checkers
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Study.py -- Pamhyr study checkers
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# AMeshingTool.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
+36
-4
@@ -1,5 +1,5 @@
|
||||
# Mage.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
@@ -65,6 +65,10 @@ class MeshingWithMage(AMeshingTool):
|
||||
)
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def _path(cls):
|
||||
return cls._exe_path()
|
||||
|
||||
def _init_c_init_bief_from_geo_file(self):
|
||||
self._c_init_bief_from_geo_file = getattr(
|
||||
self._bief_lib, 'c_init_bief_from_geo_file'
|
||||
@@ -278,11 +282,21 @@ class MeshingWithMageMailleurTT(AMeshingTool):
|
||||
)
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def _path(cls):
|
||||
return cls._exe_path()
|
||||
|
||||
###########
|
||||
# Meshing #
|
||||
###########
|
||||
|
||||
def meshing(self, reach, step: float = 50):
|
||||
def meshing(self, reach,
|
||||
step: float = 50,
|
||||
limites=[-1, -1],
|
||||
directrices=['un', 'np'],
|
||||
lplan: bool = False,
|
||||
lm: int = 3,
|
||||
linear: bool = False):
|
||||
if reach is None or len(reach.profiles) == 0:
|
||||
return reach
|
||||
|
||||
@@ -294,9 +308,27 @@ class MeshingWithMageMailleurTT(AMeshingTool):
|
||||
proc = QProcess()
|
||||
proc.setWorkingDirectory(tmp)
|
||||
|
||||
logger.debug(f"! mailleurTT {st_file} {m_file} {str(step)}")
|
||||
lplan = 1 if lplan else 0
|
||||
linear = 1 if linear else 0
|
||||
|
||||
logger.info(
|
||||
f"! mailleurTT {st_file} {m_file} " +
|
||||
f"{str(step)} " +
|
||||
f"{limites[0]} {limites[1]} " +
|
||||
f"{directrices[0]} {directrices[1]} " +
|
||||
f"{lplan} {lm} {linear}"
|
||||
)
|
||||
proc.start(
|
||||
self._exe_path(), [st_file, m_file, str(step)]
|
||||
self._exe_path(),
|
||||
list(map(
|
||||
str,
|
||||
[
|
||||
st_file, m_file, step,
|
||||
limites[0], limites[1],
|
||||
directrices[0], directrices[1],
|
||||
lplan, lm, linear
|
||||
]
|
||||
))
|
||||
)
|
||||
proc.waitForFinished()
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# __init__.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# test_Model.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# BoundaryCondition.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# BoundaryConditionList.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# BoundaryConditionTypes.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
# Except.py -- Pamhyr model exceptions
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Friction.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# FrictionList.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Point.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# PointXY.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# PointXYZ.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Profile.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# ProfileXYZ.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
@@ -478,57 +478,55 @@ class ProfileXYZ(Profile, SQLSubModel):
|
||||
return abs(rg.dist(rd))
|
||||
|
||||
def get_water_limits(self, z):
|
||||
# ====================================================================
|
||||
# détermination des points limites RG et RD pour un niveau
|
||||
# d'eau donné
|
||||
#
|
||||
# irg et ird sont les premiers indices en partant des rives
|
||||
# gauche et droite qui correspondent à des points sous la
|
||||
# surface de l'eau ptX et ptY sont les points interpolés où
|
||||
# le plan d'eau intersecte le profil known_level est le
|
||||
# niveau d'eau pour lequel on a obtenu irg, ird, ptX et ptY
|
||||
# ====================================================================
|
||||
"""
|
||||
Determine left and right limits of water elevation.
|
||||
"""
|
||||
|
||||
# initialisation
|
||||
irg = -1
|
||||
ird = -1
|
||||
# Get the index of first point with elevation lesser than water
|
||||
# elevation (for the right and left river side)
|
||||
i_left = -1
|
||||
i_right = -1
|
||||
|
||||
for i in range(self.number_points):
|
||||
if self.point(i).z <= z:
|
||||
irg = i
|
||||
i_left = i
|
||||
break
|
||||
|
||||
for i in reversed(range(self.number_points)):
|
||||
if self.point(i).z <= z:
|
||||
ird = i
|
||||
i_right = i
|
||||
break
|
||||
|
||||
# interpolation des points ptX et ptY
|
||||
if (irg < self.number_points - 1):
|
||||
# Interpolate points at river left side
|
||||
if (i_left > 0):
|
||||
x = np.interp(
|
||||
z,
|
||||
[self.point(irg).z, self.point(irg + 1).z],
|
||||
[self.point(irg).x, self.point(irg + 1).x]
|
||||
[self.point(i_left).z, self.point(i_left - 1).z],
|
||||
[self.point(i_left).x, self.point(i_left - 1).x]
|
||||
)
|
||||
y = np.interp(
|
||||
z,
|
||||
[self.point(irg).z, self.point(irg + 1).z],
|
||||
[self.point(irg).y, self.point(irg + 1).y]
|
||||
[self.point(i_left).z, self.point(i_left - 1).z],
|
||||
[self.point(i_left).y, self.point(i_left - 1).y]
|
||||
)
|
||||
ptX = PointXYZ(x, y, z)
|
||||
pt_left = PointXYZ(x, y, z)
|
||||
else:
|
||||
ptX = self.point(0)
|
||||
if (ird > 0):
|
||||
pt_left = self.point(0)
|
||||
|
||||
# Interpolate points at river right side
|
||||
if (i_right < self.number_points - 1):
|
||||
x = np.interp(
|
||||
z,
|
||||
[self.point(ird-1).z, self.point(ird).z],
|
||||
[self.point(ird-1).x, self.point(ird).x]
|
||||
[self.point(i_right).z, self.point(i_right + 1).z],
|
||||
[self.point(i_right).x, self.point(i_right + 1).x]
|
||||
)
|
||||
y = np.interp(
|
||||
z,
|
||||
[self.point(ird).z, self.point(ird - 1).z],
|
||||
[self.point(ird).y, self.point(ird - 1).y]
|
||||
[self.point(i_right).z, self.point(i_right + 1).z],
|
||||
[self.point(i_right).y, self.point(i_right + 1).y]
|
||||
)
|
||||
ptY = PointXYZ(x, y, z)
|
||||
pt_right = PointXYZ(x, y, z)
|
||||
else:
|
||||
ptY = self.point(self.number_points - 1)
|
||||
pt_right = self.point(self.number_points - 1)
|
||||
|
||||
return ptX, ptY
|
||||
return pt_left, pt_right
|
||||
@@ -1,5 +1,5 @@
|
||||
# Reach.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Vector_1d.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# HydraulicStructures.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Types.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Value.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# HydraulicStructures.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# HydraulicStructuresList.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# InitialConditions.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# InitialConditionsDict.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# LateralContribution.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# LateralContributionList.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# LateralContributionTypes.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Edge.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Graph.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Node.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Point.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# __init__.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# test_Network.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Reservoir.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# ReservoirList.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Results.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# River.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 INRAE
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -59,6 +59,9 @@ class Profile(object):
|
||||
def get_ts_key(self, timestamp, key):
|
||||
return self._data[timestamp][key]
|
||||
|
||||
def has_sediment(self):
|
||||
return any(map(lambda ts: "sl" in self._data[ts], self._data))
|
||||
|
||||
|
||||
class Reach(object):
|
||||
def __init__(self, reach, study):
|
||||
@@ -92,6 +95,9 @@ class Reach(object):
|
||||
def set(self, profile_id, timestamp, key, data):
|
||||
self._profiles[profile_id].set(timestamp, key, data)
|
||||
|
||||
def has_sediment(self):
|
||||
return any(map(lambda profile: profile.has_sediment(), self._profiles))
|
||||
|
||||
|
||||
class River(object):
|
||||
def __init__(self, study):
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
# River.py -- Pamhyr river model
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
# Saved.py -- Pamhyr model status class
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,23 @@
|
||||
# SedimentLayer.py -- Pamhyr
|
||||
# Copyright (C) 2024 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 functools import reduce
|
||||
|
||||
from tools import trace, timer
|
||||
|
||||
from Model.Tools.PamhyrDB import SQLSubModel
|
||||
@@ -346,3 +364,29 @@ class SedimentLayer(SQLSubModel):
|
||||
lst[index], lst[prev] = lst[prev], lst[index]
|
||||
|
||||
self._status.modified()
|
||||
|
||||
def compute_height_from_bottom(self, bottom_elevation: list):
|
||||
sl_height = self.height()
|
||||
|
||||
sl_height_by_profile = []
|
||||
for i in range(len(sl_height)):
|
||||
cur_profile = []
|
||||
for _ in bottom_elevation:
|
||||
cur_profile.append(sl_height[i])
|
||||
|
||||
sl_height_by_profile.append(cur_profile)
|
||||
|
||||
z_sl = reduce(
|
||||
lambda acc, current_sl: acc + [
|
||||
list(
|
||||
map(
|
||||
lambda cur_sl_h, prev_sl_h: prev_sl_h - cur_sl_h,
|
||||
current_sl, acc[-1]
|
||||
)
|
||||
)
|
||||
],
|
||||
sl_height_by_profile,
|
||||
[bottom_elevation]
|
||||
)
|
||||
|
||||
return z_sl
|
||||
@@ -1,3 +1,19 @@
|
||||
# SedimentLayerList.py -- Pamhyr
|
||||
# Copyright (C) 2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Serializable.py -- Pamhyr pickle abstract class
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# SolverParametersList.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Stricklers.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# StricklersList.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
# Study.py -- Pamhyr Study class
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# PamhyrDB.py -- Pamhyr abstract model database classes
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
@@ -23,7 +23,7 @@ import logging
|
||||
from pathlib import Path
|
||||
from functools import reduce
|
||||
|
||||
from tools import SQL
|
||||
from SQL import SQL
|
||||
from Model.Except import NotImplementedMethodeError
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# PamhyrDict.py -- Pamhyr abstract dict for model classes
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# PamhyrList.py -- Pamhyr Abstract List object for the Model
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# __init__.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# test_Model.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
+133
@@ -0,0 +1,133 @@
|
||||
# SQL.py -- Pamhyr
|
||||
# Copyright (C) 2023-2024 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 os
|
||||
import logging
|
||||
import sqlite3
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from tools import timer
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
class SQL(object):
|
||||
def _init_db_file(self, db):
|
||||
exists = Path(db).exists()
|
||||
|
||||
os.makedirs(
|
||||
os.path.dirname(db),
|
||||
exist_ok=True
|
||||
)
|
||||
|
||||
self._db = sqlite3.connect(db)
|
||||
self._cur = self._db.cursor()
|
||||
|
||||
if not exists:
|
||||
self._create() # Create db
|
||||
self._save() # Save
|
||||
else:
|
||||
self._update() # Update db scheme if necessary
|
||||
self._load() # Load data
|
||||
|
||||
def __init__(self, filename=None):
|
||||
self._db = None
|
||||
|
||||
if filename is not None:
|
||||
self._init_db_file(filename)
|
||||
|
||||
def commit(self):
|
||||
logger.debug("SQL - commit")
|
||||
self._db.commit()
|
||||
|
||||
def _close(self):
|
||||
self.commit()
|
||||
self._db.close()
|
||||
|
||||
def _fetch_string(self, s):
|
||||
return s.replace("'", "'")
|
||||
|
||||
def _fetch_tuple(self, tup):
|
||||
res = []
|
||||
for v in tup:
|
||||
if type(v) is str:
|
||||
v = self._fetch_string(v)
|
||||
res.append(v)
|
||||
|
||||
return res
|
||||
|
||||
def _fetch_list(self, lst):
|
||||
res = []
|
||||
for v in lst:
|
||||
if type(v) is str:
|
||||
v = self._fetch_string(v)
|
||||
elif type(v) is tuple:
|
||||
v = self._fetch_tuple(v)
|
||||
res.append(v)
|
||||
|
||||
return res
|
||||
|
||||
def _fetch(self, res, one):
|
||||
if one:
|
||||
value = res.fetchone()
|
||||
else:
|
||||
value = res.fetchall()
|
||||
res = value
|
||||
|
||||
if type(value) is list:
|
||||
res = self._fetch_list(value)
|
||||
elif type(value) is tuple:
|
||||
res = self._fetch_tuple(value)
|
||||
|
||||
return res
|
||||
|
||||
def _db_format(self, value):
|
||||
# Replace ''' by ''' to preserve SQL injection
|
||||
if type(value) is str:
|
||||
value = value.replace("'", "'")
|
||||
return value
|
||||
|
||||
@timer
|
||||
def execute(self, cmd, fetch_one=True, commit=False):
|
||||
logger.debug(f"SQL - {cmd}")
|
||||
|
||||
value = None
|
||||
try:
|
||||
res = self._cur.execute(cmd)
|
||||
|
||||
if commit:
|
||||
self._db.commit()
|
||||
|
||||
value = self._fetch(res, fetch_one)
|
||||
except Exception as e:
|
||||
logger_exception(e)
|
||||
finally:
|
||||
return value
|
||||
|
||||
def _create(self):
|
||||
logger.warning("TODO: Create")
|
||||
|
||||
def _update(self):
|
||||
logger.warning("TODO: Update")
|
||||
|
||||
def _save(self):
|
||||
logger.warning("TODO: Save")
|
||||
|
||||
def _load(self):
|
||||
logger.warning("TODO: LOAD")
|
||||
@@ -1,5 +1,5 @@
|
||||
# AScript.py -- Pamhyr abstract script class
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Hello.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# ListSolver.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# MageMesh.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# P3DST.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
# Run.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# ASolver.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# CommandLine.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# GenericSolver.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
+10
-12
@@ -1,5 +1,5 @@
|
||||
# Mage.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
@@ -148,9 +148,7 @@ class Mage(CommandLineSolver):
|
||||
)
|
||||
|
||||
for edge in edges:
|
||||
name = edge.name.replace(" ", "_")
|
||||
if edge._name == "":
|
||||
name = f"Reach_{edge.id}"
|
||||
name = f"Reach_{edge.id + 1:>3}".replace(" ", "0")
|
||||
|
||||
with mage_file_open(
|
||||
os.path.join(repertory, "net", f"{name}.ST"),
|
||||
@@ -819,11 +817,8 @@ class Mage8(Mage):
|
||||
)
|
||||
|
||||
for e in edges:
|
||||
name = e.name.replace(" ", "_")
|
||||
if e._name == "":
|
||||
name = f"Reach_{e.id}"
|
||||
|
||||
id = f"Bief_{e.id+1}"
|
||||
name = f"Reach_{e.id + 1:>3}".replace(" ", "0")
|
||||
id = name
|
||||
|
||||
n1 = f"{e.node1.id:3}".replace(" ", "x")
|
||||
n2 = f"{e.node2.id:3}".replace(" ", "x")
|
||||
@@ -1023,9 +1018,12 @@ class Mage8(Mage):
|
||||
reach.set(ri, timestamp, key, d)
|
||||
if key == "Z":
|
||||
profile = reach.profile(ri)
|
||||
ptX, ptY = profile.geometry.get_water_limits(d)
|
||||
reach.set(ri, timestamp, "ptX", ptX)
|
||||
reach.set(ri, timestamp, "ptY", ptY)
|
||||
limits = profile.geometry.get_water_limits(d)
|
||||
reach.set(
|
||||
ri, timestamp,
|
||||
"water_limits",
|
||||
limits
|
||||
)
|
||||
|
||||
endline()
|
||||
end = newline().size <= 0
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Solvers.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Window.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
@@ -67,5 +67,5 @@ class AboutWindow(PamhyrDialog):
|
||||
label = f"\n - {author}" + label
|
||||
except StopIteration:
|
||||
label = _translate("About", "Contributors: ") + label
|
||||
label = "Copyright © 2023 INRAE\n" + label
|
||||
label = "Copyright © 2023-2024 INRAE\n" + label
|
||||
self.set_label_text("label_copyright", label)
|
||||
@@ -1,5 +1,5 @@
|
||||
# Plot.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
@@ -27,8 +27,6 @@ from PyQt5.QtCore import (
|
||||
QCoreApplication
|
||||
)
|
||||
|
||||
from View.BoundaryCondition.Edit.translate import BCETranslate
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
logger = logging.getLogger()
|
||||
@@ -47,99 +45,60 @@ class Plot(PamhyrPlot):
|
||||
)
|
||||
|
||||
self._table_headers = self._trad.get_dict("table_headers")
|
||||
|
||||
header = self.data.header
|
||||
self.label_x = self._table_headers[header[0]]
|
||||
self.label_y = self._table_headers[header[1]]
|
||||
|
||||
self._mode = mode
|
||||
self._isometric_axis = False
|
||||
|
||||
self._auto_relim_update = True
|
||||
self._autoscale_update = True
|
||||
|
||||
def custom_ticks(self):
|
||||
if self.data.header[0] != "time":
|
||||
return
|
||||
|
||||
t0 = datetime.fromtimestamp(0)
|
||||
nb = len(self.data.data)
|
||||
mod = int(nb / 5)
|
||||
mod = mod if mod > 0 else nb
|
||||
|
||||
fx = list(
|
||||
map(
|
||||
lambda x: x[1],
|
||||
filter(
|
||||
lambda x: x[0] % mod == 0,
|
||||
enumerate(self.data.data)
|
||||
)
|
||||
)
|
||||
)
|
||||
xx = list(map(lambda v: v[0], fx))
|
||||
if self._mode == "time":
|
||||
xt = list(
|
||||
map(
|
||||
lambda v: str(
|
||||
datetime.fromtimestamp(v[0]) - t0
|
||||
).split(",")[0]
|
||||
.replace("days", _translate("BoundaryCondition", "days"))
|
||||
.replace("day", _translate("BoundaryCondition", "day")),
|
||||
fx
|
||||
)
|
||||
)
|
||||
else:
|
||||
xt = list(
|
||||
map(
|
||||
lambda v: str(datetime.fromtimestamp(v[0]).date()),
|
||||
fx
|
||||
)
|
||||
)
|
||||
|
||||
self.canvas.axes.set_xticks(ticks=xx, labels=xt, rotation=45)
|
||||
self.set_ticks_time_formater()
|
||||
|
||||
@timer
|
||||
def draw(self):
|
||||
self.canvas.axes.cla()
|
||||
self.canvas.axes.grid(color='grey', linestyle='--', linewidth=0.5)
|
||||
self.init_axes()
|
||||
|
||||
if len(self.data) == 0:
|
||||
self._init = False
|
||||
return
|
||||
|
||||
self.draw_data()
|
||||
self.custom_ticks()
|
||||
|
||||
self.idle()
|
||||
self._init = True
|
||||
|
||||
def draw_data(self):
|
||||
# Plot data
|
||||
x = list(map(lambda v: v[0], self.data.data))
|
||||
y = list(map(lambda v: v[1], self.data.data))
|
||||
|
||||
self._line, = self.canvas.axes.plot(
|
||||
x, y,
|
||||
color='r', lw=1.,
|
||||
markersize=5, marker='+',
|
||||
picker=30,
|
||||
color=self.color_plot,
|
||||
**self.plot_default_kargs
|
||||
)
|
||||
|
||||
self.custom_ticks()
|
||||
|
||||
# Plot label
|
||||
header = self.data.header
|
||||
self.canvas.axes.set_xlabel(
|
||||
self._table_headers[header[0]], color='black', fontsize=10
|
||||
)
|
||||
self.canvas.axes.set_ylabel(
|
||||
self._table_headers[header[1]], color='black', fontsize=10
|
||||
)
|
||||
|
||||
self.canvas.axes.autoscale_view(True, True, True)
|
||||
self.canvas.figure.tight_layout()
|
||||
self.canvas.figure.canvas.draw_idle()
|
||||
# self.toolbar.update()
|
||||
|
||||
self._init = True
|
||||
|
||||
@timer
|
||||
def update(self, ind=None):
|
||||
if not self._init:
|
||||
self.draw()
|
||||
return
|
||||
|
||||
self.update_data()
|
||||
|
||||
self.update_idle()
|
||||
|
||||
def update_data(self):
|
||||
x = list(map(lambda v: v[0], self.data.data))
|
||||
y = list(map(lambda v: v[1], self.data.data))
|
||||
|
||||
self._line.set_data(x, y)
|
||||
|
||||
self.custom_ticks()
|
||||
|
||||
self.canvas.axes.relim()
|
||||
self.canvas.axes.autoscale()
|
||||
self.canvas.figure.tight_layout()
|
||||
self.canvas.figure.canvas.draw_idle()
|
||||
@@ -1,5 +1,5 @@
|
||||
# Table.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
@@ -21,7 +21,11 @@ import traceback
|
||||
|
||||
from datetime import date, time, datetime, timedelta
|
||||
|
||||
from tools import trace, timer
|
||||
from tools import (
|
||||
trace, timer,
|
||||
timestamp_to_old_pamhyr_date,
|
||||
old_pamhyr_date_to_timestamp
|
||||
)
|
||||
|
||||
from View.Tools.PamhyrTable import PamhyrTableModel
|
||||
|
||||
@@ -70,9 +74,7 @@ class TableModel(PamhyrTableModel):
|
||||
value = f"{v:.4f}"
|
||||
elif self._data.header[column] == "time":
|
||||
if self._opt_data == "time":
|
||||
t0 = datetime.fromtimestamp(0)
|
||||
t = datetime.fromtimestamp(v)
|
||||
value = str(t - t0)
|
||||
value = timestamp_to_old_pamhyr_date(int(v))
|
||||
else:
|
||||
value = str(datetime.fromtimestamp(v))
|
||||
else:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# UndoCommand.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Window.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
@@ -105,12 +105,11 @@ class EditBoundaryConditionWindow(PamhyrWindow):
|
||||
trad = BCETranslate()
|
||||
self._long_types = trad.get_dict("long_types")
|
||||
|
||||
name = self._pamhyr_name
|
||||
name = trad[self._pamhyr_name]
|
||||
if self._data is not None:
|
||||
node_name = (self._data.node.name if self._data.node is not None
|
||||
else _translate("BoundaryCondition", "Not associate"))
|
||||
name = (
|
||||
_translate("Edit boundary condition", self._pamhyr_name) +
|
||||
name += (
|
||||
f" - {study.name} " +
|
||||
f" - {self._data.name} ({self._data.id}) " +
|
||||
f"({self._long_types[self._data.bctype]} - {node_name})"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# translate.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
@@ -29,6 +29,10 @@ class BCETranslate(BCTranslate):
|
||||
def __init__(self):
|
||||
super(BCETranslate, self).__init__()
|
||||
|
||||
self._dict["Edit Boundary Conditions"] = _translate(
|
||||
"BoundaryCondition", "Edit boundary conditions"
|
||||
)
|
||||
|
||||
self._sub_dict["table_headers"] = {
|
||||
"x": _translate("BoundaryCondition", "X"),
|
||||
"y": _translate("BoundaryCondition", "Y"),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Table.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# UndoCommand.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Window.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
@@ -68,13 +68,17 @@ class BoundaryConditionWindow(PamhyrWindow):
|
||||
_pamhyr_name = "Boundary conditions"
|
||||
|
||||
def __init__(self, study=None, config=None, parent=None):
|
||||
name = self._pamhyr_name + " - " + study.name
|
||||
trad = BCTranslate()
|
||||
name = (
|
||||
trad[self._pamhyr_name] +
|
||||
" - " + study.name
|
||||
)
|
||||
|
||||
super(BoundaryConditionWindow, self).__init__(
|
||||
title=name,
|
||||
study=study,
|
||||
config=config,
|
||||
trad=BCTranslate(),
|
||||
trad=trad,
|
||||
parent=parent
|
||||
)
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# translate.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
@@ -42,6 +42,10 @@ class BCTranslate(PamhyrTranslate):
|
||||
def __init__(self):
|
||||
super(BCTranslate, self).__init__()
|
||||
|
||||
self._dict["Boundary conditions"] = _translate(
|
||||
"BoundaryConditions", "Boundary conditions"
|
||||
)
|
||||
|
||||
self._sub_dict["long_types"] = {
|
||||
"ND": _translate("BoundaryCondition", "Not defined"),
|
||||
"PC": _translate("BoundaryCondition", "Ponctual contribution"),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Table.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Translate.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
@@ -27,6 +27,10 @@ class CheckListTranslate(PamhyrTranslate):
|
||||
def __init__(self):
|
||||
super(CheckListTranslate, self).__init__()
|
||||
|
||||
self._dict["Check list"] = _translate(
|
||||
"Checklist", "Check list"
|
||||
)
|
||||
|
||||
self._sub_dict["table_headers"] = {
|
||||
"name": _translate("CheckList", "Name"),
|
||||
"status": _translate("CheckList", "Status"),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Window.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
@@ -54,16 +54,18 @@ class CheckListWindow(PamhyrWindow):
|
||||
def __init__(self, autorun: bool = True,
|
||||
study=None, config=None,
|
||||
solver=None, parent=None):
|
||||
trad = CheckListTranslate()
|
||||
|
||||
self._autorun = autorun
|
||||
self._solver = solver
|
||||
|
||||
name = self._pamhyr_name + " - " + study.name
|
||||
name = trad[self._pamhyr_name] + " - " + study.name
|
||||
|
||||
super(CheckListWindow, self).__init__(
|
||||
title=name,
|
||||
study=study,
|
||||
config=config,
|
||||
trad=CheckListTranslate(),
|
||||
trad=trad,
|
||||
options=[],
|
||||
parent=parent
|
||||
)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Worker.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Window.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
@@ -20,6 +20,8 @@ from View.Tools.PamhyrWindow import PamhyrDialog
|
||||
from Solver.Solvers import solver_type_list
|
||||
from Solver.GenericSolver import GenericSolver
|
||||
|
||||
from View.Configure.Translate import ConfigureTranslate
|
||||
|
||||
from PyQt5.QtWidgets import (
|
||||
QPushButton,
|
||||
)
|
||||
@@ -30,15 +32,19 @@ class ConfigureSolverWindow(PamhyrDialog):
|
||||
_pamhyr_name = "Add/Edit Solver"
|
||||
|
||||
def __init__(self, data=None, config=None, parent=None):
|
||||
trad = ConfigureTranslate()
|
||||
|
||||
if data is not None:
|
||||
name = f"Edit Solver - {data.name}"
|
||||
name = trad["edit_solver"]
|
||||
name += f" - {data.name}"
|
||||
else:
|
||||
name = "Add a new Solver"
|
||||
name = trad["add_solver"]
|
||||
|
||||
super(ConfigureSolverWindow, self).__init__(
|
||||
title=name,
|
||||
config=config,
|
||||
options=[],
|
||||
trad=trad,
|
||||
parent=parent
|
||||
)
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Translate.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
@@ -27,8 +27,20 @@ class ConfigureTranslate(PamhyrTranslate):
|
||||
def __init__(self):
|
||||
super(ConfigureTranslate, self).__init__()
|
||||
|
||||
self._dict["Configure"] = _translate(
|
||||
"Configure", "Configure"
|
||||
)
|
||||
|
||||
self._sub_dict["table_headers"] = {
|
||||
"name": _translate("Configure", "Name"),
|
||||
"type": _translate("Configure", "Type"),
|
||||
"description": _translate("Configure", "Description"),
|
||||
}
|
||||
|
||||
# Solvers
|
||||
self._dict["edit_solver"] = _translate(
|
||||
"Configure", "Edit solver"
|
||||
)
|
||||
self._dict["add_solver"] = _translate(
|
||||
"Configure", "Add a new solver"
|
||||
)
|
||||
@@ -1,5 +1,5 @@
|
||||
# Window.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
@@ -83,10 +83,12 @@ class ConfigureWindow(PamhyrDialog):
|
||||
if config is None:
|
||||
config = Config()
|
||||
|
||||
trad = ConfigureTranslate()
|
||||
|
||||
super(ConfigureWindow, self).__init__(
|
||||
title=self._pamhyr_name,
|
||||
title=trad[self._pamhyr_name],
|
||||
config=config,
|
||||
trad=ConfigureTranslate(),
|
||||
trad=trad,
|
||||
options=[],
|
||||
parent=parent
|
||||
)
|
||||
@@ -119,15 +121,6 @@ class ConfigureWindow(PamhyrDialog):
|
||||
)
|
||||
|
||||
def setup_data(self):
|
||||
# # Meshing_Tool
|
||||
# self.set_line_edit_text("lineEdit_meshing_tool",
|
||||
# self._config.meshing_tool)
|
||||
|
||||
# Const
|
||||
self.set_line_edit_text("lineEdit_segment", str(self._config.segment))
|
||||
self.set_line_edit_text("lineEdit_max_listing",
|
||||
str(self._config.max_listing))
|
||||
|
||||
# Backup
|
||||
self.set_check_box("checkBox_backup", self._config.backup_enable)
|
||||
self.set_line_edit_text("lineEdit_backup_path",
|
||||
@@ -168,12 +161,6 @@ class ConfigureWindow(PamhyrDialog):
|
||||
"lineEdit_backup_path", f[0]
|
||||
)
|
||||
),
|
||||
# "pushButton_meshing_tool": lambda: self.file_dialog(
|
||||
# select_file=True,
|
||||
# callback=lambda f: self.set_line_edit_text(
|
||||
# "lineEdit_meshing_tool", f[0]
|
||||
# )
|
||||
# ),
|
||||
}
|
||||
|
||||
for button in buttons:
|
||||
@@ -183,15 +170,6 @@ class ConfigureWindow(PamhyrDialog):
|
||||
# Solvers
|
||||
self._config.solvers = self.solver_table_model._data.copy()
|
||||
|
||||
# # Meshing_Tool
|
||||
# self._config.meshing_tool = self.get_line_edit_text(
|
||||
# "lineEdit_meshing_tool")
|
||||
|
||||
# Const
|
||||
self._config.segment = self.get_line_edit_text("lineEdit_segment")
|
||||
self._config.max_listing = self.get_line_edit_text(
|
||||
"lineEdit_max_listing")
|
||||
|
||||
# Backup
|
||||
self._config.backup_enable = self.get_check_box("checkBox_backup")
|
||||
self._config.backup_path = self.get_line_edit_text(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Window.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
@@ -54,8 +54,10 @@ class ReplWindow(PamhyrWindow):
|
||||
|
||||
def __init__(self, study=None, config=None,
|
||||
solver=None, parent=None):
|
||||
title = _translate("Debug", "Debug REPL")
|
||||
|
||||
super(ReplWindow, self).__init__(
|
||||
title=self._pamhyr_name,
|
||||
title=title,
|
||||
study=study,
|
||||
config=config,
|
||||
options=[],
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Window.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
@@ -21,7 +21,7 @@ import sys
|
||||
import logging
|
||||
import subprocess
|
||||
|
||||
from PyQt5.QtCore import QUrl
|
||||
from PyQt5.QtCore import QUrl, QCoreApplication
|
||||
from PyQt5.QtGui import QDesktopServices
|
||||
from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QAction
|
||||
from PyQt5.QtWebEngineWidgets import QWebEngineView, QWebEngineSettings
|
||||
@@ -30,10 +30,12 @@ from View.Tools.PamhyrWindow import PamhyrWindow
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
|
||||
class DocWindow(PamhyrWindow):
|
||||
_pamhyr_ui = "WebView"
|
||||
_pamhyr_name = "Doc"
|
||||
_pamhyr_name = "Documentation"
|
||||
|
||||
@classmethod
|
||||
def _path_file(cls, filename):
|
||||
@@ -55,8 +57,11 @@ class DocWindow(PamhyrWindow):
|
||||
def __init__(self, filename=None,
|
||||
study=None, config=None,
|
||||
parent=None):
|
||||
title = _translate("Documentation", "Documentation")
|
||||
title += f" - {filename}"
|
||||
|
||||
super(DocWindow, self).__init__(
|
||||
title=self._pamhyr_name,
|
||||
title=title,
|
||||
study=study,
|
||||
config=config,
|
||||
options=[],
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# DummyWindow.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# PlotStricklers.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
@@ -31,7 +31,66 @@ _translate = QCoreApplication.translate
|
||||
|
||||
|
||||
class PlotStricklers(PamhyrPlot):
|
||||
def draw_frictions(self, frictions, color="r"):
|
||||
def __init__(self, data=None, canvas=None, trad=None,
|
||||
toolbar=None, parent=None):
|
||||
super(PlotStricklers, self).__init__(
|
||||
canvas=canvas,
|
||||
trad=trad,
|
||||
data=data,
|
||||
toolbar=toolbar,
|
||||
parent=parent
|
||||
)
|
||||
|
||||
self.label_x = self._trad["kp"]
|
||||
self.label_y = self._trad["stricklers"]
|
||||
|
||||
self.line_kp_elevation = [None, None]
|
||||
|
||||
self._isometric_axis = False
|
||||
|
||||
self._auto_relim = False
|
||||
self._auto_relim_update = False
|
||||
self._autoscale_update = True
|
||||
|
||||
@timer
|
||||
def draw(self, highlight=None):
|
||||
self.init_axes()
|
||||
|
||||
if self.data is None:
|
||||
return
|
||||
|
||||
self.draw_data()
|
||||
|
||||
self.idle()
|
||||
self._init = True
|
||||
|
||||
def draw_data(self):
|
||||
kp = self.data.reach.get_kp()
|
||||
self.canvas.axes.set_xlim(
|
||||
left=min(kp), right=max(kp)
|
||||
)
|
||||
|
||||
frictions = self.data.frictions
|
||||
if len(frictions) != 0:
|
||||
lst = frictions.frictions
|
||||
self.draw_frictions(lst, self.color_plot)
|
||||
|
||||
# HightLight
|
||||
kp_min, kp_max = (-1, -1)
|
||||
if self._highlight_data is not None:
|
||||
kp_min, kp_max = self._highlight_data
|
||||
|
||||
lst = list(
|
||||
filter(
|
||||
lambda s: (s.begin_kp == kp_min and
|
||||
s.end_kp == kp_max),
|
||||
frictions.frictions
|
||||
)
|
||||
)
|
||||
|
||||
self.draw_frictions(lst, self.color_plot_highlight)
|
||||
|
||||
def draw_frictions(self, frictions, color):
|
||||
lst = sorted(
|
||||
filter(
|
||||
lambda f: f.is_full_defined(),
|
||||
@@ -57,66 +116,16 @@ class PlotStricklers(PamhyrPlot):
|
||||
coef_minor = list(map(lambda s: s.minor, coef))
|
||||
coef_medium = list(map(lambda s: s.medium, coef))
|
||||
|
||||
self.line_kp_elevation = self.canvas.axes.plot(
|
||||
self.line_kp_elevation[0] = self.canvas.axes.plot(
|
||||
kp, coef_minor,
|
||||
color=color, lw=1.
|
||||
)
|
||||
|
||||
self.line_kp_elevation = self.canvas.axes.plot(
|
||||
self.line_kp_elevation[1] = self.canvas.axes.plot(
|
||||
kp, coef_medium,
|
||||
color=color, lw=1.
|
||||
)
|
||||
|
||||
@timer
|
||||
def draw(self, highlight=None):
|
||||
self.canvas.axes.cla()
|
||||
self.canvas.axes.grid(color='grey', linestyle='--', linewidth=0.5)
|
||||
|
||||
if self.data is None:
|
||||
return
|
||||
|
||||
self.canvas.axes.set_ylabel(
|
||||
_translate("MainWindow_reach", "Stricklers"),
|
||||
color='black', fontsize=11
|
||||
)
|
||||
self.canvas.axes.set_xlabel(
|
||||
_translate("MainWindow_reach", "Kp (m)"),
|
||||
color='black', fontsize=11
|
||||
)
|
||||
|
||||
kp = self.data.reach.get_kp()
|
||||
self.canvas.axes.set_xlim(
|
||||
left=min(kp), right=max(kp)
|
||||
)
|
||||
|
||||
frictions = self.data.frictions
|
||||
if len(frictions) != 0:
|
||||
lst = frictions.frictions
|
||||
self.draw_frictions(lst)
|
||||
|
||||
# HightLight
|
||||
kp_min, kp_max = (-1, -1)
|
||||
if highlight is not None:
|
||||
kp_min, kp_max = highlight
|
||||
|
||||
lst = list(
|
||||
filter(
|
||||
lambda s: (s.begin_kp == kp_min and
|
||||
s.end_kp == kp_max),
|
||||
frictions.frictions
|
||||
)
|
||||
)
|
||||
self.draw_frictions(lst, color="b")
|
||||
|
||||
self.canvas.figure.tight_layout()
|
||||
self.canvas.figure.canvas.draw_idle()
|
||||
if self.toolbar is not None:
|
||||
self.toolbar.update()
|
||||
|
||||
# self._init = True
|
||||
|
||||
@timer
|
||||
def update(self, ind=None):
|
||||
if not self._init:
|
||||
self.draw()
|
||||
return
|
||||
def update(self):
|
||||
self.draw()
|
||||
@@ -1,5 +1,5 @@
|
||||
# Table.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# UndoCommand.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Window.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
@@ -62,6 +62,8 @@ class FrictionsWindow(PamhyrWindow):
|
||||
_pamhyr_name = "Edit frictions"
|
||||
|
||||
def __init__(self, reach=None, study=None, config=None, parent=None):
|
||||
trad = FrictionsTranslate()
|
||||
|
||||
if reach is not None:
|
||||
self._reach = reach
|
||||
else:
|
||||
@@ -70,7 +72,7 @@ class FrictionsWindow(PamhyrWindow):
|
||||
self._frictions = self._reach.frictions
|
||||
|
||||
name = (
|
||||
self._pamhyr_name + " - "
|
||||
trad[self._pamhyr_name] + " - "
|
||||
+ study.name + " - "
|
||||
+ self._reach.name
|
||||
)
|
||||
@@ -79,7 +81,7 @@ class FrictionsWindow(PamhyrWindow):
|
||||
title=name,
|
||||
study=study,
|
||||
config=config,
|
||||
trad=FrictionsTranslate(),
|
||||
trad=trad,
|
||||
parent=parent
|
||||
)
|
||||
|
||||
@@ -130,8 +132,8 @@ class FrictionsWindow(PamhyrWindow):
|
||||
self.plot = PlotKPZ(
|
||||
canvas=self.canvas,
|
||||
data=self._reach.reach,
|
||||
trad=self._trad,
|
||||
toolbar=None,
|
||||
display_current=False
|
||||
)
|
||||
self.plot.draw()
|
||||
|
||||
@@ -143,6 +145,7 @@ class FrictionsWindow(PamhyrWindow):
|
||||
self.plot_2 = PlotStricklers(
|
||||
canvas=self.canvas_2,
|
||||
data=self._reach,
|
||||
trad=self._trad,
|
||||
toolbar=None
|
||||
)
|
||||
self.plot_2.draw()
|
||||
@@ -157,10 +160,10 @@ class FrictionsWindow(PamhyrWindow):
|
||||
table = self.find(QTableView, f"tableView")
|
||||
table.selectionModel()\
|
||||
.selectionChanged\
|
||||
.connect(self._set_current_reach)
|
||||
.connect(self.update)
|
||||
|
||||
self._table.dataChanged\
|
||||
.connect(self._set_current_reach)
|
||||
.connect(self.update)
|
||||
|
||||
def index_selected_rows(self):
|
||||
table = self.find(QTableView, f"tableView")
|
||||
@@ -174,6 +177,16 @@ class FrictionsWindow(PamhyrWindow):
|
||||
)
|
||||
)
|
||||
|
||||
def update(self):
|
||||
self._set_current_reach()
|
||||
# self._propagate_update(key="friction")
|
||||
|
||||
def _propagated_update(self, key=None):
|
||||
if key != "geometry":
|
||||
return
|
||||
|
||||
self.update_plot()
|
||||
|
||||
def _set_current_reach(self):
|
||||
rows = self.index_selected_rows()
|
||||
|
||||
@@ -187,20 +200,16 @@ class FrictionsWindow(PamhyrWindow):
|
||||
sec = self._frictions.get(rows[0])
|
||||
highlight = (sec.begin_kp, sec.end_kp)
|
||||
|
||||
self.plot = PlotKPZ(
|
||||
canvas=self.canvas,
|
||||
data=reach,
|
||||
toolbar=None,
|
||||
display_current=False
|
||||
)
|
||||
self.plot.draw(highlight=highlight)
|
||||
self.update_plot(highlight)
|
||||
|
||||
self.plot = PlotStricklers(
|
||||
canvas=self.canvas_2,
|
||||
data=data,
|
||||
toolbar=None
|
||||
)
|
||||
self.plot.draw(highlight=highlight)
|
||||
def update_plot(self, highlight=None):
|
||||
if highlight is not None:
|
||||
self.plot.highlight = highlight
|
||||
self.plot.draw()
|
||||
|
||||
if highlight is not None:
|
||||
self.plot_2.highlight = highlight
|
||||
self.plot_2.draw()
|
||||
|
||||
def add(self):
|
||||
rows = self.index_selected_rows()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# translate.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
@@ -27,6 +27,17 @@ class FrictionsTranslate(PamhyrTranslate):
|
||||
def __init__(self):
|
||||
super(FrictionsTranslate, self).__init__()
|
||||
|
||||
self._dict["kp"] = _translate(
|
||||
"Frictions", "Kp (m)"
|
||||
)
|
||||
self._dict["stricklers"] = _translate(
|
||||
"Frictions", "Stricklers"
|
||||
)
|
||||
|
||||
self._dict["Edit frictions"] = _translate(
|
||||
"Frictions", "Edit frictions"
|
||||
)
|
||||
|
||||
self._sub_dict["table_headers"] = {
|
||||
# "name": _translate("Frictions", "Name"),
|
||||
# "edge": _translate("Frictions", "Reach"),
|
||||
|
||||
@@ -0,0 +1,183 @@
|
||||
# MeshingDialog.py -- Pamhyr
|
||||
# Copyright (C) 2023-2024 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 View.Tools.PamhyrWindow import PamhyrDialog
|
||||
|
||||
from PyQt5.QtGui import (
|
||||
QKeySequence,
|
||||
)
|
||||
|
||||
from PyQt5.QtCore import (
|
||||
Qt, QVariant, QAbstractTableModel,
|
||||
)
|
||||
|
||||
from PyQt5.QtWidgets import (
|
||||
QDialogButtonBox, QComboBox, QUndoStack, QShortcut,
|
||||
QDoubleSpinBox,
|
||||
)
|
||||
|
||||
|
||||
class MeshingDialog(PamhyrDialog):
|
||||
_pamhyr_ui = "MeshingOptions"
|
||||
_pamhyr_name = "Meshing"
|
||||
|
||||
def __init__(self, reach, trad=None, parent=None):
|
||||
super(MeshingDialog, self).__init__(
|
||||
title=trad[self._pamhyr_name],
|
||||
trad=trad,
|
||||
options=[],
|
||||
parent=parent
|
||||
)
|
||||
|
||||
self._reach = reach
|
||||
self._profiles = None
|
||||
|
||||
self._init_default_values()
|
||||
|
||||
def _init_default_values(self):
|
||||
self._space_step = 50.0
|
||||
self._lplan = False
|
||||
self._lm = "3"
|
||||
self._linear = False
|
||||
self._begin_cs = -1
|
||||
self._end_cs = -1
|
||||
self._begin_dir = "un"
|
||||
self._end_dir = "np"
|
||||
|
||||
self._init_default_values_profiles()
|
||||
self._init_default_values_guidelines()
|
||||
|
||||
self.set_double_spin_box(
|
||||
"doubleSpinBox_space_step",
|
||||
self._space_step
|
||||
)
|
||||
|
||||
lm_dict = self._trad.get_dict("lm_dict")
|
||||
self.combobox_add_items(
|
||||
"comboBox_lm", list(
|
||||
map(
|
||||
lambda x: lm_dict[x],
|
||||
["1", "2", "3"]
|
||||
)
|
||||
)
|
||||
)
|
||||
self.set_combobox_text("comboBox_lm", self._lm)
|
||||
|
||||
if self._linear:
|
||||
self.set_radio_button("radioButton_linear", True)
|
||||
else:
|
||||
self.set_radio_button("radioButton_spline", True)
|
||||
|
||||
def _init_default_values_profiles(self):
|
||||
profiles = self.profiles
|
||||
|
||||
self.combobox_add_items("comboBox_begin_kp", profiles)
|
||||
self.combobox_add_items("comboBox_end_kp", profiles)
|
||||
|
||||
self.set_combobox_text("comboBox_begin_kp", profiles[0])
|
||||
self.set_combobox_text("comboBox_end_kp", profiles[-1])
|
||||
|
||||
@property
|
||||
def profiles(self):
|
||||
if self._profiles is None:
|
||||
self._profiles = list(
|
||||
map(
|
||||
lambda p: self._profile_name(p),
|
||||
self._reach.profiles
|
||||
)
|
||||
)
|
||||
|
||||
return self._profiles
|
||||
|
||||
def _profile_name(self, profile):
|
||||
name = profile.name
|
||||
|
||||
if name == "":
|
||||
name = f"{profile.kp}"
|
||||
else:
|
||||
name += f" ({profile.kp})"
|
||||
|
||||
return name
|
||||
|
||||
def _init_default_values_guidelines(self):
|
||||
gl, _ = self._reach.compute_guidelines()
|
||||
gl = list(gl)
|
||||
|
||||
bgl = ['un'] + gl
|
||||
egl = gl + ['np']
|
||||
|
||||
self.combobox_add_items("comboBox_begin_gl", bgl)
|
||||
self.combobox_add_items("comboBox_end_gl", egl)
|
||||
|
||||
self.set_combobox_text("comboBox_begin_gl", self._begin_dir)
|
||||
self.set_combobox_text("comboBox_end_gl", self._end_dir)
|
||||
|
||||
@property
|
||||
def space_step(self):
|
||||
return self._space_step
|
||||
|
||||
@property
|
||||
def lplan(self):
|
||||
return self._lplan
|
||||
|
||||
@property
|
||||
def lm(self):
|
||||
return int(self._lm)
|
||||
|
||||
@property
|
||||
def linear(self):
|
||||
return self._linear
|
||||
|
||||
@property
|
||||
def begin_cs(self):
|
||||
return self._begin_cs + 1
|
||||
|
||||
@property
|
||||
def end_cs(self):
|
||||
return self._end_cs + 1
|
||||
|
||||
@property
|
||||
def begin_dir(self):
|
||||
return self._begin_dir
|
||||
|
||||
@property
|
||||
def end_dir(self):
|
||||
return self._end_dir
|
||||
|
||||
def accept(self):
|
||||
self._space_step = self.get_double_spin_box(
|
||||
"doubleSpinBox_space_step",
|
||||
)
|
||||
self._linear = self.get_radio_button("radioButton_linear")
|
||||
|
||||
p1 = self.get_combobox_text("comboBox_begin_kp")
|
||||
p2 = self.get_combobox_text("comboBox_end_kp")
|
||||
|
||||
self._begin_cs = self.profiles.index(p1)
|
||||
self._end_cs = self.profiles.index(p2)
|
||||
|
||||
self._begin_dir = self.get_combobox_text("comboBox_begin_gl")
|
||||
self._end_dir = self.get_combobox_text("comboBox_end_gl")
|
||||
|
||||
r_lm_dict = self._trad.get_dict("r_lm_dict")
|
||||
self._lm = r_lm_dict[self.get_combobox_text("comboBox_lm")]
|
||||
|
||||
super().accept()
|
||||
|
||||
def reject(self):
|
||||
self.close()
|
||||
+115
-274
@@ -1,5 +1,5 @@
|
||||
# PlotAC.py -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2023-2024 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
|
||||
@@ -32,7 +32,7 @@ logger = logging.getLogger()
|
||||
|
||||
class PlotAC(PamhyrPlot):
|
||||
def __init__(self, canvas=None, trad=None, data=None, toolbar=None,
|
||||
plot_xy=None, parent=None):
|
||||
parent=None):
|
||||
super(PlotAC, self).__init__(
|
||||
canvas=canvas,
|
||||
trad=trad,
|
||||
@@ -41,24 +41,33 @@ class PlotAC(PamhyrPlot):
|
||||
parent=parent
|
||||
)
|
||||
|
||||
self.plot_xy = plot_xy
|
||||
self._isometric_axis = False
|
||||
|
||||
self.before_plot_selected = None
|
||||
self._auto_relim_update = True
|
||||
self._autoscale_update = True
|
||||
|
||||
self.label_x = _translate(
|
||||
"Geometry", "Transverse abscissa (m)"
|
||||
)
|
||||
self.label_y = _translate("Geometry", "Height (m)")
|
||||
|
||||
self.label_previous_plot_selected = _translate(
|
||||
"Geometry", "Previous cross-section"
|
||||
)
|
||||
self.label_plot_selected = _translate(
|
||||
"Geometry", "Cross-section"
|
||||
)
|
||||
self.label_next_plot_selected = _translate(
|
||||
"Geometry", "Next cross-section"
|
||||
)
|
||||
|
||||
self.previous_plot_selected = None
|
||||
self.plot_selected = None
|
||||
self.after_plot_selected = None
|
||||
|
||||
def get_line_gl_colors(self, line_2d):
|
||||
colors = []
|
||||
|
||||
for line in line_2d:
|
||||
colors.append(line[0].get_color())
|
||||
|
||||
return colors
|
||||
self.next_plot_selected = None
|
||||
|
||||
@timer
|
||||
def draw(self):
|
||||
self.canvas.axes.cla()
|
||||
self.canvas.axes.grid(color='grey', linestyle='--', linewidth=0.5)
|
||||
self.init_axes()
|
||||
|
||||
if self.data.number_profiles == 0:
|
||||
return
|
||||
@@ -67,311 +76,143 @@ class PlotAC(PamhyrPlot):
|
||||
if np < 2:
|
||||
return
|
||||
|
||||
selected_profile = 0
|
||||
|
||||
station = self.data.profile(selected_profile).get_station()
|
||||
elevation = self.data.profile(selected_profile).z()
|
||||
gl = self.data.profile(selected_profile).names()
|
||||
|
||||
station_plus_1 = self.data.profile(selected_profile + 1).get_station()
|
||||
elevation_i_plus_1 = self.data.profile(selected_profile + 1).z()
|
||||
|
||||
self.canvas.axes.set_xlabel(
|
||||
_translate("MainWindow_reach", "Transverse abscissa (m)"),
|
||||
color='black', fontsize=10
|
||||
)
|
||||
self.canvas.axes.set_ylabel(
|
||||
_translate("MainWindow_reach", "Height (m)"),
|
||||
color='black', fontsize=10
|
||||
)
|
||||
self.canvas.figure.tight_layout()
|
||||
|
||||
label_before_plot_selected = _translate(
|
||||
"MainWindow_reach", "Previous cross-section")
|
||||
label_plot_selected = _translate("MainWindow_reach", "Cross-section")
|
||||
label_after_plot_selected = _translate(
|
||||
"MainWindow_reach", "Next cross-section")
|
||||
color_before_plot_selected = "k" # 'grey'
|
||||
color_plot_selected = 'b'
|
||||
color_after_plot_selected = 'm'
|
||||
|
||||
self.before_plot_selected, = self.canvas.axes.plot(
|
||||
[], [], label=label_before_plot_selected, lw=1.8,
|
||||
linestyle='--', color=color_before_plot_selected
|
||||
)
|
||||
self.plot_selected, = self.canvas.axes.plot(
|
||||
station, elevation, label=label_plot_selected,
|
||||
color=color_plot_selected, lw=1.8
|
||||
)
|
||||
|
||||
self.after_plot_selected, = self.canvas.axes.plot(
|
||||
station_plus_1, elevation_i_plus_1,
|
||||
label=label_after_plot_selected,
|
||||
color=color_after_plot_selected, lw=1.6, linestyle='--'
|
||||
)
|
||||
self.annotation = []
|
||||
self.complete_gl, self.incomplete_gl = self.data.compute_guidelines()
|
||||
lcomplete = list(self.complete_gl)
|
||||
lincomplete = list(self.incomplete_gl)
|
||||
|
||||
line_2d = self.plot_xy.line_gl
|
||||
self.color_complete_gl = self.get_line_gl_colors(line_2d)
|
||||
self.color_incomplete_gl = 2 * ["#000000"]
|
||||
|
||||
x_gl_complete = []
|
||||
y_gl_complete = []
|
||||
color_scat_complete_gl = []
|
||||
x_gl_incomplete = []
|
||||
y_gl_incomplete = []
|
||||
color_scat_incomplete_gl = []
|
||||
|
||||
for i, txt in enumerate(gl):
|
||||
if txt.strip() in self.complete_gl:
|
||||
annotation = self.canvas.axes.annotate(
|
||||
txt, (station[i], elevation[i]),
|
||||
horizontalalignment='left',
|
||||
verticalalignment='top', annotation_clip=True,
|
||||
fontsize=11,
|
||||
color=self.color_complete_gl[
|
||||
lcomplete.index(txt)
|
||||
]
|
||||
)
|
||||
|
||||
annotation.set_position((station[i] + 0., elevation[i] + 0.))
|
||||
self.annotation.append(annotation)
|
||||
|
||||
x_gl_complete.append(station[i])
|
||||
y_gl_complete.append(elevation[i])
|
||||
color_scat_complete_gl.append(
|
||||
self.color_complete_gl[lcomplete.index(txt)])
|
||||
elif txt.strip() in self.incomplete_gl:
|
||||
annotate = self.canvas.axes.annotate(
|
||||
txt, (station[i], elevation[i]
|
||||
), horizontalalignment='left',
|
||||
verticalalignment='top', annotation_clip=True, fontsize=11,
|
||||
color=self.color_incomplete_gl[
|
||||
lincomplete.index(txt)
|
||||
],
|
||||
)
|
||||
|
||||
self.annotation.append(annotate)
|
||||
|
||||
x_gl_incomplete.append(station[i])
|
||||
y_gl_incomplete.append(elevation[i])
|
||||
color_scat_incomplete_gl.append(
|
||||
self.color_incomplete_gl[lincomplete.index(txt)]
|
||||
)
|
||||
self.draw_current()
|
||||
self.draw_gl()
|
||||
|
||||
self.canvas.axes.legend(fancybox=True, shadow=True, fontsize=8)
|
||||
self.canvas.figure.tight_layout()
|
||||
|
||||
self.canvas.figure.canvas.draw_idle()
|
||||
self.toolbar.update()
|
||||
|
||||
self.idle()
|
||||
self._init = True
|
||||
|
||||
def update_full(self):
|
||||
selected_profile = 0
|
||||
station = self.data.profile(selected_profile).get_station()
|
||||
station_plus_1 = self.data.profile(selected_profile + 1).get_station()
|
||||
elevation = self.data.profile(selected_profile).z()
|
||||
elevation_i_plus_1 = self.data.profile(selected_profile + 1).z()
|
||||
gl = self.data.profile(selected_profile).names()
|
||||
def draw_current(self):
|
||||
profile_id = 0
|
||||
profile = self.data.profile(profile_id)
|
||||
station = profile.get_station()
|
||||
elevation = profile.z()
|
||||
gl = profile.names()
|
||||
|
||||
self.canvas.axes.cla()
|
||||
self.canvas.axes.grid(color='grey', linestyle='--', linewidth=0.5)
|
||||
self.canvas.axes.set_xlabel(
|
||||
_translate("MainWindow_reach", "Transverse abscissa (m)"),
|
||||
color='black', fontsize=10
|
||||
self.previous_plot_selected, = self.canvas.axes.plot(
|
||||
[], [],
|
||||
label=self.label_previous_plot_selected,
|
||||
lw=1.5, linestyle='--', color=self.color_plot_previous
|
||||
)
|
||||
self.canvas.axes.set_ylabel(
|
||||
_translate("MainWindow_reach", "Height (m)"),
|
||||
color='black', fontsize=10
|
||||
)
|
||||
self.canvas.figure.tight_layout()
|
||||
|
||||
label_before_plot_selected = _translate(
|
||||
"MainWindow_reach", "Previous cross-section")
|
||||
label_plot_selected = _translate(
|
||||
"MainWindow_reach", "Cross-section")
|
||||
label_after_plot_selected = _translate(
|
||||
"MainWindow_reach", "Next cross-section")
|
||||
color_before_plot_selected = "k" # 'grey'
|
||||
color_plot_selected = 'b'
|
||||
color_after_plot_selected = 'm'
|
||||
|
||||
self.before_plot_selected, = self.canvas.axes.plot(
|
||||
[], [], label=label_before_plot_selected, lw=1.8,
|
||||
linestyle='--', color=color_before_plot_selected
|
||||
)
|
||||
self.plot_selected, = self.canvas.axes.plot(
|
||||
station, elevation, label=label_plot_selected,
|
||||
color=color_plot_selected, lw=1.8
|
||||
station, elevation,
|
||||
label=self.label_plot_selected,
|
||||
color=self.color_plot_current, lw=1.5
|
||||
)
|
||||
|
||||
self.after_plot_selected, = self.canvas.axes.plot(
|
||||
station_plus_1, elevation_i_plus_1,
|
||||
label=label_after_plot_selected,
|
||||
color=color_after_plot_selected, lw=1.6, linestyle='--'
|
||||
next_id = profile_id + 1
|
||||
station_next = self.data.profile(next_id).get_station()
|
||||
elevation_next = self.data.profile(next_id).z()
|
||||
|
||||
self.next_plot_selected, = self.canvas.axes.plot(
|
||||
station_next, elevation_next,
|
||||
label=self.label_next_plot_selected,
|
||||
color=self.color_plot_next, lw=1.6, linestyle='--'
|
||||
)
|
||||
|
||||
def draw_gl(self):
|
||||
if self._current_data_update:
|
||||
profile_id = self._current_data
|
||||
else:
|
||||
profile_id = 0
|
||||
|
||||
profile = self.data.profile(profile_id)
|
||||
station = profile.get_station()
|
||||
elevation = profile.z()
|
||||
gl = profile.names()
|
||||
|
||||
self.annotation = []
|
||||
self.complete_gl, self.incomplete_gl = self.data.compute_guidelines()
|
||||
lcomplete = list(self.complete_gl)
|
||||
lincomplete = list(self.incomplete_gl)
|
||||
|
||||
line_2d = self.plot_xy.line_gl
|
||||
self.color_complete_gl = self.get_line_gl_colors(line_2d)
|
||||
self.color_incomplete_gl = 2 * ["#000000"]
|
||||
self.color_complete_gl = self.colors
|
||||
self.color_incomplete_gl = 2 * ["grey"]
|
||||
|
||||
x_gl_complete = []
|
||||
y_gl_complete = []
|
||||
color_scat_complete_gl = []
|
||||
x_gl_incomplete = []
|
||||
y_gl_incomplete = []
|
||||
color_scat_incomplete_gl = []
|
||||
|
||||
for i, txt in enumerate(gl):
|
||||
if txt == "":
|
||||
continue
|
||||
|
||||
if txt.strip() in self.complete_gl:
|
||||
annotation = self.canvas.axes.annotate(
|
||||
txt, (station[i], elevation[i]),
|
||||
horizontalalignment='left',
|
||||
verticalalignment='top', annotation_clip=True,
|
||||
fontsize=11,
|
||||
color=self.color_complete_gl[
|
||||
lcomplete.index(txt)
|
||||
]
|
||||
)
|
||||
color = self.color_complete_gl[
|
||||
lcomplete.index(txt)
|
||||
]
|
||||
else:
|
||||
color = self.color_incomplete_gl[
|
||||
lincomplete.index(txt)
|
||||
]
|
||||
|
||||
annotation.set_position((station[i] + 0., elevation[i] + 0.))
|
||||
self.annotation.append(annotation)
|
||||
annotation = self.canvas.axes.annotate(
|
||||
txt, (station[i], elevation[i]),
|
||||
horizontalalignment='left',
|
||||
verticalalignment='top',
|
||||
annotation_clip=True,
|
||||
fontsize=11, color=color
|
||||
)
|
||||
|
||||
annotation.set_position((station[i] + 0., elevation[i] + 0.))
|
||||
self.annotation.append(annotation)
|
||||
|
||||
if txt.strip() in self.complete_gl:
|
||||
x_gl_complete.append(station[i])
|
||||
y_gl_complete.append(elevation[i])
|
||||
color_scat_complete_gl.append(
|
||||
self.color_complete_gl[lcomplete.index(txt)]
|
||||
)
|
||||
elif txt.strip() in self.incomplete_gl:
|
||||
annotate = self.canvas.axes.annotate(
|
||||
txt,
|
||||
(station[i], elevation[i]),
|
||||
horizontalalignment='left',
|
||||
verticalalignment='top',
|
||||
annotation_clip=True, fontsize=11,
|
||||
color=self.color_incomplete_gl[
|
||||
lincomplete.index(txt)
|
||||
],
|
||||
)
|
||||
|
||||
self.annotation.append(annotate)
|
||||
|
||||
else:
|
||||
x_gl_incomplete.append(station[i])
|
||||
y_gl_incomplete.append(elevation[i])
|
||||
color_scat_incomplete_gl.append(
|
||||
self.color_incomplete_gl[lincomplete.index(txt)]
|
||||
)
|
||||
|
||||
self.canvas.axes.legend(fancybox=True, shadow=True, fontsize=8)
|
||||
self.canvas.figure.tight_layout()
|
||||
|
||||
self.canvas.figure.canvas.draw_idle()
|
||||
self.toolbar.update()
|
||||
|
||||
def update_annotate_full(self, ind):
|
||||
for a in self.annotation:
|
||||
a.remove()
|
||||
|
||||
self.annotation[:] = []
|
||||
|
||||
x = self.data.profile(ind).get_station()
|
||||
y = self.data.profile(ind).z()
|
||||
gl = self.data.profile(ind).names()
|
||||
complete, incomplete = self.data.compute_guidelines()
|
||||
|
||||
lcomplete = list(complete)
|
||||
lincomplete = list(incomplete)
|
||||
|
||||
self.x_complete = []
|
||||
color_scat_complete = []
|
||||
self.x_incomplete = []
|
||||
color_scat_incomplete = []
|
||||
|
||||
try:
|
||||
for i, txt in enumerate(gl):
|
||||
if txt in complete:
|
||||
annotate = self.canvas.axes.annotate(
|
||||
txt, (x[i], y[i]), horizontalalignment='left',
|
||||
verticalalignment='top', annotation_clip=True,
|
||||
fontsize=11,
|
||||
color=self.color_complete_gl[
|
||||
lcomplete.index(txt)
|
||||
],
|
||||
)
|
||||
self.annotation.append(annotate)
|
||||
self.x_complete.append([x[i], y[i]])
|
||||
color_scat_complete.append(
|
||||
self.color_complete_gl[lcomplete.index(txt)]
|
||||
)
|
||||
elif txt in incomplete:
|
||||
annotate = self.canvas.axes.annotate(
|
||||
txt, (x[i], y[i]), horizontalalignment='left',
|
||||
verticalalignment='top', annotation_clip=True,
|
||||
fontsize=11,
|
||||
color=self.color_incomplete_gl[
|
||||
lincomplete.index(txt)
|
||||
],
|
||||
)
|
||||
self.annotation.append(annotate)
|
||||
self.x_incomplete.append([x[i], y[i]])
|
||||
color_scat_incomplete.append(
|
||||
self.color_incomplete_gl[lincomplete.index(txt)]
|
||||
)
|
||||
except Exception as e:
|
||||
logger.warning(f"{e}")
|
||||
|
||||
self.canvas.figure.canvas.draw_idle()
|
||||
|
||||
@timer
|
||||
def update(self, ind=None):
|
||||
def update(self):
|
||||
if not self._init:
|
||||
self.draw()
|
||||
return
|
||||
|
||||
line_2d = self.plot_xy.line_gl
|
||||
self.color_complete_gl = self.get_line_gl_colors(line_2d)
|
||||
self.color_incomplete_gl = 2 * ["#000000"]
|
||||
self.update_current()
|
||||
self.update_gl()
|
||||
|
||||
if ind is not None:
|
||||
before = ind - 1
|
||||
after = ind + 1
|
||||
self.update_idle()
|
||||
|
||||
self.before_plot_selected.set_data([], [])
|
||||
def update_current(self):
|
||||
if self._current_data_update:
|
||||
profile_id = self._current_data
|
||||
previous_id = profile_id - 1
|
||||
next_id = profile_id + 1
|
||||
|
||||
self.previous_plot_selected.set_data([], [])
|
||||
self.plot_selected.set_data([], [])
|
||||
self.after_plot_selected.set_data([], [])
|
||||
self.next_plot_selected.set_data([], [])
|
||||
|
||||
if 0 <= before < self.data.number_profiles:
|
||||
self.before_plot_selected.set_data(
|
||||
self.data.profile(before).get_station(),
|
||||
self.data.profile(before).z()
|
||||
if 0 <= previous_id < self.data.number_profiles:
|
||||
self.previous_plot_selected.set_data(
|
||||
self.data.profile(previous_id).get_station(),
|
||||
self.data.profile(previous_id).z()
|
||||
)
|
||||
|
||||
if 0 <= ind < self.data.number_profiles:
|
||||
if 0 <= profile_id < self.data.number_profiles:
|
||||
self.plot_selected.set_data(
|
||||
self.data.profile(ind).get_station(),
|
||||
self.data.profile(ind).z()
|
||||
self.data.profile(profile_id).get_station(),
|
||||
self.data.profile(profile_id).z()
|
||||
)
|
||||
|
||||
if 0 <= after < self.data.number_profiles:
|
||||
self.after_plot_selected.set_data(
|
||||
self.data.profile(after).get_station(),
|
||||
self.data.profile(after).z()
|
||||
if 0 <= next_id < self.data.number_profiles:
|
||||
self.next_plot_selected.set_data(
|
||||
self.data.profile(next_id).get_station(),
|
||||
self.data.profile(next_id).z()
|
||||
)
|
||||
|
||||
self.update_annotate_full(ind)
|
||||
else:
|
||||
self.update_full()
|
||||
self.update_annotate_full(0)
|
||||
def update_full(self):
|
||||
self.draw()
|
||||
|
||||
self.canvas.axes.relim()
|
||||
self.canvas.axes.autoscale()
|
||||
self.canvas.axes.autoscale_view()
|
||||
self.canvas.figure.canvas.draw_idle()
|
||||
def update_gl(self):
|
||||
for a in self.annotation:
|
||||
a.remove()
|
||||
|
||||
self.annotation[:] = []
|
||||
self.draw_gl()
|
||||
Loaded 100 of 223 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user