wolfhece.pybridges
==================

.. py:module:: wolfhece.pybridges

.. autoapi-nested-parse::

   Author: HECE - University of Liege, Pierre Archambeau
   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:class:: stored_values_unk(*args, **kwds)

   Bases: :py:obj:`enum.Enum`

   .. autoapi-inheritance-diagram:: wolfhece.pybridges.stored_values_unk
      :parts: 1
      :private-bases:


   Create a collection of name/value pairs.

   Example enumeration:

   >>> class Color(Enum):
   ...     RED = 1
   ...     BLUE = 2
   ...     GREEN = 3

   Access them by:

   - attribute access::

   >>> Color.RED
   <Color.RED: 1>

   - value lookup:

   >>> Color(1)
   <Color.RED: 1>

   - name lookup:

   >>> Color['RED']
   <Color.RED: 1>

   Enumerations can be iterated over, and know how many members they have:

   >>> len(Color)
   3

   >>> list(Color)
   [<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]

   Methods can be added to enumerations, and members can have their own
   attributes -- see the documentation for details.


   .. py:attribute:: WATERDEPTH


   .. py:attribute:: QX


   .. py:attribute:: QY


   .. py:attribute:: UX


   .. py:attribute:: UY


   .. py:attribute:: UNORM


   .. py:attribute:: FROUDE


   .. py:attribute:: WATERLEVEL


   .. py:attribute:: WATERSTAGE


   .. py:attribute:: TOPOGRAPHY


   .. py:attribute:: HEAD


   .. py:attribute:: DIFFERENCE_Z_UP_DOWN


   .. py:attribute:: DIFFERENCE_HEAD_UP_DOWN


.. py:class:: stored_values_pos(*args, **kwds)

   Bases: :py:obj:`enum.Enum`

   .. autoapi-inheritance-diagram:: wolfhece.pybridges.stored_values_pos
      :parts: 1
      :private-bases:


   Create a collection of name/value pairs.

   Example enumeration:

   >>> class Color(Enum):
   ...     RED = 1
   ...     BLUE = 2
   ...     GREEN = 3

   Access them by:

   - attribute access::

   >>> Color.RED
   <Color.RED: 1>

   - value lookup:

   >>> Color(1)
   <Color.RED: 1>

   - name lookup:

   >>> Color['RED']
   <Color.RED: 1>

   Enumerations can be iterated over, and know how many members they have:

   >>> len(Color)
   3

   >>> list(Color)
   [<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]

   Methods can be added to enumerations, and members can have their own
   attributes -- see the documentation for details.


   .. py:attribute:: INDICE_I
      :value: (0, 'Indice i')



   .. py:attribute:: INDICE_J
      :value: (1, 'Indice j')



   .. py:attribute:: NUM_BLOCK
      :value: (2, 'Block')



.. py:class:: stored_values_coords(*args, **kwds)

   Bases: :py:obj:`enum.Enum`

   .. autoapi-inheritance-diagram:: wolfhece.pybridges.stored_values_coords
      :parts: 1
      :private-bases:


   Create a collection of name/value pairs.

   Example enumeration:

   >>> class Color(Enum):
   ...     RED = 1
   ...     BLUE = 2
   ...     GREEN = 3

   Access them by:

   - attribute access::

   >>> Color.RED
   <Color.RED: 1>

   - value lookup:

   >>> Color(1)
   <Color.RED: 1>

   - name lookup:

   >>> Color['RED']
   <Color.RED: 1>

   Enumerations can be iterated over, and know how many members they have:

   >>> len(Color)
   3

   >>> list(Color)
   [<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]

   Methods can be added to enumerations, and members can have their own
   attributes -- see the documentation for details.


   .. py:attribute:: X
      :value: (0, 'CoordX')



   .. py:attribute:: Y
      :value: (1, 'CoordY')



.. py:class:: zones_in_file_fr_vec(*args, **kwds)

   Bases: :py:obj:`enum.Enum`

   .. autoapi-inheritance-diagram:: wolfhece.pybridges.zones_in_file_fr_vec
      :parts: 1
      :private-bases:


   Create a collection of name/value pairs.

   Example enumeration:

   >>> class Color(Enum):
   ...     RED = 1
   ...     BLUE = 2
   ...     GREEN = 3

   Access them by:

   - attribute access::

   >>> Color.RED
   <Color.RED: 1>

   - value lookup:

   >>> Color(1)
   <Color.RED: 1>

   - name lookup:

   >>> Color['RED']
   <Color.RED: 1>

   Enumerations can be iterated over, and know how many members they have:

   >>> len(Color)
   3

   >>> list(Color)
   [<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]

   Methods can be added to enumerations, and members can have their own
   attributes -- see the documentation for details.


   .. py:attribute:: PARTS
      :value: '3 zones'



   .. py:attribute:: RIVER
      :value: 'entier'



.. py:class:: zones_in_file(*args, **kwds)

   Bases: :py:obj:`enum.Enum`

   .. autoapi-inheritance-diagram:: wolfhece.pybridges.zones_in_file
      :parts: 1
      :private-bases:


   Create a collection of name/value pairs.

   Example enumeration:

   >>> class Color(Enum):
   ...     RED = 1
   ...     BLUE = 2
   ...     GREEN = 3

   Access them by:

   - attribute access::

   >>> Color.RED
   <Color.RED: 1>

   - value lookup:

   >>> Color(1)
   <Color.RED: 1>

   - name lookup:

   >>> Color['RED']
   <Color.RED: 1>

   Enumerations can be iterated over, and know how many members they have:

   >>> len(Color)
   3

   >>> list(Color)
   [<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]

   Methods can be added to enumerations, and members can have their own
   attributes -- see the documentation for details.


   .. py:attribute:: PARTS


   .. py:attribute:: RIVER


   .. py:attribute:: DECK


   .. py:attribute:: ROOF


   .. py:attribute:: PIER


   .. py:attribute:: CROSS_SECTIONS


   .. py:attribute:: EXTRACTION


.. py:class:: operators(*args, **kwds)

   Bases: :py:obj:`enum.Enum`

   .. autoapi-inheritance-diagram:: wolfhece.pybridges.operators
      :parts: 1
      :private-bases:


   Create a collection of name/value pairs.

   Example enumeration:

   >>> class Color(Enum):
   ...     RED = 1
   ...     BLUE = 2
   ...     GREEN = 3

   Access them by:

   - attribute access::

   >>> Color.RED
   <Color.RED: 1>

   - value lookup:

   >>> Color(1)
   <Color.RED: 1>

   - name lookup:

   >>> Color['RED']
   <Color.RED: 1>

   Enumerations can be iterated over, and know how many members they have:

   >>> len(Color)
   3

   >>> list(Color)
   [<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]

   Methods can be added to enumerations, and members can have their own
   attributes -- see the documentation for details.


   .. py:attribute:: MEDIAN
      :value: 'median'



   .. py:attribute:: MIN
      :value: 'min'



   .. py:attribute:: MAX
      :value: 'max'



   .. py:attribute:: PERCENTILE5
      :value: 'p5'



   .. py:attribute:: PERCENTILE95
      :value: 'p95'



   .. py:attribute:: ALL
      :value: 'all'



.. py:class:: parts_values(*args, **kwds)

   Bases: :py:obj:`enum.Enum`

   .. autoapi-inheritance-diagram:: wolfhece.pybridges.parts_values
      :parts: 1
      :private-bases:


   Create a collection of name/value pairs.

   Example enumeration:

   >>> class Color(Enum):
   ...     RED = 1
   ...     BLUE = 2
   ...     GREEN = 3

   Access them by:

   - attribute access::

   >>> Color.RED
   <Color.RED: 1>

   - value lookup:

   >>> Color(1)
   <Color.RED: 1>

   - name lookup:

   >>> Color['RED']
   <Color.RED: 1>

   Enumerations can be iterated over, and know how many members they have:

   >>> len(Color)
   3

   >>> list(Color)
   [<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]

   Methods can be added to enumerations, and members can have their own
   attributes -- see the documentation for details.


   .. py:attribute:: CENTRAL


   .. py:attribute:: UPSTREAM


   .. py:attribute:: DOWNSTREAM


.. py:class:: rivers_values(*args, **kwds)

   Bases: :py:obj:`enum.Enum`

   .. autoapi-inheritance-diagram:: wolfhece.pybridges.rivers_values
      :parts: 1
      :private-bases:


   Create a collection of name/value pairs.

   Example enumeration:

   >>> class Color(Enum):
   ...     RED = 1
   ...     BLUE = 2
   ...     GREEN = 3

   Access them by:

   - attribute access::

   >>> Color.RED
   <Color.RED: 1>

   - value lookup:

   >>> Color(1)
   <Color.RED: 1>

   - name lookup:

   >>> Color['RED']
   <Color.RED: 1>

   Enumerations can be iterated over, and know how many members they have:

   >>> len(Color)
   3

   >>> list(Color)
   [<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]

   Methods can be added to enumerations, and members can have their own
   attributes -- see the documentation for details.


   .. py:attribute:: RIVERBED


   .. py:attribute:: LEFTBANK


   .. py:attribute:: RIGHTBANK


.. py:class:: cs_values(*args, **kwds)

   Bases: :py:obj:`enum.Enum`

   .. autoapi-inheritance-diagram:: wolfhece.pybridges.cs_values
      :parts: 1
      :private-bases:


   Create a collection of name/value pairs.

   Example enumeration:

   >>> class Color(Enum):
   ...     RED = 1
   ...     BLUE = 2
   ...     GREEN = 3

   Access them by:

   - attribute access::

   >>> Color.RED
   <Color.RED: 1>

   - value lookup:

   >>> Color(1)
   <Color.RED: 1>

   - name lookup:

   >>> Color['RED']
   <Color.RED: 1>

   Enumerations can be iterated over, and know how many members they have:

   >>> len(Color)
   3

   >>> list(Color)
   [<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]

   Methods can be added to enumerations, and members can have their own
   attributes -- see the documentation for details.


   .. py:attribute:: UPSTREAM


   .. py:attribute:: MIDDLE


   .. py:attribute:: DOWNSTREAM


.. py:class:: Bridge(myfile='', ds: float = 5.0, ox: float = 0, oy: float = 0, tx: float = 0, ty: float = 0, parent=None, is2D=True, idx: str = '', wx_exists: bool = False, mapviewer=None)

   Bases: :py:obj:`wolfhece.PyVertexvectors.Zones`

   .. autoapi-inheritance-diagram:: wolfhece.pybridges.Bridge
      :parts: 1
      :private-bases:


   Bridge class

   Representation :

           Downstream

               |
           *-------*
           |   |   |
           |  down |
           |   |   |
           *-------*
           |   |   |
           |  cent |
           |   |   |
           *-------*
           |   |   |
           |   up  |
           |   |   |
           *-------*
               |

               /            Upstream

   Enumeration of vertices :

               ^               ^               ^
           3-------2       0-------3       1-------2
           |   |   |       |   |   |       |   |   |
           |  cent |       |  upst |       |  down |
           |   |   |       |   |   |       |   |   |
           0-------1       1-------2       0-------3
               ^               ^               ^



   .. py:method:: new_bridge(name: str)
      :classmethod:


      Create a new bridge with name



   .. py:attribute:: centralpart
      :value: None



   .. py:attribute:: upstream
      :value: None



   .. py:attribute:: downstream
      :value: None



   .. py:attribute:: riverbed
      :value: None



   .. py:attribute:: leftbank
      :value: None



   .. py:attribute:: rightbank
      :value: None



   .. py:attribute:: polygons_zone
      :value: None



   .. py:attribute:: mapviewer
      :value: None



   .. py:attribute:: parent
      :value: None



   .. py:method:: force_plot()


   .. py:method:: create_polygon_river(ds: float = 5.0)

      Create river polygons



   .. py:method:: colorize()

      Colorisation des polygones pour l'interface graphique



   .. py:method:: get_distance(x: float, y: float)

      Compute the distance in-between x,y and the center of the deck



   .. py:method:: highlighting(rgb=(255, 0, 0), linewidth=3)

      Mise en évidence



   .. py:method:: withdrawal()

      Mise en retrait



   .. py:method:: compute_distance(poly: shapely.geometry.LineString)

      Compute the curvilinear distance along a support polyline



   .. py:method:: plot(sx=None, sy=None, xmin=None, ymin=None, xmax=None, ymax=None, size=None)

      Plot into GUI



   .. py:method:: find_values_inside_parts(linked_arrays)

      Récupère les valeurs à l'intérieur :
       - des parties du pont (amont, centrale, aval)
       - de la discrétisation rivière en polygones

      Retour :
       - dictionnaire dont la clé est le nom (ou l'index) du polygone dans la zone --> parties centrale, amont ou aval
       - chaque entrée est un dictionnaire dont la clé 'values' contient un dictionnaire pour chaque matrice du projet
       - chaque élément de ce sous-dictionnaire est un tuple contenant toutes les valeurs utiles


      ATTENTION : si linked_arrays est un dictionnaire, alors un niveau supérieur est ajouté sur base des clés de ce dictionnaire, dans ce cas, self.linked est un dict et non une liste




   .. py:method:: get_diff(which_value=Literal[stored_values_unk.DIFFERENCE_Z_UP_DOWN, stored_values_unk.DIFFERENCE_HEAD_UP_DOWN], operator: operators = operators.MEDIAN, which_group=None)

      Compute Head or Elevation differences



   .. py:method:: _get_heads(which_part: parts_values, which_group=None)

      Compute Head



   .. py:method:: _get_river_heads(which_group=None)

      Compute Head



   .. py:method:: get_values(which_part: parts_values, which_value: Union[stored_values_unk, stored_values_pos], which_group=None) -> dict

      Get values for a specific part

      La donnée retournée est un dictionnaire --> dépend du typage de "self.linked" (cf "find_values_inside_parts)" pour plus d'infos)

      Soit il n'y a qu'un projet à traiter --> le dictionnaire reprend les différentes valeurs pour chaque matrice/simulation du projet
      Soit il y a plusiuers projets à traiter --> le dictionnaire contient autant d'entrées que de projet et chaque sous-dictionnaire reprend les différentes valeurs pour chaque matrice/simulation du projet



   .. py:method:: get_river_values(which_value: Union[stored_values_unk, stored_values_pos], which_group=None) -> dict

      Get values for the river polygons

      La donnée retournée est un dictionnaire --> dépend du typage de "self.linked" (cf "find_values_inside_parts)" pour plus d'infos)

      Soit il n'y a qu'un projet à traiter --> le dictionnaire contient une entrée pour chaque polygone et les différentes valeurs pour chaque matrice/simulation du projet dans chaque polygone
      Soit il y a plusiuers projets à traiter --> le dictionnaire contient autant d'entrées que de projet et chaque sous-dictionnaire reprend les différentes valeurs comme ci-dessus



   .. py:method:: get_values_op(which_part: parts_values, which_value: Union[stored_values_unk, stored_values_pos], which_group=None, operator: operators = operators.MEDIAN) -> dict


   .. py:method:: get_river_values_op(which_value: Union[stored_values_unk, stored_values_pos], which_group=None, operator: operators = operators.MEDIAN) -> dict


   .. py:method:: plot_unk(figax=None, which_value: Union[stored_values_unk, stored_values_pos] = stored_values_unk.WATERLEVEL, which_group=None, operator: operators = operators.MEDIAN, options: dict = None, label=True, show=False)


   .. py:method:: plot_waterline(figax=None, which_group=None, operator: operators = operators.MEDIAN, show=False)


   .. py:method:: plot_waterhead(figax=None, which_group=None, operator: operators = operators.MEDIAN, show=False)


   .. py:method:: plot_deck(ax, width, height, lower_level)


.. py:class:: Bridges(directory: str, idx: str = '', plotted: bool = True, mapviewer=None, need_for_wx: bool = False, TypeObj=Bridge)

   Bases: :py:obj:`wolfhece.drawing_obj.Element_To_Draw`

   .. autoapi-inheritance-diagram:: wolfhece.pybridges.Bridges
      :parts: 1
      :private-bases:


   Base class of element to add into WolfMapViewer or another GUI


   .. py:attribute:: myelts


   .. py:attribute:: mysites


   .. py:attribute:: active_elt
      :value: None



   .. py:attribute:: active_site
      :value: None



   .. py:attribute:: keys_values
      :value: None



   .. py:attribute:: _directory


   .. py:attribute:: xmin
      :value: 0.0



   .. py:attribute:: xmax
      :value: 0.0



   .. py:attribute:: ymin
      :value: 0.0



   .. py:attribute:: ymax
      :value: 0.0



   .. py:method:: addnew(idx: str = '')

      Add a new bridge



   .. py:method:: plot(sx=None, sy=None, xmin=None, ymin=None, xmax=None, ymax=None, size=None)

      Plot elements inside PyDraw



   .. py:method:: find_minmax(update=False)

      Find Min and Max for graphical/GUI needs



   .. py:method:: _get_list(site) -> list[Bridge]


   .. py:method:: get_elts(site) -> list[Bridge]


   .. py:method:: find_nearest(x: float, y: float, site: str = None) -> Bridge

      Find the nearest bridge

      site : (optional) key name of a site



   .. py:method:: find_inside_poly(vec: wolfhece.PyVertexvectors.vector) -> list

      Find bridges inside polygon/vector



   .. py:method:: select_inside_contour(contours: wolfhece.PyVertexvectors.Zones)

      Sort bridges inside "contour" stored in multiple zones

      Fill-in dict "self.sites" with key names based on names of zones



   .. py:method:: compute_distances(poly: wolfhece.PyVertexvectors.vector, site: str = None)

      Compute the curvilinear distance along a support polyline

      site : (optional) key name of a site



   .. py:method:: get_curvis(site: str = None) -> list

      Crée une liste contenant les coordonnées curviligne des ponts



   .. py:method:: get_centralparts(site: str = None) -> wolfhece.PyVertexvectors.zone

      Crée une nouvelle zone avec tous les tabliers de ponts



   .. py:method:: get_upstreams(site: str = None) -> wolfhece.PyVertexvectors.zone

      Crée une nouvelle zone avec tous les zones amont de ponts



   .. py:method:: get_downstreams(site: str = None) -> wolfhece.PyVertexvectors.zone

      Crée une nouvelle zone avec tous les zones aval de ponts



   .. py:method:: find_values_inside_parts(linked_arrays, site: str = None)

      Récupère les valeurs à l'intérieur des parties du pont

      Stockage dans chaque ouvrage
      On retient par contre dans l'objet courant les clés des matrices sur lesquelles on travaille   --> keys_values



   .. py:method:: get_values(which_part: parts_values, which_value: Union[stored_values_unk, stored_values_pos], which_group=None, site: str = None) -> dict


   .. py:method:: get_diff(which_value, which_group=None, operator: operators = operators.MEDIAN, site: str = None) -> dict


   .. py:method:: get_river_values(which_value: Union[stored_values_unk, stored_values_pos], which_group=None, site: str = None) -> dict


   .. py:method:: plot_landmarks(landmarks, s_landmarks, ax, ypos, plot_text=True)


   .. py:method:: plot_group(which_part: parts_values = None, which_value: Union[stored_values_unk, stored_values_pos] = None, which_group=None, operator: operators = operators.MEDIAN, options: dict = None, fig=None, ax=None, ybounds=None, site: str = None, show=True)


   .. py:method:: plot_part_vs_part_group(which_parts: list = None, which_value: Union[stored_values_unk, stored_values_pos] = None, which_group=None, operator: operators = operators.MEDIAN, options: dict = None, fig=None, ax=None, ybounds=None, site: str = None, show=True)


   .. py:method:: plot_part_group_vs_group(which_part: parts_values = None, which_value: Union[stored_values_unk, stored_values_pos] = None, which_groups: list = None, operator: operators = operators.MEDIAN, options: dict = None, fig=None, ax=None, ybounds=None, site: str = None, show=True)


   .. py:method:: plot_all_groups(which_part: parts_values = None, which_value: Union[stored_values_unk, stored_values_pos] = None, operator: operators = operators.MEDIAN, options: dict = None, fig=None, ax=None, ybounds=None, site: str = None, show=True)

      Graphique de toutes les valeurs associées aux éléments



   .. py:method:: plot_vs_all_groups(which_part_source: parts_values = None, which_value: Union[stored_values_unk, stored_values_pos] = None, operator: operators = operators.MEDIAN, options: dict = None, fig=None, ax=None, ybounds=None, site: str = None, show=True)

      Graphique de toutes les valeurs associées aux éléments



   .. py:method:: plot_all_vs_groups(which_part: parts_values = None, which_value: Union[stored_values_unk, stored_values_pos] = None, which_group_source=None, operator: operators = operators.MEDIAN, options: dict = None, fig=None, ax=None, ybounds=None, site: str = None, show=True)

      Graphique de toutes les valeurs associées aux éléments



.. py:class:: Weir(myfile='', ds: float = 5, ox: float = 0, oy: float = 0, tx: float = 0, ty: float = 0, parent=None, is2D=True, idx='', wx_exists: bool = False)

   Bases: :py:obj:`Bridge`

   .. autoapi-inheritance-diagram:: wolfhece.pybridges.Weir
      :parts: 1
      :private-bases:


   Bridge class

   Representation :

           Downstream

               |
           *-------*
           |   |   |
           |  down |
           |   |   |
           *-------*
           |   |   |
           |  cent |
           |   |   |
           *-------*
           |   |   |
           |   up  |
           |   |   |
           *-------*
               |

               /            Upstream

   Enumeration of vertices :

               ^               ^               ^
           3-------2       0-------3       1-------2
           |   |   |       |   |   |       |   |   |
           |  cent |       |  upst |       |  down |
           |   |   |       |   |   |       |   |   |
           0-------1       1-------2       0-------3
               ^               ^               ^



   .. py:method:: colorize()

      Colorisation des polygones pour l'interface graphique



.. py:class:: Weirs(directory: str, idx: str = '', plotted: bool = True, mapviewer=None, need_for_wx: bool = False, TypeObj=Weir)

   Bases: :py:obj:`Bridges`

   .. autoapi-inheritance-diagram:: wolfhece.pybridges.Weirs
      :parts: 1
      :private-bases:


   Base class of element to add into WolfMapViewer or another GUI


   .. py:method:: _get_list(site) -> list[Weir]


   .. py:method:: get_elts(site) -> list[Weir]