:py:mod:`wolfhece.pypolygons_scen` ================================== .. py:module:: wolfhece.pypolygons_scen .. 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:: ZipFileWrapper(file, mode='r', compression=ZIP_STORED, allowZip64=True, compresslevel=None, *, strict_timestamps=True) Bases: :py:obj:`zipfile.ZipFile` .. autoapi-inheritance-diagram:: wolfhece.pypolygons_scen.ZipFileWrapper :parts: 1 :private-bases: Class with methods to open, read, write, close, list zip files. z = ZipFile(file, mode="r", compression=ZIP_STORED, allowZip64=True, compresslevel=None) file: Either the path to the file, or a file-like object. If it is a path, the file will be opened and closed by ZipFile. mode: The mode can be either read 'r', write 'w', exclusive create 'x', or append 'a'. compression: ZIP_STORED (no compression), ZIP_DEFLATED (requires zlib), ZIP_BZIP2 (requires bz2) or ZIP_LZMA (requires lzma). allowZip64: if True ZipFile will create files with ZIP64 extensions when needed, otherwise it will raise an exception when this would be necessary. compresslevel: None (default for the given compression type) or an integer specifying the level to pass to the compressor. When using ZIP_STORED or ZIP_LZMA this keyword has no effect. When using ZIP_DEFLATED integers 0 through 9 are accepted. When using ZIP_BZIP2 integers 1 through 9 are accepted. .. py:method:: open(name='data', mode='r', pwd=None, **kwargs) Return file-like object for 'name'. name is a string for the file name within the ZIP file, or a ZipInfo object. mode should be 'r' to read a file already in the ZIP file, or 'w' to write to a file newly added to the archive. pwd is the password to decrypt files (only used for reading). When writing, if the file size is not known in advance but may exceed 2 GiB, pass force_zip64 to use the ZIP64 format, which can handle large files. If the size is known in advance, it is best to pass a ZipInfo instance for name, with zinfo.file_size set. .. py:method:: read() Return file bytes for name. .. py:class:: Extracting_Zones(filename='', ox: float = 0, oy: float = 0, tx: float = 0, ty: float = 0, parent=None, is2D=True, idx: str = '', plotted: bool = True, mapviewer=None, need_for_wx: bool = False) Bases: :py:obj:`wolfhece.PyVertexvectors.Zones` .. autoapi-inheritance-diagram:: wolfhece.pypolygons_scen.Extracting_Zones :parts: 1 :private-bases: Classe permettant de récupérer les valeurs à l'intérieur des polygones définis dans plusieurs zones. Ces polygones ne sont pas nécessairement ordonnés ou relatifs au lit mineur. .. py:method:: cache_data(outputfile: str) Serialize the values in a file .. py:method:: load_data(inputfile: str) Deserialize the values from a file .. py:method:: _serialize_values(outputfile: str) Serialize the values in a file .. py:method:: _deserialize_values(inputfile: str) Deserialize the values from a file .. py:method:: find_values_inside_parts(linked_arrays) Récupère les valeurs à l'intérieur de la zone 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_heads(which_vec: str, which_group=None) Compute Head .. py:method:: get_values(which_vec: str, which_value: Union[wolfhece.pybridges.stored_values_unk, wolfhece.pybridges.stored_values_pos, wolfhece.pybridges.stored_values_coords], 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_values_op(which_vec: str, which_value: Union[wolfhece.pybridges.stored_values_unk, wolfhece.pybridges.stored_values_pos, wolfhece.pybridges.stored_values_coords], which_group=None, operator: wolfhece.pybridges.operators = operators.MEDIAN) -> dict .. py:class:: Polygons_Analyze(myfile='', ds: float = 5.0, ox: float = 0, oy: float = 0, tx: float = 0, ty: float = 0, parent=None, is2D=True, wx_exists: bool = False) Bases: :py:obj:`wolfhece.PyVertexvectors.Zones` .. autoapi-inheritance-diagram:: wolfhece.pypolygons_scen.Polygons_Analyze :parts: 1 :private-bases: Classe permettant de récupérer les valeurs à l'intérieur des polygones définis dans la dernière zone d'une fichier .vecz. Ce fichier est typiquement le résultat de la création de polygones sur base de parallèles via l'interface graphique. Utile notamment dans l'analyse de modélisations 2D (CPU et/ou GPU). .. py:method:: cache_data(outputfile: str) Serialize the values in a json file -- zipped .. py:method:: load_data(inputfile: str) Deserialize the values from a json file -- zipped .. py:method:: _serialize_values(outputfile: str) Serialize the values in a file .. py:method:: _deserialize_values(inputfile: str) Deserialize the values from a file .. py:method:: compute_distance(poly: shapely.geometry.LineString | wolfhece.PyVertexvectors.vector) Compute the curvilinear distance along a support polyline :param poly: vector or LineString Shapely object .. py:method:: find_values_inside_parts(linked_arrays: Union[dict, list]) Récupère les valeurs à l'intérieur des polygones - dernière zone du fichier Stockage : - dictionnaire dont la clé est le nom (ou l'index) du polygone dans la zone - 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_river_heads(which_group=None) Compute Head :param which_group: group to get .. py:method:: get_river_values(which_value: Union[wolfhece.pybridges.stored_values_unk, wolfhece.pybridges.stored_values_pos, wolfhece.pybridges.stored_values_coords], 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 :param which_value: value to get :param which_group: group to get .. py:method:: get_river_values_op(which_value: Union[wolfhece.pybridges.stored_values_unk, wolfhece.pybridges.stored_values_pos, wolfhece.pybridges.stored_values_coords], which_group=None, operator: wolfhece.pybridges.operators = operators.MEDIAN) -> dict Get values for the river polygons with an operator :param which_value: value to get :param which_group: group to get :param operator: MEDIAN, MIN, MAX, PERCENTILE95, PERCENTILE5, ALL .. py:method:: list_groups() List the groups of the river polygons .. py:method:: list_sims(which_group=None) List the sims for a specific group or for all the groups of the river polygons .. py:method:: get_s_values(which_value: Union[wolfhece.pybridges.stored_values_unk, wolfhece.pybridges.stored_values_pos, wolfhece.pybridges.stored_values_coords] = stored_values_unk.WATERLEVEL, which_group: str = None, which_sim: str = None, operator: wolfhece.pybridges.operators = operators.MEDIAN) Get the values of the river polygons for a specific simulation :param which_value: value to get :param which_group: group to get :param which_sim: simulation to get :param operator: operator to use .. py:method:: get_s_xy() Get the centroids of the river polygons .. py:method:: get_s_xy4sim(which_group: str, which_sim: str, operator: wolfhece.pybridges.operators = operators.MEDIAN) Get the position for a specific simulation .. py:method:: save_xy_s_tofile(outputfile: str) Save the centroids of the river polygons to a file .. py:method:: save_xy_s_tofile_4sim(outputfile: str, which_group: str, which_sim: str) Save the centroids of the river polygons to a file .. py:method:: export_as(outputfile: pathlib.Path, unks: list[wolfhece.pybridges.stored_values_unk | wolfhece.pybridges.stored_values_coords], which_group: str, which_sim: str, operator: wolfhece.pybridges.operators = operators.MEDIAN) Export the values of the river polygons to a file :param outputfile: output file (supported formats: csv, xlsx) :param unks: list of values to export :param which_group: group to export :param which_sim: simulation to export :param operator: operator to use for values (coordinates will be exported as MEDIAN) .. py:method:: plot_unk(figax=None, which_value: Union[wolfhece.pybridges.stored_values_unk, wolfhece.pybridges.stored_values_pos] = stored_values_unk.WATERLEVEL, which_group=None, operator: wolfhece.pybridges.operators = operators.MEDIAN, options: dict = None, label=True, show=False) Plot the values of the river polygons :param figax: tuple (fig, ax) for the plot :param which_value: value to plot :param which_group: group to plot :param operator: operator to use :param options: options for the plot :param label: show the labels or not :param show: show the plot or not .. py:method:: plot_waterline(figax=None, which_group=None, operator: wolfhece.pybridges.operators = operators.MEDIAN, show=False) Plot the waterline :param figax: tuple (fig, ax) for the plot :param which_group: group to plot :param operator: operator to use :param show: show the plot or not .. py:method:: plot_bedelevation(figax=None, which_group=None, operator: wolfhece.pybridges.operators = operators.MEDIAN, show=False) Plot the bed elevation :param figax: tuple (fig, ax) for the plot :param which_group: group to plot :param operator: operator to use :param show: show the plot or not .. py:method:: plot_stage(figax=None, which_group=None, operator: wolfhece.pybridges.operators = operators.MEDIAN, show=False) Plot the water stage /water level :param figax: tuple (fig, ax) for the plot :param which_group: group to plot :param operator: operator to use :param show: show the plot or not .. py:method:: plot_waterhead(figax=None, which_group=None, operator: wolfhece.pybridges.operators = operators.MEDIAN, show=False) Plot the water head :param figax: tuple (fig, ax) for the plot :param which_group: group to plot :param operator: operator to use :param show: show the plot or not