Compare commits

..
8 Commits
Author SHA1 Message Date
Theophile Terraz eae1f83a73 remove GL doublons 2023-12-20 14:53:18 +01:00
Theophile Terraz a738bf3679 merge 2023-12-20 14:10:33 +01:00
Theophile Terraz 888002cd10 another purge criterion 2023-10-03 13:13:52 +02:00
Theophile Terraz e1880c6549 work on purge 2023-09-28 17:09:40 +02:00
Theophile Terraz 9f0caaaa69 Merge branch 'master' into mesh 2023-09-27 10:16:02 +02:00
Theophile Terraz fa35d49a42 add purge 2023-07-06 11:33:59 +02:00
Theophile Terraz 4935069864 add a basic st_to_m method 2023-07-05 15:49:30 +02:00
Theophile Terraz 6438d23304 begin interpolation 2023-06-28 15:32:24 +02:00
335 changed files with 5262 additions and 15942 deletions

No files matched your search

-2
View File
@@ -19,8 +19,6 @@ tmp
*.pdf *.pdf
*.odt *.odt
!doc/**/*.pdf
doc/dev/images/auto_* doc/dev/images/auto_*
doc/dev/documentation.* doc/dev/documentation.*
!doc/dev/*.org !doc/dev/*.org
+60 -235
View File
@@ -1,5 +1,5 @@
# .gitlab-ci.yml -- Pamhyr gitlab-ci # .gitlab-ci.yml -- Pamhyr gitlab-ci
# Copyright (C) 2023-2024 INRAE # Copyright (C) 2023 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
@@ -20,68 +20,45 @@ stages:
- test - test
- build - build
- package - package
- hash
- antivirus
- release - release
############# #############
# DOWNLOADS # # DOWNLOADS #
############# #############
variables: dl-mage-linux:
MAGE_8_VERSION: "v8.3.5"
dl-mage8-doc:
stage: downloads stage: downloads
tags: tags:
- linux - linux
rules: rules:
- if: $CI_COMMIT_BRANCH == 'ci-test' || $CI_COMMIT_BRANCH == 'master' || $CI_COMMIT_TAG - if: $CI_COMMIT_BRANCH == 'ci-test' || $CI_COMMIT_BRANCH == 'master' || $CI_COMMIT_TAG
script: script:
- mkdir -p doc - curl -L -o mage.tgz https://gitlab.irstea.fr/jean-baptiste.faure/mage/-/releases/v8.3.0/downloads/packages/mage_linux.tgz
- cd doc - mkdir -p mage-linux
- curl -L -o mage8.pdf https://gitlab.irstea.fr/jean-baptiste.faure/mage/-/releases/$MAGE_8_VERSION/downloads/documents/Mage-8_Documentation.pdf - cd mage-linux
- tar xvf ../mage.tgz
artifacts: artifacts:
paths: paths:
- doc/mage8.pdf - mage-linux/mage
- mage-linux/mage_extraire
- mage-linux/mailleurPF
dl-mage8-linux: dl-mage-windows:
stage: downloads stage: downloads
tags: tags:
- linux - linux
rules: rules:
- if: $CI_COMMIT_BRANCH == 'ci-test' || $CI_COMMIT_BRANCH == 'master' || $CI_COMMIT_TAG - if: $CI_COMMIT_BRANCH == 'ci-test' || $CI_COMMIT_BRANCH == 'master' || $CI_COMMIT_TAG
script: script:
- curl -L -o mage8.tgz https://gitlab.irstea.fr/jean-baptiste.faure/mage/-/releases/$MAGE_8_VERSION/downloads/packages/mage_linux.tgz - curl -L -o mage.tgz https://gitlab.irstea.fr/jean-baptiste.faure/mage/-/releases/v8.3.0/downloads/packages/mage_windows.tgz
- mkdir -p mage8-linux - mkdir -p mage-windows
- cd mage8-linux - cd mage-windows
- tar xvf ../mage8.tgz - tar xvf ../mage.tgz
artifacts: artifacts:
paths: paths:
- mage8-linux/mage - mage-windows/mage.exe
- mage8-linux/mage_as7 - mage-windows/mage_extraire.exe
- mage8-linux/mage_extraire - mage-windows/mailleurPF.exe
- mage8-linux/mailleurTT
- mage8-linux/libbief.so
dl-mage8-windows:
stage: downloads
tags:
- linux
rules:
- if: $CI_COMMIT_BRANCH == 'ci-test' || $CI_COMMIT_BRANCH == 'master' || $CI_COMMIT_TAG
script:
- curl -L -o mage8.tgz https://gitlab.irstea.fr/jean-baptiste.faure/mage/-/releases/$MAGE_8_VERSION/downloads/packages/mage_windows.tgz
- mkdir -p mage8-windows
- cd mage8-windows
- tar xvf ../mage8.tgz
artifacts:
paths:
- mage8-windows/mage.exe
- mage8-windows/mage_as7.exe
- mage8-windows/mage_extraire.exe
- mage8-windows/mailleurTT.exe
- mage8-windows/libbief.dll
############# #############
# CONFIGURE # # CONFIGURE #
@@ -152,24 +129,7 @@ test-pep8:
# BUILD # # BUILD #
######### #########
# build-users-doc: build-users-doc:
# stage: build
# tags:
# - linux
# needs:
# - job: set-version
# artifacts: true
# script:
# - cd ./doc/users/
# - ./build.sh
# artifacts:
# paths:
# - doc/users/documentation.pdf
# - doc/users/documentation.html
# - doc/users/images/
# allow_failure: true
build-td:
stage: build stage: build
tags: tags:
- linux - linux
@@ -177,13 +137,13 @@ build-td:
- job: set-version - job: set-version
artifacts: true artifacts: true
script: script:
- cd ./doc/users/Tuto1/ - cd ./doc/users/
- ./build.sh - ./build.sh
artifacts: artifacts:
paths: paths:
- doc/users/Tuto1/step-by-step.pdf - doc/users/documentation.pdf
- doc/users/Tuto1/pas-a-pas.pdf - doc/users/documentation.html
- doc/users/Tuto1/data/ - doc/users/images/
allow_failure: true allow_failure: true
build-developers-doc: build-developers-doc:
@@ -224,9 +184,7 @@ build-linux:
rules: rules:
- if: $CI_COMMIT_BRANCH == 'ci-test' || $CI_COMMIT_BRANCH == 'master' || $CI_COMMIT_TAG - if: $CI_COMMIT_BRANCH == 'ci-test' || $CI_COMMIT_BRANCH == 'master' || $CI_COMMIT_TAG
needs: needs:
- job: dl-mage8-linux - job: dl-mage-linux
artifacts: true
- job: dl-mage8-doc
artifacts: true artifacts: true
- job: set-version - job: set-version
artifacts: true artifacts: true
@@ -234,9 +192,7 @@ build-linux:
artifacts: true artifacts: true
- job: build-developers-doc - job: build-developers-doc
artifacts: true artifacts: true
# - job: build-users-doc - job: build-users-doc
# artifacts: true
- job: build-td
artifacts: true artifacts: true
script: script:
- mkdir -p linux - mkdir -p linux
@@ -251,27 +207,28 @@ build-linux:
- pyinstaller -y --paths linux-venv/lib/python3.8/site-packages ../src/pamhyr.py - pyinstaller -y --paths linux-venv/lib/python3.8/site-packages ../src/pamhyr.py
# Create directory # Create directory
- mkdir -p pamhyr - mkdir -p pamhyr
- mkdir -p pamhyr/_internal - mkdir -p pamhyr/pamhyr
- mkdir -p pamhyr/pamhyr/_internal
# Copy Pamhyr info # Copy Pamhyr info
- cp -v ../VERSION pamhyr/_internal/ - cp -v ../VERSION pamhyr/pamhyr/_internal/
- cp -v ../AUTHORS pamhyr/_internal/ - cp -v ../AUTHORS pamhyr/pamhyr/_internal/
- cp -v ../LICENSE pamhyr/_internal/ - cp -v ../LICENSE pamhyr/pamhyr/_internal/
- cp -v ../src/motd.txt pamhyr/_internal/ - cp -v ../src/motd.txt pamhyr/pamhyr/_internal/
# Copy mage # Copy mage
- mkdir -p pamhyr/mage8 - mkdir -p pamhyr/mage
- cp -v ../mage8-linux/* pamhyr/mage8/ - cp -v ../mage-linux/* pamhyr/mage/
# Copy Pamhyr # Copy Pamhyr
- cp -r dist/pamhyr/* pamhyr/ - cp -r dist/pamhyr pamhyr/
# Copy Pamhyr resources # Copy Pamhyr resources
- mkdir -p pamhyr/_internal/View - mkdir -p pamhyr/pamhyr/_internal/View
- mkdir -p pamhyr/_internal/View/ui - mkdir -p pamhyr/pamhyr/_internal/View/ui
- mkdir -p pamhyr/_internal/View/ui/Widgets - mkdir -p pamhyr/pamhyr/_internal/View/ui/Widgets
- cp -r ../src/View/ui/*.ui pamhyr/_internal/View/ui/ - cp -r ../src/View/ui/*.ui pamhyr/pamhyr/_internal/View/ui/
- cp -r ../src/View/ui/ressources/ pamhyr/_internal/View/ui - cp -r ../src/View/ui/ressources/ pamhyr/pamhyr/_internal/View/ui
- cp -r ../src/View/ui/Widgets/*.ui pamhyr/_internal/View/ui/Widgets - cp -r ../src/View/ui/Widgets/*.ui pamhyr/pamhyr/_internal/View/ui/Widgets
# Copy lang # Copy lang
- mkdir -p pamhyr/_internal/lang - mkdir -p pamhyr/pamhyr/_internal/lang
- cp -r ../src/lang/*.qm pamhyr/_internal/lang - cp -r ../src/lang/*.qm pamhyr/pamhyr/_internal/lang
# Copy tests cases # Copy tests cases
- mkdir -p pamhyr/tests_cases/ - mkdir -p pamhyr/tests_cases/
- mkdir -p pamhyr/tests_cases/Saar - mkdir -p pamhyr/tests_cases/Saar
@@ -280,25 +237,17 @@ build-linux:
- mkdir -p pamhyr/doc/ - mkdir -p pamhyr/doc/
- mkdir -p pamhyr/doc/images/ - mkdir -p pamhyr/doc/images/
- mkdir -p pamhyr/doc/html/ - mkdir -p pamhyr/doc/html/
# - cp ../doc/users/documentation.pdf pamhyr/doc/Pamhyr2-users.pdf - cp ../doc/users/documentation.pdf pamhyr/doc/Pamhyr2-users.pdf
# - cp ../doc/users/documentation.html pamhyr/doc/Pamhyr2-users.html - cp ../doc/users/documentation.html pamhyr/doc/Pamhyr2-users.html
- cp ../doc/mage8.pdf pamhyr/doc/mage8.pdf
- cp ../doc/dev/documentation.pdf pamhyr/doc/Pamhyr2-dev.pdf - cp ../doc/dev/documentation.pdf pamhyr/doc/Pamhyr2-dev.pdf
- cp ../doc/dev/documentation.html pamhyr/doc/Pamhyr2-dev.html - cp ../doc/dev/documentation.html pamhyr/doc/Pamhyr2-dev.html
#- cp ../doc/users/images/* pamhyr/doc/images #- cp ../doc/users/images/* pamhyr/doc/images
- cp -r ../doc/dev/images/* pamhyr/doc/images - cp ../doc/dev/images/* pamhyr/doc/images
- cp -r ../doc/images/* pamhyr/doc/images - cp ../doc/images/* pamhyr/doc/images
# Copy Tuto # Create running script
- mkdir -p pamhyr/doc/Tuto1/ - echo "#!/bin/sh" > pamhyr/Pamhyr2
- mkdir -p pamhyr/doc/Tuto1/data - echo "./pamhyr/pamhyr $@" >> pamhyr/Pamhyr2
- cp ../doc/users/Tuto1/Hogneau_Engees2022.pdf pamhyr/doc/Tuto1/Hogneau_Engees2022.pdf - chmod u+x pamhyr/Pamhyr2
- cp ../doc/users/Tuto1/step-by-step.pdf pamhyr/doc/Tuto1/Tuto1-en.pdf
- cp ../doc/users/Tuto1/pas-a-pas.pdf pamhyr/doc/Tuto1/Tuto1-fr.pdf
- cp ../doc/users/Tuto1/*.pamhyr pamhyr/doc/Tuto1/
- cp ../doc/users/Tuto1/data/* pamhyr/doc/Tuto1/data/
# Copy TP charriage
- mkdir -p pamhyr/doc/TP_charriage/
- cp ../doc/users/TP_charriage/* pamhyr/doc/TP_charriage
artifacts: artifacts:
paths: paths:
- linux/pamhyr - linux/pamhyr
@@ -310,9 +259,7 @@ build-windows:
rules: rules:
- if: $CI_COMMIT_BRANCH == 'ci-test' || $CI_COMMIT_BRANCH == 'master' || $CI_COMMIT_TAG - if: $CI_COMMIT_BRANCH == 'ci-test' || $CI_COMMIT_BRANCH == 'master' || $CI_COMMIT_TAG
needs: needs:
- job: dl-mage8-windows - job: dl-mage-windows
artifacts: true
- job: dl-mage8-doc
artifacts: true artifacts: true
- job: set-version - job: set-version
artifacts: true artifacts: true
@@ -320,20 +267,16 @@ build-windows:
artifacts: true artifacts: true
- job: build-developers-doc - job: build-developers-doc
artifacts: true artifacts: true
# - job: build-users-doc - job: build-users-doc
# artifacts: true
- job: build-td
artifacts: true artifacts: true
script: script:
- mkdir windows - mkdir windows
- cd windows - cd windows
# Setup env # Setup env
- python -m pip install -U pip
- python -m pip install -r ..\requirements.txt - python -m pip install -r ..\requirements.txt
- python -m pip install -U -r ..\requirements.txt - python -m pip install -U -r ..\requirements.txt
# Run Pyinstaller # Run Pyinstaller
# - pyinstaller --noconsole -y ..\src\pamhyr.py - pyinstaller -y ..\src\pamhyr.py
- pyinstaller --hide-console hide-early -y ..\src\pamhyr.py
# Create directory # Create directory
- mkdir pamhyr - mkdir pamhyr
- dir - dir
@@ -403,111 +346,6 @@ windows-package-exe:
- copy ..\packages\pamhyr.nsi pamhyr.nsi - copy ..\packages\pamhyr.nsi pamhyr.nsi
- .\make-windows-exe.bat - .\make-windows-exe.bat
########
# HASH #
########
linux-build-hash:
stage: hash
tags:
- release
- linux
needs:
- job: build-linux
artifacts: true
rules:
- if: $CI_COMMIT_BRANCH == 'ci-test' || $CI_COMMIT_BRANCH == 'master' || $CI_COMMIT_TAG
script:
- cd linux
- sha256sum -b pamhyr/pamhyr > pamhyr/pamhyr.sha256
artifacts:
paths:
- linux/pamhyr/pamhyr.sha256
windows-build-hash:
stage: hash
tags:
- release
- linux
needs:
- job: build-windows
artifacts: true
rules:
- if: $CI_COMMIT_BRANCH == 'ci-test' || $CI_COMMIT_BRANCH == 'master' || $CI_COMMIT_TAG
script:
- cd windows
- sha256sum -b pamhyr/pamhyr.exe > pamhyr/pamhyr.exe.sha256
artifacts:
paths:
- windows/pamhyr/pamhyr.exe.sha256
pkg-hash:
stage: hash
tags:
- release
- linux
needs:
- job: linux-package-tar
artifacts: true
- job: windows-package-zip
artifacts: true
- job: windows-package-exe
artifacts: true
rules:
- if: $CI_COMMIT_BRANCH == 'ci-test' || $CI_COMMIT_TAG
script:
- cd windows
- sha256sum -b pamhyr-windows.exe > pamhyr-windows.exe.sha256
- sha256sum -b pamhyr-windows.zip > pamhyr-windows.zip.sha256
- cd ..
- cd linux
- sha256sum -b pamhyr-gnulinux.tar.xz > pamhyr-gnulinux.tar.xz.sha256
artifacts:
paths:
- windows/pamhyr-windows.exe.sha256
- windows/pamhyr-windows.zip.sha256
- linux/pamhyr-gnulinux.tar.xz.sha256
#############
# ANTIVIRUS #
#############
build-check-clamav:
stage: antivirus
tags:
- release
- linux
needs:
- job: build-linux
artifacts: true
- job: build-windows
artifacts: true
rules:
- if: $CI_COMMIT_BRANCH == 'ci-test' || $CI_COMMIT_BRANCH == 'master' || $CI_COMMIT_TAG
script:
- cd packages
- ./clamav-scan.sh builds
allow_failure: true
pkg-check-clamav:
stage: antivirus
tags:
- release
- linux
needs:
- job: linux-package-tar
artifacts: true
- job: windows-package-zip
artifacts: true
- job: windows-package-exe
artifacts: true
rules:
- if: $CI_COMMIT_BRANCH == 'ci-test' || $CI_COMMIT_TAG
script:
- cd packages
- ./clamav-scan.sh packages
allow_failure: true
########### ###########
# RELEASE # # RELEASE #
########### ###########
@@ -524,11 +362,9 @@ tag-release:
artifacts: true artifacts: true
- job: windows-package-exe - job: windows-package-exe
artifacts: true artifacts: true
# - job: build-users-doc - job: build-users-doc
# artifacts: true
- job: build-developers-doc
artifacts: true artifacts: true
- job: pkg-hash - job: build-developers-doc
artifacts: true artifacts: true
rules: rules:
- if: $CI_COMMIT_TAG - if: $CI_COMMIT_TAG
@@ -537,44 +373,33 @@ tag-release:
- linux/pamhyr-gnulinux.tar.xz - linux/pamhyr-gnulinux.tar.xz
- windows/pamhyr-windows.zip - windows/pamhyr-windows.zip
- windows/pamhyr-windows.exe - windows/pamhyr-windows.exe
- linux/pamhyr-gnulinux.tar.xz.sha256
- windows/pamhyr-windows.zip.sha256
- windows/pamhyr-windows.exe.sha256
- doc/dev/documentation.pdf - doc/dev/documentation.pdf
# - doc/users/documentation.pdf - doc/users/documentation.pdf
script: script:
- cd packages - cd packages
release: release:
name: '$CI_COMMIT_TAG' name: '$CI_COMMIT_TAG'
description: '$CI_COMMIT_TAG_MESSAGE' description: 'Automatic release from tag $CI_COMMIT_TAG'
tag_name: '$CI_COMMIT_TAG' tag_name: '$CI_COMMIT_TAG'
ref: '$CI_COMMIT_SHA' ref: '$CI_COMMIT_SHA'
assets: assets:
links: links:
- name: 'GNU/Linux CHECKSUM SHA256 (tar.xz)'
url: '${CI_PROJECT_URL}/-/jobs/${CI_JOB_ID}/artifacts/raw/linux/pamhyr-gnulinux.tar.xz.sha256'
filepath: '/linux/pamhyr-gnulinux.tar.xz.sha256'
link_type: 'package'
- name: 'GNU/Linux (tar.xz)' - name: 'GNU/Linux (tar.xz)'
url: '${CI_PROJECT_URL}/-/jobs/${CI_JOB_ID}/artifacts/raw/linux/pamhyr-gnulinux.tar.xz' url: '${CI_PROJECT_URL}/-/jobs/${CI_JOB_ID}/artifacts/raw/linux/pamhyr-gnulinux.tar.xz'
filepath: '/linux/pamhyr-gnulinux.tar.xz' filepath: '/linux/pamhyr-gnulinux.tar.xz'
link_type: 'package' link_type: 'package'
- name: 'Windows CHECKSUM SHA256 (exe)'
url: '${CI_PROJECT_URL}/-/jobs/${CI_JOB_ID}/artifacts/raw/windows/pamhyr-windows.exe.sha256'
filepath: '/windows/pamhyr-windows.exe.sha256'
link_type: 'package'
- name: 'Windows (exe)' - name: 'Windows (exe)'
url: '${CI_PROJECT_URL}/-/jobs/${CI_JOB_ID}/artifacts/raw/windows/pamhyr-windows.exe' url: '${CI_PROJECT_URL}/-/jobs/${CI_JOB_ID}/artifacts/raw/windows/pamhyr-windows.exe'
filepath: '/windows/pamhyr-windows.exe' filepath: '/windows/pamhyr-windows.exe'
link_type: 'package' link_type: 'package'
- name: 'Windows CHECKSUM SHA256 (zip)'
url: '${CI_PROJECT_URL}/-/jobs/${CI_JOB_ID}/artifacts/raw/windows/pamhyr-windows.zip.sha256'
filepath: '/windows/pamhyr-windows.zip.sha256'
link_type: 'package'
- name: 'Windows (zip)' - name: 'Windows (zip)'
url: '${CI_PROJECT_URL}/-/jobs/${CI_JOB_ID}/artifacts/raw/windows/pamhyr-windows.zip' url: '${CI_PROJECT_URL}/-/jobs/${CI_JOB_ID}/artifacts/raw/windows/pamhyr-windows.zip'
filepath: '/windows/pamhyr-windows.zip' filepath: '/windows/pamhyr-windows.zip'
link_type: 'package' link_type: 'package'
- name: 'User documentations (pdf)'
url: '${CI_PROJECT_URL}/-/jobs/${CI_JOB_ID}/artifacts/raw/doc/users/documentation.pdf'
filepath: '/doc/users/documentation.pdf'
link_type: 'other'
- name: 'Dev documentations (pdf)' - name: 'Dev documentations (pdf)'
url: '${CI_PROJECT_URL}/-/jobs/${CI_JOB_ID}/artifacts/raw/doc/dev/documentation.pdf' url: '${CI_PROJECT_URL}/-/jobs/${CI_JOB_ID}/artifacts/raw/doc/dev/documentation.pdf'
filepath: '/doc/dev/documentation.pdf' filepath: '/doc/dev/documentation.pdf'
+2 -2
View File
@@ -1,3 +1,3 @@
Sylvain COULIBALY, INRAE, 2020 - 2022 Sylvain COULIBALY, INRAE, 2020 - 2022
Théophile TERRAZ, INRAE, 2022 - 2024 Théophile TERRAZ, INRAE, 2022 - 2023
Pierre-Antoine ROUBY, INRAE, 2023 - 2024 Pierre-Antoine ROUBY, INRAE, 2023
+13 -18
View File
@@ -10,40 +10,35 @@ modelling of rivers.
+ Define boundary conditions + Define boundary conditions
+ Define lateral contribution + Define lateral contribution
+ Edit river friction + Edit river friction
+ Add reservoirs
+ Add hydraulic structures
+ Generate initial conditions + Generate initial conditions
+ Edit river sedimentary layers + Edit river sedimentary layers
+ Save the study in a unique file + Save the study in a unique file
+ Run Mage 8 on a study and visualize results + Run Mage 8 on a study and visualize results
Let see the
[documentation](https://gitlab.irstea.fr/theophile.terraz/pamhyr/-/wikis/home)
for more details.
## Install ## Install
### GNU/Linux ### GNU/Linux
[See documentation](https://gitlab.irstea.fr/theophile.terraz/pamhyr/-/wikis/home/en/Install%20on%20GNULinux) Downloads [last
realease](https://gitlab.irstea.fr/theophile.terraz/pamhyr/-/releases/permalink/latest)
GNU/Linux binary archive.
```shell
tar xf pamhyr-gnulinux-amd64.tar.xz
cd pamhyr
./pamhyr
```
### Windows ### Windows
[See documentation](https://gitlab.irstea.fr/theophile.terraz/pamhyr/-/wikis/home/en/Install%20on%20Windows) Downloads [last
realease](https://gitlab.irstea.fr/theophile.terraz/pamhyr/-/releases/permalink/latest)
Windows installer.
### From source code ### From source code
```shell ```shell
# Get mage # Get source code
mkdir mage
cd mage
curl -L -o mage.tgz https://gitlab.irstea.fr/jean-baptiste.faure/mage/-/releases/v8.3.2/downloads/packages/mage_linux.tgz
tar xf mage.tgz
cd ..
# Get Pamhyr2 source code
git clone https://gitlab.irstea.fr/theophile.terraz/pamhyr/ git clone https://gitlab.irstea.fr/theophile.terraz/pamhyr/
cd pamhyr cd pamhyr
+17 -54
View File
@@ -1,5 +1,5 @@
# documentation.org -- Pamhyr developers documentation # documentation.org -- Pamhyr developers documentation
# Copyright (C) 2023-2024 INRAE # Copyright (C) 2023 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
@@ -369,7 +369,6 @@ of Bar (Listing [[sql-bar]] and [[sql-foo]]).
CREATE TABLE bar ( CREATE TABLE bar (
id INTEGER NOT NULL PRIMARY KEY, id INTEGER NOT NULL PRIMARY KEY,
x INTEGER NOT NULL, x INTEGER NOT NULL,
y INTEGER NOT NULL,
foo_id INTEGER NOT NULL, foo_id INTEGER NOT NULL,
FOREIGN KEY(foo_id) REFERENCES foo(id), FOREIGN KEY(foo_id) REFERENCES foo(id),
)""") )""")
@@ -456,15 +455,6 @@ of Bar (Listing [[sql-bar]] and [[sql-foo]]).
bar._sql_save(execute, data=data) bar._sql_save(execute, data=data)
#+end_src #+end_src
Let see the results database scheme for Pamhyr2 at version v0.0.7 in
Figure [[sql_schema]].
#+NAME: sql_schema
#+ATTR_LATEX: :width 16cm
#+CAPTION: SQLite database scheme at Pamhyr2 version v0.0.7 (generate with [[https://gitlab.com/Screwtapello/sqlite-schema-diagram]])
[[./images/schema_v0.0.7.png]]
[fn:sqlite] The SQLite web site: https://www.sqlite.org/index.html [fn:sqlite] The SQLite web site: https://www.sqlite.org/index.html
(last access 2023-09-20) (last access 2023-09-20)
@@ -556,8 +546,8 @@ generic value from optional parameters, for examples:
_pamhyr_ui = "MyUI" _pamhyr_ui = "MyUI"
_pamhyr_name = "My window" _pamhyr_name = "My window"
def __init__(self, study=None, config=None, def __init__(self, my_data=None,
my_data=None, study=None, config=None,
parent=None): parent=None):
self._my_data = my_data self._my_data = my_data
@@ -671,13 +661,11 @@ creation, this stack is accessible at =self._undo_stack=.
*** Plot *** Plot
To define a new plot you can create a class who inherit to To define a new plot you can create a class who inherit to APlot. The
PamhyrPlot. The creator need at leaste five argument: creator need threee argument:
- A =canvas= of type =MplCanvas= - A =canvas= of type =MplCanvas=
- A (optional) =trad= of type =PamhyrTranslate=
- A =data= used in =draw= and =update= to create and update the plot - A =data= used in =draw= and =update= to create and update the plot
- A optional =toolbar= of type =PamhyrToolbar= - A optional =toolbar= of type =PamhyrToolbar=
- A =parent= window
This class must implement two method =draw= and =update=, the first This class must implement two method =draw= and =update=, the first
method to draw the plot from scratch, the second to update the plot if method to draw the plot from scratch, the second to update the plot if
data has changed. data has changed.
@@ -685,36 +673,19 @@ data has changed.
#+begin_src python :python python3 :results output :noweb yes #+begin_src python :python python3 :results output :noweb yes
from View.Tools.PamhyrPlot import PamhyrPlot from View.Tools.PamhyrPlot import PamhyrPlot
class MyPlot(PamhyrPlot): class MyPlot(APlot):
def __init__(self, canvas=None, trad=None, toolbar=None def __init__(self, canvas=None, data=None, toolbar=None):
data=None, parent=None):
super(MyPlot, self).__init__( super(MyPlot, self).__init__(
canvas=canvas, canvas=canvas,
trad=trad,
data=data, data=data,
toolbar=toolbar, toolbar=toolbar
parent=parent
) )
self.label_x = self._trad["x"]
self.label_y = self._trad["y"]
# Optional configuration
self._isometric_axis = False
self._auto_relim_update = True
self._autoscale_update = True
def draw(self): def draw(self):
# Draw function code... # Draw function code...
def update(self): def update(self, ind = None):
# Update function code... # Update function code...
def clear(self):
# Clear plot values...
# ...
#+end_src #+end_src
** Solver ** Solver
@@ -774,7 +745,7 @@ execute a code on distant computer, for example, over ssh.
style=dashed; style=dashed;
subgraph cluster021 { subgraph cluster021 {
label="Solver Classes"; label="Solver Classes";
//classSolverM7[label="Mage7", fillcolor=6]; classSolverM7[label="Mage7", fillcolor=6];
classSolverM8[label="Mage8", fillcolor=6]; classSolverM8[label="Mage8", fillcolor=6];
classSolverR[label="RubarBE", fillcolor=6]; classSolverR[label="RubarBE", fillcolor=6];
} }
@@ -857,7 +828,7 @@ solver and get results:
- (2.1) The solver read the input file(s) - (2.1) The solver read the input file(s)
- (2.2) The solver compute results and write it to solver output - (2.2) The solver compute results and write it to solver output
file(s) file(s)
- (3) Pamhyr2 create a =Results= object - (3) Pamhyr2 create a Reuslts
- (3.1) The Pamhyr2 solver class read solver output file(s) and - (3.1) The Pamhyr2 solver class read solver output file(s) and
complete Results with readed data complete Results with readed data
@@ -987,16 +958,8 @@ different methods:
** Unit tests ** Unit tests
A very small part of Pamhyr2 has unit test. This part is limited to the Model. The unit tests is actually not implemented in Pamhyr2, it is a *work
in progress*.
#+begin_src shell
python3 -m venv test
. test test/bin/activate
pip3 install -U -r ./full-requirements.txt
cd src/
python3 -Walways -m unittest discovert -v -t .
#+end_src
** The debug mode ** The debug mode
@@ -1007,14 +970,14 @@ line:
./Pamhyr2 debug ./Pamhyr2 debug
#+end_src #+end_src
This mode add some log and add two action in main window menu: "About This mode add some log and add two action in main window menu:
> Debug" open a window with Python Repl in current Python "About/Debug" open a window with Python Repl in current Python
environement, and "About > Debug SQLite" who open the application environement, and "About/Debug SQLite" who open the application
SQLiteBrowser (if installed) on current Study to explore the study SQLiteBrowser (if installed) on current Study to explore the study
data base file. data base file.
#+NAME: debug-repl #+NAME: debug-repl
#+ATTR_LATEX: :width 14cm #+ATTR_LATEX: :width 12cm
#+CAPTION: Pamhyr2 debug Python REPL #+CAPTION: Pamhyr2 debug Python REPL
[[./images/python-debug-repl.png]] [[./images/python-debug-repl.png]]
Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 224 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 87 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 69 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 134 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 131 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File renamed without changes.
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
-4
View File
@@ -1,4 +0,0 @@
#! /bin/sh
pdflatex -no-shell-escape step-by-step.tex
pdflatex -no-shell-escape pas-a-pas.tex
File renamed without changes.
Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB

File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 115 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

File renamed without changes.
File renamed without changes.
-299
View File
@@ -1,299 +0,0 @@
%% LyX 2.0.2 created this file. For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[12pt,french]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{geometry}
\geometry{verbose,tmargin=2cm,bmargin=2cm,lmargin=2cm,rmargin=2cm,headheight=2cm,headsep=2cm,footskip=2cm}
\usepackage{textcomp}
\usepackage{graphicx}
\usepackage{hyperref}
\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
\newcommand{\noun}[1]{\textsc{#1}}
%% Because html converters don't know tabularnewline
\providecommand{\tabularnewline}{\\}
\makeatother
\usepackage{babel}
\addto\extrasfrench{%
\providecommand{\og}{\leavevmode\flqq~}%
\providecommand{\fg}{\ifdim\lastskip>\z@\unskip\fi~\frqq}%
}
\begin{document}
\includegraphics[width=5cm]{img/Logo-INRAE_Transparent.png}
~
~
~
\begin{center}
Tutoriel pour Pamhyr2
Janvier 2024
\par\end{center}
~
~
\begin{center}
\textbf{\LARGE Modélisation 1D de la rivière } \\
\textbf{\LARGE Hogneau (Nord, France) avec Pamhyr2}
\par\end{center}{\LARGE \par}
~
~
\begin{center}
{\large INRAE Lyon-Grenoble Auvergne-Rhône-Alpes}
\par\end{center}{\large \par}
\begin{center}
RiverLy, Hydraulique des rivières
\par\end{center}
~
~
~
~
~
~
\begin{center}
\begin{tabular}{lll}
Autors : & Pierre-Antoine Rouby & pierre-antoine.rouby@inrae.fr\tabularnewline
& Théophile TERRAZ & theophile.terraz@inrae.fr\tabularnewline
& Lionel Pénard & lionel.penard@inrae.fr\tabularnewline
\end{tabular}
\par\end{center}
~
\pagebreak{}
\begin{center}
\tableofcontents{}
\par\end{center}
~
\pagebreak{}
% \section{Introduction}
%
% TODO
%
% \pagebreak{}
\section{Installer Pamhyr2}
Pamhyr2 peut être téléchargé ici : \url{https://gitlab.irstea.fr/theophile.terraz/pamhyr}.
\begin{center}
\includegraphics[width=15cm]{img/dl.png}
\par\end{center}
Utilisez le bouton de téléchargement GNU Linux ou Windows en fonction de votre système. Sous Windows, lancez le programme d'installation. Sous Linux, décompressez l'archive et lancez Pamhyr2.
\section{Créer une première étude}
Dans la fenêtre principale, cliquez sur \texttt{[Fichier] => [Nouvelle étude]} pour créer une nouvelle étude. Choisissez un nom, par exemple Hogneau, et validez
Cliquez sur \texttt{[Réseau] => [Editer le réseau]} pour créer les biefs de votre rivière. Dans cette fenêtre, vous devez définir un graphe orienté qui représente les biefs de votre réseau fluvial : les arêtes sont les biefs et les n½uds sont soit des conditions limites amont, soit des conditions limites aval, soit des jonctions entre biefs.
Appuyez sur le bouton \includegraphics[width=0.5cm]{img/gtk_add.png} pour entrer dans le mode \textit{Ajout}. Créez deux n½uds en cliquant dans la zone grise de la fenêtre, et créez un lien en cliquant à nouveau sur chaque n½ud. Appuyez à nouveau sur \includegraphics[width=0.5cm]{img/gtk_add.png} pour quitter le mode \textit{Ajout}. Vous avez créé votre premier bief, avec un n½ud amont et un n½ud aval. Dans la partie inférieure de la fenêtre \textit{Editer le réseau hydrographique}, vous pouvez renommer les n½uds et les biefs. Comme le bief que vous avez créé est automatiquement sélectionné, toutes les étapes suivantes s'appliqueront à ce bief. La fenêtre doit se présenter comme suit :
\begin{center}
\includegraphics[width=15cm]{img/network.png}
\par\end{center}
Fermer la fenêtre \textit{Editer le réseau}.
\section{Editer la géometrie de la rivière}
Cliquez sur \texttt{[Géometrie] => [Editer la géometrie]} pour définir la géométrie du bief sélectionné. Cliquez sur le bouton \texttt{[Importer]} et sélectionnez le fichier \texttt{Data/Bief\_1.st}. Vous devriez voir :
\begin{center}
\includegraphics[width=15cm]{img/Geo.png}
\par\end{center}
Le panneau de gauche contient une liste de toutes les sections en travers avec leur nom et leur abscisse longitudinale (PK). Dans le graphique en haut à gauche, vous pouvez voir la vue de dessus de la rivière, dans le panneau en haut à droite, la coupe longitudinale de la rivière et dans le graphique en bas, vous pouvez voir la section en travers sélectionnée (bleu) ainsi que la suivante (pointillés violets) et la précédente (pointillés noirs). Vous pouvez vous déplacer dans la liste des sections en cliquant dans le tableau ou à l'aide de l'ascenseur situé entre le tableau et les graphiques.
Vous pouvez éditer la section en travers sélectionnée en cliquant sur l'icône \includegraphics[width=0.5cm]{"img/edit.png"}.
Sélectionnez la section en travers nommée \textit{PontRD101m} et ouvrez la fenêtre d'édition. Vous devriez voir :
\begin{center}
\includegraphics[width=15cm]{img/editsect.png}
\par\end{center}
Sur le panneau de gauche se trouve la liste de tous les points de la section, avec leurs coordonnées, leur nom et leur abscisse transversale. La coordonnée Z du point le plus haut est inscrite en bleu et celle du point le plus bas en rouge. Les points peuvent avoir un nom. Si un point portant le même nom existe dans toutes les sections d'un bief, il forme une ligne longitudinale (ou ligne directrice). Par exemple, nous avons ici \textit{rg} et \textit{rd} qui représentent la rive gauche et la rive droite du lit mineur.
Sur le graphique figure une projection de la section en travers. Vous pouvez utiliser \texttt{[ctrl + clic]} pour sélectionner un point dans le tracé et \texttt{[maj + clic]} pour sélectionner une ligne d'eau et visualiser des données géométriques utiles. Vous pouvez fermer la fenêtre d'édition de la section en travers et la fenêtre d'édition de la géométrie.
\section{Editer les conditions aux limites}
Dans la fenêtre principale, cliquez sur \texttt{[Hydraulique] => [Conditions aux limites et apports ponctuels]} :
\begin{center}
\includegraphics[width=15cm]{img/boundary.png}
\par\end{center}
Utilisez le bouton \textit{ajouter} en haut à gauche de la fenêtre pour ajouter une condition limite pour le liquide.
Sur la nouvelle ligne, on peut cliquer pour sélectionner la ligne entière, et double-cliquer pour sélectionner la cellule.
Sélectionnez la cellule \textit{Type} pour donner un nom à la condition limite. Ici, nous définirons le débit mesuré lors de la crue de février 2002. Vous pouvez nommer cette condition limite "crue2002".
Sélectionner la cellule \textit{Type} et utiliser la combo box pour mettre une loi Q(t).
Sélectionnez la cellule \textit{Noeud} et attribuez cette condition au noeud amont.
Les noms des noeuds sont rappelés dans le réseau du panneau de droite.
Sélectionnez maintenant la ligne entière et cliquez sur le bouton d'édition \includegraphics[width=0.5cm]{"img/edit.png"}. Vous avez ouvert la fenêtre \textit{Éditer les conditions aux limites}.
Dans un éditeur de texte, ouvrez le fichier \texttt{Données/Fevrier\_2002.txt}. Copiez le contenu du fichier (par exemple avec \textit{ctrl+a} puis \textit{ctrl+c}) et collez-le dans le panneau gauche de la fenêtre \textit{Éditer les conditions aux limites} avec \textit{ctrl+v}. Vous pouvez maintenant voir la courbe de débit :
\begin{center}
\includegraphics[width=15cm]{img/fev2002.png}
\par\end{center}
Fermer cette fenêtre. Revenir sur la fenêtre \textit{Conditions aux limites}. Ajouter une nouvelle ligne, lui donner un nom, lui donner le type \textit{Z(T)} et l'associer au noeud aval du réseau. Ouvrez la fenêtre \textit{Éditer les conditions aux limites} (\includegraphics[width=0.5cm]{"img/edit.png"}). Ajoutez deux lignes. Dans la première, entrez le temps : 0.00.00 et Z : 15.000.
Dans la seconde, saisissez le temps : 1.00.00 et Z : 15.000. Cela crée une côte constante de l'eau en aval. Pour le calcul, Mage extrapolera continuellement l'élévation de l'eau.
Vous pouvez fermer les fenêtres \textit{Éditer les conditions aux limites} et \textit{Conditions aux limites}.
\section{Créer les conditions initiales}
Dans la fenêtre principale, cliquez sur \texttt{[Hydraulique] => [Conditions initiales]}.
Si vous ne connaissez pas les conditions initiales de la côte de l'eau et du débit de la rivière, vous pouvez utiliser les boutons \texttt{[Générer une hauteur minimale]} ou \texttt{[Générer un débit constant]} pour laisser Pamhyr2 estimer une condition initiale à l'aide de la formule de Manning-Strickler.
Cliquez sur \texttt{[Générer à partir du débit]} et saisissez un débit de $4 m^3$ dans la fenêtre contextuelle pour générer une condition initiale de hauteur d'eau basée sur la formule de Manning-Strickler et un débit uniforme de $4 m^3$. Vous devriez voir :
\begin{center}
\includegraphics[width=15cm]{img/ic.png}
\par\end{center}
Fermer la fenêtre \textit{Conditions initiales}
\section{Editer les coefficients de frottement}
Dans la fenêtre principale, cliquez sur \texttt{[Hydraulique] => [Editer les frottements]}.
Vous devez d'abord définir des jeux de coefficients de Strickler. Cliquez sur \includegraphics[width=0.5cm]{"img/edit.png"} pour ouvrir la fenêtre \textit{Strickler}. Vous pouvez y créer des couples de coefficients de Strickler, le premier pour le lit mineur, le second pour le lit moyen. Cliquez quatre fois sur \textit{add} pour créer quatre nouveaux couples. Donnez-leur les valeurs suivantes :
\begin{center}
\includegraphics[width=15cm]{img/K.png}
\par\end{center}
Fermez la fenêtre \textit{Strickler}. Dans la fenêtre \textit{Editer les frottements}, ajoutez quatre lignes avec le bouton \includegraphics[width=0.5cm]{img/gtk_add.png} pour créer quatre zones de frottement. Chaque zone est définie par un PK \textit{début} et de \textit{fin} PK et un couple \textit{begin} et \textit{end} couple de Strickler. Les couples de coefficients de Strickler à l'intérieur d'une zone sont interpolés à partir des couples \textit{begin} et \textit{end}. Dans notre cas, nous utiliserons des coefficients constants par zone. Définissez les zones comme suit :
\begin{center}
\includegraphics[width=15cm]{img/frictions.png}
\par\end{center}
La zone sélectionnée est surlignée en bleu. Fermez la fenêtre \textit{Editer les frottements}.
\section{Modélisation des ouvrages hydrauliques}
Parfois, il peut y avoir des sections en travers dans lesquelles les équations de Saint-Venant ne peuvent pas être utilisées pour modéliser l'écoulement de l'eau. Dans ce cas, nous devons définir une autre loi pour relier la côte de l'eau et le débit. C'est le cas, par exemple, au niveau des ponts lorsque la hauteur d'eau est trop élevée, ce qui entraîne un écoulement en charge. Pamhyr2 permet de définir différents ouvrages hydrauliques avec des lois paramétrables. Dans notre cas, on doit représenter un seuil et deux ponts comme ouvrages hydrauliques.
Dans la fenêtre principale, cliquez sur \texttt{[Hydraulique] => [Ouvrages hydrauliques]} pour ouvrir la fenêtre des ouvrages hydrauliques. Cliquez trois fois sur le bouton \includegraphics[width=0.5cm]{img/gtk_add.png} pour créer trois ouvrages hydrauliques. Chaque structure peut avoir un nom et doit avoir une portée et un PK. Définissez-les comme suit :
\begin{center}
\includegraphics[width=15cm]{img/hs.png}
\par\end{center}
Sélectionnez le seuil aval et cliquez sur \includegraphics[width=0.5cm]{"img/edit.png"} pour modifier les lois de cette ouvrage. Les ouvrages hydrauliques sont composés d'ouvrages hydrauliques élémentaires. Vous pouvez combiner les lois de plusieurs ouvrages hydrauliques élémentaires pour créer votre ouvrage. Pour ce seuil, nous n'avons besoin que d'un ouvrage hydraulique élémentaire de type déversoir. Cliquez sur \includegraphics[width=0.5cm]{img/gtk_add.png} pour ajouter un nouvel ouvrage hydraulique élémentaire, donnez-lui le type \textit{seuil} et configurez-le comme suit :
\begin{center}
\includegraphics[width=15cm]{img/seuil.png}
\par\end{center}
Retournez à la fenêtre \textit{Ouvrages hydrauliques}.
Sélectionnez le pont RS101 et cliquez sur \includegraphics[width=0.5cm]{"img/edit.png"} pour éditer les lois de cet ouvrage. Un pont peut être modélisé comme une combinaison d'un orifice pour l'écoulement sous le pont et d'un déversoir pour l'écoulement au-dessus du pont. Créez deux ouvrages hydrauliques élémentaires et définissez-les comme suit :
\begin{center}
\includegraphics[width=15cm]{img/seuilRS101.png}
\includegraphics[width=15cm]{img/orificeRS101.png}
\par\end{center}
Revenez à la fenêtre \textit{Ouvrages hydrauliques} et appliquez la même procédure pour le pont de Thivencelle :
\begin{center}
\includegraphics[width=15cm]{img/orificeThivencelle.png}
\includegraphics[width=15cm]{img/seuilThivencelle.png}
\par\end{center}
Vous pouvez maintenant fermer les fenêtres \textit{Ouvrages hydrauliques}.
\section{Paramètres du solveur}
Dans la fenêtre principale, cliquez sur \texttt{[Exécuter] => [Parameters numériques des solveurs]}.
Dans la fenêtre \textit{Paramètres du solveur}, sélectionnez l'onglet \textit{Mage v8}. Réglez les paramètres du solveur comme suit :
\begin{center}
\includegraphics[width=15cm]{img/param.png}
\par\end{center}
Fermer la fenêtre \textit{Paramètres du solveur}.
\section{Lancer la simulation}
Dans la fenêtre principale, cliquez sur \texttt{[Exécuter] => [Lancer le solveur]}.
Sélectionnez \textit{Defaut-Mage - (Mage8)} et cliquez sur le bouton \textit{Exécuter}.
Deux fenêtres s'ouvrent : la fenêtre \textit{check list} et la fenêtre \textit{Log du solveur}.
La fenêtre \textit{Check list} donne quelques indications sur la validité de votre modèle, et la fenêtre \textit{Log du solveur} affiche les résultats du solveur.
À partir de la fenêtre \textit{Log du solveur}, vous pouvez réexécuter le calcul, et vous pouvez cliquer sur le bouton \textit{Résultats} pour ouvrir la fenêtre \textit{Résultats}.
\section{Visualiser les résultats}
il est aussi possible d'ouvrir la fenêtre \textit{Résultats} si vous avez fermé la fenêtre \textit{Log du solveur}, en cliquant sur \texttt{[Résultats] => [Visualiser les derniers résultats]} à partir de la fenêtre principale. Le panneau supérieur vous permet de sélectionner le bief, le panneau inférieur gauche vous permet de sélectionner une section en travers dans ce bief. Les trois diagrammes sur la droite montrent le bief et la section en travers de la même manière que dans la fenêtre \textit{Géométrie}. Vous pouvez utiliser le curseur du bas pour visualiser la côte de l'eau à différents pas de temps.
Pour visualiser le débit, passez à l'onglet \textit{Hydrogramme}.
Pour créer des tracés 2D personnalisés, cliquez sur le bouton \includegraphics[width=0.5cm]{img/gtk_add.png} en haut à gauche de la fenêtre. Sélectionnez les valeurs que vous voulez sur les axes $X$ et $Y$ et cliquez sur \textit{OK}.
Vous pouvez maintenant voir un nouvel onglet avec le tracé 2D personnalisé dans le panneau droit de la fenêtre \textit{Results}.
\pagebreak{}
\end{document}
+39 -40
View File
@@ -25,7 +25,7 @@
} }
\begin{document} \begin{document}
\includegraphics[width=5cm]{img/Logo-INRAE_Transparent.png} \includegraphics[width=5cm]{Logo-INRAE_Transparent.png}
~ ~
@@ -58,7 +58,7 @@ using Pamhyr2
\par\end{center}{\large \par} \par\end{center}{\large \par}
\begin{center} \begin{center}
RiverLy, river hydraulics Riverly, river hydraulics
\par\end{center} \par\end{center}
~ ~
@@ -75,9 +75,8 @@ RiverLy, river hydraulics
\begin{center} \begin{center}
\begin{tabular}{lll} \begin{tabular}{lll}
Authors : & Pierre-Antoine Rouby & pierre-antoine.rouby@inrae.fr\tabularnewline Autors : & Pierre-Antoine Rouby & pierre-antoine.rouby@inrae.fr\tabularnewline
& Théophile Terraz & theophile.terraz@inrae.fr\tabularnewline & Théophile TERRAZ & theophile.terraz@inrae.fr\tabularnewline
& Lionel Pénard & lionel.penard@inrae.fr\tabularnewline
\end{tabular} \end{tabular}
\par\end{center} \par\end{center}
@@ -93,17 +92,17 @@ Authors : & Pierre-Antoine Rouby & pierre-antoine.rouby@inrae.fr\tabularnewline
\pagebreak{} \pagebreak{}
% \section{Introduction} \section{Introduction}
%
% TODO TODO
%
% \pagebreak{} \pagebreak{}
\section{Install Pamhyr2} \section{Install Pamhyr2}
Pamhyr2 can be downloaded from \url{https://gitlab.irstea.fr/theophile.terraz/pamhyr}. Pamhyr2 can be downloaded from \url{https://gitlab.irstea.fr/theophile.terraz/pamhyr}.
\begin{center} \begin{center}
\includegraphics[width=15cm]{img/dl.png} \includegraphics[width=15cm]{dl.png}
\par\end{center} \par\end{center}
Use the GNU Linux or the Windows download button depending on your system. On windows, launch the installer. On Linux, unpack the archive and launch Pamhyr2. Use the GNU Linux or the Windows download button depending on your system. On windows, launch the installer. On Linux, unpack the archive and launch Pamhyr2.
@@ -114,10 +113,10 @@ Use the GNU Linux or the Windows download button depending on your system. On wi
On the main windows, click on \texttt{[Files] => [New Study]} to create a new study. On the main windows, click on \texttt{[Files] => [New Study]} to create a new study.
Click on \texttt{[River Network] => [Edit River Network]} to create the reaches of your river. In this window, you must define an oriented graph that represents the reaches of your river network: the edges are the reaches and the nodes are either upstream boundary conditions, downstream boundary conditions or junctions. Click on \texttt{[River Network] => [Edit River Network]} to create the reaches of your river. In this window, you must define an oriented graph that represents the reaches of your river network: the edges are the reaches and the nodes are either upstream boundary conditions, downstream boundary conditions or junctions.
Press the \includegraphics[width=0.5cm]{img/gtk_add.png} to enter the \textit{add} mode. Create two nodes by clicking in the grey zone of the window, and create a link by clicking again on each node. press \includegraphics[width=0.5cm]{img/gtk_add.png} again to exit the \textit{add} mode. You created your first reach, with an upstream node and a downstream node. In the lower part of the \textit{Edit River Network} window you can rename the nodes and the reaches. As the reach you created is automaticaly selected, all the next steps will apply to this reach. The window should look like that: Press the \includegraphics[width=0.5cm]{gtk_add.png} to enter the \textit{add} mode. Create two nodes by clicking in the grey zone of the window, and create a link by clicking again on each node. press \includegraphics[width=0.5cm]{gtk_add.png} again to exit the \textit{add} mode. You created your first reach, with an upstream node and a downstream node. In the lower part of the \textit{Edit River Network} window you can rename the nodes and the reaches. As the reach you created is automaticaly selected, all the next steps will apply to this reach. The window should look like that:
\begin{center} \begin{center}
\includegraphics[width=15cm]{img/network.png} \includegraphics[width=15cm]{network.png}
\par\end{center} \par\end{center}
Close the \textit{Edit River Network} window. Close the \textit{Edit River Network} window.
@@ -128,29 +127,29 @@ Close the \textit{Edit River Network} window.
Click on \texttt{[Geometry] => [Edit Geometry]} to define the geometry of the selected bief. Click on the \texttt{[Import]} button and select the file \texttt{Data/Bief\_1.st}. You should see: Click on \texttt{[Geometry] => [Edit Geometry]} to define the geometry of the selected bief. Click on the \texttt{[Import]} button and select the file \texttt{Data/Bief\_1.st}. You should see:
\begin{center} \begin{center}
\includegraphics[width=15cm]{img/Geo.png} \includegraphics[width=15cm]{Geo.png}
\par\end{center} \par\end{center}
On the left panel is a list of all the cross sections with their name and longitudinal abscisa. In the top left plot you can see the top view of the river, on the top right panel the longitudinal cross-section of the river and in the bottom plot you can see the selected cross-section (blue) along with the next one (dashed purple) and previous one (dashed black). You can move in the section list using the slider at the very right of the window. On the left panel is a list of all the cross sections with their name and longitudinal abscisa. In the top left plot you can see the top view of the river, on the top right panel the longitudinal cross-section of the river and in the bottom plot you can see the selected cross-section (blue) along with the next one (dashed purple) and previous one (dashed black). You can move in the section list using the slider at the very right of the window.
You can edit the selected cross section by clicking on the \includegraphics[width=0.5cm]{"img/edit.png"} icon. You can edit the selected cross section by clicking on the \includegraphics[width=0.5cm]{"../../../src/View/ui/ressources/edit.png"} icon.
select the cross section named \textit{PontRD101m} and open the edition window. You should see: select the cross section named \textit{PontRD101m} and open the edition window. You should see:
\begin{center} \begin{center}
\includegraphics[width=15cm]{img/editsect.png} \includegraphics[width=15cm]{editsect.png}
\par\end{center} \par\end{center}
On the left panel is the list of all the points of the section, with their coordinates, their name and their transversal absisa. The Z coordinate of the highest point is written in blue and the lowest in red. Points can have a name. If a point with the same name exists in every section in a reach, it forms a longitudinal line. For example, here we have \textit{rg} and \textit{rd} which represent the left bank and the right bank of the main chanel. On the left panel is the list of all the points of the section, with their coordinates, their name and their transversal absisa. The Z coordinate of the highest point is written in blue and the lowest in red. Points can have a name. If a point with the same name exists in every section in a reach, it forms a longitudinal line. For example, here we have \textit{rg} and \textit{rd} which represent the left bank and the right bank of the main chanel.
On the plot is a projection of the cross section. You can use \texttt{[ctrl + click]} to select a point in the plot and \texttt{[shift + click]} to select a water line and visualize usefull geometric data. You can close the cross section edition window and the geometry edition window. On the plot is a projection of the cross section. You can use \texttt{[ctrl + click]} to select a point in the plot and \texttt{[shift + click]} to select a water line and fisualize usefull geometric data. You can close the cross section edition window and the geometry edition window.
\section{Edit the boundary conditions} \section{Edit the boundary conditions}
From the main window, click on \texttt{[Hydraulics] => [Boundary conditions and punctual contributions]}.You should see: From the main window, click on \texttt{[Hydraulics] => [Boundary conditions and punctual contributions]}.You should see:
\begin{center} \begin{center}
\includegraphics[width=15cm]{img/boundary.png} \includegraphics[width=15cm]{boundary.png}
\par\end{center} \par\end{center}
Use the \textit{add} button on the top left of the window to add a liquid boundary condition. Use the \textit{add} button on the top left of the window to add a liquid boundary condition.
@@ -159,25 +158,25 @@ From the main window, click on \texttt{[Hydraulics] => [Boundary conditions and
Select the \textit{Type} cell and use the combo box to put a Q(t) law. Select the \textit{Type} cell and use the combo box to put a Q(t) law.
Select the \textit{Node} cell and atribute this condition to the upstream node. Select the \textit{Node} cell and atribute this condition to the upstream node.
Names of the nodes are recalled in network in the right panel. Names of the nodes are recalled in network in the right panel.
Now select the whole line and click on the edit button \includegraphics[width=0.5cm]{"img/edit.png"}. You opened the \textit{Edit Boundary Conditions} window. Now select the whole line and click on the edit button \includegraphics[width=0.5cm]{"../../../src/View/ui/ressources/edit.png"}. You opened the \textit{Edit Boundary Conditions} window.
On a text editor, open the \texttt{Data/Fevrier\_2002.txt} file. Copy the content of the file (for example with \textit{ctrl+a ctrl+c}) and paste it in the left panel of the \textit{Edit Boundary Conditions} window with \textit{ctrl+v}. You can now see the flow discharge curve: On a text editor, open the \texttt{Data/Fevrier\_2002.txt} file. Copy the content of the file (for example with \textit{ctrl+a ctrl+c}) and paste it in the left panel of the \textit{Edit Boundary Conditions} window with \textit{ctrl+v}. You can now see the flow discharge curve:
\begin{center} \begin{center}
\includegraphics[width=15cm]{img/fev2002.png} \includegraphics[width=15cm]{fev2002.png}
\par\end{center} \par\end{center}
Close this window. Go back on the \textit{Boundary Conditions} window. Add a new line, give it a name, give it the textit{Z(T)} type and associate it to the downstream node of the network. Open the \textit{Edit Boundary Conditions} window (\includegraphics[width=0.5cm]{"img/edit.png"}). Add two lines. In the first one, enter time: 0.00.00 and Z: 15.000. Close this window. Go back on the \textit{Boundary Conditions} window. Add a new line, give it a name, give it the textit{Z(T)} type and associate it to the downstream node of the network. Open the \textit{Edit Boundary Conditions} window (\includegraphics[width=0.5cm]{"../../../src/View/ui/ressources/edit.png"}). Add two lines. In the first one, enter time: 0.00.00 and Z: 15.000.
On the second one, time: 1.00.00 and Z: 15.000. It creates a constant downstream water elevation. For the computaion, Mage will extrapolate continuously the water elevation, that's why we only need to define one hour. On the second one, time: 1.00.00 and Z: 15.000. It creates a constant downstream water elevation. For the computaion, Mage will extrapolate continuously the water elevation, that's why we only need to define one hour.
You can close the the \textit{Edit Boundary Conditions} and the \textit{Boundary Conditions} window. You can close the the \textit{Edit Boundary Conditions} and the \textit{Boundary Conditions} window.
\section{Create initial conditions} \section{Create initial conditions}
From the main window, click on \texttt{[Hydraulics] => [Initial conditions]}. From the main window, click on \texttt{[Hydraulics] => [Initial conditions]}.
If you don't know the initial conditions in water elevation and flow discharge of the river, you can use \texttt{[Generate minimal height]} or \texttt{[Generate from discharge]} buttons to let Pamhyr2 estimate an initial condition using the Manning-Strickler formula. If you don't know the initial conditions in water elevation and flow discharge of the river, you can use \texttt{[Generate minimal height]} or \texttt{[Generate constant discharge]} buttons to let Pamhyr2 estimate an initial condition using the Manning-Strickler formula.
Click on \texttt{[Generate from discharge]} and enter a discharge of $4 m^3$ in the pop-up window to generate an initial water height condition based on the Manning-Strickler formula and a uniform discharge of $4 m^3$. You should see: Click on \texttt{[Generate minimal height]} and enter a discharge of $4 m^2$ in the pop-up window to generate an initial water height condition based on the Manning-Strickler formula and a uniform discharge of $4 m^2$. You should see:
\begin{center} \begin{center}
\includegraphics[width=15cm]{img/ic.png} \includegraphics[width=15cm]{ic.png}
\par\end{center} \par\end{center}
Close the \textit{Initial conditions} window. Close the \textit{Initial conditions} window.
@@ -186,16 +185,16 @@ Close the \textit{Initial conditions} window.
\section{Edit friction coefficients} \section{Edit friction coefficients}
From the main window, click on \texttt{[Hydraulics] => [Edit friction]}. From the main window, click on \texttt{[Hydraulics] => [Edit friction]}.
You fist have to define sets of Strickler coefficients. Click on \includegraphics[width=0.5cm]{"img/edit.png"} to open the \textit{Strickler} window. Here you can create couples of Strickler coefficients, the first one for the minor bed, the second one for the medium bed. Click on \textit{add} four times to create four new couple. Give them the folowing values: You fist have to define sets of Strickler coefficients. Click on \includegraphics[width=0.5cm]{"../../../src/View/ui/ressources/edit.png"} to open the \textit{Strickler} window. Here you can create couples of Strickler coefficients, the first one for the minor bed, the second one for the medium bed. Click on \textit{add} four times to create four new couple. Give them the folowing values:
\begin{center} \begin{center}
\includegraphics[width=15cm]{img/K.png} \includegraphics[width=15cm]{K.png}
\par\end{center} \par\end{center}
Close the \textit{Strickler} window. On the \textit{Edit friction} window, add four lines with the button \includegraphics[width=0.5cm]{img/gtk_add.png} to create four friction zones. Each zone is defined by a \textit{begin} and \textit{end} KP and a \textit{begin} and \textit{end} Strickler couple. The strickler coefficient couples inside a zone are interpolated from the \textit{begin} and \textit{end} couples. In our case, we will use constant coefficients per zone. Set the zones as follow: Close the \textit{Strickler} window. On the \textit{Edit friction} window, add four lines with the button \includegraphics[width=0.5cm]{gtk_add.png} to create four friction zones. Each zone is defined by a \textit{begin} and \textit{end} PK and a \textit{begin} and \textit{end} Strickler couple. The strickler coefficient couples inside a zone are interpolated from the \textit{begin} and \textit{end} couples. In our case, we will use constant coefficients per zone. Set the zones as follow:
\begin{center} \begin{center}
\includegraphics[width=15cm]{img/frictions.png} \includegraphics[width=15cm]{frictions.png}
\par\end{center} \par\end{center}
The selected zone is highlighted in blue. Close the \textit{Edit friction} window. The selected zone is highlighted in blue. Close the \textit{Edit friction} window.
@@ -204,34 +203,34 @@ The selected zone is highlighted in blue. Close the \textit{Edit friction} windo
\section{Model hydraulic structures} \section{Model hydraulic structures}
Sometimes there can be cross-sections in which Shallow water equations can not be used to model the water flow. In that case, we have to define an other law to link the water elevation and the flow discharge. This is the case, for example, under bridges when the water elevation is too high, leading to a flow in charge. Pamhyr2 enables to define various hydraulic structures with laws that can be parametrized. In our case, a weir and two bridges have to be represented as hydraulic structures. Sometimes there can be cross-sections in which Shallow water equations can not be used to model the water flow. In that case, we have to define an other law to link the water elevation and the flow discharge. This is the case, for example, under bridges when the water elevation is too high, leading to a flow in charge. Pamhyr2 enables to define various hydraulic structures with laws that can be parametrized. In our case, a weir and two bridges have to be represented as hydraulic structures.
From the main window, click on \texttt{[Hydraulics] => [Hydraulic structures]} to open the hydraulic structures window. Click tree times on the \includegraphics[width=0.5cm]{img/gtk_add.png} button to create three hydraulic structures. Each structure can have a name and must have a reach and a KP. Set them as follow: From the main window, click on \texttt{[Hydraulics] => [Hydraulic structures]} to open the hydraulic structures window. Click tree times on the \includegraphics[width=0.5cm]{gtk_add.png} button to create three hydraulic structures. Each structure can have a name and must have a reach and a kp. Set them as follow:
\begin{center} \begin{center}
\includegraphics[width=15cm]{img/hs.png} \includegraphics[width=15cm]{hs.png}
\par\end{center} \par\end{center}
Select the downstream weir and click on \includegraphics[width=0.5cm]{"img/edit.png"} to edit the laws of this structure. Hydraulic structures are composed of basic hydraulic structures. You can combine the laws of several basic hydraulic structures to setup your structure. For this weir, we only need a weir basic hydraulic structure. Click on \includegraphics[width=0.5cm]{img/gtk_add.png} to add a new basic hydraulic structure, give it the \textit{weir} type and set it up as folow: Select the downstream weir and click on \includegraphics[width=0.5cm]{"../../../src/View/ui/ressources/edit.png"} to edit the laws of this structure. Hydraulic structures are composed of basic hydraulic structures. You can combine the laws of several basic hydraulic structures to setup your structure. For this weir, we only need a weir basic hydraulic structure. Click on \includegraphics[width=0.5cm]{gtk_add.png} to add a new basic hydraulic structure, give it the \textit{weir} type and set it up as folow:
\begin{center} \begin{center}
\includegraphics[width=15cm]{img/seuil.png} \includegraphics[width=15cm]{seuil.png}
\par\end{center} \par\end{center}
Go back to the \textit{hydraulic structures} window. Go back to the \textit{hydraulic structures} window.
Select the RS101 bridge and click on \includegraphics[width=0.5cm]{"img/edit.png"} to edit the laws of this structure. A bridge can be modeled as a combination of an orifice for the flow under the bridge and a weir for the flow over the bridge. Create two basic hydraulic structures and set them as folow: Select the RS101 bridge and click on \includegraphics[width=0.5cm]{"../../../src/View/ui/ressources/edit.png"} to edit the laws of this structure. A bridge can be modeled as a combination of an orifice for the flow under the bridge and a weir for the flow over the bridge. Create two basic hydraulic structures and set them as folow:
\begin{center} \begin{center}
\includegraphics[width=15cm]{img/seuilRS101.png} \includegraphics[width=15cm]{seuilRS101.png}
\includegraphics[width=15cm]{img/orificeRS101.png} \includegraphics[width=15cm]{orificeRS101.png}
\par\end{center} \par\end{center}
Go back to the \textit{hydraulic structures} window and aply the same procedure for the Thivencelle bridge: Go back to the \textit{hydraulic structures} window and aply the same procedure for the Thivencelle bridge:
\begin{center} \begin{center}
\includegraphics[width=15cm]{img/orificeThivencelle.png} \includegraphics[width=15cm]{orificeThivencelle.png}
\includegraphics[width=15cm]{img/seuilThivencelle.png} \includegraphics[width=15cm]{seuilThivencelle.png}
\par\end{center} \par\end{center}
You can now close the \textit{hydraulic structures} windows. You can now close the \textit{hydraulic structures} windows.
@@ -242,7 +241,7 @@ From the main window, click on \texttt{[Execute] => [Numerical parameters for so
In the window \textit{solver parameters} select the \textit{Mage v8} tab. Set the solver parameters as follow: In the window \textit{solver parameters} select the \textit{Mage v8} tab. Set the solver parameters as follow:
\begin{center} \begin{center}
\includegraphics[width=15cm]{img/param.png} \includegraphics[width=15cm]{param.png}
\par\end{center} \par\end{center}
Close the \textit{solver parameters} window. Close the \textit{solver parameters} window.
@@ -257,9 +256,9 @@ From the \textit{Solver log} window you can re-run the computation, and from the
\section{Visualize the results} \section{Visualize the results}
If you closed the \textit{Solver log} window, you can click on \texttt{[Results] => [Visualize last results]} from the main window to open the \textit{Results} window. The top lets panel let you select your reach, the bottom left panel lets you select a cross-section in that reach. the three plots on the right show the reach and the cross-section the same way than in the \textit{Geometry} window. You can use the bottom slider to visualize the water elevation at different timesteps. If you closed the textit{Solver log} window, you can click on \texttt{[Results] => [Visualize last results]} from the main window to open the \textit{Results} window. The top lets panel let you select your reach, the bottom left panel lets you select a cross-section in that reach. the tree plots on the right show the reach and the cross-section the same way than in the \textit{Geometry} window. You can use the bottom slider to visualize the water elevation at different timesteps.
To visualize the flow discharge, switch to the \textit{Hydrograph} tab. To visualize the flow discharge, switch to the \textit{Hydrograph} tab.
To create custom 2D plots, click on the \includegraphics[width=0.5cm]{img/gtk_add.png} button on the top left of the window. Select the values you want on the $X$ and $Y$ axis and click on \textit{OK}. To create custom 2D plots, click on the \includegraphics[width=0.5cm]{gtk_add.png} button on the top left of the window. Select the values you want on the $X$ and $Y$ axis and click on \textit{OK}.
You can now see a new tab with the custom 2D plot in the right panel of the \textit{Results} window. You can now see a new tab with the custom 2D plot in the right panel of the \textit{Results} window.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1 -2
View File
@@ -4,10 +4,9 @@ PyQt5-sip==12.12.2
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.7.1 matplotlib>=3.4.1
numpy>=1.24.2 numpy>=1.24.2
colorama>=0.4.3 colorama>=0.4.3
pyinstaller>=5.11.0 pyinstaller>=5.11.0
shapely>=2.0.1 shapely>=2.0.1
lxml>=4.9.3 lxml>=4.9.3
platformdirs>=4.2.0
-21
View File
@@ -1,21 +0,0 @@
#! /bin/bash
set +x
OPTS="-r -a -i"
if [ "$1" == "builds" ]; then
FILES="../windows/ ../linux/"
else
FILES="../windows/pamhyr-windows.exe ../windows/pamhyr-windows.zip ../linux/pamhyr-gnulinux.tar.xz"
fi
clamscan $OPTS $FILES | tee clamav.log
RES=$(cat clamav.log | grep "Infected files: 0")
if [ -z "$RES" ]; then
echo "Infected files"
exit -1
else
echo "OK"
exit 0
fi
-3
View File
@@ -1,3 +0,0 @@
@echo off
start cmd /c pamhyr.exe debug
-3
View File
@@ -1,3 +0,0 @@
#! /bin/sh
./pamhyr debug
+19 -35
View File
@@ -16,35 +16,33 @@ rem along with this program. If not, see <https://www.gnu.org/licenses/>.
@ECHO ON @ECHO ON
mkdir pamhyr\_internal mkdir pamhyr\pamhyr\_internal
xcopy /s /e /y dist\pamhyr pamhyr xcopy /s /e /y dist\pamhyr pamhyr\pamhyr
rem Copy data rem Copy data
mkdir pamhyr\_internal\lang mkdir pamhyr\pamhyr\_internal\lang
mkdir pamhyr\_internal\View\ui\ressources mkdir pamhyr\pamhyr\_internal\View\ui\ressources
mkdir pamhyr\_internal\View\ui\Widgets mkdir pamhyr\pamhyr\_internal\View\ui\Widgets
rem UI rem UI
copy /y ..\src\View\ui\ressources\ pamhyr\_internal\View\ui\ressources copy /y ..\src\View\ui\ressources\ pamhyr\pamhyr\_internal\View\ui\ressources
copy /y ..\src\View\ui\Widgets\*.ui pamhyr\_internal\View\ui\Widgets copy /y ..\src\View\ui\Widgets\*.ui pamhyr\pamhyr\_internal\View\ui\Widgets
copy /y ..\src\View\ui\*.ui pamhyr\_internal\View\ui\ copy /y ..\src\View\ui\*.ui pamhyr\pamhyr\_internal\View\ui\
rem Lang rem Lang
copy /y ..\src\lang\*.qm pamhyr\_internal\lang\ copy /y ..\src\lang\*.qm pamhyr\pamhyr\_internal\lang\
rem Information rem Information
copy /y ..\VERSION pamhyr\_internal copy /y ..\VERSION pamhyr\pamhyr\_internal
copy /y ..\AUTHORS pamhyr\_internal copy /y ..\AUTHORS pamhyr\pamhyr\_internal
copy /y ..\LICENSE pamhyr\_internal copy /y ..\LICENSE pamhyr\pamhyr\_internal
copy /y ..\src\motd.txt pamhyr\_internal copy /y ..\src\motd.txt pamhyr\pamhyr\_internal
rem MAGE rem MAGE
mkdir pamhyr\mage8 mkdir pamhyr\mage
copy /y ..\mage8-windows\mage.exe pamhyr\mage8\ copy /y ..\mage-windows\mage.exe pamhyr\mage\
copy /y ..\mage8-windows\mage_as7.exe pamhyr\mage8\ copy /y ..\mage-windows\mage_extraire.exe pamhyr\mage\
copy /y ..\mage8-windows\mage_extraire.exe pamhyr\mage8\ copy /y ..\mage-windows\mailleurPF.exe pamhyr\mage\
copy /y ..\mage8-windows\mailleurTT.exe pamhyr\mage8\
copy /y ..\mage8-windows\libbief.dll pamhyr\mage8\
rem Copy tests_cases rem Copy tests_cases
mkdir pamhyr\tests_cases mkdir pamhyr\tests_cases
@@ -54,24 +52,10 @@ copy /y ..\tests_cases\Saar\Saar.pamhyr pamhyr\tests_cases\Saar\
rem Documentations rem Documentations
mkdir pamhyr\doc mkdir pamhyr\doc
mkdir pamhyr\doc\images mkdir pamhyr\doc\images
rem copy /y ..\doc\users\documentation.pdf pamhyr\doc\Pamhyr2-users.pdf copy /y ..\doc\users\documentation.pdf pamhyr\doc\Pamhyr2-users.pdf
copy /y ..\doc\dev\documentation.pdf pamhyr\doc\Pamhyr2-dev.pdf copy /y ..\doc\dev\documentation.pdf pamhyr\doc\Pamhyr2-dev.pdf
copy /y ..\doc\mage8.pdf pamhyr\doc\mage8.pdf copy /y ..\doc\users\documentation.html pamhyr\doc\Pamhyr2-users.html
rem copy /y ..\doc\users\documentation.html pamhyr\doc\Pamhyr2-users.html
copy /y ..\doc\dev\documentation.html pamhyr\doc\Pamhyr2-dev.html copy /y ..\doc\dev\documentation.html pamhyr\doc\Pamhyr2-dev.html
copy /y ..\doc\users\images\* pamhyr\doc\images copy /y ..\doc\users\images\* pamhyr\doc\images
copy /y ..\doc\dev\images\* pamhyr\doc\images copy /y ..\doc\dev\images\* pamhyr\doc\images
copy /y ..\doc\images\* pamhyr\doc\images copy /y ..\doc\images\* pamhyr\doc\images
rem Tuto
mkdir pamhyr\doc\Tuto1\
mkdir pamhyr\doc\Tuto1\data
copy /y ..\doc\users\Tuto1\Hogneau_Engees2022.pdf pamhyr\doc\Tuto1\Hogneau_Engees2022.pdf
copy /y ..\doc\users\Tuto1\step-by-step.pdf pamhyr\doc\Tuto1\Tuto1-en.pdf
copy /y ..\doc\users\Tuto1\pas-a-pas.pdf pamhyr\doc\Tuto1\Tuto1-fr.pdf
copy /y ..\doc\users\Tuto1\*.pamhyr pamhyr\doc\Tuto1\
copy /y ..\doc\users\Tuto1\data\* pamhyr\doc\Tuto1\data\
rem TP charriage
mkdir pamhyr\doc\TP_charriage
copy /y ..\doc\users\TP_charriage\ pamhyr\doc\TP_charriage
+3 -3
View File
@@ -5,7 +5,7 @@
Name "Pamhyr2" Name "Pamhyr2"
OutFile "pamhyr-windows.exe" OutFile "pamhyr-windows.exe"
LicenseData "pamhyr\_internal\LICENSE" LicenseData "pamhyr\pamhyr\_internal\LICENSE"
LicenseText "I Agree" LicenseText "I Agree"
RequestExecutionLevel admin RequestExecutionLevel admin
@@ -41,12 +41,12 @@ SectionEnd
Section "Start Menu Shortcuts" Section "Start Menu Shortcuts"
CreateDirectory "$SMPROGRAMS\Pamhyr2" CreateDirectory "$SMPROGRAMS\Pamhyr2"
CreateShortcut "$SMPROGRAMS\Pamhyr2\Uninstall.lnk" "$INSTDIR\uninstall.exe" CreateShortcut "$SMPROGRAMS\Pamhyr2\Uninstall.lnk" "$INSTDIR\uninstall.exe"
CreateShortcut "$SMPROGRAMS\Pamhyr2\Pamhyr2.lnk" "$INSTDIR\pamhyr.exe" CreateShortcut "$SMPROGRAMS\Pamhyr2\Pamhyr2.lnk" "$INSTDIR\pamhyr\pamhyr.exe"
SectionEnd SectionEnd
Section "Desktop Shortcuts" Section "Desktop Shortcuts"
SetShellVarContext all SetShellVarContext all
CreateShortcut "$desktop\Pamhyr2.lnk" "$instdir\pamhyr.exe" CreateShortcut "$desktop\Pamhyr2.lnk" "$instdir\pamhyr\pamhyr.exe"
SectionEnd SectionEnd
Section "Uninstall" Section "Uninstall"
+1 -2
View File
@@ -4,10 +4,9 @@ PyQt5-sip==12.12.2
#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.7.1 matplotlib>=3.4.1
numpy>=1.24.2 numpy>=1.24.2
colorama>=0.4.3 colorama>=0.4.3
pyinstaller>=5.11.0 pyinstaller>=5.11.0
shapely>=2.0.1 shapely>=2.0.1
lxml>=4.9.3 lxml>=4.9.3
platformdirs>=4.2.0
+2 -32
View File
@@ -1,5 +1,5 @@
# Checker.py -- Pamhyr abstract checker class # Checker.py -- Pamhyr abstract checker class
# Copyright (C) 2023-2024 INRAE # Copyright (C) 2023 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
@@ -16,53 +16,23 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import logging
from enum import Enum from enum import Enum
from Modules import Modules
from Model.Except import NotImplementedMethodeError from Model.Except import NotImplementedMethodeError
logger = logging.getLogger()
class STATUS(Enum): class STATUS(Enum):
UNKNOWN = -1
OK = 0 OK = 0
WARNING = 1 WARNING = 1
ERROR = 2 ERROR = 2
UNKNOWN = 999
def __eq__(self, y):
return self.value == y.value
def __gt__(self, y):
return self.value > y.value
def __or__(self, y):
v = [self, y]
r = self.OK
if self.UNKNOWN in v:
r = self.UNKNOWN
if self.ERROR in v:
r = self.ERROR
if self.WARNING in v:
r = self.WARNING
logger.debug(f"CHECKER: STATUS: {self} | {y} = {r}")
return r
class AbstractModelChecker(object): class AbstractModelChecker(object):
def __init__(self): def __init__(self):
self._name = "" self._name = ""
self._description = "" self._description = ""
self._solver = "study"
self._modules = Modules.NONE
self.reset()
def reset(self):
self._status = STATUS.UNKNOWN self._status = STATUS.UNKNOWN
self._summary = "Unknown" self._summary = "Unknown"
+2 -58
View File
@@ -1,5 +1,5 @@
# Mage.py -- Pamhyr MAGE checkers # Mage.py -- Pamhyr MAGE checkers
# Copyright (C) 2023-2024 INRAE # Copyright (C) 2023 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
@@ -23,16 +23,13 @@ from tools import flatten, timer
from PyQt5.QtCore import QCoreApplication from PyQt5.QtCore import QCoreApplication
from Modules import Modules
from Checker.Checker import AbstractModelChecker, STATUS from Checker.Checker import AbstractModelChecker, STATUS
from Checker.Study import StudyGeometryChecker
_translate = QCoreApplication.translate _translate = QCoreApplication.translate
class MageNetworkGraphChecker(AbstractModelChecker): class MageNetworkGraphChecker(AbstractModelChecker):
def __init__(self, connectivity=True, version="mage8"): def __init__(self, connectivity=True):
super(MageNetworkGraphChecker, self).__init__() super(MageNetworkGraphChecker, self).__init__()
self._mode_conn = connectivity self._mode_conn = connectivity
@@ -46,8 +43,6 @@ class MageNetworkGraphChecker(AbstractModelChecker):
"Checker", f"Mage network graph {mode} checker") "Checker", f"Mage network graph {mode} checker")
self._description = _translate( self._description = _translate(
"Checker", "Check if the network graph is valid") "Checker", "Check if the network graph is valid")
self._solver = version
self._modules = Modules.NETWORK
@timer @timer
def _connectivity(self, summary, status, graph): def _connectivity(self, summary, status, graph):
@@ -200,54 +195,3 @@ class MageNetworkGraphChecker(AbstractModelChecker):
self._summary = summary self._summary = summary
self._status = status self._status = status
return True return True
class MageGeometryGuideLineChecker(StudyGeometryChecker):
def __init__(self, version="mage8"):
super(MageGeometryGuideLineChecker, self).__init__()
self._name = _translate("Checker", "Mage geometry guide line checker")
self._description = _translate(
"Checker",
"Check if exists geometry guide line is correctly defined \
for each reaches of the study"
)
self._solver = version
self._modules = Modules.GEOMETRY
self._reachs = []
def run(self, study):
ok = super(MageGeometryGuideLineChecker, self).run(study)
if not ok:
return ok
river = study.river
edges = river.enable_edges()
gls = []
for edge in edges:
comp, incomp = edge.reach.compute_guidelines()
if len(incomp) != 0:
self._status = STATUS.WARNING
self._summary = "incomplete_guideline"
return False
gls.append(comp)
profiles = edge.reach.profiles
for profile in profiles:
if not profile.has_standard_named_points():
self._status = STATUS.WARNING
self._summary = "no_standard_guileline_defined"
return False
for gl in gls[1:]:
if len(gls[0].symmetric_difference(gl)) != 0:
self._status = STATUS.WARNING
self._summary = "no_all_reaches_do_not_have_same_defined"
return False
return ok
+6 -12
View File
@@ -1,5 +1,5 @@
# Study.py -- Pamhyr study checkers # Study.py -- Pamhyr study checkers
# Copyright (C) 2023-2024 INRAE # Copyright (C) 2023 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
@@ -20,7 +20,6 @@ import time
from PyQt5.QtCore import QCoreApplication from PyQt5.QtCore import QCoreApplication
from Modules import Modules
from Checker.Checker import AbstractModelChecker, STATUS from Checker.Checker import AbstractModelChecker, STATUS
_translate = QCoreApplication.translate _translate = QCoreApplication.translate
@@ -32,9 +31,7 @@ class StudyNetworkReachChecker(AbstractModelChecker):
self._name = _translate("Checker", "Study network reach checker") self._name = _translate("Checker", "Study network reach checker")
self._description = _translate( self._description = _translate(
"Checker", "Check if exists at least one reach for study" "Checker", "Check if exists at least one reach for study")
)
self._modules = Modules.NETWORK
def run(self, study): def run(self, study):
if study is None: if study is None:
@@ -65,10 +62,7 @@ class StudyGeometryChecker(AbstractModelChecker):
self._name = _translate("Checker", "Study geometry checker") self._name = _translate("Checker", "Study geometry checker")
self._description = _translate( self._description = _translate(
"Checker", "Check if exists geometry for each reach of study" "Checker", "Check if exists geometry for each reach of study")
)
self._modules = Modules.GEOMETRY
self._reachs = [] self._reachs = []
def run(self, study): def run(self, study):
@@ -88,15 +82,15 @@ class StudyGeometryChecker(AbstractModelChecker):
self._summary = "no_river_found" self._summary = "no_river_found"
return False return False
edges = river.enable_edges() edges = list(filter(lambda e: e.is_enable(), river.edges()))
if len(edges) == 0: if len(edges) == 0:
self._status = STATUS.ERROR self._status = STATUS.ERROR
self._summary = "no_reach_defined" self._summary = "no_reach_defined"
return False return False
for edge in edges: for edge in edges:
if len(edge.reach.profiles) < 2: if edge.is_enable() and len(edge.reach.profiles) < 3:
summary = "no_geometry_defined" summary = f"no_geometry_defined"
status = STATUS.ERROR status = STATUS.ERROR
ok = False ok = False
self._reachs.append(edge) self._reachs.append(edge)
-27
View File
@@ -1,27 +0,0 @@
# AMeshingTool.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 Model.Except import NotImplementedMethodeError
class AMeshingTool(object):
def __init__(self):
super(AMeshingTool, self).__init__()
def meshing(self, reach, **kwargs):
raise NotImplementedMethodeError(self, self.meshing)
-369
View File
@@ -1,369 +0,0 @@
# Mage.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 tempfile
from ctypes import (
cdll,
byref, Structure,
c_char_p, c_wchar_p,
create_string_buffer,
POINTER, c_void_p,
c_int, c_double, c_bool
)
from PyQt5.QtCore import QProcess
from tools import logger_color_red, logger_color_reset, logger_exception
from Meshing.AMeshingTool import AMeshingTool
logger = logging.getLogger()
class MeshingWithMage(AMeshingTool):
def __init__(self):
super(MeshingWithMage, self).__init__()
self._init_bief_lib()
def _init_bief_lib(self):
self._bief_lib = cdll.LoadLibrary(self._lib_path())
self._init_c_init_bief_from_geo_file()
self._init_c_get_nb_sections()
self._init_c_get_nb_points_section()
self._init_c_set_bief_name()
self._init_c_st_to_m_compl()
self._init_c_interpolate_profils_pas_transversal()
self._init_c_purge()
self._init_c_output_bief()
@classmethod
def _lib_path(cls):
ext = "so" if os.name == "posix" else "dll"
return os.path.abspath(
os.path.join(
os.path.dirname(__file__),
"..", "..", "..", "mage", f"libbief.{ext}"
)
)
@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'
)
self._c_init_bief_from_geo_file.argtypes = [
c_char_p, POINTER(c_int), POINTER(c_int)
]
self._c_init_bief_from_geo_file.restype = None
def _init_c_get_nb_sections(self):
self._c_get_nb_sections = getattr(self._bief_lib, 'c_get_nb_sections')
self._c_get_nb_sections.argtypes = [POINTER(c_int)]
self._c_get_nb_sections.restype = None
def _init_c_get_nb_points_section(self):
self._c_get_nb_points_section = getattr(
self._bief_lib, 'c_get_nb_points_section'
)
self._c_get_nb_points_section.argtypes = [
POINTER(c_int), POINTER(c_int)
]
self._c_get_nb_points_section.restype = None
def _init_c_set_bief_name(self):
self._c_set_bief_name = getattr(self._bief_lib, 'c_set_bief_name')
self._c_set_bief_name.argtypes = [c_char_p]
self._c_set_bief_name.restype = None
def _init_c_st_to_m_compl(self):
self._c_st_to_m_compl = getattr(self._bief_lib, 'c_st_to_m_compl')
self._c_st_to_m_compl.argtypes = [POINTER(c_int), c_char_p, c_char_p]
self._c_st_to_m_compl.restype = None
def _init_c_interpolate_profils_pas_transversal(self):
self._c_interpolate_profils_pas_transversal = getattr(
self._bief_lib, 'c_interpolate_profils_pas_transversal'
)
self._c_interpolate_profils_pas_transversal.argtypes = [
POINTER(c_int), POINTER(c_int),
c_char_p, c_char_p,
POINTER(c_double), POINTER(c_bool),
POINTER(c_int), POINTER(c_bool)
]
self._c_interpolate_profils_pas_transversal.restype = None
def _init_c_purge(self):
self._c_purge = getattr(self._bief_lib, 'c_purge')
self._c_purge.argtypes = None
self._c_purge.restype = None
def _init_c_output_bief(self):
self._c_output_bief = getattr(self._bief_lib, 'c_output_bief')
self._c_output_bief.argtypes = [c_char_p]
self._c_output_bief.restype = None
#####################
# Binding functions #
#####################
def init_bief_from_geo_file(self, name, with_charriage, with_water):
cname = create_string_buffer(name.encode())
self._c_init_bief_from_geo_file(
cname,
byref(c_int(with_charriage)),
byref(c_int(with_water))
)
def get_nb_sections(self):
nb_sections = c_int(0)
self._c_get_nb_sections(byref(nb_sections))
return nb_sections.value
def get_nb_points_section(self, section):
nb_points = c_int(0)
self._c_get_nb_points_section(
byref(c_int(section)), byref(nb_points)
)
return nb_points.value
def set_bief_name(self, name):
cname = create_string_buffer(name.encode())
self._c_set_bief_name(cname)
def st_to_m_compl(self, npoints, tag1=' ', tag2=' '):
cnpoints = c_int(npoints)
ctag1 = create_string_buffer(tag1.encode())
ctag2 = create_string_buffer(tag2.encode())
self._c_st_to_m_compl(byref(cnpoints), ctag1, ctag2)
def interpolate_profils_pas_transversal(self, limite1, limite2,
directrice1, directrice2,
pas, lplan=False,
lm=3, lineaire=False):
climite1 = c_int(limite1)
climite2 = c_int(limite2)
cpas = c_double(pas)
clplan = c_bool(lplan)
clm = c_int(lm)
clineaire = c_bool(lineaire)
cdirectrice1 = create_string_buffer(directrice1.encode())
cdirectrice2 = create_string_buffer(directrice2.encode())
self._c_interpolate_profils_pas_transversal(
byref(climite1), byref(climite2),
cdirectrice1, cdirectrice2,
byref(cpas), byref(clplan),
byref(clm), byref(clineaire)
)
def output_bief(self, name):
cname = create_string_buffer(name.encode())
self._c_output_bief(cname)
###########
# Meshing #
###########
def meshing(self, reach, step: float = 50):
if reach is None or len(reach.profiles) == 0:
return reach
with tempfile.TemporaryDirectory() as tmp:
st_file = self.export_reach_to_st(reach, tmp)
m_file = st_file.rsplit(".ST", 1)[0] + ".M"
self.load_st_file(st_file)
ns, npts_max = self.get_reach_stat()
gl = reach.compute_guidelines()
# we make sure that the lines are in the left-to-right order
guide_list = [
x.name
for x in reach.profiles[0].named_points()
if x.name in gl[0]
]
self.complete_cross_section(guide_list)
self.interpolate_cross_section(ns, step)
self.purge()
self.export_to_m(m_file)
self.import_m_file(reach, m_file)
return reach
def export_reach_to_st(self, reach, tmp):
tmp_st = os.path.join(tmp, "meshing.ST")
logger.debug(f"meshing: Export ST to {tmp_st}")
reach.export_reach(tmp_st)
return tmp_st
def load_st_file(self, st):
self.init_bief_from_geo_file(st, 0, 0)
self.set_bief_name("tmp")
def get_reach_stat(self):
ns = self.get_nb_sections()
npts_max = max(
map(
lambda i: self.get_nb_points_section(i),
range(1, ns)
)
)
return ns, npts_max
def complete_cross_section(self, gl=[]):
gl1 = ["un"] + gl
gl2 = gl + ["np"]
for gls in zip(gl1, gl2):
self.st_to_m_compl(0, gls[0], gls[1])
def interpolate_cross_section(self, ns, step: float):
self.interpolate_profils_pas_transversal(
1, ns,
'un', 'np',
step
)
def purge(self):
self._c_purge()
def export_to_m(self, m):
self.output_bief(m)
def import_m_file(self, reach, m):
reach.purge()
logger.debug(f"meshing: Import geometry from {m}")
reach.import_geometry(m)
class MeshingWithMageMailleurTT(AMeshingTool):
def __init__(self):
super(MeshingWithMageMailleurTT, self).__init__()
@classmethod
def _exe_path(cls):
ext = "" if os.name == "posix" else ".exe"
return os.path.abspath(
os.path.join(
os.path.dirname(__file__),
"..", "..", "mage8", f"mailleurTT{ext}"
)
)
@classmethod
def _path(cls):
return cls._exe_path()
###########
# Meshing #
###########
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
with tempfile.TemporaryDirectory() as tmp:
logger.debug(f"temp file: {tmp}")
st_file = self.export_reach_to_st(reach, tmp)
m_file = st_file.rsplit(".ST", 1)[0] + ".M"
os.sync()
proc = QProcess()
proc.setWorkingDirectory(tmp)
lplan = 1 if lplan else 0
linear = 1 if linear else 0
logger.info(
f"! {self._exe_path()} {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(),
list(map(
str,
[
st_file, m_file, step,
limites[0], limites[1],
directrices[0], directrices[1],
lplan, lm, linear
]
))
)
proc.waitForFinished()
if proc.exitCode() != 0:
logger.error(
f"{logger_color_red()}" +
f"MailleurTT error: {proc.exitCode()}" +
f"{logger_color_reset()}"
)
outputs = proc.readAllStandardOutput()
logger.debug(outputs)
errors = proc.readAllStandardError()
logger.error(
f"{logger_color_red()}{errors}{logger_color_reset()}"
)
else:
self.import_m_file(reach, m_file)
return reach
def export_reach_to_st(self, reach, tmp):
tmp_st = os.path.join(tmp, "meshing.ST")
logger.debug(f"meshing: Export ST to {tmp_st}")
reach.export_reach(tmp_st)
return tmp_st
def import_m_file(self, reach, m):
if os.path.exists(m):
reach.purge()
logger.debug(f"meshing: Import geometry from {m}")
reach.import_geometry(m)
else:
logger.error(f"meshing: Meshed geometry file {m} do not exists")
-17
View File
@@ -1,17 +0,0 @@
# __init__.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 -*-
-43
View File
@@ -1,43 +0,0 @@
# test_Model.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 unittest
import warnings
import tempfile
from Model.Saved import SavedStatus
from Model.Study import Study
from Model.River import River
from Meshing.Mage import MeshingWithMage, MeshingWithMageMailleurTT
mage_mesher = os.path.exists(MeshingWithMage._lib_path())
mage_mesher_TT = os.path.exists(MeshingWithMageMailleurTT._exe_path())
class MeshingTestCase(unittest.TestCase):
@unittest.skipIf(not mage_mesher, "libbief is not available")
def test_create_meshingtool_mage(self):
mesher = MeshingWithMage()
self.assertNotEqual(mesher, None)
@unittest.skipIf(not mage_mesher_TT, "mailleurTT is not available")
def test_create_meshingtool_mageTT(self):
mesher = MeshingWithMageMailleurTT()
self.assertNotEqual(mesher, None)
-178
View File
@@ -1,178 +0,0 @@
# AddFile.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
from Model.Except import NotImplementedMethodeError
class AddFile(SQLSubModel):
_sub_classes = []
_id_cnt = 0
def __init__(self, id: int = -1, enabled=True,
name="", path="", text="",
status=None):
super(AddFile, self).__init__()
if id == -1:
self.id = AddFile._id_cnt
else:
self.id = id
self._status = status
self._enabled = enabled
self._name = f"File {self.id}" if name == "" else name
self._path = path
self._text = text
AddFile._id_cnt = max(id, AddFile._id_cnt+1)
def __getitem__(self, key):
value = None
if key == "enabled":
value = self._enabled
elif key == "name":
value = self._name
elif key == "path":
value = self._path
elif key == "text":
value = self._text
return value
def __setitem__(self, key, value):
if key == "enabled":
self._enabled = value
elif key == "name":
self._name = value
elif key == "path":
self._path = value
elif key == "text":
self._text = value
self._status.modified()
@property
def enabled(self):
return self._enabled
@enabled.setter
def enabled(self, enabled):
self._enabled = enabled
self._status.modified()
def is_enabled(self):
return self._enabled
@property
def name(self):
return self._name
@name.setter
def name(self, name):
self._name = name
self._status.modified()
@property
def path(self):
return self._path
@path.setter
def path(self, path):
self._path = path
self._status.modified()
@property
def text(self):
return self._text
@text.setter
def text(self, text):
self._text = text
self._status.modified()
@classmethod
def _db_create(cls, execute):
execute("""
CREATE TABLE additional_files(
id INTEGER NOT NULL PRIMARY KEY,
enabled BOOLEAN NOT NULL,
name TEXT NOT NULL,
path TEXT NOT NULL,
text TEXT NOT NULL
)
""")
return cls._create_submodel(execute)
@classmethod
def _db_update(cls, execute, version):
major, minor, release = version.strip().split(".")
if major == minor == "0":
if int(release) < 8:
cls._db_create(execute)
return True
@classmethod
def _db_load(cls, execute, data=None):
new = []
table = execute(
"SELECT id, enabled, name, path, text " +
"FROM additional_files"
)
for row in table:
it = iter(row)
id = next(it)
enabled = (next(it) == 1)
name = next(it)
path = next(it)
text = next(it)
f = cls(
id=id, enabled=enabled, name=name, path=path, text=text,
status=data['status']
)
new.append(f)
return new
def _db_save(self, execute, data=None):
sql = (
"INSERT INTO " +
"additional_files(id, enabled, name, path, text) " +
"VALUES (" +
f"{self.id}, {self._enabled}, " +
f"'{self._db_format(self._name)}', " +
f"'{self._db_format(self._path)}', " +
f"'{self._db_format(self._text)}'" +
")"
)
execute(sql)
return True
-56
View File
@@ -1,56 +0,0 @@
# AddFileList.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
from Model.Except import NotImplementedMethodeError
from Model.Tools.PamhyrList import PamhyrModelList
from Model.AdditionalFile.AddFile import AddFile
class AddFileList(PamhyrModelList):
_sub_classes = [AddFile]
@classmethod
def _db_load(cls, execute, data=None):
new = cls(status=data["status"])
new._lst = AddFile._db_load(execute, data)
return new
def _db_save(self, execute, data=None):
ok = True
# Delete previous data
execute("DELETE FROM additional_files")
for af in self._lst:
ok &= af._db_save(execute, data)
return ok
@property
def files(self):
return self.lst
def new(self, index):
n = AddFile(status=self._status)
self.insert(index, n)
self._status.modified()
return n
@@ -1,5 +1,5 @@
# BoundaryCondition.py -- Pamhyr # BoundaryCondition.py -- Pamhyr
# Copyright (C) 2023-2024 INRAE # Copyright (C) 2023 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
@@ -18,12 +18,7 @@
import logging import logging
from tools import ( from tools import trace, timer, old_pamhyr_date_to_timestamp
trace, timer,
old_pamhyr_date_to_timestamp,
date_iso_to_timestamp,
date_dmy_to_timestamp,
)
from Model.Tools.PamhyrDB import SQLSubModel from Model.Tools.PamhyrDB import SQLSubModel
from Model.Except import NotImplementedMethodeError from Model.Except import NotImplementedMethodeError
@@ -194,10 +189,6 @@ class BoundaryCondition(SQLSubModel):
@classmethod @classmethod
def time_convert(cls, data): def time_convert(cls, data):
if type(data) is str: if type(data) is str:
if data.count("-") == 2:
return date_iso_to_timestamp(data)
if data.count("/") == 2:
return date_dmy_to_timestamp(data)
if data.count(":") == 3: if data.count(":") == 3:
return old_pamhyr_date_to_timestamp(data) return old_pamhyr_date_to_timestamp(data)
if data.count(":") == 2: if data.count(":") == 2:
@@ -209,9 +200,6 @@ class BoundaryCondition(SQLSubModel):
@property @property
def name(self): def name(self):
if self._name == "":
return f"B{self.id + 1}"
return self._name return self._name
@name.setter @name.setter
@@ -1,5 +1,5 @@
# BoundaryConditionList.py -- Pamhyr # BoundaryConditionList.py -- Pamhyr
# Copyright (C) 2023-2024 INRAE # Copyright (C) 2023 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-2024 INRAE # Copyright (C) 2023 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 -36
View File
@@ -1,5 +1,5 @@
# Except.py -- Pamhyr model exceptions # Except.py -- Pamhyr model exceptions
# Copyright (C) 2023-2024 INRAE # Copyright (C) 2023 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
@@ -179,38 +179,3 @@ class ClipboardFormatError(ExeceptionWithMessageBox):
def message(self): def message(self):
return self.msg return self.msg
class ExternFileMissingError(ExeceptionWithMessageBox):
def __init__(self, module="mage", filename="libbief", path="??/libbief.so",
src_except=None):
super(ExternFileMissingError, self).__init__(
title=_translate(
"Exception", "External file dependence is missing"
)
)
self.msg = _translate(
"Exception",
"'@file' is missing for module @module:\n'@path'"
)
self.msg = self.msg.replace("@file", filename)
self.msg = self.msg.replace("@module", module)
self.msg = self.msg.replace("@path", path)
if src_except is not None:
self.msg = self.msg + "\n\n" + f"Exception: {src_except}"
self.alert()
def __str__(self):
return self.msg
def header(self):
return _translate("Exception", "External file dependence is missing")
def short_message(self):
return _translate("Exception", "External file dependence is missing")
def message(self):
return self.msg
+15 -44
View File
@@ -1,5 +1,5 @@
# Friction.py -- Pamhyr # Friction.py -- Pamhyr
# Copyright (C) 2023-2024 INRAE # Copyright (C) 2023 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
@@ -26,21 +26,11 @@ logger = logging.getLogger()
class Friction(SQLSubModel): class Friction(SQLSubModel):
_id_cnt = 0 def __init__(self, name: str = "", status=None):
def __init__(self, id: int = -1, name: str = "",
status=None):
super(Friction, self).__init__() super(Friction, self).__init__()
self._status = status self._status = status
if id == -1:
self.id = Friction._id_cnt
else:
self.id = id
Friction._id_cnt = max(self.id, Friction._id_cnt+1)
self._name = name self._name = name
self._edge = None self._edge = None
self._begin_kp = 0.0 self._begin_kp = 0.0
@@ -52,13 +42,13 @@ class Friction(SQLSubModel):
def _db_create(cls, execute): def _db_create(cls, execute):
execute(""" execute("""
CREATE TABLE friction( CREATE TABLE friction(
id INTEGER NOT NULL PRIMARY KEY, id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
ind INTEGER NOT NULL, ind INTERGER NOT NULL,
begin_kp REAL NOT NULL, begin_kp REAL NOT NULL,
end_kp REAL NOT NULL, end_kp REAL NOT NULL,
reach INTEGER NOT NULL, reach INTEGER NOT NULL,
begin_strickler INTEGER NOT NULL, begin_strickler INTERGER,
end_strickler INTEGER NOT NULL, end_strickler INTERGER,
FOREIGN KEY(reach) REFERENCES river_reach(id), FOREIGN KEY(reach) REFERENCES river_reach(id),
FOREIGN KEY(begin_strickler) REFERENCES stricklers(id), FOREIGN KEY(begin_strickler) REFERENCES stricklers(id),
FOREIGN KEY(end_strickler) REFERENCES stricklers(id) FOREIGN KEY(end_strickler) REFERENCES stricklers(id)
@@ -80,30 +70,21 @@ class Friction(SQLSubModel):
stricklers = data["stricklers"].stricklers stricklers = data["stricklers"].stricklers
table = execute( table = execute(
"SELECT id, ind, begin_kp, end_kp, " + "SELECT ind, begin_kp, end_kp, begin_strickler, end_strickler " +
"begin_strickler, end_strickler " +
f"FROM friction WHERE reach = {reach.id}" f"FROM friction WHERE reach = {reach.id}"
) )
for row in table: for row in table:
id = row[0] ind = row[0]
ind = row[1]
# Get stricklers # Get stricklers
if int(row[4]) == -1: bs = next(filter(lambda s: s.id == row[3], stricklers))
bs = None es = next(filter(lambda s: s.id == row[4], stricklers))
else:
bs = next(filter(lambda s: s.id == row[4], stricklers))
if int(row[5]) == -1:
es = None
else:
es = next(filter(lambda s: s.id == row[5], stricklers))
# Create friction # Create friction
sec = cls(status=status) sec = cls(status=status)
sec.edge = reach sec.edge = reach
sec.begin_kp = row[2] sec.begin_kp = row[1]
sec.end_kp = row[3] sec.end_kp = row[2]
sec.begin_strickler = bs sec.begin_strickler = bs
sec.end_strickler = es sec.end_strickler = es
@@ -113,24 +94,14 @@ class Friction(SQLSubModel):
def _db_save(self, execute, data=None): def _db_save(self, execute, data=None):
ind = data["ind"] ind = data["ind"]
b_s_id = -1
e_s_id = -1
if self._begin_strickler is not None:
b_s_id = self._begin_strickler.id
if self._end_strickler is not None:
e_s_id = self._end_strickler.id
execute( execute(
"INSERT INTO " + "INSERT INTO " +
"friction(id, ind, begin_kp, end_kp, " + "friction(ind, begin_kp, end_kp, " +
"reach, begin_strickler, end_strickler) " + "reach, begin_strickler, end_strickler) " +
"VALUES (" + "VALUES (" +
f"{self.id}, {ind}, " + f"{ind}, {self._begin_kp}, {self._end_kp}, " +
f"{self._begin_kp}, {self._end_kp}, " +
f"{self._edge.id}, " + f"{self._edge.id}, " +
f"{b_s_id}, {e_s_id}" + f"{self._begin_strickler.id}, {self._end_strickler.id}" +
")" ")"
) )
+1 -1
View File
@@ -1,5 +1,5 @@
# FrictionList.py -- Pamhyr # FrictionList.py -- Pamhyr
# Copyright (C) 2023-2024 INRAE # Copyright (C) 2023 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
View File
@@ -1,5 +1,5 @@
# Point.py -- Pamhyr # Point.py -- Pamhyr
# Copyright (C) 2023-2024 INRAE # Copyright (C) 2023 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
View File
@@ -1,5 +1,5 @@
# PointXY.py -- Pamhyr # PointXY.py -- Pamhyr
# Copyright (C) 2023-2024 INRAE # Copyright (C) 2023 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
+55 -3
View File
@@ -1,5 +1,5 @@
# PointXYZ.py -- Pamhyr # PointXYZ.py -- Pamhyr
# Copyright (C) 2023-2024 INRAE # Copyright (C) 2023 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
@@ -16,7 +16,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from math import dist from math import dist, sqrt, acos
import numpy as np import numpy as np
from Model.Tools.PamhyrDB import SQLSubModel from Model.Tools.PamhyrDB import SQLSubModel
@@ -47,7 +47,7 @@ class PointXYZ(Point, SQLSubModel):
z INTEGER NOT NULL, z INTEGER NOT NULL,
profile INTEGER NOT NULL, profile INTEGER NOT NULL,
sl INTEGER, sl INTEGER,
FOREIGN KEY(profile) REFERENCES geometry_profileXYZ(id), FOREIGN KEY(profile) REFERENCES profileXYZ(id),
FOREIGN KEY(sl) REFERENCES sedimentary_layer(id) FOREIGN KEY(sl) REFERENCES sedimentary_layer(id)
) )
""") """)
@@ -204,3 +204,55 @@ class PointXYZ(Point, SQLSubModel):
Euclidean distance between the two points Euclidean distance between the two points
""" """
return dist((p1.x, p1.y, p1.z), (p2.x, p2.y, p2.z)) return dist((p1.x, p1.y, p1.z), (p2.x, p2.y, p2.z))
@staticmethod
def angle(p1, p2, p3):
"""angle p1 p2 p3.
Args:
p1: A XYZ Point
p2: A XYZ Point
p3: A XYZ Point
Returns:
angle p1 p2 p3
"""
a = PointXYZ.distance(p1, p2)
b = PointXYZ.distance(p2, p3)
c = PointXYZ.distance(p1, p3)
return acos((a**2 + b**2 - c**2) / (2 * a * b))
@staticmethod
def triangle_height(p1, p2, p3):
"""triangle p1 p2 p3 height starting at p2.
Args:
p1: A XYZ Point
p2: A XYZ Point
p3: A XYZ Point
Returns:
triangle height starting at p2
"""
a = PointXYZ.distance(p1, p2)
b = PointXYZ.distance(p2, p3)
c = PointXYZ.distance(p1, p3)
h2 = a**2 - ((c**2 - b**2 + a**2) / 2*c)**2
return sqrt(h2)
@staticmethod
def triangle_area(p1, p2, p3):
"""triangle p1 p2 p3 area.
Args:
p1: A XYZ Point
p2: A XYZ Point
p3: A XYZ Point
Returns:
triangle height starting at p2
"""
h = PointXYZ.triangle_height(p1, p2, p3)
d = PointXYZ.distance(p1, p3)
return h*d/2
+15 -1
View File
@@ -1,5 +1,5 @@
# Profile.py -- Pamhyr # Profile.py -- Pamhyr
# Copyright (C) 2023-2024 INRAE # Copyright (C) 2023 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
@@ -214,6 +214,20 @@ class Profile(object):
self.points.insert(index, point) self.points.insert(index, point)
self._status.modified() self._status.modified()
def add_point(self, point:Point):
"""append point at end of profile.
Args:
point: The point.
Returns:
Nothing.
"""
self._points.append(point)
self._status.modified()
def delete_i(self, indexes: list): def delete_i(self, indexes: list):
self._points = list( self._points = list(
map( map(
+105 -63
View File
@@ -1,5 +1,5 @@
# ProfileXYZ.py -- Pamhyr # ProfileXYZ.py -- Pamhyr
# Copyright (C) 2023-2024 INRAE # Copyright (C) 2023 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
@@ -19,7 +19,6 @@
import logging import logging
import numpy as np import numpy as np
from typing import List from typing import List
from functools import reduce
from tools import timer from tools import timer
@@ -213,21 +212,11 @@ class ProfileXYZ(Profile, SQLSubModel):
return profile return profile
def point_from_data(self, header, data): def point_from_data(self, header, data):
def float_format(s: str):
return float(
s.replace(",", ".")
)
point = None point = None
try: try:
if len(header) == 0: if len(header) == 0:
x = float_format(data[0])
y = float_format(data[1])
z = float_format(data[2])
name = data[3] if len(data) == 4 else ""
point = PointXYZ( point = PointXYZ(
x, y, z, name, profile=self, status=self._status *data, profile=self, status=self._status
) )
else: else:
valid_header = {'name', 'x', 'y', 'z'} valid_header = {'name', 'x', 'y', 'z'}
@@ -320,23 +309,7 @@ class ProfileXYZ(Profile, SQLSubModel):
) )
except Exception as e: except Exception as e:
logger.debug(f"{e}") logger.debug(f"{e}")
raise IndexError( raise IndexError(f"Invalid point name: {name}")
f"Invalid point name: {name} " +
f"for profile ({self.id}) kp = {self.kp}"
)
def has_standard_named_points(self):
l, r = reduce(
lambda acc, n: (
(acc[0] | (n == "rg")),
(acc[1] | (n == "rd"))
),
map(lambda p: p.name.lower().strip(),
self.points),
(False, False)
)
return l & r
def add(self): def add(self):
"""Add a new PointXYZ to profile. """Add a new PointXYZ to profile.
@@ -467,66 +440,135 @@ class ProfileXYZ(Profile, SQLSubModel):
return list(map(lambda s: s - constant, station)) return list(map(lambda s: s - constant, station))
@timer
def length(self) -> list:
l = []
x = self.x()
y = self.y()
z = self.z()
for i in range(len(self.points)-1):
dx = x[i+1] - x[i]
dy = y[i+1] - y[i]
dz = z[i+1] - z[i]
l.append( np.sqrt(dx*dx + dy*dy + dz*dz) )
return l
@timer
def cumul_length(self) -> list:
lcum = []
lc = 0.0
l = self.length()
for i in l:
lc = lc + i
lcum.append(lc)
return lcum
@timer
def purge1(self, np) -> list:
points = self.points
if (self.number_points <= np): return points
while len(points) > np:
x1 = [point.x() for point in points]
y1 = [point.y() for point in points]
z1 = [point.z() for point in points]
l = [(x*x+y*y+z*z) for (x,y,z) in zip(x1,y1,z1)]
l2 = [(x + y) for (x, y) in zip(l[:-1], l[1:])]
imin = np.argmin(l2)+1
points.pop(imin)
return points
@timer
def purge2(self, np) -> list:
points = self.points
if (self.number_points <= np): return points
while len(points) > np:
l2 = []
for i in range(len(points)-2):
l2.append(PointXYZ.angle(points(i),points(i+1),points(i+2)))
imax = np.argmax(l2)+1
points.pop(imax)
return points
@timer
def purge3(self, np) -> list:
points = self.points
if (self.number_points <= np): return points
while len(points) > np:
l2 = []
for i in range(len(points)-2):
l2.append(PointXYZ.triangle_area(points(i),points(i+1),points(i+2)))
imin = np.argmin(l2)+1
points.pop(imin)
return points
def width_approximation(self): def width_approximation(self):
if self.has_standard_named_points():
rg = self.get_point_by_name("rg") rg = self.get_point_by_name("rg")
rd = self.get_point_by_name("rd") rd = self.get_point_by_name("rd")
else:
rg = self.points[0]
rd = self.points[-1]
return abs(rg.dist(rd)) return abs(rg.dist(rd))
def get_water_limits(self, z): def get_water_limits(self, z):
""" # ====================================================================
Determine left and right limits of water elevation. # 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
# ====================================================================
# Get the index of first point with elevation lesser than water # initialisation
# elevation (for the right and left river side) irg = -1
i_left = -1 ird = -1
i_right = -1
for i in range(self.number_points): for i in range(self.number_points):
if self.point(i).z <= z: if self.point(i).z <= z:
i_left = i irg = i
break
for i in reversed(range(self.number_points)): for i in reversed(range(self.number_points)):
if self.point(i).z <= z: if self.point(i).z <= z:
i_right = i ird = i
break
# Interpolate points at river left side # interpolation des points ptX et ptY
if (i_left > 0): if (irg < self.number_points - 1):
x = np.interp( x = np.interp(
z, z,
[self.point(i_left).z, self.point(i_left - 1).z], [self.point(irg).z, self.point(irg + 1).z],
[self.point(i_left).x, self.point(i_left - 1).x] [self.point(irg).x, self.point(irg + 1).x]
) )
y = np.interp( y = np.interp(
z, z,
[self.point(i_left).z, self.point(i_left - 1).z], [self.point(irg).z, self.point(irg + 1).z],
[self.point(i_left).y, self.point(i_left - 1).y] [self.point(irg).y, self.point(irg + 1).y]
) )
pt_left = PointXYZ(x, y, z) ptX = PointXYZ(x, y, z)
else: else:
pt_left = self.point(0) ptX = self.point(0)
if (ird > 0):
# Interpolate points at river right side
if (i_right < self.number_points - 1):
x = np.interp( x = np.interp(
z, z,
[self.point(i_right).z, self.point(i_right + 1).z], [self.point(ird-1).z, self.point(ird).z],
[self.point(i_right).x, self.point(i_right + 1).x] [self.point(ird-1).x, self.point(ird).x]
) )
y = np.interp( y = np.interp(
z, z,
[self.point(i_right).z, self.point(i_right + 1).z], [self.point(ird).z, self.point(ird - 1).z],
[self.point(i_right).y, self.point(i_right + 1).y] [self.point(ird).y, self.point(ird - 1).y]
) )
pt_right = PointXYZ(x, y, z) ptY = PointXYZ(x, y, z)
else: else:
pt_right = self.point(self.number_points - 1) ptY = self.point(self.number_points - 1)
return pt_left, pt_right return ptX, ptY
+285 -109
View File
@@ -1,5 +1,5 @@
# Reach.py -- Pamhyr # Reach.py -- Pamhyr
# Copyright (C) 2023-2024 INRAE # Copyright (C) 2023 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
@@ -25,7 +25,7 @@ from copy import deepcopy
from operator import itemgetter from operator import itemgetter
from functools import reduce from functools import reduce
from tools import flatten, timer, trace, logger_exception from tools import flatten, timer, trace
from Model.Tools.PamhyrDB import SQLSubModel from Model.Tools.PamhyrDB import SQLSubModel
@@ -65,7 +65,7 @@ class Reach(SQLSubModel):
new._profiles = ProfileXYZ._db_load( new._profiles = ProfileXYZ._db_load(
execute, execute,
data=data.copy() data=data
) )
return new return new
@@ -111,7 +111,7 @@ class Reach(SQLSubModel):
def _get_profiles_list(self): def _get_profiles_list(self):
# Profiles list generator is type (int, Point) with the first # Profiles list generator is type (int, Point) with the first
# element the index of the Point in list # element the index of the Point in list
logger.debug(f"Load profiles from reach {self.name}") logger.info(f"Load profiles from reach {self.name}")
return list( return list(
map( map(
lambda p: p[1], lambda p: p[1],
@@ -247,11 +247,6 @@ class Reach(SQLSubModel):
self._update_profile_numbers() self._update_profile_numbers()
self._status.modified() self._status.modified()
def purge(self):
self._profiles = []
self._update_profile_numbers()
self._status.modified()
def move_up_profile(self, index: int): def move_up_profile(self, index: int):
if index < len(self.profiles): if index < len(self.profiles):
next = index - 1 next = index - 1
@@ -269,37 +264,13 @@ class Reach(SQLSubModel):
self._status.modified() self._status.modified()
def get_x(self): def get_x(self):
return list( return [profile.x() for profile in self.profiles]
map(
lambda profile: profile.x(),
filter(
lambda profile: len(profile) > 0,
self.profiles
)
)
)
def get_y(self): def get_y(self):
return list( return [profile.y() for profile in self.profiles]
map(
lambda profile: profile.y(),
filter(
lambda profile: len(profile) > 0,
self.profiles
)
)
)
def get_z(self): def get_z(self):
return list( return [profile.z() for profile in self.profiles]
map(
lambda profile: profile.z(),
filter(
lambda profile: len(profile) > 0,
self.profiles
)
)
)
def get_z_min(self): def get_z_min(self):
"""List of z min for each profile """List of z min for each profile
@@ -307,15 +278,7 @@ class Reach(SQLSubModel):
Returns: Returns:
List of z min for each profile List of z min for each profile
""" """
return list( return [profile.z_min() for profile in self.profiles]
map(
lambda profile: profile.z_min(),
filter(
lambda profile: len(profile) > 0,
self.profiles
)
)
)
def get_z_max(self): def get_z_max(self):
"""List of z max for each profile """List of z max for each profile
@@ -323,15 +286,7 @@ class Reach(SQLSubModel):
Returns: Returns:
List of z max for each profile List of z max for each profile
""" """
return list( return [profile.z_max() for profile in self.profiles]
map(
lambda profile: profile.z_max(),
filter(
lambda profile: len(profile) > 0,
self.profiles
)
)
)
def get_kp(self): def get_kp(self):
"""List of profiles kp """List of profiles kp
@@ -341,28 +296,11 @@ class Reach(SQLSubModel):
""" """
return [profile.kp for profile in self.profiles] return [profile.kp for profile in self.profiles]
def get_kp_complete_profiles(self):
return list(
map(
lambda profile: profile.kp,
filter(
lambda profile: len(profile) > 0,
self.profiles
)
)
)
def get_kp_min(self): def get_kp_min(self):
if len(self.get_kp()) > 0:
return min(self.get_kp()) return min(self.get_kp())
else:
return 0.0
def get_kp_max(self): def get_kp_max(self):
if len(self.get_kp()) > 0:
return max(self.get_kp()) return max(self.get_kp())
else:
return 0.0
# Sediment Layers # Sediment Layers
@@ -431,7 +369,7 @@ class Reach(SQLSubModel):
Returns: Returns:
Tuple of complete and incomplete guidelines name. Tuple of complete and incomplete guidelines name.
""" """
# Get all point contained into a guideline # Get all point contains into a guideline
named_points = [profile.named_points() for profile in self.profiles] named_points = [profile.named_points() for profile in self.profiles]
points_name = list( points_name = list(
map( map(
@@ -544,7 +482,8 @@ class Reach(SQLSubModel):
Returns: Returns:
Nothing. Nothing.
""" """
imported_profiles = [] list_profile = []
list_header = []
try: try:
list_profile, list_header = self.read_file_st(str(file_path_name)) list_profile, list_header = self.read_file_st(str(file_path_name))
@@ -561,8 +500,9 @@ class Reach(SQLSubModel):
**d, reach=self, status=self._status **d, reach=self, status=self._status
) )
prof.import_points(profile) prof.import_points(profile)
self.profiles.append(prof)
self._update_profile_numbers()
imported_profiles.append(prof)
self._status.modified() self._status.modified()
except FileNotFoundError as e: except FileNotFoundError as e:
logger.error(e) logger.error(e)
@@ -570,11 +510,6 @@ class Reach(SQLSubModel):
except FileFormatError as e: except FileFormatError as e:
logger.error(e) logger.error(e)
e.alert() e.alert()
finally:
self.profiles = imported_profiles + self.profiles
self._update_profile_numbers()
return imported_profiles
@timer @timer
def read_file_st(self, filename): def read_file_st(self, filename):
@@ -590,8 +525,6 @@ class Reach(SQLSubModel):
list_header = [] list_header = []
stop_code = "999.999" stop_code = "999.999"
logger.debug(f"Import geometry from {filename}")
with open(filename, encoding="utf-8") as file_st: with open(filename, encoding="utf-8") as file_st:
for line in file_st: for line in file_st:
if not (line.startswith("#") or line.startswith("*")): if not (line.startswith("#") or line.startswith("*")):
@@ -630,31 +563,281 @@ class Reach(SQLSubModel):
# TODO: Move this function to model reach # TODO: Move this function to model reach
def export_reach(self, filename): def export_reach(self, filename):
with open(f"{filename}", "w") as st: with open(f"{filename}", "w") as file_st:
cnt = 0 for index in range(len(self.profiles)):
for profile in self.profiles: profile = self.profiles[index]
num = f"{cnt:>6}"
c1 = f"{profile.code1:>6}"
c2 = f"{profile.code2:>6}"
t = f"{len(profile.points):>6}"
kp = f"{profile.kp:>12f}"[0:12]
pname = profile.name
if profile.name == "":
pname = f"p{profile.id:>3}".replace(" ", "0")
st.write(f"{num}{c1}{c2}{t} {kp} {pname}\n") for v in profile.header:
file_st.write(f"{v:>6}")
file_st.write("\n")
for point in profile.points: for point in self._data.profile[index_pro].points:
x = f"{point.x:<12.4f}"[0:12] for i in [point.x, point.y, point.z, point.name]:
y = f"{point.y:<12.4f}"[0:12] file_st.write(f"{i:>13.4f}")
z = f"{point.z:<12.4f}"[0:12] file_st.write("\n")
n = f"{point.name:<3}"
st.write(f"{x} {y} {z} {n}\n") file_st.write(" 999.9990 999.9990 999.9990")
file_st.write("\n")
st.write(" 999.9990 999.9990 999.9990") # Interpolate
st.write("\n")
cnt += 1 @timer
def interpolate_step(self, lim: list, guideline1: str, guideline2: str, step: float, longmi: int, linear: bool):
"""interpolate with a given step between profile lim[0] and profile lim[1]
Args:
lim: index of profiles for interpolation
guideline1: first guideline for distance
guideline2: second guideline for distance
step: interpolation step
longmi: 1 if distance computed on min(dist(guideline1),dist(guideline2))
2 if distance computed on max(dist(guideline1),dist(guideline2))
else: distance computed on (dist(guideline1)+dist(guideline2))/2
linear: true if linear interpolation, false if spline interpolation
Returns:
List of profiles including old profiles and interpolated profiles.
"""
if len(lim) != 2:
print('TODO: CRITICAL ERROR!') # error for now, only one interval
if lim[0] < 0 or lim[0] >= lim[1] or lim[1] >= self.number_profiles:
print('TODO: CRITICAL ERROR!')
if lim[1] < 0 or lim[0] > lim[1]:
print('TODO: CRITICAL ERROR!')
comp, inconmp = self.compute_guidelines()
if not guideline1 in comp:
print('TODO: CRITICAL ERROR!')
if not guideline2 in comp:
print('TODO: CRITICAL ERROR!')
nbsti = [] # number of profiles to add between self._profile[i] and self._profile[i+1]
for i in range(lim[0]):
nbsti.append(0)
for i in range(lim[0],lim[1]-1):
points = self.profile(i).points
point11 = next(filter(lambda p: p.name == guideline1, points))
point12 = next(filter(lambda p: p.name == guideline2, points))
points = self.profile(i+1).points
point21 = next(filter(lambda p: p.name == guideline1, points))
point22 = next(filter(lambda p: p.name == guideline2, points))
d1 = point11.dist(point21)
d2 = point12.dist(point22) # warning: 3D distance
if (longmi == 1):
d = max(d1, d2)
elif (longmi == 2):
d = min(d1, d2)
else:
d = 0.5*(d1 + d2)
nbsti[i] = nint(d / pas) - 1
if(nbsti[i] < 0): nbsti[i] = 0
for i in range(lim[1]-1,self.number_profiles-1):
nbsti.append(0)
return self.interpolate_nprof(nbsti, lineaire)
@timer
def interpolate_nprof(self, nbsti: List[int], linear: bool):
"""add nbsti[i] profiles between self._profile[i] and self._profile[i+1]
Args:
nbsti: number of profiles to add between self._profile[i] and self._profile[i+1]
linear: true if linear interpolation, false if spline interpolation
Returns:
List of profiles including old profiles and interpolated profiles.
"""
if(lineaire):
return self.interpolate_linear(nbsti)
else:
# we might add the spline interpolation later
print('TODO: CRITICAL ERROR!')
@timer
def interpolate_linear(self, nbsti: List[int]):
"""add nbsti[i] profiles between self._profile[i] and self._profile[i+1]
Args:
nbsti: number of profiles to add between self._profile[i] and self._profile[i+1]
Returns:
List of profiles including old profiles and interpolated profiles.
"""
if len(nbsti) != self.number_profiles()-1:
print('TODO: CRITICAL ERROR!') # error for now, only one interval
sections_out = []
kps = self.get_kp()
for isect_in in range(len(nbsti)):
sections_out.append(self.profiles(isect_in))
dkp = kps[isect_in + 1] - kps[isect_in]
sect_in1 = self.profiles(isect_in)
sect_in2 = self.profiles(isect_in+1)
for isect_loc in range(nbsti[isect_in]):
# RATIO entre les deux sections initiales
d=float(isect_loc)/float(nbsti(isect_in)+1)
x1 = sect_in1.x()
y1 = sect_in1.y()
z1 = sect_in1.z()
x2 = sect_in2.x()
y2 = sect_in2.y()
z2 = sect_in2.z()
tags = sect_in1.names()
section_out.append(ProfileXYZ(kp = kps[isect_in] + d*dkp,
reach = self))
for i in range(len(x1)): # can do better...
# add the points to the created section
sections_out[-1].add_point(PointXYZ(x = x1[i] + d*(x2[i] - x1[i]),
y = y1[i] + d*(y2[i] - y1[i]),
z = z1[i] + d*(z2[i] - z1[i]),
name = tags[i]))
# don't forget the last one:
sections_out.append(self.profiles[self.number_profiles-1])
return sections_out
@timer
def st_to_m(self):
"""convert a ST bief to a M bief (same number of points on every section)
Args:
nbsti: number of profiles to add between self._profile[i] and self._profile[i+1]
Returns:
List of profiles including old profiles and interpolated profiles.
"""
isectmax = 0
npoint_max = 0
new_profiles = []
np = []
nprof = len(self.number_profiles)
# find the profile with more points
for isect in range(nprof):
new_profiles.append(self.profile(isect))
points = new_profiles[isect].points
np.append(len(points))
if(npoint_max < len(points)):
npoint_max = len(points)
isectmax = isect
# let's go ! up from isectmax
for isect in range(isectmax+1,nprof):
# TODO case new_profiles[isect].length() = 0.0
# TODO case new_profiles[isect-1].length() = 0.0
l = new_profiles[isect-1].length() # length of each segment
lcum = new_profiles[isect-1].cumul_length() # lcum[-1] is length
alpha = [i/lcum[-1] for i in lcum]
l = new_profiles[isect].length()
lcum = new_profiles[isect].cumul_length()
beta = [i/lcum[-1] for i in lcum]
for i in range(np[isect], npoints_max):
beta.append(1.0)
for k in range(np[isect]): # boucle sur les points à rajouter
trouve = False
for j0 in range(np[isect]-1):
if(trouve):break
undeplus=True
for j1 in range(j0, np[isect]-1):
if(undeplus):
if(beta[j1].le.alpha[j1]):
undeplus=False
break
if (undeplus):
if (j0 == np[isect]-2):
trouve=True
else:
j1=j0+1
if (beta[j0]-alpha[j0] > alpha[j1]-beta[j0]): # beta(j0) > (alpha(j1)+alpha(j2))/2
trouve = True
if (trouve):
# on rajoute un point
ratio=(alpha[j0]-beta[j0-1])/(beta[j0]-beta[j0-1])
if (ratio < 0.0):
# on double le point a gauche
new_profiles[isect].insert_point(j0,new_profiles[isect].points[j0])
beta[j0]=beta[j0-1]
new_profiles[isect].points[j0+1].name('')
else:
p = PointXYZ(x = (1.0-ratio)*new_profiles[isect].points[j0].x + ratio*new_profiles[isect].points[j0].x,
y = (1.0-ratio)*new_profiles[isect].points[j0].y + ratio*new_profiles[isect].points[j0].y,
z = (1.0-ratio)*new_profiles[isect].points[j0].z + ratio*new_profiles[isect].points[j0].z
)
new_profiles[isect].insert_point(j0,p)
n = len(new_profiles[isect].points)
if n <= npoint_max: # we add the missing points at the end of the profile
for k in range(n,npoints_max): new_profiles[isect].add_point(new_profiles[isect].points[-1])
# let's go ! down from isectmax
for isect in range(isectmax-1,-1,-1):
# TODO case new_profiles[isect].length() = 0.0
# TODO case new_profiles[isect-1].length() = 0.0
l = new_profiles[isect+1].length() # length of each segment
lcum = new_profiles[isect+1].cumul_length() # lcum[-1] is length
alpha = [i/lcum[-1] for i in lcum]
l = new_profiles[isect].length()
lcum = new_profiles[isect].cumul_length()
beta = [i/lcum[-1] for i in lcum]
for i in range(np[isect], npoints_max):
beta.append(1.0)
for k in range(np[isect]): # boucle sur les points à rajouter
trouve = False
for j0 in range(np[isect]-1):
if(trouve):break
undeplus=True
for j1 in range(j0, np[isect]-1):
if(undeplus):
if(beta[j1].le.alpha[j1]):
undeplus=False
break
if (undeplus):
if (j0 == np[isect]-2):
trouve=True
else:
j1=j0+1
if (beta[j0]-alpha[j0] > alpha[j1]-beta[j0]): # beta(j0) > (alpha(j1)+alpha(j2))/2
trouve = True
if (trouve):
# on rajoute un point
ratio=(alpha[j0]-beta[j0-1])/(beta[j0]-beta[j0-1])
if (ratio < 0.0):
# on double le point a gauche
new_profiles[isect].insert_point(j0,new_profiles[isect].points[j0])
new_profiles[isect].points[j0+1].name('')
beta[j0]=beta[j0-1]
else:
p = PointXYZ(x = (1.0-ratio)*new_profiles[isect].points[j0].x + ratio*new_profiles[isect].points[j0].x,
y = (1.0-ratio)*new_profiles[isect].points[j0].y + ratio*new_profiles[isect].points[j0].y,
z = (1.0-ratio)*new_profiles[isect].points[j0].z + ratio*new_profiles[isect].points[j0].z,
)
new_profiles[isect].insert_point(j0,p)
n = len(new_profiles[isect].points)
if n <= npoint_max: # we add the missing points at the end of the profile
for k in range(n,npoints_max): new_profiles[isect].add_point(new_profiles[isect].points[-1])
@timer
def purge(self, np: int) -> list:
profiles = []
for profile in self.profiles():
points = profile.purge2(np)
profiles.append(ProfileXYZ())
profiles[-1].import_points(points)
return profiles
def get_incline(self): def get_incline(self):
first = self.profile(0) first = self.profile(0)
@@ -743,15 +926,11 @@ class Reach(SQLSubModel):
incline_acc.sort() incline_acc.sort()
marge = round(len(incline_acc) * 0.1) marge = round(len(incline_acc) * 0.1)
if marge > 0:
incline_set = incline_acc[marge:-marge] incline_set = incline_acc[marge:-marge]
else:
incline_set = incline_acc
logger.debug(f"+{incline_acc}") logger.debug(f"+{incline_acc}")
logger.debug(f"-{incline_set}") logger.debug(f"-{incline_set}")
try:
return ( return (
reduce( reduce(
lambda acc, x: acc + x, lambda acc, x: acc + x,
@@ -759,6 +938,3 @@ class Reach(SQLSubModel):
0.0 0.0
) / (len(incline_set)) ) / (len(incline_set))
) )
except Exception as e:
logger_exception(e)
return 0
Loaded 100 of 335 files, more files were not shown because too many files have changed in this diff. Show more