wolfhece.PyCrosssections

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

wolfhece.PyCrosssections.example_largesect = Multiline-String[source]
Show Value
"""-138 100
-114 90
-70 80
-45 70
-32 62
0 61.5
32 62
60 70
80 80
98 84
120 87"""
wolfhece.PyCrosssections.example_smallsect = Multiline-String[source]
Show Value
"""0 68
10 67
12 65
15 63
20 62
24 61.5
30 62
35 64
40 66
42 66.5
50 68"""
wolfhece.PyCrosssections.example_diffsect1 = Multiline-String[source]
Show Value
"""0 10
10 5
12 5
15 6
16 6
17 5
20 3
25 3
30 5
42 7
50 10"""
wolfhece.PyCrosssections.INTERSEC(x1: float, y1: float, x2: float, y2: float, el: float)[source]

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)

wolfhece.PyCrosssections._shift_np(base: numpy.ndarray, x: float, y: float)[source]

Copy a Numpy array and translate it by (x,y) in the XY plane

wolfhece.PyCrosssections._find_shift_at_xy(section: numpy.ndarray, x3: float, y3: float)[source]

Find the Delta X and Delta Y to shift a section to be parallel to itself at point (x3,y3)

class wolfhece.PyCrosssections.postype(*args, **kwds)[source]

Bases: enum.Enum

Inheritance diagram of wolfhece.PyCrosssections.postype

Mode de stockage des points de référence (berges, fond lit)

BY_VERTEX = 0[source]
BY_S3D = 1[source]
BY_INDEX = 2[source]
class wolfhece.PyCrosssections.profile(name: str, data_sect: str | numpy.ndarray | list | wolfhece.PyVertexvectors.vector = '', parent=None)[source]

Bases: wolfhece.PyVertexvectors.vector

Inheritance diagram of wolfhece.PyCrosssections.profile

Subclass of a vector to define a river profile/cross-section.

Some attributes are added to manage specific points of the profile (banks, bed). The bankleft, bankright, bed, bankleft_down, bankright_down attributes can be wolfvertex, index of vertex or s3D position depending on banksbed_postype.

If a profile is part of a croossection object, the parent attribute points to it. If the profiles are ordered along a river, the up and down attributes point to the upstream and downstream profiles.

sdatum and zdatum are offsets to be added to the curvilinear abscissa and altitudes of the profile.

The stored coordinates are in 3D (x, y, z). If data_sect is provided at initialization, we expect (X, Z) data. The x coordinate is the curvilinear abscissa along the section and z is the altitude (y is set to 0).

Attention

Normally, a profile is a succession of points in a vertical plane, aligned along a trace. In this implementation, the points can be in 3D space, not necessarily aligned. Some routines have a ‘cumul’ parameter to compute the curvilinear abscissa along the section. If ‘cumul’ is True, the real curvilinear abscissa is computed. If ‘cumul’ is False, the distance between each point and the first point is computed.

_bankleft = None[source]
_bankright = None[source]
_bed = None[source]
_bankleft_down = None[source]
_bankright_down = None[source]
banksbed_postype[source]
refpoints[source]
s = 0.0[source]
up: profile = None[source]
down: profile = None[source]
laz = False[source]
parent = None[source]
orient = None[source]
sz = None[source]
sz_bankbed = None[source]
s3d_bankbed = None[source]
prepared = False[source]
smin = -99999[source]
smax = -99999[source]
zmin = -99999[source]
zmax = -99999[source]
q_slope = None[source]
q_down = 0.0[source]
q_up = 0.0[source]
q_centered = 0.0[source]
wetarea = None[source]
wetperimeter = None[source]
hydraulicradius = None[source]
waterdepth = None[source]
localwidth = None[source]
criticaldischarge = None[source]
_linestring_sz = None[source]
_linestring_s3dz = None[source]
property linked_arrays[source]

Return the linked arrays from parent crosssection if any. Useful to plot associated data along the section.

property bankleft[source]

Return the bankleft reference point in its raw format (wolfvertex, index or s3D)

property bankright[source]

Return the bankright reference point in its raw format (wolfvertex, index or s3D)

property bankleft_down[source]

Return the bankleft_down reference point in its raw format (wolfvertex, index or s3D)

property bankright_down[source]

Return the bankright_down reference point in its raw format (wolfvertex, index or s3D)

property bed[source]

Return the bed reference point in its raw format (wolfvertex, index or s3D)

property bankleft_vertex[source]

Return the bankleft reference point as a wolfvertex whatever the storage format

property bankright_vertex[source]

Return the bankright reference point as a wolfvertex whatever the storage format

property bankleft_down_vertex[source]

Return the bankleft_down reference point as a wolfvertex whatever the storage format

property bankright_down_vertex[source]

Return the bankright_down reference point as a wolfvertex whatever the storage format

property bed_vertex[source]

Return the bed reference point as a wolfvertex whatever the storage format

property bankleft_s3D[source]

Return the bankleft reference point as a s3D position whatever the storage format

property bankright_s3D[source]

Return the bankright reference point as a s3D position whatever the storage format

property bankleft_down_s3D[source]

Return the bankleft_down reference point as a s3D position whatever the storage format

property bankright_down_s3D[source]

Return the bankright_down reference point as a s3D position whatever the storage format

property bed_s3D[source]

Return the bed reference point as a s3D position whatever the storage format

property bankleft_sz[source]

Return the bankleft reference point as a (s,z) tuple whatever the storage format

property bankright_sz[source]

Return the bankright reference point as a (s,z) tuple whatever the storage format

property bed_sz[source]

Return the bed reference point as a (s,z) tuple whatever the storage format

property bankleft_down_sz[source]

Return the bankleft_down reference point as a (s,z) tuple whatever the storage format

property bankright_down_sz[source]

Return the bankright_down reference point as a (s,z) tuple whatever the storage format

verif()[source]
triangulation_gltf(zmin: float)[source]

Génération d’un info de triangulation pour sortie au format GLTF –> Blender

La triangulation est constituée de la section et d’une base plane à l’altitude zmin, a priori sous le lit de la rivière.

Parameters:

zmin – position d’altitude minimale de la triangulation

triangulation_ponts(x: float, y: float, zmax: float)[source]

Triangulation d’une section de pont

Parameters:
  • x – coordonnée X du point de référence du pont

  • y – coordonnée Y du point de référence du pont

  • zmax – altitude du tablier du pont

_set_orient()[source]

Calcul du vecteur directeur de la section sur base des points extrêmes

property trace_increments[source]

Return the orientation vector of the section (unit vector in the XY plane)

get_xy_from_s(s: float) tuple[float, float][source]

Récupération d’un tuple (x,y) sur base d’une distance 2D ‘s’ orientée dans l’axe de la section

Parameters:

s – distance curviligne 2D le long de la section supposée plane étant donné l’utilisation de l’orientation

set_vertices_sz_orient(sz: numpy.ndarray | tuple | list, xy1: numpy.ndarray | list | tuple, xy2: numpy.ndarray | list | tuple)[source]
Ajout de vertices depuis :
  • une matrice numpy (s,z) – shape = (nb_vert,2) ou une liste ou un tuple convertibles en numpy array

  • un point source [x,y]

  • un point visé [x,y]

Le point source correspond au vertex de s=0. Le point visé sert uniquement à définir l’orientation de la section.

Parameters:
  • sz – matrice numpy (s,z) – shape = (nb_vert,2)

  • xy1 – point source [x,y]

  • xy2 – point visé [x,y]

get_laz_around(length_buffer: float = 10.0)[source]

Récupération de points LAZ autour de la section

Parameters:

length_buffer – distance latérale [m] autour de la section pour la récupération des points LAZ

plot_laz(length_buffer: float = 5.0, fig: matplotlib.figure.Figure = None, ax: matplotlib.axes.Axes = None, show=False)[source]

Dessin des points LAZ sur le graphique Matplotlib

Parameters:
  • length_buffer – distance latérale [m] autour de la section pour la récupération des points LAZ

  • fig – figure Matplotlib

  • ax – axes Matplotlib

  • show – if True, show the figure

slide_vertex(s: float)[source]

Glissement des vertices d’une constante ‘s’

Parameters:

s – distance de glissement dans l’axe de la section

movebankbed_index(which: Literal['left', 'right', 'bed', 'left_down', 'right_down'], orientation: Literal['left', 'right']) None[source]

Déplacement des points de référence sur base d’un index. Le cas échéant, adaptation du mode de stockage.

Parameters:
  • which – point à déplacer (‘left’, ‘right’, ‘bed’, ‘left_down’, ‘right_down’)

  • orientation – direction du déplacement (‘left’ ou ‘right’)

update_sdatum(new_sdatum: float)[source]

Mise à jour de la position de la section selon sa trace

Parameters:

new_sdatum – nouvelle valeur de sdatum

update_zdatum(new_zdatum: float)[source]

Mise à jour de l’altitude de référence de la section

Parameters:

new_zdatum – nouvelle valeur de zdatum

update_banksbed_from_s3d(which: Literal['left', 'right', 'bed', 'left_down', 'right_down'], s: float)[source]

Mise à jour des points de référence depuis une coordonnée curvi 3D

Parameters:
  • which – point à modifier (‘left’, ‘right’, ‘bed’, ‘left_down’, ‘right_down’)

  • s – nouvelle position curvi 3D du point

save(f)[source]

Surcharge de l’opération d’écriture

Parameters:

f – fichier ouvert en écriture

get_s_from_xy(xy: wolfhece.PyVertex.wolfvertex, cumul: bool = False) float[source]

Retourne la coordonnée curviligne (ou distance euclidienne selon l’orientation de la section) du point xy donné en tant qu’objet wolfvertex.

Dans cette routine, ‘cumul’ est à False par défaut pour être rétro-compatible avec les versions précédentes. ATTENTION: Cette valeur par défaut n’est pas identique à celle utilisée dans ‘get_sz’.

Parameters:
  • xy – vertex dont on veut la coordonnée curvi 2D

  • cumul – si True, la coordonnée curvi 2D est cumulée (distance le long de la section) si False, la coordonnée curvi 2D est la distance euclidienne au point de départ

set_sz(sz: numpy.ndarray, trace: list[tuple[float, float]])[source]

Calcule les positions des vertices sur base d’une matrice sz et d’une trace.

Parameters:
  • s – colonne 0

  • z – colonne 1

  • trace – liste de 2 couples xy -> [[x1,y1], [x2,y2]]

FIXME: Vérifier la possibilité de fusionner avec set_vertices_sz_orient

get_sz_banksbed(cumul=True, force: bool = False) tuple[float, float, float, float, float, float, float, float, float, float][source]
Retourne les positions des points de référence mais avec la coordonnée curvi 2D
  • (sleft, sbed, sright, zleft, zbed, zright, sbankleft_down, sbankright_down, zbankleft_down, zbankright_down)

Parameters:
  • cumul – si True, la coordonnée curvi 2D est cumulée (distance le long de la section) si False, la coordonnée curvi 2D est la distance euclidienne au point de départ

  • force – si True, force le recalcul même si la section est déjà préparée

get_s3d_banksbed(force: bool = False) tuple[float, float, float, float, float][source]
Retourne les coordonnée curvi 3D des points de référence
  • (sleft, sleft_down, sbed, sright_down, sright)

asshapely_sz() shapely.geometry.LineString[source]

Retroune la section comme objet shapely - polyligne selon la trace avec altitudes

property linestring_sz: shapely.geometry.LineString[source]

Retroune la section comme objet shapely - polyligne selon la trace avec altitudes

asshapely_s3dz() shapely.geometry.LineString[source]

Retroune la section comme objet shapely - polyligne selon la trace 3D avec altitudes

property s3dz: numpy.ndarray[source]

Retroune la section comme matrice numpy (s3d,z)

property linestring_s3dz: shapely.geometry.LineString[source]

Retroune la section comme objet shapely - polyligne selon la trace 3D avec altitudes

prepare(cumul=True)[source]

Pre-Compute sz, sz_banked and shapely objects to avoid multiple computation

_reset_linestring_sz_s3dz()[source]
reset_prepare()[source]

Réinitialisation de la préparation de la section

get_min() wolfhece.PyVertex.wolfvertex[source]

Return the vertex with minimum elevation

get_max() wolfhece.PyVertex.wolfvertex[source]

Return the vertex with maximum elevation

get_minz() float[source]

Return the minimum elevation

get_maxz() float[source]

Return the maximum elevation

relation_oneh(cury: float, x: float = None, y: float = None)[source]

Compute the hydraulic characteristics for a given water elevation ‘cury’

Parameters:
  • cury – water elevation

  • x – optional x coordinates of the section (if None, use the section’s coordinates)

  • y – optional y coordinates of the section (if None, use the section’s coordinates)

Returns:

a,s,w,r (wetted area, wetted perimeter, top width, hydraulic radius)

relations(discretize: int = 100, plot=True)[source]

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).

slopes()[source]

Compute the slopes of the section with respect to the upstream and downstream sections

ManningStrickler_Q(slope: float = 0.001, nManning: float = 0.0, KStrickler: float = 0.0)[source]

Procédure générique pour obtenir une relation uniforme Q-H sur base d’une pente et d’un coefficient de frottement.

Parameters:
  • slope – une pente

  • nManning – un coefficient de frottement

  • KStrickler – un coefficient de frottement (if nManning > 0.0, KStrickler is ignored)

ManningStrickler_oneQ(slope: float = 0.001, nManning: float = 0.0, KStrickler: float = 0.0, cury: float = 0.0)[source]

Procédure générique pour obtenir une relation uniforme Q-H sur base

Parameters:
  • slope – une pente

  • nManning – un coefficient de frottement

  • KStrickler – un coefficient de frottement (if nManning > 0.0, KStrickler is ignored)

  • cury – une hauteur d’eau

Returns:

le débit Q

deepcopy_profile(name: str = None, appendstr: str = '_copy')[source]

This method returns a deepcopy of the active profile. The profile features are individually transferred, therefore, only the necessary features are copied.

Parameters:
  • name – name of the copied profile (if None, the current profile’s name + appendstr is used)

  • appendstr – string to append to the current profile’s name if no new name is given (default: ‘_copy’)

Returns:

the copied profile

color_active_profile(width: float = 3.0, color: list = [255, 0, 0], plot_opengl: bool = True)[source]

This method colors and thickens the active profile (default width : 3, default color: red).

Parameters:
  • width – width of the profile

  • color – color of the profile as a list of RGB values (0-255)

  • plot_opengl – if True, update the OpenGL plot of the parent zone

highlighting(width: float = 3.0, color: list = [255, 0, 0], plot_opengl: bool = True)[source]

Alias for color_active_profile

uncolor_active_profile(plot_opengl=True)[source]

This method resets the width and the color of the active profile to 1 and black.

withdrawing(plot_opengl: bool = True)[source]

Alias for uncolor_active_profile

ManningStrickler_profile(slope: float = 0.001, nManning: float = 0.0, KStrickler: float = 0.0)[source]

Procédure générique pour obtenir une relation uniforme Q-H d’un profile

Parameters:
  • slope – une pente

  • nManning – un coefficient de frottement

  • KStrickler – un coefficient de frottement (if nManning > 0.0, KStrickler is ignored)

ainsi que les relations correspondant aux pentes aval(slope down), amont(slopeup), et amont-aval (centered).

Returns:

le débit Q maximum parmi les 4 relations

plotcs_profile(fig: matplotlib.figure.Figure = None, ax: matplotlib.axes.Axes = None, compare: profile = None, vecs: list = [], col_structure: str = 'none', fwl: float = None, fwd: float = None, simuls: list = None, show: bool = False, forceaspect: bool = True, plotlaz: bool = True, clear: bool = True, redraw: bool = True)[source]

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.

Parameters:
  • fig – Matplotlib figure

  • ax – Matplotlib axes

  • compare – reference profile to compare with

  • vecs – list of vector objects to plot on the section (e.g. levees, dikes, …)

  • col_structure – color of the structures (default: ‘none’)

  • fwl – water level to plot (if None, no water level is plotted)

  • fwd – water depth to plot (if None, no water level is plotted)

  • simuls – list of simulations containing the profile (id, name, date, time, water level)

  • show – if True, show the figure

  • forceaspect – if True, force aspect ratio

  • plotlaz – if True, plot LAZ points if available

  • clear – if True, clear the axis before plotting

  • redraw – if True, redraw the figure after plotting

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: bool = False, clear: bool = True, labels: bool = True, redraw: bool = True, force_label_to_right: bool = True)[source]

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.

Parameters:
  • fig – Matplotlib figure

  • ax – Matplotlib axes

  • fwl – water level to plot (if None, no water level is plotted)

  • fwd – water depth to plot (if None, no water level is plotted)

  • fwq – discharge to plot (if None, no discharge is plotted)

  • simuls – list of simulations containing the profile (id, name, date, time, discharge, water level)

  • show – if True, show the figure

  • clear – if True, clear the axis before plotting

  • labels – if True, show the legend

  • redraw – if True, redraw the figure after plotting

plot_discharges_UnCr(fig: matplotlib.figure.Figure = None, ax: matplotlib.axes.Axes = None, fwl: float = None, fwd: float = None, fwq: float = None, simuls: list = None, show: bool = False, clear: bool = True, labels: bool = True, redraw: bool = True, force_label_to_right: bool = False)[source]
plotcs_hspw(fig: matplotlib.figure.Figure = None, ax: matplotlib.axes.Axes = None, fwl: float = None, fwd: float = None, fwq: float = None, show: bool = False, clear: bool = True, labels: bool = True, redraw: bool = True, force_label_to_right: bool = True)[source]

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.

Parameters:
  • fig – Matplotlib figure

  • ax – Matplotlib axes

  • fwl – water level to plot (if None, no water level is plotted)

  • fwd – water depth to plot (if None, no water level is plotted)

  • fwq – discharge to plot (if None, no discharge is plotted)

  • show – if True, show the figure

  • clear – if True, clear the axis before plotting

  • labels – if True, show the legend

  • redraw – if True, redraw the figure after plotting

plotcs_relations(fig: matplotlib.figure.Figure = None, ax: matplotlib.axes.Axes = None, fwl: float = None, fwd: float = None, fwq: float = None, show: bool = False, clear: bool = True, labels: bool = True, redraw: bool = True, force_label_to_right: bool = False)[source]

This method plots the cross section relations (geometry, hydraulic geometries)

It is the same than ‘plotcs_hspw’ but with (force_label_to_right = False) by default

plot_linked(fig: matplotlib.figure.Figure, ax: matplotlib.axes.Axes, linked_arrays: dict, colors: list = ['red', 'blue', 'green'])[source]

Plot linked arrays on the section plot

_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')[source]

Plot only the cross section line on an existing axis

_plot_only_cs_min_at_x0(fig: matplotlib.figure.Figure = None, ax: matplotlib.axes.Axes = None, label='', alpha=0.8, lw=1.0, style: str = 'dashed', grid=True, col_ax: str = 'black')[source]

Plot only the cross section line on an existing axis. We assume that the minimum elevation is at x=0.

plot_cs(fwl: float = None, show: bool = False, forceaspect: bool = True, fig: matplotlib.figure.Figure = None, ax: matplotlib.axes.Axes = None, plotlaz: bool = True, clear: bool = True, linked_arrays: dict = {})[source]

Plot the cross section with matplotlib - with options

Parameters:
  • fwl – fill water level - if None, no filling

  • show – if True, show the figure

  • forceaspect – if True, force aspect ratio

  • fig – figure Matplotlib

  • ax – axes Matplotlib

  • plotlaz – if True, plot LAZ points if available

  • clear – if True, clear the axis before plotting

  • linked_arrays – dictionary of linked arrays to plot on the section

_plot_extremities(ax: matplotlib.pyplot.Axes, s: int = 50, colors: tuple[str, str] = ('blue', 'green')) None[source]

Plot the extremities of the cross-section on the given axes.

_plot_extremities_sz(ax: matplotlib.pyplot.Axes, s: int = 10, colors: tuple[str, str] = ('blue', 'green')) None[source]

Plot the extremities of the cross-section on the given axes.

class wolfhece.PyCrosssections.crosssections(fn_or_Zones: str | pathlib.Path | wolfhece.PyVertexvectors.Zones = '', format: Literal['2000', '2022', '2025_xlsx', 'vecz', 'sxy', 'zones'] = '2022', dirlaz: 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, from_zones: wolfhece.PyVertexvectors.Zones = None, force_unique_name: bool = False)[source]

Bases: wolfhece.drawing_obj.Element_To_Draw

Inheritance diagram of wolfhece.PyCrosssections.crosssections
Gestion de sections en travers pour différents formats
  • SPW 2000 –> format =’2000’

  • SPW 2022 –> format =’2022’

  • SPW_2025 –> format =’2025_xlsx’

  • WOLF vecz –> format =’vecz’

  • WOLF sxy –> format =’sxy’

  • WOLF zones –> format =’zones’

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 [‘left_down’] : wolfvertex [‘right_down’]: wolfvertex [‘cs’] : profile (surcharge de vector)

Pour le moment, il est possible de lire les fichiers et d’effectuer certains 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

Attention:

!! La classe n’est pas encore prévue pour créer des sections en travers!!

myprofiles: dict[str | int:dict['cs':profile, 'index':int, 'left':wolfvertex, 'bed':wolfvertex, 'right':wolfvertex, 'left_down':wolfvertex, 'right_down':wolfvertex]][source]
mygenprofiles: dict[source]
dirlaz = None[source]
gridlaz = None[source]
myzones = None[source]
myzone = None[source]
format = None[source]
linked_zones = None[source]
cloud = None[source]
cloud_all = None[source]
multils = None[source]
sorted: dict[str, dict['sorted':list[vector], 'support':LineString]][source]
plotted = False[source]
property nb_profiles[source]

Return the number of profiles in the cross-sections.

init_cloud()[source]

Initialiaze cloud points for cross-sections.

add(newprofile: profile | wolfhece.PyVertexvectors.vector)[source]

Add a new profile or vector to the cross-sections.

Parameters:

newprofile (profile | vector) – A profile or vector to be added.

get_linked_arrays()[source]

Passerelle pour obntenir les matrices liées

get_profile(which_prof, which_dict: str = None)[source]

Recherche et renvoi d’un profil sur base du nom ou de son index et éventuellement de la liste triée.

Parameters:
  • which_prof (str | int) – Nom du profil ou index du profil à rechercher.

  • which_dict (str | None) – Nom du dictionnaire trié à utiliser, si applicable.

fillin_cloud_all()[source]

Fill the cloud_all with all vertices from all profiles.

update_cloud()[source]

Update the cloud with vertices from all profiles.

create_vector_from_centers(which_dict: str = None)[source]

Create a vector from the centers of the cross-sections.

create_vector_from_lefts(copy: bool = True, which_dict: str = None)[source]

Create a vector from the left (first vertex) of the cross-sections.

Parameters:

copy (bool) – If True, create a copy of the left vertices. If False, use the original vertices.

create_vector_from_rights(copy: bool = True, which_dict: str = None)[source]

Create a vector from the right (last vertex) of the cross-sections.

Parameters:

copy (bool) – If True, create a copy of the right vertices. If False, use the original vertices.

check_left_right_coherence()[source]

Check the coherence of left and right banks in the cross-sections.

Returns:

-2 if both banks intersect the center line, -1 if only left bank intersects, 1 if only right bank intersects, 0 if no intersection.

Return type:

int

create_zone_from_banksbed()[source]

Create a zone from the banks and bed of the cross-sections.

Link the cross-sections to external zones.

Find intersections between the cross-sections and linked zones.

export_gltf(zmin, fn='')[source]

Export the cross-sections to a GLTF file.

export_gltf_gen(points, triangles, fn='')[source]

Export generated cross-sections to a GLTF file.

set_zones(forceupdate: bool = False)[source]

Set/Prepare the zones for the cross-sections.

showstructure(parent=None, forceupdate=False)[source]

Show the structure of the cross-sections in the zones.

get_upstream() dict['cs':profile, 'index':int, 'left':wolfvertex | None, 'bed':wolfvertex | None, 'right':wolfvertex | None, 'left_down':wolfvertex | None, 'right_down':wolfvertex | None][source]

Get the upstream profile of the cross-sections.

get_downstream() dict['cs':profile, 'index':int, 'left':wolfvertex | None, 'bed':wolfvertex | None, 'right':wolfvertex | None, 'left_down':wolfvertex | None, 'right_down':wolfvertex | None][source]

Get the downstream profile of the cross-sections.

rename(fromidx: int, updown: bool = True)[source]

“ Rename the cross-sections starting from a given index.

Parameters:
  • fromidx (int) – The index from which to start renaming.

  • updown (bool) – If True, renames upstream sections; if False, renames all sections.

saveas(filename: str | pathlib.Path = None)[source]

Save the cross-sections to a file in the specified format.

get_label(profile_dict: dict, vertex: wolfhece.PyVertex.wolfvertex)[source]

Get the label for a vertex based on its type.

Parameters:
  • profile_dict (dict) – Dictionary containing the profile information.

  • vertex (wolfvertex) – The vertex for which to get the label.

Returns:

The label for the vertex.

Return type:

str

verif_bed()[source]

Verification de l’existence du point lit mineur sinon attribution de l’altitude minimale

get_min(whichname: str = '', whichprofile: profile = None)[source]

Get the minimum vertex of a profile or cross-section.

asshapely_ls()[source]

Convert the cross-sections to a MultiLineString using Shapely.

prepare_shapely()[source]

Prepare the cross-sections for Shapely operations.

sort_along(vecsupport: shapely.geometry.LineString | wolfhece.PyVertexvectors.vector, name: str, downfirst=True)[source]

Sélectionne les sections qui intersectent un vecteur support et les trie selon l’abscisse curviligne

find_minmax(update: bool = False)[source]

Find the minimum and maximum coordinates of the cross-sections.

Parameters:

update (bool) – If True, updates the min/max values based on the current profiles.

plot(sx=None, sy=None, xmin=None, ymin=None, xmax=None, ymax=None, size=None)[source]

Plotting cross-sections

_prep_listogl()[source]

Prepare list of GL objects

saveas_wolfvec(filename: str)[source]

Save the cross-sections as a WOLF vector file.

select_profile(x: float, y: float) profile[source]

Select the profile closest to the given coordinates (x, y).

Parameters:
  • x – X coordinate of the point.

  • y – Y coordinate of the point.

class wolfhece.PyCrosssections.Interpolator(vec1: wolfhece.PyVertexvectors.vector, vec2: wolfhece.PyVertexvectors.vector, supports: list[wolfhece.PyVertexvectors.vector], ds: float = 1.0, epsilon: float = 0.05)[source]

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

interpolants = [][source]
get_xyz_for_viewer(nbsub=10)[source]

Get the XYZ coordinates for the viewer.

Parameters:

nbsub (int) – Number of subdivisions for each segment, default is 10.

Returns:

A numpy array of shape [(nb-1)*nbsub, 4] containing the XYZ coordinates.

Return type:

np.ndarray

add_triangles_to_zone(myzone: wolfhece.PyVertexvectors.zone)[source]

Add triangles to the specified zone based on the interpolants.

Parameters:

myzone (zone) – The zone to which the triangles will be added.

get_triangles(forgltf=True)[source]

Get the triangles and points for the interpolants.

ATTENTION : gltf format coordinates as [x, z, -y] and “forgltf” is True by default. It is not the case in “get_points” where forgltf is False by default.

Parameters:

forgltf (bool) – If True, formats the points for glTF export, default is True.

Returns:

A tuple containing the number of points, points array, and triangles array.

Return type:

tuple[int, np.ndarray, np.ndarray]

get_points(forgltf=False)[source]

Get the points for the interpolants.

ATTENTION : gltf format coordinates as [x, z, -y] and “forgltf” is False by default. It is not the case in “get_triangles” where forgltf is True by default.

Parameters:

forgltf (bool) – If True, formats the points for glTF export, default is False.

Returns:

A tuple containing the number of points and the points array.

Return type:

tuple[int, np.ndarray]

export_gltf(points=None, triangles=None, fn: str | pathlib.Path = None)[source]

Export the interpolated sections as a glTF file.

GLTF can be opened in many 3D viewers, including Blender, Cesium, and others.

Parameters:
  • points (np.ndarray | None) – Optional points array, if None, it will be generated from the interpolants.

  • triangles (np.ndarray | None) – Optional triangles array, if None, it will be generated from the interpolants.

  • fn (str | Path | None) – The filename to save the glTF file, if None, a file dialog will be shown.

Returns:

None

Return type:

None

get_xy_z_for_griddata()[source]

Get the XY and Z coordinates for griddata interpolation (Scipy).

class wolfhece.PyCrosssections.Interpolators(banks: wolfhece.PyVertexvectors.Zones, cs: crosssections, ds: float = 1.0)[source]

Classe de gestion des interpolations sur sections en travers.

La préparation de la triangulation est faite sur base de vecteurs supports (instance de type “Zones”) et de sections en travers stockées dans une instance de type “crosssections”.

points = None[source]
triangles = None[source]
mybanks[source]
myinterp: list[Interpolator] = [][source]
add_interpolators(parent)[source]

Ajout d’objets ‘Interpolators’ pour affichage/stockage

export_gltf(fn: str | pathlib.Path = None)[source]

Export the interpolated sections as a glTF file.

viewer_interpolator()[source]

Display the interpolated sections in a viewer.

property points_xyz[source]

Get the XYZ coordinates of the interpolated points.

Points are stored as [x,z,-y] for glTF compatibility. Convert them to [x,y,z] for other uses.

interp_on_array(myarray, method: Literal['nearest', 'linear', 'cubic'], use_cloud: bool = True, mask_outside_polygons: bool = False)[source]

Interpolate the sections on a WolfArray.

Parameters:
  • myarray (WolfArray) – The WolfArray to interpolate on.

  • method (str) – The interpolation method to use, default is “linear”.

  • use_cloud (bool) – If True, uses cloud interpolation, otherwise triangulation, default is True.

saveas(fn: str | pathlib.Path)[source]

Save the interpolators to files.

Each interpolator will be saved as a separate file with a .tri extension.

Parameters:

fn (str | Path) – The filename to save the interpolators.