:py:mod:`wolfhece.wolf_array` ============================= .. py:module:: wolfhece.wolf_array .. 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:data:: msg .. py:data:: msg .. py:data:: WOLF_ARRAY_HILLSHAPE .. py:data:: WOLF_ARRAY_FULL_SINGLE :value: 1 .. py:data:: WOLF_ARRAY_FULL_DOUBLE :value: 2 .. py:data:: WOLF_ARRAY_SYM_DOUBLE :value: 12 .. py:data:: WOLF_ARRAY_FULL_LOGICAL :value: 4 .. py:data:: WOLF_ARRAY_CSR_DOUBLE :value: 5 .. py:data:: WOLF_ARRAY_FULL_INTEGER :value: 6 .. py:data:: WOLF_ARRAY_FULL_SINGLE_3D :value: 7 .. py:data:: WOLF_ARRAY_FULL_INTEGER8 :value: 8 .. py:data:: WOLF_ARRAY_FULL_UINTEGER8 :value: 88 .. py:data:: WOLF_ARRAY_MB_SINGLE :value: 3 .. py:data:: WOLF_ARRAY_MB_INTEGER :value: 9 .. py:data:: WOLF_ARRAY_FULL_INTEGER16_2 :value: 0 .. py:data:: WOLF_ARRAY_FULL_INTEGER16 :value: 11 .. py:data:: WOLF_ARRAY_MNAP_INTEGER :value: 20 .. py:data:: WOLF_ARRAY_MB .. py:data:: VERSION_RGB :value: 3 .. py:function:: custom_gradient(array: numpy.ndarray) Calculate the gradient manually .. py:function:: hillshade(array: numpy.ndarray, azimuth: float, angle_altitude: float) -> numpy.ndarray Create a hillshade array .. py:class:: Rebin_Ops Bases: :py:obj:`enum.Enum` .. autoapi-inheritance-diagram:: wolfhece.wolf_array.Rebin_Ops :parts: 1 :private-bases: Generic enumeration. Derive from this class to define new enumerations. .. py:attribute:: MIN :value: 0 .. py:attribute:: MEAN :value: 1 .. py:attribute:: MAX :value: 2 .. py:attribute:: SUM :value: 3 .. py:attribute:: MEDIAN :value: 4 .. py:method:: get_numpy_ops() :classmethod: Return a list of numpy functions corresponding to the enum values .. py:method:: get_ops(name: str) :classmethod: Return the numpy function corresponding to a string .. py:function:: getkeyblock(i, addone=True) -> str Name/Key of a block in the dictionnary of a WolfArrayMB instance For Fortran compatibility, addone is True by default so first block is "block1" and not "block0" .. py:function:: decodekeyblock(key, addone=True) -> int Decode key of a block in the dictionnary of a WolfArrayMB instance For Fortran compatibility, addone is True by default so first block is "block1" and not "block0" .. py:class:: header_wolf Header of WolfArray In case of a mutliblock, the header have informations about all the blocks in head_blocks dictionnary. Block keys are generated by "getkeyblock" function .. py:property:: nullvalue .. py:property:: nbdims .. py:property:: shape .. py:property:: nb_blocks .. py:property:: resolution .. py:property:: origin .. py:property:: translation .. py:attribute:: head_blocks :type: dict[str, header_wolf] .. py:method:: set_resolution(dx: float, dy: float, dz: float = 0.0) Set resolution .. py:method:: set_origin(x: float, y: float, z: float = 0.0) Set origin :param x: origin along X :param y: origin along Y :param z: origin along Z .. py:method:: get_origin() Return origin .. py:method:: get_resolution() Return resolution .. py:method:: get_translation() Return translation .. py:method:: set_translation(tr_x: float, tr_y: float, tr_z: float = 0.0) Set translation :param tr_x: translation along X :param tr_y: translation along Y :param tr_z: translation along Z .. py:method:: get_bounds(abs=True) Return bounds in coordinates :param abs: if True, add translation to (x, y) (coordinate to global space) :return: tuple of two lists of two floats - ([xmin, xmax],[ymin, ymax]) .. py:method:: get_bounds_ij(abs=False) Return bounds in indices Firstly, get_bounds is called to get bounds in coordinates and then get_ij_from_xy is called to get bounds in indices. :param abs: if True, add translation to (x, y) (coordinate to global space) .. py:method:: get_ij_from_xy(x: float, y: float, z: float = 0.0, scale: float = 1.0, aswolf: bool = False, abs: bool = True, forcedims2: bool = False) -> Union[tuple[numpy.int32, numpy.int32], tuple[numpy.int32, numpy.int32, numpy.int32]] Get indices from coordinates :param x: X coordinate :param y: Y coordinate :param z: Z coordinate (optional) :param scale: scaling of the spatial resolution (dx,dy,[dz]) :param aswolf: if True, return if one-based (as Wolf VB6 or Fortran), otherwise 0-based (default Python standard) :param abs: if True, remove translation from (x, y, [z]) (coordinate from global space) :param forcedims2: if True, force to return only 2 indices even if z is supplied .. py:method:: get_ij_from_xy_array(xy: numpy.ndarray, scale: float = 1.0, aswolf: bool = False, abs: bool = True, forcedims2: bool = False) -> numpy.ndarray Get indices from coordinates :param xy = numpy array containing (x, y, [z]) coordinates - shape (n, 2) or (n, 3) :param scale = scaling of the spatial resolution (dx,dy,[dz]) :param aswolf = if True, return if one-based (as Wolf VB6 or Fortran), otherwise 0-based (default Python standard) :param abs = if True, remove translation from (x, y, [z]) (coordinate from global space) :param forcedims2 = if True, force to return only 2 indices even if z is supplied :return: numpy array containing (i, j, [k]) indices - shape (n, 2) or (n, 3) .. py:method:: get_xy_from_ij(i: int, j: int, k: int = 0, scale: float = 1.0, aswolf: bool = False, abs: bool = True) -> Union[tuple[numpy.float64, numpy.float64], tuple[numpy.float64, numpy.float64, numpy.float64]] Get coordinates from indices :param i = index along X coordinate :param j = index along Y coordinate :param k = index along Z coordinate (optional) :param scale = scaling of the spatial resolution (dx,dy,[dz]) :param aswolf = if True, input is one-based (as Wolf VB6 or Fortran), otherwise 0-based (default Python standard) :param abs = if True, add translation to results (x, y, [z]) (coordinate to global space) .. py:method:: transform() Return the affine transformation. Similar to rasterio.transform.Affine In WOLF, the convention is : - origin is at the lower-left corner - the origin is at the corner of the cell dx, dy, so the center of the cell is at dx/2, dy/2 - X axis is along the rows - i index - Y axis is along the columns - j index So, the affine transformation is : (dx, 0, origx + translx + dx /2, 0, dy, origy + transly + dy/2) .. py:method:: _transform_gmrio() Return the affine transformation. !! Inverted ij/ji convention !! Similar to rasterio.transform.Affine In WOLF, the convention is : - origin is at the lower-left corner - the origin is at the corner of the cell dx, dy, so the center of the cell is at dx/2, dy/2 - X axis is along the rows - i index - Y axis is along the columns - j index So, the affine transformation is : (dx, 0, origx + translx + dx /2, 0, dy, origy + transly + dy/2) .. py:method:: get_xy_from_ij_array(ij: numpy.ndarray, scale: float = 1.0, aswolf: bool = False, abs: bool = True) -> numpy.ndarray Converts array coordinates (numpy cells) to this array's world coodinates. :param ij = numpy array containing (i, j, [k]) indices - shape (n, 2) or (n, 3) :param scale = scaling of the spatial resolution (dx,dy,[dz]) :param aswolf = if True, input is one-based (as Wolf VB6 or Fortran), otherwise 0-based (default Python standard) :param abs = if True, add translation to results (x, y, [z]) (coordinate to global space) ..warning: 'ij' is not the result of np.where() but if you want to use np.where() you can use the following code: ``` np.vstack((ij[0], ij[1])).T ``` .. py:method:: ij2xy(i: int, j: int, k: int = 0, scale: float = 1.0, aswolf: bool = False, abs: bool = True) -> Union[tuple[numpy.float64, numpy.float64], tuple[numpy.float64, numpy.float64, numpy.float64]] alias for get_xy_from_ij .. py:method:: ij2xy_np(ij: numpy.ndarray, scale: float = 1.0, aswolf: bool = False, abs: bool = True) -> numpy.ndarray alias for get_xy_from_ij_array :param ij: numpy array containing (i, j, [k]) indices :param scale: scaling of the spatial resolution (dx,dy,[dz]) :param aswolf: if True, input is one-based (as Wolf VB6 or Fortran), otherwise 0-based (default Python standard) :param abs: if True, add translation to results (x, y, [z]) (coordinate to global space) ..warning: 'ij' is not the result of np.where() but if you want to use np.where() you can use the following code: ``` np.vstack((ij[0], ij[1])).T ``` :return: numpy array containing (x, y, [z]) coordinates - shape (n, 2) or (n, 3) .. py:method:: xy2ij(x: float, y: float, z: float = 0.0, scale: float = 1.0, aswolf: bool = False, abs: bool = True, forcedims2: bool = False) -> Union[tuple[numpy.int32, numpy.int32], tuple[numpy.int32, numpy.int32, numpy.int32]] alias for get_ij_from_xy .. py:method:: xy2ij_np(xy: numpy.ndarray, scale: float = 1.0, aswolf: bool = False, abs: bool = True) -> numpy.ndarray alias for get_ij_from_xy_array :param xy: numpy array containing (x, y, [z]) coordinates - shape (n, 2) or (n, 3) :param scale: scaling of the spatial resolution (dx,dy,[dz]) :param aswolf: if True, return if one-based (as Wolf VB6 or Fortran), otherwise 0-based (default Python standard) :param abs: if True, remove translation from (x, y, [z]) (coordinate from global space) :param forcedims2: if True, force to return only 2 indices even if z is supplied :return : numpy array containing (i, j, [k]) indices - shape (n, 2) or (n, 3) .. py:method:: xyz2ijk_np(xyz: numpy.ndarray, scale: float = 1.0, aswolf: bool = False, abs: bool = True) -> numpy.ndarray alias for get_xy_from_ij_array .. py:method:: ijk2xyz_np(ijk: numpy.ndarray, scale: float = 1.0, aswolf: bool = False, abs: bool = True) -> numpy.ndarray alias for get_xy_from_ij_array .. py:method:: find_intersection(other: header_wolf, ij: bool = False) -> Union[tuple[list[float], list[float]], tuple[list[list[float]], list[list[float]]]] Find the intersection of two header :param other: other header :param ij: if True, return indices instead of coordinates :return: None or tuple of two lists of two floats - ([xmin, xmax],[ymin, ymax]) or indices in each header (if ij=True) [[imin1, imax1], [jmin1, jmax1]], [[imin2, imax2], [jmin2, jmax2]] .. py:method:: find_union(other: Union[header_wolf, list[header_wolf]]) -> tuple[list[float], list[float]] Find the union of two header :return: tuple of two lists of two floats - ([xmin, xmax],[ymin, ymax]) .. py:method:: read_txt_header(filename: str) Read informations from header .txt :param filename: path and filename of the basefile If filename is a Path object, it is converted to a string If filename ends with '.tif', nothing is done because infos are in the .tif file If filename ends with '.flt', a .hdr file must be present and it will be read Otherwise, a filename.txt file must be present .. py:method:: read_header(filename: str) -> header_wolf :classmethod: alias for read_txt_header .. py:method:: write_header(filename: str, wolftype: int, forceupdate: bool = False) alias for write_txt_header .. py:method:: write_txt_header(filename: str, wolftype: int, forceupdate: bool = False) Writing the header to a text file Nullvalue is not written :param filename: path and filename with '.txt' extension, which will NOT be automatically added :param wolftype: type of the WOLF_ARRAY_* array :param forceupdate: if True, the file is rewritten even if it already exists .. py:method:: is_like(other: header_wolf, check_mb: bool = False) -> bool Comparison of two headers :param other: other header to compare :param check_mb: if True, the comparison is done on the blocks too The nullvalue is not taken into account .. py:method:: align2grid(x1: float, y1: float, eps: float = 0.0001) -> tuple[float, float] Align coordinates to nearest grid point where the grid is defined by the borders of the array. .. py:method:: _rasterize_segment(x1: float, y1: float, x2: float, y2: float, xstart: float = None, ystart: float = None) -> list[list[float]] Rasterize a segment according to the grid where the grid is defined by the borders of the array. :param x1: x coordinate of the first point :param y1: y coordinate of the first point :param x2: x coordinate of the second point :param y2: y coordinate of the second point :param xstart: x coordinate of the starting point :param ystart: y coordinate of the starting point :return: numpy array of the rasterized segment .. py:method:: rasterize_vector(vector2raster: wolfhece.PyVertexvectors.vector, outformat: Union[numpy.ndarray, wolfhece.PyVertexvectors.vector] = vector) -> Union[numpy.ndarray, wolfhece.PyVertexvectors.vector] Rasterize a vector according to the grid :param vector2raster: vector to rasterize :param outformat: output format (np.ndarray or vector) .. py:method:: get_xy_infootprint_vect(myvect: wolfhece.PyVertexvectors.vector | shapely.geometry.Polygon, eps: float = 0.0) -> tuple[numpy.ndarray, numpy.ndarray] Return the coordinates of the cells in the footprint of a vector :param myvect: target vector :return: tuple of two numpy arrays - (coordinates, indices) :param eps: epsilon to avoid rounding errors .. py:method:: get_ij_infootprint_vect(myvect: wolfhece.PyVertexvectors.vector | shapely.geometry.Polygon, eps: float = 0.0) -> numpy.ndarray Return the indices of the cells in the footprint of a vector :param myvect: target vector :return: numpy array of indices :param eps: epsilon to avoid rounding errors .. py:method:: convert_xy2ij_np(xy) Convert XY coordinates to IJ indices **(0-based)** with Numpy without any check/options :param xy: = numpy array of shape (n,2) with XY coordinates .. py:method:: convert_ij2xy_np(ij) Convert IJ indices **(0-based)** to XY coordinates with Numpy without any check/options :param ij: = numpy array of shape (n,2) with IJ indices .. py:class:: NewArray(parent, mapviewer=None) Bases: :py:obj:`wx.Dialog` .. autoapi-inheritance-diagram:: wolfhece.wolf_array.NewArray :parts: 1 :private-bases: wx GUI interaction to create a new WolfArray Once filled, user/__init__ must call "init_from_new" .. py:method:: on_samezoom_parent(event) Fill the fields with the same values as the parent .. py:method:: on_sameas(event) Fill the fields with the same values as a file array .. py:class:: CropDialog(parent, mapviewer=None) Bases: :py:obj:`wx.Dialog` .. autoapi-inheritance-diagram:: wolfhece.wolf_array.CropDialog :parts: 1 :private-bases: wx GUI interaction to crop 2D array's data Used in "read_data" of a WolfArray .. py:method:: get_header() Return a header_wolf object with the values of the dialog .. py:method:: on_samezoom_parent(event) Fill the fields with the same values as the parent .. py:method:: on_sameas(event) Fill the fields with the same values as a file array .. py:method:: get_crop() Return the crop values .. py:class:: IntValidator Bases: :py:obj:`wx.Validator` .. autoapi-inheritance-diagram:: wolfhece.wolf_array.IntValidator :parts: 1 :private-bases: Validates data as it is entered into the text controls. .. py:method:: Clone() Required Validator method .. py:method:: Validate(win) .. py:method:: TransferToWindow() .. py:method:: TransferFromWindow() .. py:method:: OnChar(event) .. py:class:: Ops_Array(parentarray: WolfArray, mapviewer=None) Bases: :py:obj:`wx.Frame` .. autoapi-inheritance-diagram:: wolfhece.wolf_array.Ops_Array :parts: 1 :private-bases: Operations wx.Frame on WolfArray class This class is used to perform operations on a WolfArray .. py:property:: idx Return the idx of the parentarray .. py:property:: is_shared Check if the vector manager is shared .. py:method:: get_mapviewer() Retourne l'instance WolfMapViewer .. py:method:: get_linked_arrays() Pour compatibilité avec la gestion de vecteur et WolfMapViewer .. py:method:: set_GUI() Set the wx GUI .. py:method:: OnBlockSelect(event) Select block .. py:method:: interpolation2D(event: wx.MouseEvent) calling Interpolation 2D .. py:method:: Unmaskall(event: wx.MouseEvent) Unmask all values in the current array @author Pierre Archambeau .. py:method:: Unmasksel(event: wx.MouseEvent) Enlève le masque des éléments sélectionnés @author Pierre Archambeau .. py:method:: InvertMask(event: wx.MouseEvent) Invert mask .. py:method:: interp2Dpolygons(event: wx.MouseEvent) Bouton d'interpolation sous tous les polygones d'une zone cf WolfArray.interp2Dpolygon .. py:method:: interp2Dpolygon(event: wx.MouseEvent) Bouton d'interpolation sous un polygone cf WolfArray.interp2Dpolygon .. py:method:: interp2Dpolylines(event: wx.MouseEvent) Bouton d'interpolation sous toutes les polylignes de la zone cf parent.interp2Dpolyline .. py:method:: interp2Dpolyline(event: wx.MouseEvent) Bouton d'interpolation sous la polyligne active cf parent.interp2Dpolyline .. py:method:: volumesurface(event) Click on evaluation of stage-storage-surface relation .. py:method:: OnAllSelect(event) Select all --> just put "all" in "myselection" .. py:method:: OnReselectMemory(event) Reselect from memory .. py:method:: OnMoveSelect(event) Transfert de la sélection courante dans un dictionnaire .. py:method:: OnContractSelection(event) Contract selection .. py:method:: OnExpandSelection(event) Expand selection .. py:method:: OnExpandUnselectInterior(event) Expand contour .. py:method:: OnUnselectInterior(event) Contract contour .. py:method:: reset_selection() Reset of current selection .. py:method:: reset_all_selection() Reset of current selection and stored ones .. py:method:: OnResetSelect(event) Click on Reset of current selection .. py:method:: OnResetAllSelect(event) Click on reset all .. py:method:: OnSaveSelection(event) Save the current selection .. py:method:: OnLoadSelection(event) Load a selection .. py:method:: OnToClipboardStr(event) Copy the current selection to the clipboard as a string .. py:method:: OnApplyOpSelect(event) Select nodes based on condition .. py:method:: OnApplyNullvalue(event: wx.MouseEvent) Apply null value to the array .. py:method:: refresh_array() Force refresh of the parent array .. py:method:: OnNullBorder(event: wx.MouseEvent) Nullify the border of the array .. py:method:: OnFilterZone(event: wx.MouseEvent) Filter the array based on contiguous zones .. py:method:: OnClean(event: wx.MouseEvent) Clean the array -- Remove the isolated cells .. py:method:: OnLabelling(event: wx.MouseEvent) Labelling of contiguous zones .. py:method:: OnStatistics(event: wx.MouseEvent) Statistics on the array .. py:method:: OnExtractSelection(event: wx.MouseEvent) Extract the current selection .. py:method:: OnContourInt(event: wx.MouseEvent) Create contour - number of contours .. py:method:: OnContourList(event: wx.MouseEvent) Create contour - list of values .. py:method:: OnApplyOpMath(event: wx.MouseEvent) Apply math operator to the array .. py:method:: Onmask(event: wx.MouseEvent) Mask nodes based on condition .. py:method:: OnManageVectors(event: wx.MouseEvent) Open vector manager .. py:method:: show_structure_OpsVectors() Show the structure of the vector manager .. py:method:: hide_properties() Hide the properties panel .. py:method:: _get_comp_elts_diff() Get the elements and the differences of the linked arrays .. py:method:: _link_zones() Link the same vector manager to all the linked arrays .. py:method:: OnLoadvec(event: wx.MouseEvent) Load vector file .. py:method:: OnSaveasvec(event: wx.MouseEvent) Save vector file .. py:method:: OnSavevec(event: wx.MouseEvent) Save vector file .. py:method:: select_node_by_node() Select nodes by individual clicks Set the right action in the mapviewer who will attend the clicks .. py:method:: select_zone_inside_manager() Select nodes inside the active zone (manager) .. py:method:: select_vector_inside_manager() Select nodes inside the active vector (manager) .. py:method:: _select_vector_inside_manager(vect: wolfhece.PyVertexvectors.vector) Select nodes inside a vector or set action to add vertices to a vector by clicks .. py:method:: select_zone_under_manager() Select nodes along the active zone (manager) .. py:method:: select_vector_under_manager() Select nodes along the active vector (manager) .. py:method:: _select_vector_under_manager(vect: wolfhece.PyVertexvectors.vector) Select nodes along a vector or set action to add vertices to a vector by clicks .. py:method:: select_vector_inside_tmp() Select nodes inside the temporary vector .. py:method:: select_vector_under_tmp() Select nodes along the temporary vector .. py:method:: OnLaunchSelect(event: wx.MouseEvent) Action button .. py:method:: onclose(event: wx.MouseEvent) Hide the window .. py:method:: onshow(event: wx.MouseEvent) Show the window - set string with null value and update palette .. py:method:: Active_vector(vect: wolfhece.PyVertexvectors.vector, copyall: bool = True) Set the active vector to vect and forward to mapviewer .. py:method:: Active_zone(target_zone: wolfhece.PyVertexvectors.zone) Set the active zone to target_zone and forward to mapviewer .. py:method:: update_palette() Update palette Redraw the palette with Matplotlib and fill the grid with the values and RGB components .. py:method:: Onsavepal(event: wx.MouseEvent) Save palette to file .. py:method:: Onloadpal(event: wx.MouseEvent) Load palette from file .. py:method:: Onloaddefaultpal(event: wx.MouseEvent) Load default palette .. py:method:: Onpalimage(event: wx.MouseEvent) Create image from palette .. py:method:: Onpaldistribute(event: wx.MouseEvent) Evenly spaced values in palette .. py:method:: Onupdatepal(event: wx.MouseEvent) Apply options to palette .. py:method:: OnClickHistoUpdate(event: wx.Event) Create a histogram of the current array .. py:method:: OnClickColorPal(event: wx.Event) Edit color of a palette item .. py:class:: SelectionData(parent: WolfArray) User-selected data in a WolfArray Contains two storage elements : - myselection (list): Current selection which will be lost in the event of a reset - selections( dict): Stored selection(s) to be used, for example, in a spatial interpolation operation. These selections are only lost in the event of a general reset. The selected nodes are stored using their "world" spatial coordinates so that they can be easily transferred to other objects. .. py:property:: dx :type: float Resolution in x .. py:property:: dy :type: float Resolution in y .. py:property:: nb :type: int Number of selected nodes .. py:attribute:: myselection :type: list[tuple[float, float]] .. py:attribute:: selections :type: dict[str:dict['select':list[tuple[float, float]], 'idgllist':int, 'color':list[float]]] .. py:method:: set_selection_from_list_xy(xylist: list[tuple[float, float]]) Set the current selection from a list of (x, y) coordinates .. py:method:: Unmasksel(resetplot: bool = True) Unmask selection .. py:method:: reset() Reset the selection .. py:method:: reset_all() Reset the selection .. py:method:: get_string(which: str = None, all_memories: bool = False) -> str Get string of the current selection or of a stored one .. py:method:: get_script(which: int = None) -> str Get script of the current selection or of a stored one .. py:method:: copy_to_clipboard(which: int = None, typestr: Literal[string, script] = 'string') Copy current selection to clipboard .. py:method:: reselect_from_memory(idx: list[str] = None) Reselect a stored selection :param idx: id/key of the selection .. py:method:: move_selectionto(idx: str, color: list[float], resetplot: bool = True) Transfer current selection to dictionary :param idx: id/key of the selection :param color: color of the selection - list of 4 integers between 0 and 255 .. py:method:: plot_selection() Plot current selection and stored selections .. py:method:: _plot_selection(curlist: list[float], color: list[float], loclist: int = 0) Plot a selection :param curlist: list of selected nodes -- list of tuples (x,y) :param color: color of the selection - list of 3 floats between 0 and 1 :param loclist: index of OpenGL list .. py:method:: add_node_to_selection(x: float, y: float, verif: bool = True) Add one coordinate to the selection :param x: x coordinate :param y: y coordinate :param verif: if True, the coordinates are checked to avoid duplicates .. py:method:: add_nodes_to_selection(xy: list[float], verif: bool = True) Add multiple coordinates to the selection :param xy: list of coordinates :param verif: if True, the coordinates are checked to avoid duplicates .. py:method:: _add_node_to_selectionij(i: int, j: int, verif=True) Add one ij coordinate to the selection :param i: i coordinate :param j: j coordinate :param verif: if True, the coordinates are checked to avoid duplicates .. py:method:: _add_nodes_to_selectionij(ij: list[tuple[float, float]], verif: bool = True) Add multiple ij coordinates to the selection :param ij: list of ij coordinates :param verif: if True, the coordinates are checked to avoid duplicates .. py:method:: select_insidepoly(myvect: wolfhece.PyVertexvectors.vector) Select nodes inside a polygon .. py:method:: select_underpoly(myvect: wolfhece.PyVertexvectors.vector) Select nodes along a polyline .. py:method:: dilate_selection(nb_iterations: int, use_mask: bool = True, structure: numpy.ndarray = None) Extend the selection .. py:method:: erode_selection(nb_iterations: int, use_mask: bool = True, structure: numpy.ndarray = None) Reduce the selection .. py:method:: dilate_contour_selection(nbiter: int = 1, use_mask: bool = True, structure: numpy.ndarray = np.ones((3, 3))) Dilate the contour of the selection .. py:method:: erode_contour_selection() Erode the contour of the selection .. py:method:: save_selection(filename: str = None) Save the selection to a file .. py:method:: load_selection(filename: str = None) Load a selection from a file .. py:method:: update_nb_nodes_selection() Update the number of selected nodes .. py:method:: condition_select(cond, condval, condval2=0, usemask=False) .. py:method:: treat_select(op, cond, opval, condval) .. py:method:: refresh_parantarray() Refresh the parent array after a selection .. py:method:: mask_condition(op, cond, opval, condval) .. py:method:: get_values_sel() .. py:method:: _get_header() Header corresponding to the selection .. py:method:: get_newarray() Create a new array from the selection .. py:method:: select_all() Select all nodes .. py:method:: interp2Dpolygons(working_zone: wolfhece.PyVertexvectors.zone, method: Literal[nearest, linear, cubic] = None, resetplot: bool = True) Interpolation sous tous les polygones d'une zone cf parent.interp2Dpolygon .. py:method:: interp2Dpolygon(working_vector: wolfhece.PyVertexvectors.vector, method: Literal[nearest, linear, cubic] = None, resetplot: bool = True) Interpolation sous un polygone cf parent.interp2Dpolygon .. py:method:: interp2Dpolylines(working_zone: wolfhece.PyVertexvectors.zone, resetplot: bool = True) Interpolation sous toutes les polylignes de la zone cf parent.interp2Dpolyline .. py:method:: interp2Dpolyline(working_vector: wolfhece.PyVertexvectors.vector, resetplot: bool = True) Interpolation sous la polyligne active cf parent.interp2Dpolyline .. py:method:: copy(source: SelectionData) .. py:method:: volumesurface(show=True) Evaluation of stage-storage-surface relation .. py:class:: SelectionDataMB(parent: WolfArrayMB) Bases: :py:obj:`SelectionData` .. autoapi-inheritance-diagram:: wolfhece.wolf_array.SelectionDataMB :parts: 1 :private-bases: Extension of SelectionData to manage multiple blocks .. py:property:: nb Number of selected nodes .. py:method:: Unmasksel() Unmask selection .. py:method:: reset() Reset the selection .. py:method:: select_all() Select all nodes .. py:method:: reset_all() Reset the selection .. py:method:: get_string(which: str = None) -> str Get string of the current selection or of a stored one .. py:method:: save_selection(filename: str = None, which: str = None) Save the selection to a file .. py:method:: load_selection(filename: str = None, which: str = None) Load a selection from a file .. py:method:: get_script(which: int = None) -> str Get script of the current selection or of a stored one .. py:method:: get_newarray() Create a new array from the selection .. py:method:: add_node_to_selection(x: float, y: float, verif: bool = True) Add a node to the selection .. py:method:: add_nodes_to_selection(xy: list[float], verif: bool = True) Add nodes to the selection .. py:method:: select_insidepoly(myvect: wolfhece.PyVertexvectors.vector) Select nodes inside a polygon .. py:method:: select_underpoly(myvect: wolfhece.PyVertexvectors.vector) Select nodes along a polyline .. py:method:: dilate_selection(nb_iterations: int, use_mask: bool = True, structure: numpy.ndarray = None) Extend the selection .. py:method:: erode_selection(nb_iterations: int, use_mask: bool = True, structure: numpy.ndarray = None) Reduce the selection .. py:method:: update_nb_nodes_selection() Update the number of nodes selected .. py:method:: condition_select(cond, condval, condval2=0, usemask=False) .. py:method:: treat_select(op, cond, opval, condval) .. py:method:: mask_condition(op, cond, opval, condval) .. py:method:: plot_selection() Plot current selection and stored selections .. py:method:: move_selectionto(idx: str, color: list[float]) Transfer current selection to dictionary :param idx: id/key of the selection :param color: color of the selection - list of 4 integers between 0 and 255 .. py:method:: copy_to_clipboard(which: int = None, typestr: Literal[string, script] = 'string') Copy current selection to clipboard .. py:method:: interp2Dpolygons(working_zone: wolfhece.PyVertexvectors.zone, method: Literal[nearest, linear, cubic] = None) Interpolation sous tous les polygones d'une zone cf parent.interp2Dpolygon .. py:method:: interp2Dpolygon(working_vector: wolfhece.PyVertexvectors.vector, method: Literal[nearest, linear, cubic] = None) Interpolation sous un polygone cf parent.interp2Dpolygon .. py:method:: interp2Dpolylines(working_zone: wolfhece.PyVertexvectors.zone, resetplot: bool = True) Interpolation sous toutes les polylignes de la zone cf parent.interp2Dpolyline .. py:method:: interp2Dpolyline(working_vector: wolfhece.PyVertexvectors.vector, resetplot: bool = True) Interpolation sous la polyligne active cf parent.interp2Dpolyline .. py:method:: volumesurface(show=True) Evaluation of stage-storage-surface relation .. py:class:: WolfArray(fname: str = None, mold: WolfArray = None, masknull: bool = True, crop: list[list[float], list[float]] = None, whichtype=WOLF_ARRAY_FULL_SINGLE, preload: bool = True, create: bool = False, mapviewer=None, nullvalue: float = 0.0, srcheader: header_wolf = None, idx: str = '', plotted: bool = False, need_for_wx: bool = False, mask_source: numpy.ndarray = None, np_source: numpy.ndarray = None) Bases: :py:obj:`wolfhece.drawing_obj.Element_To_Draw`, :py:obj:`header_wolf` .. autoapi-inheritance-diagram:: wolfhece.wolf_array.WolfArray :parts: 1 :private-bases: Classe pour l'importation de WOLF arrays simple précision, double précision, entier... .. py:property:: memory_usage Return the memory usage of the header .. py:property:: memory_usage_mask Return the memory usage of the mask .. py:property:: nullvalue :type: float Return the null value .. py:property:: nodata :type: float alias for nullvalue .. py:property:: SelectionData :type: SelectionData Return the data of the selection .. py:property:: Operations :type: Ops_Array Return the operations on the array .. py:property:: active_blocks :type: list[WolfArray] Return the active blocks .. py:property:: dtype Return the numpy dtype corresponding to the WOLF type Pay ettention to the difference between : - LOGICAL : Fortran and VB6 - Bool : Python In VB6, logical is stored as int16 In Fortran, there are Logical*1, Logical*2, Logical*4, Logical*8 In Python, bool is one byte In Numpy, np.bool_ is one byte .. py:property:: dtype_gdal Return the GDAL dtype corresponding to the WOLF type .. py:property:: dtype_str Return the numpy dtype corresponding to the WOLF type, as a string Pay ettention to the difference between : - LOGICAL : Fortran and VB6 - Bool : Python In VB6, logical is stored as int16 In Fortran, there are Logical*1, Logical*2, Logical*4, Logical*8 In Python, bool is one byte In Numpy, np.bool_ is one byte .. py:property:: zmin Return the minimum value of the masked array .. py:property:: zmax Return the maximum value of the masked array .. py:property:: zmin_global Return the minimum value of the array -- all data (masked or not) .. py:property:: zmax_global Return the maximum value of the array -- all data (masked or not) .. py:attribute:: array :type: numpy.ma.masked_array .. py:attribute:: mygrid :type: dict .. py:attribute:: linkedvec :type: wolfhece.PyVertexvectors.vector .. py:attribute:: linkedarrays :type: list[WolfArray] .. py:attribute:: origx :type: float .. py:attribute:: origy :type: float .. py:attribute:: origz :type: float .. py:attribute:: translx :type: float .. py:attribute:: transly :type: float .. py:attribute:: translz :type: float .. py:attribute:: myops :type: Ops_Array .. py:method:: set_opacity(alpha: float) Set the transparency of the array .. py:method:: extract_selection() Extract the current selection .. py:method:: crop_array(bbox: list[list[float], list[float]], setnull_trx_try: bool = False) -> WolfArray Crop the data based on the bounding box :param bbox: bounding box [[xmin, xmax], [ymin, ymax]] :param setnull_trx_try: set the translation to 0 if True, origx and origy will be set to the lower left corner of the bbox. Default is False .. py:method:: get_centers(usenap: bool = True) Get the centers of the cells .. py:method:: prepare_3D() Prepare the array for 3D display .. py:method:: check_bounds_ij(i: int, j: int) Check if i and j are inside the array bounds .. py:method:: check_bounds_xy(x: float, y: float) Check if i and j are inside the array bounds .. py:method:: show_properties() Affichage des propriétés de la matrice dans une fenêtre wxPython .. py:method:: hide_properties() Hide the properties window .. py:method:: loadnap_and_apply() Load a mask file (aka nap) and apply it to the array; The mask values are set to the nullvalue. The mask file must have the same name as the array file, with the extension .napbin. It is useful for 2D WOLF simulations. .. py:method:: add_crosslinked_array(newlink: WolfArray) Ajout d'une matrice liée croisée .. py:method:: share_palette() Partage de la palette de couleurs entre matrices liées .. py:method:: filter_inundation(epsilon: float = None, mask: numpy.ndarray = None) Apply filter on array : - mask data below eps - mask data outisde linkedvec :param epsilon: value under which data are masked :param mask: mask to apply if eps is None If all params are None, the function will mask NaN values .. py:method:: filter_independent_zones(n_largest: int = 1, reset_plot: bool = True) Filtre des zones indépendantes et conservation des n plus grandes .. py:method:: filter_zone(set_null: bool = False, reset_plot: bool = True) Filtre des zones et conservation de celles pour lesquelles des mailles sont sélectionnées .. py:method:: clean_small_patches(min_size: int = 1, set_null: bool = False, reset_plot: bool = True) Clean small patches in the array .. py:method:: labelling(reset_plot: bool = True) Labelling of the array using Scipy .. py:method:: statistics(inside_polygon: wolfhece.PyVertexvectors.vector | shapely.geometry.Polygon = None) Statistics on Selected data or the whole array if no selection :param inside_polygon: vector or Polygon to select data inside the polygon :return: mean, std, median, sum, volume (sum*dx*dy), values .. py:method:: export_geotif(outdir: str = '', extent: str = '', EPSG: int = 31370) Export de la matrice au format Geotiff (Lambert 72 - EPSG:31370) Pour sauvegarder l'objet au format Geotiff, il est recommandé d'utiliser la fonction write_all plutôt que celle-ci directement. Formats supportés : - Int32 - Int16 - Int8 - Byte - Float32 - Float64 :param outdir: directory - If provided, the file will be savd as "outdir/idx+extent.tif" If not provided, we use the filename attribute :param extent: suffix to add to the filename before the extension '.tif' (only if outdir is provided) :param EPSG: EPSG code, by default 31370 (Lambert 72) .. py:method:: get_dxdy_min() Return the minimal size Mainly useful in PyVertexVectors to get the minimal size of the cells and ensure compatibility with the 2D results (GPU and Multiblocks) .. py:method:: get_dxdy_max() Return the maximal size Mainly useful in PyVertexVectors to get the minimal size of the cells and ensure compatibility with the 2D results (GPU and Multiblocks) .. py:method:: _import_npy(fn: str = '', crop: list[float] = None) Import a numpy file. Must be called after the header is initialized, e.g. read_txt_header. :param fn: filename :param crop: crop the data - [xmin, xmax, ymin, ymax] .. py:method:: import_vrt(fn: str = '', which: int = None, crop: list[float] = None) Import a VRT file :param fn: filename :param which: band to import :param crop: crop the data - [xmin, xmax, ymin, ymax] .. py:method:: import_geotif(fn: str = '', which: int = None, crop: list[float] = None) Import de la matrice au format Geotiff Formats supportés : - Int32 - Float32 - Float64 :param fn: filename :param which: band to import :param crop: crop the data - [xmin, xmax, ymin, ymax] .. py:method:: add_ops_sel() Adding selection manager and operations array - Ops_Array (GUI) if mapviewer is not None - create SelectionData (Selection manager) if None .. py:method:: change_gui(newparentgui) Move GUI to another instance :param newparentgui: WolfMapViewer instance .. py:method:: compare_cloud(mycloud: wolfhece.PyVertex.cloud_vertices, delta: list[float] = [0.15, 0.5, 1.0]) Graphique de comparaison des valeurs d'un nuage de points et des valeurs de la matrice sous les mêmes positions :param mycloud: cloud_vertices :param delta: list of tolerance for the comparison .. py:method:: compare_tri(mytri: wolfhece.PyVertexvectors.Triangulation) Graphique de comparaison des valeurs d'un nuage de points et des valeurs de la matrice sous les mêmes positions .. py:method:: interpolate_on_polygon(working_vector: wolfhece.PyVertexvectors.vector, method: Literal[nearest, linear, cubic] = 'linear') Interpolation sous un polygone L'interpolation a lieu : - uniquement dans les mailles sélectionnées si elles existent - dans les mailles contenues dans le polygone sinon On utilise ensuite "griddata" de Scipy pour interpoler les altitudes des mailles depuis les vertices 3D du polygone .. py:method:: interpolate_on_polygons(working_zone: wolfhece.PyVertexvectors.zone, method: Literal[nearest, linear, cubic] = 'linear') Interpolation sous plusieurs polygones d'une même zone .. py:method:: interpolate_on_polyline(working_vector: wolfhece.PyVertexvectors.vector, usemask=True) Interpolation sous une polyligne L'interpolation a lieu : - uniquement dans les mailles sélectionnées si elles existent - dans les mailles sous la polyligne sinon On utilise ensuite "interpolate" de shapely pour interpoler les altitudes des mailles depuis les vertices 3D de la polyligne .. py:method:: interpolate_on_polylines(working_zone: wolfhece.PyVertexvectors.zone, usemask=True) Interpolation sous toutes les polylignes d'une même zone .. py:method:: interpolate_on_cloud(xy: numpy.ndarray, z: numpy.ndarray, method: Literal[linear, nearest, cubic] = 'linear') Interpolation sur un nuage de points. L'interpolation a lieu : - uniquement dans les mailles sélectionnées si elles existent - dans les mailles contenues dans le polygone convexe contenant les points sinon Using griddata from Scipy. :param xy: numpy.array of vertices - shape (n,2) :param z: numpy.array of values - shape (n,) :param method: method for the interpolation -- 'nearest', 'linear' or 'cubic' See : https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.griddata.html .. py:method:: interpolate_on_triangulation(coords, triangles, grid_x=None, grid_y=None, mask_tri=None, interp_method: Literal[matplotlib, scipy] = 'matplotlib') Interpolation sur une triangulation. L'interpolation a lieu : - uniquement dans les mailles sélectionnées si elles existent - dans les mailles contenues dans la triangulation sinon Matplotlib is used by default, but Scipy(griddata) can be used as well. If Matplotlib crashes, try with Scipy. Matplotlib is more strict on the quality of the triangulation. :param coords: numpy.array of vertices - shape (n,3) :param triangles: numpy.array of triangles - shape (m,3) :param grid_x: numpy.array of x values where the interpolation will be done -- if None, the grid is created from the array :param grid_y: numpy.array of y values where the interpolation will be done -- if None, the grid is created from the array :param mask_tri: numpy.array of mask for the triangles :param interp_method: method for the interpolation -- 'matplotlib' or 'scipy' For matplotlib algo, see : https://matplotlib.org/stable/gallery/images_contours_and_fields/triinterp_demo.html For scipy algo, see : https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.griddata.html .. py:method:: import_from_gltf(fn: str = '', fnpos: str = '', interp_method: Literal[matplotlib, scipy] = 'matplotlib') Import from GLTF/GLB format :param fn: filename :param fnpos: filename for the position's information :param interp_method: method for the interpolation -- 'matplotlib' or 'scipy' .. py:method:: export_to_gltf(bounds: list[float] = None, fn: str = '') Export to GLTF/GLB format :param bounds: [[xmin,xmax],[ymin,ymax]] :param fn: filename .. py:method:: get_triangulation(bounds: list[float] = None) Traingulation of the array :param bounds: [[xmin,xmax],[ymin,ymax]] .. py:method:: hillshade(azimuth: float, angle_altitude: float) Create a hillshade array -- see "hillshade" function accelerated by JIT .. py:method:: get_gradient_norm() Compute and return the norm of the gradient .. py:method:: get_laplace() Compute and return the laplacian .. py:method:: volume_estimation(axs: matplotlib.pyplot.Axes = None) Estimation of the volume of the selected zone .. py:method:: paste_all(fromarray: WolfArray, mask_after: bool = True) Paste all the values from another WolfArray .. py:method:: set_values_sel(xy: list[float], z: list[float], update: bool = True) Set values at the selected positions :param xy: [[x1,y1],[x2,y2],...] :param z: [z1,z2,...] :param update: update the plot .. py:method:: init_from_new(dlg: NewArray) Initialize the array properties from the NewArray dialog .. py:method:: init_from_header(myhead: header_wolf, dtype: numpy.dtype = None, force_type_from_header: bool = False) Initialize the array properties from a header_wolf object :param myhead: header_wolf object :param dtype: numpy dtype :param force_type_from_header: force the type from the header passed as argument .. py:method:: interpolation2D(key: str = '1') Interpolation 2D basde on selected points in key 1 .. py:method:: copy_mask(source: WolfArray, forcenullvalue: bool = False, link: bool = True) Copy/Link the mask from another WolfArray :param source: WolfArray source :param forcenullvalue: force nullvalue in the masked zone :param link: link the mask if True (default), copy it otherwise .. py:method:: mask_union(source: WolfArray, link: bool = True) Union of the mask with another WolfArray :param source: WolfArray source :param link: link the mask if True (default), copy it otherwise .. py:method:: mask_unions(sources: list[WolfArray], link: bool = True) Union of the mask with another WolfArrays :param source: list of WolfArray sourceq :param link: link the mask if True (default), copy it otherwise .. py:method:: copy_mask_log(mask: numpy.ndarray, link: bool = True) Copy the mask from a numpy array :param mask: numpy array :param link: link the mask if True (default), copy it otherwise .. py:method:: check_plot() Make sure the array is plotted .. py:method:: uncheck_plot(unload: bool = True, forceresetOGL: bool = False, askquestion: bool = True) Make sure the array is not plotted :param unload: unload the data if True (default), keep it otherwise :param forceresetOGL: force the reset of the OpenGL lists :param askquestion: ask the question if True and a wx App is running (default), don't ask it otherwise .. py:method:: get_header(abs: bool = True) -> header_wolf Return a header_wolf object - different from the self object header :param abs: if True (default), return an absolute header (shifted origin) and translation set to 0. .. py:method:: set_header(header: header_wolf) Set the header from a header_wolf object .. py:method:: concatenate(list_arr: list[WolfArray], nullvalue: float = 0.0) Concatenate the values from another WolfArrays into a new one :param list_arr: list of WolfArray objects :return: a new WolfArray :return_type: WolfArray .. py:method:: mask_outsidepoly(myvect: wolfhece.PyVertexvectors.vector, eps: float = 0.0, set_nullvalue: bool = True, method: Literal[matplotlib, shapely_strict, shapely_wboundary, rasterio] = 'shapely_strict') Mask nodes outside a polygon and set values to nullvalue :param myvect: target vector in global coordinates .. py:method:: mask_insidepoly(myvect: wolfhece.PyVertexvectors.vector, eps: float = 0.0, set_nullvalue: bool = True, method: Literal[matplotlib, shapely_strict, shapely_wboundary, rasterio] = 'mpl') Mask nodes inside a polygon and set values to nullvalue :param myvect: target vector in global coordinates .. py:method:: mask_insidepolys(myvects: list[wolfhece.PyVertexvectors.vector], eps: float = 0.0, set_nullvalue: bool = True, method: Literal[matplotlib, shapely_strict, shapely_wboundary, rasterio] = 'mpl') Mask nodes inside a polygon and set values to nullvalue :param myvect: target vector in global coordinates .. py:method:: get_xy_inside_polygon(myvect: wolfhece.PyVertexvectors.vector | shapely.geometry.Polygon, usemask: bool = True, method: Literal[matplotlib, shapely_strict, shapely_wboundary, rasterio] = 'shapely_strict') .. py:method:: get_xy_inside_polygon_mpl(myvect: wolfhece.PyVertexvectors.vector | shapely.geometry.Polygon, usemask: bool = True) Return the coordinates inside a polygon :param myvect: target vector :param usemask: limit potential nodes to unmaksed nodes .. py:method:: get_xy_inside_polygon_shapely(myvect: wolfhece.PyVertexvectors.vector | shapely.geometry.Polygon, usemask: bool = True, strictly: bool = True) Return the coordinates inside a polygon :param myvect: target vector :param usemask: limit potential nodes to unmaksed nodes .. py:method:: get_xy_inside_polygon_rasterio(myvect: wolfhece.PyVertexvectors.vector | shapely.geometry.Polygon, usemask: bool = True) Return the coordinates inside a polygon .. py:method:: get_xy_under_polyline(myvect: wolfhece.PyVertexvectors.vector, usemask: bool = True) Return the coordinates along a polyline :param myvect: target vector :param usemask: limit potential nodes to unmaksed nodes .. py:method:: get_ij_inside_polygon(myvect: wolfhece.PyVertexvectors.vector | shapely.geometry.Polygon, usemask: bool = True, eps: float = 0.0, method: Literal[matplotlib, shapely_strict, shapely_wboundary, rasterio] = 'shapely_strict') Return the indices inside a polygon :param myvect: target vector :param usemask: limit potential nodes to unmaksed nodes :param eps: epsilon for the intersection .. py:method:: get_ij_inside_polygon_mpl(myvect: wolfhece.PyVertexvectors.vector | shapely.geometry.Polygon, usemask: bool = True, eps: float = 0.0) Return the indices inside a polygon :param myvect: target vector :param usemask: limit potential nodes to unmaksed nodes :param eps: epsilon for the intersection .. py:method:: get_ij_inside_polygon_shapely(myvect: wolfhece.PyVertexvectors.vector | shapely.geometry.Polygon, usemask: bool = True, eps: float = 0.0, strictly: bool = True) Return the indices inside a polygon with the contains method of shapely :param myvect: target vector :param usemask: limit potential nodes to unmaksed nodes :param eps: epsilon for the intersection :param strictly: if True, the points on the border are not considered inside .. py:method:: _get_ij_inside_polygon_rasterio(myvect: wolfhece.PyVertexvectors.vector | shapely.geometry.Polygon, usemask: bool = True, eps: float = 0.0) Return the indices inside a polygon with the geometry_mask method of rasterio. :remark: get_ij_inside_polygon_shapely is more efficient FIXME : geometry_mask seems strange -- it does not work as documented -- RatsrIO 1.3.x :param myvect: target vector :param usemask: limit potential nodes to unmaksed nodes :param eps: epsilon for the intersection .. py:method:: intersects_polygon(myvect: wolfhece.PyVertexvectors.vector | shapely.geometry.Polygon, usemask: bool = True, method: Literal[matplotlib, shapely_strict, shapely_wboundary, rasterio] = 'shapely_strict', buffer: float = 0.0) -> bool Return True if the array intersects the polygon :param myvect: target vector :param usemask: limit potential nodes to unmaksed nodes .. py:method:: intersects_polygon_shapely(myvect: wolfhece.PyVertexvectors.vector | shapely.geometry.Polygon, eps: float = 0.0, usemask: bool = True, buffer: float = 0.0) -> bool Return True if the array intersects the polygon :param myvect: target vector :param usemask: limit potential nodes to unmaksed nodes :param eps: epsilon for the intersection :param buffer: buffer for the intersection - using buffer from Shapely [m] .. py:method:: interects_listofpolygons(myvects: wolfhece.PyVertexvectors.zone | list[wolfhece.PyVertexvectors.vector], usemask: bool = True, method: Literal[matplotlib, shapely_strict, shapely_wboundary, rasterio] = 'shapely_strict', buffer: float = 0.0) -> list[bool] Element-wise intersection with a list of polygons .. py:method:: intersects_zones(zones: wolfhece.PyVertexvectors.Zones | list[wolfhece.PyVertexvectors.zone], usemask: bool = True, method: Literal[matplotlib, shapely_strict, shapely_wboundary, rasterio] = 'shapely_strict', buffer: float = 0.0) -> list[list[bool]] Element-wise intersection with a list of zones .. py:method:: get_total_area_if_intersects(myvects: wolfhece.PyVertexvectors.Zones | list[wolfhece.PyVertexvectors.vector], usemask: bool = True, method: Literal[matplotlib, shapely_strict, shapely_wboundary, rasterio] = 'shapely_strict', buffer: float = 0.0, coefficient: float = 1.0) -> float | list[float] Return the area of the intersection with a list of polygons .. py:method:: get_ij_under_polyline(myvect: wolfhece.PyVertexvectors.vector, usemask: bool = True, step_factor: float = 1.0) Return the indices along a polyline :param myvect: target vector :param usedmask: limit potential nodes to unmaksed nodes :param step_factor: step factor for the discretization of myvect (<1 for thinner, >1 for coarser) .. py:method:: get_values_insidepoly(myvect: wolfhece.PyVertexvectors.vector, usemask: bool = True, getxy: bool = False) -> tuple[numpy.ndarray, numpy.ndarray | None] Récupération des valeurs contenues dans un polygone :param usemask: (optional) restreint les éléments aux éléments non masqués de la matrice :param getxy: (optional) retourne en plus les coordonnées des points .. py:method:: get_values_inside_listofpolygons(myvects: wolfhece.PyVertexvectors.zone | list[wolfhece.PyVertexvectors.vector], usemask: bool = True, getxy: bool = False) -> dict Récupération des valeurs contenues dans une instance Zones ou une liste de vecteurs .. py:method:: get_values_inside_zones(zones: wolfhece.PyVertexvectors.Zones | list[WolfArray.get_values_inside_zones.zone], usemask: bool = True, getxy: bool = False) -> dict Récupération des valeurs contenues dans une instance Zones ou une liste de "zone" .. py:method:: get_values_underpoly(myvect: wolfhece.PyVertexvectors.vector, usemask: bool = True, getxy: bool = False) Récupération des valeurs contenues sous une polyligne :param usemask: (optional) restreint les éléments aux éléments non masqués de la matrice :param getxy: (optional) retourne en plus les coordonnées des points .. py:method:: get_all_values_insidepoly(myvect: wolfhece.PyVertexvectors.vector, usemask: bool = True, getxy: bool = False) Récupération de toutes les valeurs contenues dans un polygone :param usemask: (optional) restreint les éléments aux éléments non masqués de la matrice :param getxy: (optional) retourne en plus les coordonnées des points ICI on retourne le résultat de get_values_insidepoly, car une seule matrice, mais une autre classe pourrait vouloir faure autre chose C'est le cas notamment de Wolfresults_2D .. py:method:: get_all_values_underpoly(myvect: wolfhece.PyVertexvectors.vector, usemask: bool = True, getxy: bool = False) Récupération de toutes les valeurs sous la polyligne :param usemask: (optional) restreint les éléments aux éléments non masqués de la matrice :param getxy: (optional) retourne en plus les coordonnées des points ICI on retourne le résultat de get_values_underpoly, car une seule matrice, mais une autre classe pourrait vouloir faure autre chose C'est le cas notamment de Wolfresults_2D .. py:method:: count_insidepoly(myvect: wolfhece.PyVertexvectors.vector, usemask: bool = True, method: Literal[matplotlib, shapely_strict, shapely_wboundary, rasterio] = 'shapely_strict', coefficient: float = 1.0) Compte le nombre de valeurs contenues dans un polygone :param myvect: target vector :param usemask: (optional) restreint les éléments aux éléments non masqués de la matrice :param method: (optional) method to use :param coefficient: (optional) coefficient to apply to the count (default 1.) .. py:method:: count_inside_listofpolygons(myvects: wolfhece.PyVertexvectors.zone | list[wolfhece.PyVertexvectors.vector], usemask: bool = True, method: Literal[matplotlib, shapely_strict, shapely_wboundary, rasterio] = 'shapely_strict', coefficient: float = 1.0) Compte le nombre de valeurs contenues dans une instance Zones ou une liste de vecteurs :param myvects: target vectors or zone :param usemask: (optional) restreint les éléments aux éléments non masqués de la matrice :param method: (optional) method to use :param coefficient: (optional) coefficient to apply to the count (default 1.) .. py:method:: count_inside_zones(zones: wolfhece.PyVertexvectors.Zones | list[wolfhece.PyVertexvectors.zone], usemask: bool = True, method: Literal[matplotlib, shapely_strict, shapely_wboundary, rasterio] = 'shapely_strict', coefficient: float = 1.0) Compte le nombre de valeurs contenues dans une instance Zones ou une liste de "zone" :param zones: target zones or list of zones :param usemask: (optional) restreint les éléments aux éléments non masqués de la matrice :param method: (optional) method to use :param coefficient: (optional) coefficient to apply to the count (default 1.) .. py:method:: reset() Reset the array to nullvalue .. py:method:: allocate_ressources() Memory Allocation according to dtype/wolftype .. py:method:: read_all(which_band=None) Lecture d'un Wolf aray depuis le nom de fichier .. py:method:: write_all(newpath: str | pathlib.Path = None, EPSG: int = 31370) Ecriture de tous les fichiers d'un Wolf array :param newpath: new path and filename with extension -- if None, use the current filename :param EPSG: EPSG code for geotiff .. py:method:: get_rebin_shape_size(factor: float) -> tuple[tuple[int, int], tuple[float, float]] Return the new shape after rebinning. newdx = dx * factor newdy = dy * factor The shape is adjusted to be a multiple of the factor. :param factor: factor of resolution change -- > 1.0 : decrease resolution, < 1.0 : increase resolution :type factor: float :return: new shape :rtype: Tuple[int, int], Tuple[float, float] .. py:method:: get_rebin_header(factor: float) -> header_wolf Return a new header after rebinning. :param factor: factor of resolution change -- > 1.0 : decrease resolution, < 1.0 : increase resolution :type factor: float :return: new header :rtype: header_wolf .. py:method:: rebin(factor: float, operation: Literal[mean, sum, min, max, median] = 'mean', operation_matrix: WolfArray = None) -> None Change resolution - **in place**. If you want to keep current data, copy the WolfArray into a new variable -> newWA = Wolfarray(mold=curWA). :param factor: factor of resolution change -- > 1.0 : decrease resolution, < 1.0 : increase resolution :type factor: float :param operation: operation to apply on the blocks ('mean', 'sum', 'min', 'max', 'median') :type operation: str, Rebin_Ops :param operation_matrix: operation matrix to apply on the blocks -- see the Enum "Rebin_Ops" for more infos. The matrix must have the same shape as the new array :type operation_matrix: WolfArray .. py:method:: read_txt_header() Read header from txt file Supercharged by WolfArray to avoid explicit call to read_txt_header with parameters .. py:method:: write_txt_header() Write header to txt file Supercharged by WolfArray to avoid explicit call to write_txt_header with parameters .. py:method:: read_data() Opération de lecture des données depuis le fichier connu .. py:method:: _read_binary_data(f, seek=0) Read binary data from file .. py:method:: write_array() Ecriture du tableau en binaire .. py:method:: write_xyz(fname: str) Ecriture d un fichier xyz avec toutes les données du Wolf Array .. py:method:: get_xyz(which='all') -> numpy.ndarray Return an array of xyz coordinates and values .. py:method:: set_general_frame_from_xyz(fname: str, dx: float, dy: float, border_size: int = 5, delimiter: str = ',', fillin: bool = False) :classmethod: Lecture d'un fichier texte xyz et initialisation des données de base :param fname: nom du fichier xyz :param dx: pas en x :param dy: pas en y :param border_size: nombre de mailles de bordure en plus de l'extension spatiale du fichier .. py:method:: set_general_frame_from_xyz_dir(path: str, bounds: list, delimiter: str = ',', dxdy: tuple[float, float] = None, border_size: int = 5, fillin: bool = True) :classmethod: Lecture d'un dossier contenant des fichiers texte xyz, initialisation des données de base et chargement de la matrice Renvoie un WolfArray or False si le fichier n'est pas dans les limites :param path: chemin du dossier avec les fichier xyz :dtype path: str :param bounds: limites de l'extension spatiale :dtype bounds: list :param delimiter: délimiteur des fichiers xyz :dtype delimiter: str :param border_size: nombre de mailles de bordure en plus de l'extension spatiale du fichier :dtype border_size: int .. py:method:: fillin_from_xyz(xyz: numpy.ndarray) Remplissage du tableau à partir d'un tableau xyz .. py:method:: fillin_from_ijz(ijz: numpy.ndarray) Remplissage du tableau à partir d'un tableau ijz .. py:method:: mask_force_null() Force to unmask all and mask null value .. py:method:: unmask() alias to mask_reset .. py:method:: mask_clear() alias to mask_reset .. py:method:: mask_reset() Unmask everything .. py:method:: count() Count the number of not masked values .. py:method:: mask_data(value) Mask cell where values are equal to `value` .. py:method:: mask_lower(value) Mask cell where values are strictly lower than `value` .. py:method:: mask_lowerequal(value) Mask cell where values are lower or equal than `value` .. py:method:: mask_greater(value) Mask cell where values are strictly greater than `value` .. py:method:: mask_greaterequal(value) Mask cell where values are greater or equal than `value` .. py:method:: set_nullvalue_in_mask() Set nullvalue in masked cells .. py:method:: reset_plot(whichpal=0, mimic=True) Reset plot of the array .. py:method:: mask_allexceptdata(value) Mask cell where values are different from `value` .. py:method:: mask_invert() Invert the mask .. py:method:: meshgrid(mode: Literal[gc, borders] = 'gc') Création d'un maillage 2D :param mode: 'gc' pour les centres de mailles, 'borders' pour les bords de mailles .. py:method:: crop_masked_at_edges() Crop the array to remove masked cells at the edges of the array :return: cropped array, WolfArray instance .. py:method:: crop(i_start: int, j_start: int, nbx: int, nby: int, k_start: int = 1, nbz: int = 1) Crop the array :param i_start: start index in x :param j_start: start index in y :param nbx: number of cells in x :param nby: number of cells in y :param k_start: start index in z :param nbz: number of cells in z :return: cropped array, WolfArray instance .. py:method:: extend(x_ext: int, y_ext: int) Extend the array Crop is the opposite .. py:method:: extremum(which: Literal[min, max] = 'min') Return the extremum value .. py:method:: get_value(x: float, y: float, z: float = 0.0, nullvalue: float = -99999) Return the value at given coordinates :param x: x coordinate :param y: y coordinate :param z: z coordinate :param nullvalue: value to return if the point is outside the array .. py:method:: get_xlim(window_x: float, window_y: float) Return the limits in x for a given window size :param window_x: window size in x :param window_y: window size in y .. py:method:: get_ylim(window_x: float, window_y: float) Retrun the limits in y for a given window size :param window_x: window size in x :param window_y: window size in y .. py:method:: get_working_array(onzoom: list[float] = []) Return the part of the array in the zoom window :param onzoom: zoom window -- [xmin, xmax, ymin, ymax] .. py:method:: updatepalette(which: int = 0, onzoom=[]) Update the palette/colormap :param which: which palette to update :param onzoom: zoom window -- [xmin, xmax, ymin, ymax] .. py:method:: plot(sx: float = None, sy: float = None, xmin: float = None, ymin: float = None, xmax: float = None, ymax: float = None, size: float = None) Plot the array - OpenGL :param sx: scale along X :param sy: scale along Y :param xmin: Lower-Left coordinates in X :param ymin: Lower-Left coordinates in Y :param xmax: Upper-Right coordinates in X :param ymax: Upper-Right coordinates in Y :param size: size of the window (not used here but necessary for compatibility with Element_To_Draw) .. py:method:: delete_lists() Delete OpenGL lists .. py:method:: plot_matplotlib(figax: tuple = None, getdata_im: bool = False, update_palette: bool = True, vmin: float = None, vmax: float = None, figsize: tuple = None, Walonmap: bool = False, cat: str = 'IMAGERIE/ORTHO_2022_ETE') Plot the array - Matplotlib version Using imshow and RGB array Plot the array using Matplotlib. This method visualizes the array data using Matplotlib's `imshow` function. It supports optional overlays, custom palettes, and value range adjustments. Notes: ------ - The method applies a mask to the data using the `nullvalue` attribute before plotting. - If `Walonmap` is True, the method fetches and overlays a map image using the WalOnMap service. - The aspect ratio of the plot is set to 'equal'. :param figax: A tuple containing a Matplotlib figure and axis (fig, ax). If None, a new figure and axis are created. :type figax: tuple, optional (Default value = None) :param getdata_im: If True, returns the image object along with the figure and axis. Default is False, then it only returns (fig, ax). :type getdata_im: bool, optional (Default value = False) :param update_palette: If True, updates the color palette before plotting. Default is True. :type update_palette: bool, optional (Default value = True) :param vmin: Minimum value for color scaling. If None, the minimum value is determined automatically. Default is None. :type vmin: float, optional (Default value = None) :param vmax: Maximum value for color scaling. If None, the maximum value is determined automatically. Default is None. :type vmax: float, optional (Default value = None) :param figsize: Size of the figure in inches (width, height). Only used if `figax` is None. Default is None. :type figsize: tuple, optional (Default value = None) :param Walonmap: If True, overlays a map image using the WalOnMap service. Default is False. :type Walonmap: bool, optional (Default value = False) :param cat: The category of the map to fetch from the WalOnMap service. Default is 'IMAGERIE/ORTHO_2022_ETE'. Available orthos: - `'IMAGERIE/ORTHO_1971'` - `'IMAGERIE/ORTHO_1994_2000'` - `'IMAGERIE/ORTHO_2006_2007'` - `'IMAGERIE/ORTHO_2009_2010'` - `'IMAGERIE/ORTHO_2012_2013'` - `'IMAGERIE/ORTHO_2015'` - `'IMAGERIE/ORTHO_2016'` - `'IMAGERIE/ORTHO_2017'` - `'IMAGERIE/ORTHO_2018'` - `'IMAGERIE/ORTHO_2019'` - `'IMAGERIE/ORTHO_2020'` - `'IMAGERIE/ORTHO_2021'` - `'IMAGERIE/ORTHO_2022_PRINTEMPS'` - `'IMAGERIE/ORTHO_2022_ETE'` - `'IMAGERIE/ORTHO_2023_ETE'` - `'IMAGERIE/ORTHO_LAST'` :type cat: str, optional (Default value = `'IMAGERIE/ORTHO_2022_ETE'`) :return: If `getdata_im` is False, returns (fig, ax), where `fig` is the Matplotlib figure and `ax` is the axis. If `getdata_im` is True, returns (fig, ax, im), where `im` is the image object created by `imshow`. :rtype: tuple .. py:method:: fillonecellgrid(curscale, loci, locj, force=False) Fill one cell of the plotted grid .. py:method:: suxsuy_contour(filename: str = '', abs: bool = False, one_vec_if_ml: bool = True) -> tuple[list[int, int], list[int, int], wolfhece.PyVertexvectors.vector | wolfhece.PyVertexvectors.zone, bool] The borders are computed on basis of the current *mask* :param filename: if provided, write 'sux', 'sux' and 'xy' files :param abs: add translation coordinates (Global World Coordinates) :return indicesX, indicesY, contourgen, interior indicesX : list of coupled indices along X - vertical border - 1-based like Fortran indicesY : list of coupled indices along Y - horizontal border - 1-based like Fortran contourgen : external contour interior : if False, contour is unique ; if True, interior contours exist -> interior parts are merged .. py:method:: imshow(figax: tuple[matplotlib.figure.Figure, matplotlib.axis.Axis] = None, cmap: matplotlib.colors.Colormap = None, step_ticks=100.0) -> tuple[matplotlib.figure.Figure, matplotlib.axis.Axis] Create Matplotlib image from WolfArray .. py:method:: set_array_from_numpy(array: numpy.ndarray, nullvalue: float = None) Set array from numpy array .. py:method:: nullify_border(width: int = 1) Set border to nullvalue .. py:method:: as_WolfArray(abs: bool = True) -> WolfArray Return a WolfArray object from this WolfArray .. py:method:: get_unique_values() Return unique values in the array .. py:method:: map_values(keys_vals: dict, default: float = None) Mapping array values to new values defined by a dictionnary. First, check if all values are in keys_vals. If not, set to default. If default is None, set to nullvalue. :param keys_vals: dictionary of values to map :param default: default value if key not found .. py:method:: from_other_epsg_coo(input_raster_path: str, input_srs='EPSG:3812', output_srs='EPSG:31370', resampling_method=gdal.GRA_Bilinear, xRes: float = 0.5, yRes: float = 0.5) :classmethod: Reprojects and resamples a raster file from an other EPSG coordinates and return it as a WolfArray. :param input_raster_path: The path to the input raster file. :type input_raster_path: str :param input_srs: The input spatial reference system (SRS) in the format 'EPSG:XXXX'. Defaults to Lambert 2008 'EPSG:3812'. :type input_srs: str :param output_srs: The output spatial reference system (SRS) in the format 'EPSG:XXXX'. Defaults to Belgian Lambert 72 'EPSG:31370'. :type output_srs: str :param resampling_method: The resampling method to use. Defaults to gdal.GRA_Bilinear. Resampling method can be chosen among the gdal GRA_* constants (gdal.GRA_Average; gdal.GRA_Bilinear; gdal.GRA_Cubic; gdal.GRA_CubicSpline; gdal.GRA_Lanczos; gdal.GRA_Mode; gdal.GRA_NearestNeighbour) :type resampling_method: int :param xRes: The desired output resolution in the x direction. Defaults to 0.5. :type xRes (float): float :param yRes: The desired output resolution in the y direction. Defaults to 0.5. :type yRes (float): float :raises AssertionError: If the input or output raster file is not a GeoTIFF file. :raises RuntimeError: If the input raster file cannot be opened. :raises PermissionError: If there is a permission error while trying to delete the output raster file. :raises Exception: If an unexpected error occurs while trying to delete the output raster file. :raises RuntimeError: If the reprojection fails for the input raster file. :return: WolfArray .. py:method:: contour(levels: Union[int, list[float]] = 10) -> wolfhece.PyVertexvectors.Zones Compute contour lines .. py:method:: inpaint(mask_array: WolfArray = None, test_array: WolfArray = None, ignore_last: int = 1, multiprocess: bool = True) InPaintaing holes in the array :param mask_array: where computation is done :param test_array: used in test -- interpolation is accepted if new value is over test_array :param ignore_last: number of last patches to ignore :param multiprocess: use multiprocess for inpainting .. py:method:: _inpaint_waterlevel_dem_dtm(dem: WolfArray, dtm: WolfArray, ignore_last: int = 1, use_fortran: bool = False, multiprocess: bool = True) InPaintaing waterlevel holes in the array. We use DEM and DTM to mask and constraint the inpainting process. :param dem: Digital Elevation Model (same as simulation model) :param dtm: Digital Terrain Model :param ignore_last: number of last patches to ignore :param use_fortran: use Fortran inpainting code :param multiprocess: use multiprocess for inpainting .. py:method:: count_holes(mask: WolfArray = None) Count holes in the array .. py:method:: select_holes(mask: WolfArray = None, ignore_last: int = 1) Select holes in the array .. py:method:: create_mask_holes(ignore_last: int = 1) -> WolfArray Select holes in the array and create a new aray .. py:method:: create_binary_mask(threshold: float = 0.0) -> WolfArray Create a binary mask from the array .. py:method:: fill_holes_with_value(value: float, mask: WolfArray = None, ignore_last: int = 1) Fill holes in the array with a value .. py:method:: fill_holes_with_value_if_intersects(value: float, vects: list[wolfhece.PyVertexvectors.vector] | wolfhece.PyVertexvectors.Zones, method: Literal[matplotlib, shapely_strict, shapely] = 'shapely_strict', buffer: float = 0.0) Fill holes in the array with a value if it intersects with the mask .. py:method:: _fill_holes_with_value_if_intersects(value: float, vect: wolfhece.PyVertexvectors.vector, method: Literal[matplotlib, shapely_strict, shapely] = 'shapely_strict', buffer: float = 0.0) -> WolfArray .. py:method:: _create_building_holes_dem_dtm(dem: WolfArray, dtm: WolfArray, ignore_last: int = 1) -> WolfArray Select holes in the array and create a new aray .. py:method:: merge(others: list[WolfArrayMB], abs: bool = True, copy: bool = True) -> WolfArray :classmethod: Merge several WolfArray into a single WolfArray :param others: list of WolfArray to merge :param abs: if True -> Global World Coordinates :param copy: if True -> copy data (**Not necessary** if data header CAN BE modified. It can be save memory) .. py:class:: WolfArrayMB(fname=None, mold=None, masknull=True, crop=None, whichtype=WOLF_ARRAY_MB_SINGLE, preload=True, create=False, mapviewer=None, nullvalue=0, srcheader=None) Bases: :py:obj:`WolfArray` .. autoapi-inheritance-diagram:: wolfhece.wolf_array.WolfArrayMB :parts: 1 :private-bases: Matrice multiblocks Les blocs (objets WolfArray) sont stockés dans un dictionnaire "myblocks" .. py:property:: zmin :type: float Return the minimum value of the array .. py:property:: zmax :type: float Return the maximum value of the array .. py:property:: zmin_global :type: float Return the minimum value of the array .. py:property:: zmax_global :type: float Return the maximum value of the array .. py:property:: nullvalue :type: float Return the null value .. py:attribute:: myblocks :type: dict[str, WolfArray] .. py:method:: contour(levels: Union[int, list[float]] = 10) -> wolfhece.PyVertexvectors.Zones Compute contour lines .. py:method:: extract_selection() Extract the current selection .. py:method:: add_ops_sel() Add operations and selection manager to all blocks .. py:method:: filter_zone(set_null: bool = False) Filtre des zones et conservation de celles pour lesquelles des mailles sont sélectionnées .. py:method:: labelling() Labelling of the array using Scipy .. py:method:: interpolate_on_polygon(working_vector: wolfhece.PyVertexvectors.vector, method: Literal[nearest, linear, cubic] = 'linear') Interpolation sous un polygone L'interpolation a lieu : - uniquement dans les mailles sélectionnées si elles existent - dans les mailles contenues dans le polygone sinon On utilise ensuite "griddata" pour interpoler les altitudes des mailles depuis les vertices 3D du polygone .. py:method:: interpolate_on_polygons(working_zone: wolfhece.PyVertexvectors.zone, method: Literal[nearest, linear, cubic] = 'linear') Interpolation sous plusieurs polygones d'une même zone .. py:method:: interpolate_on_polyline(working_vector: wolfhece.PyVertexvectors.vector, usemask=True) Interpolation sous une polyligne L'interpolation a lieu : - uniquement dans les mailles sélectionnées si elles existent - dans les mailles sous la polyligne sinon On utilise ensuite "interpolate" de shapely pour interpoler les altitudes des mailles depuis les vertices 3D de la polyligne .. py:method:: interpolate_on_polylines(working_zone: wolfhece.PyVertexvectors.zone, usemask=True) Interpolation sous les polylignes d'une même zone .. py:method:: check_bounds_ij(i: int, j: int) Check if i and j are inside the array bounds .. py:method:: check_bounds_xy(x: float, y: float) Check if i and j are inside the array bounds .. py:method:: add_block(arr: WolfArray, force_idx: bool = False, copyarray=False) Adds a properly configured block this multiblock. :param arr: The block to add. :param force_idx: If True, the index/key will be set on `arr`. If False, the index/key must already be set on `arr`. .. py:method:: share_palette() Partage de la palette de couleurs entre matrices liées .. py:method:: copy_mask(source: WolfArrayMB, forcenullvalue: bool = False) Copy the mask of two arrays .. py:method:: count() Count the number of not null cells .. py:method:: check_plot() Check plot and apply to each block .. py:method:: uncheck_plot(unload: bool = True, forceresetOGL: bool = False, askquestion: bool = True) Uncheck plot and apply to each block .. py:method:: mask_data(value) Mask cells where values are equal to `value` .. py:method:: mask_union(source: WolfArrayMB) Union of the masks of two arrays Applying for each block iteratively. .. py:method:: read_data() Lecture du tableau en binaire .. py:method:: write_array() Ecriture du tableau en binaire .. py:method:: get_ij_from_xy(x: float, y: float, z: float = 0.0, scale: float = 1.0, aswolf: bool = False, abs: bool = True, which_block: int = 1) alias for get_ij_from_xy for the block `which_block :param x: x coordinate :param y: y coordinate :param z: z coordinate :param scale: scale factor :param aswolf: if True, then the indices are 1-based like Fortran, otherwise 0-based like Python :param abs: if True, then the translation is taken into account :param which_block: block index 1-based .. py:method:: get_values_as_wolf(i: int, j: int, which_block: int = 1) Return the value at indices (i,j) of the block `which_block. :param i: i index :param j: j index :param which_block: block index 1-based .. py:method:: get_value(x: float, y: float, abs: bool = True) Read the value at world coordinate (x,y). if `abs` is given, then the translation is is taken into account. If no block covers the coordinate, then np.NaN is returned If several blocks cover the given coordinate then the first match is returned (and thus, the others are ignored). :param x: x coordinate :param y: y coordinate :param abs: if True, then the translation is taken into account :return: the value at (x,y) or np.NaN if no block covers the coordinate .. py:method:: get_xy_from_ij(i: int, j: int, which_block: int, aswolf: bool = False, abs: bool = True) Return the world coordinates (x,y) of the indices (i,j) of the block `which_block. :param i: i index -- 1-based like Fortran or 0-based like Python, see 'aswolf' parameter :param j: j index -- 1-based like Fortran or 0-based like Python, see 'aswolf' parameter :param which_block: block index 1-based :param aswolf: if True, (i,j) are 1-based like Fortran, otherwise 0-based like Python :param abs: if True, then the translation is taken into account .. py:method:: get_blockij_from_xy(x: float, y: float, abs: bool = True) Return the block indices (i,j) of the block covering the world coordinate (x,y) :param x: x coordinate :param y: y coordinate :param abs: if True, then the translation is taken into account :return: the block indices (i,j,[k]) or (-1,-1,-1) if no block covers the coordinate .. py:method:: link_palette() Lier les palettes des blocs à la palette de l'objet parent .. py:method:: updatepalette(which: int = 0, onzoom: list[float] = []) Update the palette/colormap of the array :param which: which colormap to use :param onzoom: if not empty, then only the values within the zoom are used to update the palette -- [xmin,xmax,ymin,ymax] .. py:method:: delete_lists() Delete OpenGL lists .. py:method:: mimic_plotdata() Copy plot flags to children .. py:method:: plot(sx=None, sy=None, xmin=None, ymin=None, xmax=None, ymax=None, size=None) Plot the array .. py:method:: fillonecellgrid(curscale, loci, locj, force=False) Fill one cell of the plotted grid .. py:method:: check_consistency(other) Vérifie la cohérence entre deux matrices .. py:method:: reset() Reset each block .. py:method:: mask_reset() Reset mask -- mask = False everywhere .. py:method:: mask_lower(value) Mask cell where values are strictly lower than `value` .. py:method:: imshow(figax: tuple[matplotlib.figure.Figure, matplotlib.axis.Axis] = None, cmap: matplotlib.colors.Colormap = None, step_ticks=100.0) -> tuple[matplotlib.figure.Figure, matplotlib.axis.Axis] Create Matplotlib image from MultiBlock array .. py:method:: allocate_ressources() Allocate memory ressources .. py:method:: set_header_from_added_blocks() Set header from blocks .. py:method:: as_WolfArray(abs: bool = True, forced_header: header_wolf = None) -> WolfArray Convert to WolfArray -- Rebin blocks if necessary :param abs: if True, then the translation is taken into account :param forced_header: if not None, then the header is forced to this value .. py:method:: plot_matplotlib(figax: tuple = None, getdata_im: bool = False, update_palette: bool = True, vmin: float = None, vmax: float = None, figsize: tuple = None, Walonmap: bool = False, cat: str = 'IMAGERIE/ORTHO_2022_ETE') Plot the multi-block (MB) array - Matplotlib version Converts the MB array to single/mono-block and, Uses the `plot_matplotlib` method of the WolfArray class. Using imshow and RGB array Plot the array using Matplotlib. This method visualizes the array data using Matplotlib's `imshow` function. It supports optional overlays, custom palettes, and value range adjustments. Notes: ------ - The method applies a mask to the data using the `nullvalue` attribute before plotting. - If `Walonmap` is True, the method fetches and overlays a map image using the WalOnMap service. - The aspect ratio of the plot is set to 'equal'. :param figax: A tuple containing a Matplotlib figure and axis (fig, ax). If None, a new figure and axis are created. :type figax: tuple, optional (Default value = None) :param getdata_im: If True, returns the image object along with the figure and axis. Default is False, then it only returns (fig, ax). :type getdata_im: bool, optional (Default value = False) :param update_palette: If True, updates the color palette before plotting. Default is True. :type update_palette: bool, optional (Default value = True) :param vmin: Minimum value for color scaling. If None, the minimum value is determined automatically. Default is None. :type vmin: float, optional (Default value = None) :param vmax: Maximum value for color scaling. If None, the maximum value is determined automatically. Default is None. :type vmax: float, optional (Default value = None) :param figsize: Size of the figure in inches (width, height). Only used if `figax` is None. Default is None. :type figsize: tuple, optional (Default value = None) :param Walonmap: If True, overlays a map image using the WalOnMap service. Default is False. :type Walonmap: bool, optional (Default value = False) :param cat: The category of the map to fetch from the WalOnMap service. Default is 'IMAGERIE/ORTHO_2022_ETE'. Available orthos: - `'IMAGERIE/ORTHO_1971'` - `'IMAGERIE/ORTHO_1994_2000'` - `'IMAGERIE/ORTHO_2006_2007'` - `'IMAGERIE/ORTHO_2009_2010'` - `'IMAGERIE/ORTHO_2012_2013'` - `'IMAGERIE/ORTHO_2015'` - `'IMAGERIE/ORTHO_2016'` - `'IMAGERIE/ORTHO_2017'` - `'IMAGERIE/ORTHO_2018'` - `'IMAGERIE/ORTHO_2019'` - `'IMAGERIE/ORTHO_2020'` - `'IMAGERIE/ORTHO_2021'` - `'IMAGERIE/ORTHO_2022_PRINTEMPS'` - `'IMAGERIE/ORTHO_2022_ETE'` - `'IMAGERIE/ORTHO_2023_ETE'` - `'IMAGERIE/ORTHO_LAST'` :type cat: str, optional (Default value = `'IMAGERIE/ORTHO_2022_ETE'`) :return: If `getdata_im` is False, returns (fig, ax), where `fig` is the Matplotlib figure and `ax` is the axis. If `getdata_im` is True, returns (fig, ax, im), where `im` is the image object created by `imshow`. :rtype: tuple .. py:class:: WolfArrayMNAP(fname=None, mold=None, masknull=True, crop=None) Bases: :py:obj:`WolfArrayMB` .. autoapi-inheritance-diagram:: wolfhece.wolf_array.WolfArrayMNAP :parts: 1 :private-bases: Matrice MNAP d'une modélisation WOLF2D Elle contient toutes les informations de maillage en Multi-blocks ainsi que les relations de voisinage de blocs. Surcharge de WolfArrayMB avec modification des opérations de lecture/écriture car le fichier est au format TEXTE/ASCII et d'une structure spécifique. .. py:attribute:: contour :type: wolfhece.PyVertexvectors.Zones .. py:method:: write_all() Ecriture de tous les fichiers d'un Wolf array :param newpath: new path and filename with extension -- if None, use the current filename :param EPSG: EPSG code for geotiff .. py:method:: read_data() Lecture du tableau en binaire .. py:method:: read_txt_header() Surcharge de la lecture du header Il n'y a pas en tant que tel de header d'un fichier MNAP. Les informations de translation sont dans le fichier ".trl". Les informations de tailles de maille 'fines', Nbx, Nby et coordonnées d'origine sont dans le fichier ".par" .. py:method:: get_one_mask(which: int | str) Return the mask of the block `which` .. py:method:: get_all_masks() Return all masks