:py:mod:`wolfhece.PyCrosssections`
==================================
.. py:module:: wolfhece.PyCrosssections
.. autoapi-nested-parse::
Author: HECE - University of Liege, Pierre Archambeau, Utashi Ciraane Docile
Date: 2024
Copyright (c) 2024 University of Liege. All rights reserved.
This script and its content are protected by copyright law. Unauthorized
copying or distribution of this file, via any medium, is strictly prohibited.
Module Contents
---------------
.. py:data:: example_largesect
:value: Multiline-String
.. raw:: html
Show Value
.. code-block:: python
"""-138 100
-114 90
-70 80
-45 70
-32 62
0 61.5
32 62
60 70
80 80
98 84
120 87"""
.. raw:: html
.. py:data:: example_smallsect
:value: Multiline-String
.. raw:: html
Show Value
.. code-block:: python
"""0 68
10 67
12 65
15 63
20 62
24 61.5
30 62
35 64
40 66
42 66.5
50 68"""
.. raw:: html
.. py:data:: example_diffsect1
:value: Multiline-String
.. raw:: html
Show Value
.. code-block:: python
"""0 10
10 5
12 5
15 6
16 6
17 5
20 3
25 3
30 5
42 7
50 10"""
.. raw:: html
.. py:function:: INTERSEC(x1, y1, x2, y2, el)
Procédure de calcul de l'abscisse d'intersection d'une altitude donnée el
dans un segment défini par ses coordonnées (x1,y1) et (x2,y2)
.. py:function:: partranslation(base, x, y)
.. py:function:: find_xy(section, x3, y3)
.. py:class:: postype
Bases: :py:obj:`enum.Enum`
.. autoapi-inheritance-diagram:: wolfhece.PyCrosssections.postype
:parts: 1
:private-bases:
Mode de stockage des points de référence (berges, fond lit)
.. py:attribute:: BY_VERTEX
:value: 0
.. py:attribute:: BY_S3D
:value: 1
.. py:attribute:: BY_INDEX
:value: 2
.. py:class:: profile(name, data_sect='', parent=None)
Bases: :py:obj:`wolfhece.PyVertexvectors.vector`
.. autoapi-inheritance-diagram:: wolfhece.PyCrosssections.profile
:parts: 1
:private-bases:
Surcharge d'un vecteur en vue de définir un profil de rivière
Les coordonnées attendues sont en 3D (x,y,z)
.. py:property:: linked_arrays
.. py:property:: bankleft
.. py:property:: bankright
.. py:property:: bed
.. py:property:: bankleft_vertex
.. py:property:: bankright_vertex
.. py:property:: bed_vertex
.. py:property:: bankleft_s3D
.. py:property:: bankright_s3D
.. py:property:: bed_s3D
.. py:property:: bankleft_sz
.. py:property:: bankright_sz
.. py:property:: bed_sz
.. py:method:: verif()
.. py:method:: triangulation_gltf(zmin)
Génération d'un info de triangulation pour sortie au format GLTF --> Blender
:zmin : position d'altitude minimale de la triangulation
.. py:method:: triangulation_ponts(x, y, zmax)
Triangulation d'une section de pont
.. py:method:: set_orient()
Calcul du vecteur directeur de la section sur base des points extrêmes
.. py:method:: get_xy_from_s(s) -> tuple[float, float]
Récupération d'un tuple (x,y) sur base d'une distance 2D 's' orientée dans l'axe de la section
.. py:method:: set_vertices_sz_orient(sz: numpy.ndarray, xy1: numpy.ndarray, xy2: numpy.ndarray)
Ajout de vertices depuis :
- une matrice numpy (s,z) -- shape = (nb_vert,2)
- d'un point source [x,y]_1
- d'un point visé [x,y]_2
.. py:method:: get_laz_around(length_buffer=10.0)
Récupération de points LAZ autour de la section
.. py:method:: plot_laz(length_buffer=5.0, fig: matplotlib.figure.Figure = None, ax: matplotlib.axes.Axes = None, show=False)
Dessin des points LAZ sur le graphique Matplotlib
.. py:method:: slide_vertex(s)
Glissement des vertices d'une constante 's'
.. py:method:: movebankbed_index(which, orientation)
Déplacement des points de référence sur base d'un index
Le cas échéant, adaptation du mode de stockage
.. py:method:: update_sdatum(new_sdatum)
MAJ de la position de la section selon sa trace
.. py:method:: update_zdatum(new_zdatum)
MAJ de l'altitude de référence de la section
.. py:method:: update_banksbed_from_s3d(which, s: float)
MAJ des points de référence depuis une coordonnée curvi 3D
.. py:method:: save(f)
Surcharge de l'opération d'écriture
.. py:method:: get_s_from_xy(xy: wolfhece.PyVertex.wolfvertex) -> float
Retourne la coordonnér curvi sur base d'un vertex
.. py:method:: get_sz(cumul=True) -> tuple[numpy.ndarray, numpy.ndarray]
Retourne 2 vecteurs avec la position curvi 2D et l'altitude des points
.. py:method:: set_sz(sz, trace)
Calcule les positions des vertices sur base d'une matrice sz et d'une trace
s : colonne 0
z : colonne 1
trace : liste de 2 couples xy -> [[x1,y1], [x2,y2]]
.. py:method:: get_sz_banksbed(cumul=True, force: bool = False) -> tuple[float, float, float, float, float, float]
Retourne les positions des points de référence mais avec la coordonnée curvi 2D
- (sleft, sbed, sright, zleft, zbed, zright)
.. py:method:: get_s3d_banksbed(force: bool = False) -> tuple[float, float, float]
Retourne les coordonnée curvi 3D des points de référence
- (sleft, sbed, sright)
.. py:method:: asshapely_sz() -> shapely.geometry.LineString
Retroune la section comme objet shapely - polyligne selon la trace avec altitudes
.. py:method:: asshapely_s3dz() -> shapely.geometry.LineString
Retroune la section comme objet shapely - polyligne selon la trace 3D avec altitudes
.. py:method:: prepare(cumul=True)
Pre-Compute sz and sz_banked to avoid multiple computation
.. py:method:: reset_prepare()
Réinitialisation de la préparation de la section
.. py:method:: get_min()
.. py:method:: get_max()
.. py:method:: get_minz()
.. py:method:: get_maxz()
.. py:method:: plot_linked(fig, ax, linked_arrays: dict)
Graphique Matplolib de valeurs dans les matrices liées
.. py:method:: _plot_only_cs(fig: matplotlib.figure.Figure = None, ax: matplotlib.axes.Axes = None, label='', alpha=0.8, lw=1.0, style: str = 'dashed', centerx=0.0, centery=0.0, grid=True, col_ax: str = 'black')
.. py:method:: plot_cs(fwl=None, show=False, forceaspect=True, fig: matplotlib.figure.Figure = None, ax: matplotlib.axes.Axes = None, plotlaz=True, clear=True, linked_arrays: dict = {})
.. py:method:: relation_oneh(cury, x=None, y=None)
.. py:method:: relations(discretize: int = 100, plot=True)
This method returns 6 numpy arrays each containing the evolution
of a specific hydraulic characteristic with respect to the water depth in the profile
(wetted area, wetted perimeter, top width, water detph, hydraulic radius, critical discharge).
.. py:method:: slopes()
.. py:method:: ManningStrickler_Q(slope=0.001, nManning=0.0, KStrickler=0.0)
Procédure générique pour obtenir une relation uniforme Q-H sur base
- nManning : un coefficient de frottement
- slope : une pente
.. py:method:: ManningStrickler_oneQ(slope=0.001, nManning=0.0, KStrickler=0.0, cury=0.0)
Procédure générique pour obtenir une relation uniforme Q-H sur base
- nManning : un coefficient de frottement
- slope : une pente
.. py:method:: deepcopy_profile(name: str = None)
This method returns a deepcopy of the active profile.
The profile features are individually transferred, therefore,
only the necessary features are copied.
.. py:method:: color_active_profile(width: float = 3.0, color: list = [255, 0, 0], plot_opengl=True)
This method colors and thickens the active profile
(default width : 3, default color: red).
.. py:method:: highlightning(width: float = 3.0, color: list = [255, 0, 0], plot_opengl=True)
Alias for color_active_profile
.. py:method:: uncolor_active_profile(plot_opengl=True)
This method resets the width and the color of the active profile to 1 and black.
.. py:method:: withdrawing(plot_opengl=True)
Alias for uncolor_active_profile
.. py:method:: ManningStrickler_profile(slope: float = 0.001, nManning: float = 0.0, KStrickler: float = 0.0)
Procédure générique pour obtenir une relation uniforme Q-H d'un profile sur base:
- nManning ou KStrickler: un coefficient de frottement,
- slope : une pente fournie (default: 0.001),
ainsi que les relations correspondant aux pentes aval(slope down), amont(slopeup), et amont-aval (centered).
.. py:method:: plotcs_profile(fig: matplotlib.figure.Figure = None, ax: matplotlib.axes.Axes = None, compare=None, vecs: list = [], col_structure: str = 'none', fwl: float = None, fwd: float = None, simuls: list = None, show=False, forceaspect=True, plotlaz=True, clear=True, redraw=True)
This method plots the physical geometry of the current cross section (profile).
- If a reference profile (compare) is given, the method hatchs the differences with resepect to cuts and fills.
- If forceaspect is activated, the x and y axes are plotted using the same scale, otherwise, the figure is anamorphosed.
- fwl (for water level) and fwd (for water depth) allow the visualisation of a specific water level on the graph.
- idsimul: list of available numerical simulations containing this profile,
- zsimul: list of water level in the simulations.
- col_structure colors the structure displayed.
.. py:method:: plotcs_discharges(fig: matplotlib.figure.Figure = None, ax: matplotlib.axes.Axes = None, fwl: float = None, fwd: float = None, fwq: float = None, simuls: list = None, show=False, clear=True, labels=True, redraw=True)
This method plots the discharges relationship computed
with the methods: relations and ManningStrcikler_profile.
- fwl: for water level,
- fwd: for water depth,
- fwq: for water discharge,
- idsimul: list of available numerical models.
- qsimul: list of discharges in the available numerical models,
- hsimul: list of water depth in the available numerical models.
.. py:method:: plotcs_hspw(fig: matplotlib.figure.Figure = None, ax: matplotlib.axes.Axes = None, fwl: float = None, fwd: float = None, fwq: float = None, show=False, clear=True, labels=True, redraw=True)
This method plots the hydraulic geometries computed by the relations method
(Hydraulic radius, wetted area, wetted perimeter, Top width).
- fwl: for water level,
- fwd: for water depth,
- fwq: for water discharge.
.. py:class:: crosssections(myfile: str = '', format: Literal[2000, 2022, vecz, sxy] = '2022', dirlaz: Union[str, wolfhece.lazviewer.laz_viewer.xyz_laz_grids] = 'D:\\OneDrive\\OneDrive - Universite de Liege\\Crues\\2021-07 Vesdre\\CSC - Convention - ARNE\\Data\\LAZ_Vesdre\\2023', mapviewer=None, idx='', plotted=True)
Bases: :py:obj:`wolfhece.drawing_obj.Element_To_Draw`
.. autoapi-inheritance-diagram:: wolfhece.PyCrosssections.crosssections
:parts: 1
:private-bases:
Gestion de sections en travers pour différents formats
- SPW 2000 --> format ='2000'
- SPW 2022 --> format ='2022'
- WOLF vecz --> format ='vecz'
- WOLF sxy --> format ='sxy'
L'objet stocke ses informations dans un dictionnaire : self.myprofiles
Les clés de chaque entrée sont:
['index'] : integer
['left'] : wolfvertex
['bed'] : wolfvertex
['right'] : wolfvertex
['cs'] : profile (surcharge de vector)
Pour le moment, il est possible de lire les fichiers et d'effectuer cerrains traitements (tri selon vecteur, export gltf...).
Une instance de cet objet peut être ajouté à une instance graphique WOLF pour affichage.
Pour ce faire:
- une propriété "myzones" de type "Zones" est présente pour stocker les sections sous forme WOLF "ZONES/ZONE/VECTOR/VERTICES". --> "crosssections" n'est donc pas une extension de "Zones" !!
- deux instances de "cloud_vertices" contiennent les vertices des sections :
- cloud
- cloud_all
:remark !! La classe n'est pas encore prévue pour créer des sections en travers!!
.. py:attribute:: myprofiles
:type: dict
.. py:attribute:: mygenprofiles
:type: dict
.. py:method:: init_cloud()
.. py:method:: add(newprofile: profile | wolfhece.PyVertexvectors.vector)
.. py:method:: get_linked_arrays()
Passerelle pour obntenir les matrices liées
.. py:method:: get_profile(which_prof, which_dict: str = None)
Recherche et renvoi d'un profil sur base du nom ou de son index et éventuellement de la liste triée
.. py:method:: fillin_cloud_all()
.. py:method:: update_cloud()
.. py:method:: create_zone_from_banksbed()
.. py:method:: link_external_zones(mylink: wolfhece.PyVertexvectors.Zones)
.. py:method:: find_intersect_with_link_zones()
.. py:method:: export_gltf(zmin, fn='')
.. py:method:: export_gltf_gen(points, triangles, fn='')
.. py:method:: set_zones(forceupdate: bool = False)
.. py:method:: showstructure(parent=None, forceupdate=False)
.. py:method:: get_upstream() -> dict
.. py:method:: get_downstream() -> dict
.. py:method:: rename(fromidx, updown=True)
.. py:method:: saveas(filename=None)
.. py:method:: verif_bed()
Verification de l'existence du point lit mineur sinon attribution de l'altitude minimale
.. py:method:: get_min(whichname='', whichprofile=None)
.. py:method:: asshapely_ls()
.. py:method:: prepare_shapely()
.. py:method:: sort_along(vecsupport: shapely.geometry.LineString, name: str, downfirst=True)
Sélectionne les sections qui intersectent un vecteur support
et les trie selon l'abscisse curviligne
.. py:method:: find_minmax(update: bool = False)
Generic function to find min and max spatial extent in data
example : a WolfMapViewer instance needs spatial extent to zoom or test if
element must be plotted
.. py:method:: plot(sx=None, sy=None, xmin=None, ymin=None, xmax=None, ymax=None, size=None)
Plotting cross-sections
.. py:method:: _prep_listogl()
Prepare list of GL objects
.. py:method:: saveas_wolfvec(filename: str)
.. py:method:: select_profile(x, y)
.. py:class:: Interpolator(vec1: wolfhece.PyVertexvectors.vector, vec2: wolfhece.PyVertexvectors.vector, supports: list[wolfhece.PyVertexvectors.vector], ds=1.0)
Objet d'interpolation sur sections en travers
- self.interpolants est une liste de listes
- chaque élément de self.interpolants est également une liste de listes
- chaque liste de self.interpolants[k] contient les wolfvertex de la section discrétisée
.. py:method:: get_xyz_for_viewer(nbsub=10)
.. py:method:: add_triangles_to_zone(myzone: wolfhece.PyVertexvectors.zone)
.. py:method:: get_triangles(forgltf=True)
.. py:method:: get_points(forgltf=False)
.. py:method:: export_gltf(points=None, triangles=None)
.. py:method:: get_xy_z_for_griddata()
.. py:class:: Interpolators(banks: wolfhece.PyVertexvectors.Zones, cs: crosssections, ds=1.0)
Classe de gestion des interpolations sur sections en travers
.. py:method:: add_interpolators(parent)
Ajout d'objets 'Interpolators' pour affichage/stockage
.. py:method:: viewer_interpolator()
.. py:method:: interp_on_array(myarray, method: Literal[nearest, linear, cubic])