wolfhece.wolf_array

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

wolfhece.wolf_array.msg[source]
wolfhece.wolf_array.msg[source]
wolfhece.wolf_array.WOLF_ARRAY_HILLSHAPE[source]
wolfhece.wolf_array.WOLF_ARRAY_FULL_SINGLE = 1[source]
wolfhece.wolf_array.WOLF_ARRAY_FULL_DOUBLE = 2[source]
wolfhece.wolf_array.WOLF_ARRAY_SYM_DOUBLE = 12[source]
wolfhece.wolf_array.WOLF_ARRAY_FULL_LOGICAL = 4[source]
wolfhece.wolf_array.WOLF_ARRAY_CSR_DOUBLE = 5[source]
wolfhece.wolf_array.WOLF_ARRAY_FULL_INTEGER = 6[source]
wolfhece.wolf_array.WOLF_ARRAY_FULL_SINGLE_3D = 7[source]
wolfhece.wolf_array.WOLF_ARRAY_FULL_INTEGER8 = 8[source]
wolfhece.wolf_array.WOLF_ARRAY_MB_SINGLE = 3[source]
wolfhece.wolf_array.WOLF_ARRAY_MB_INTEGER = 9[source]
wolfhece.wolf_array.WOLF_ARRAY_FULL_INTEGER16_2 = 0[source]
wolfhece.wolf_array.WOLF_ARRAY_FULL_INTEGER16 = 11[source]
wolfhece.wolf_array.WOLF_ARRAY_MNAP_INTEGER = 20[source]
wolfhece.wolf_array.WOLF_ARRAY_MB[source]
wolfhece.wolf_array.VERSION_RGB = 3[source]
wolfhece.wolf_array.custom_gradient(array: numpy.ndarray)[source]

Calculate the gradient manually

wolfhece.wolf_array.hillshade(array: numpy.ndarray, azimuth: float, angle_altitude: float) numpy.ndarray[source]

Create a hillshade array

class wolfhece.wolf_array.Rebin_Ops[source]

Bases: enum.Enum

Inheritance diagram of wolfhece.wolf_array.Rebin_Ops

Generic enumeration.

Derive from this class to define new enumerations.

MIN = 0[source]
MEAN = 1[source]
MAX = 2[source]
SUM = 3[source]
MEDIAN = 4[source]
classmethod get_numpy_ops()[source]

Return a list of numpy functions corresponding to the enum values

classmethod get_ops(name: str)[source]

Return the numpy function corresponding to a string

wolfhece.wolf_array.getkeyblock(i, addone=True) str[source]

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”

wolfhece.wolf_array.decodekeyblock(key, addone=True) int[source]

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”

class wolfhece.wolf_array.header_wolf[source]

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

property nullvalue[source]
property nbdims[source]
property shape[source]
property nb_blocks[source]
head_blocks: dict[str, header_wolf][source]
set_origin(x: float, y: float, z: float)[source]

Set origin

:param x = origin along X :param y = origin along Y :param z = origin along Z

set_translation(tr_x: float, tr_y: float, tr_z: float)[source]

Set translation

Parameters:
  • tr_x – translation along X

  • tr_y – translation along Y

  • tr_z – translation along Z

get_bounds(abs=True)[source]

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

get_bounds_ij(abs=False)[source]

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)

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) tuple[numpy.int32, numpy.int32] | tuple[numpy.int32, numpy.int32, numpy.int32][source]

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

get_ij_from_xy_array(xy: numpy.ndarray, scale: float = 1.0, aswolf: bool = False, abs: bool = True, forcedims2: bool = False) numpy.ndarray[source]

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)

get_xy_from_ij(i: int, j: int, k: int = 0, scale: float = 1.0, aswolf: bool = False, abs: bool = True) tuple[numpy.float64, numpy.float64] | tuple[numpy.float64, numpy.float64, numpy.float64][source]

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)

get_xy_from_ij_array(ij: numpy.ndarray, scale: float = 1.0, aswolf: bool = False, abs: bool = True) numpy.ndarray[source]

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 `

ij2xy(i: int, j: int, k: int = 0, scale: float = 1.0, aswolf: bool = False, abs: bool = True) tuple[numpy.float64, numpy.float64] | tuple[numpy.float64, numpy.float64, numpy.float64][source]

alias for get_xy_from_ij

ij2xy_np(ij: numpy.ndarray, scale: float = 1.0, aswolf: bool = False, abs: bool = True) numpy.ndarray[source]

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)

xy2ij(x: float, y: float, z: float = 0.0, scale: float = 1.0, aswolf: bool = False, abs: bool = True, forcedims2: bool = False) tuple[numpy.int32, numpy.int32] | tuple[numpy.int32, numpy.int32, numpy.int32][source]

alias for get_ij_from_xy

xy2ij_np(xy: numpy.ndarray, scale: float = 1.0, aswolf: bool = False, abs: bool = True) numpy.ndarray[source]

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)

xyz2ijk_np(xyz: numpy.ndarray, scale: float = 1.0, aswolf: bool = False, abs: bool = True) numpy.ndarray[source]

alias for get_xy_from_ij_array

ijk2xyz_np(ijk: numpy.ndarray, scale: float = 1.0, aswolf: bool = False, abs: bool = True) numpy.ndarray[source]

alias for get_xy_from_ij_array

find_intersection(other: header_wolf, ij: bool = False) tuple[list[float], list[float]] | tuple[list[list[float]], list[list[float]]][source]

Find the intersection of two header

@arg other: other header @arg ij: if True, return indices instead of coordinates

Returns:

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]]

find_union(other: header_wolf | list[header_wolf]) tuple[list[float], list[float]][source]

Find the union of two header

Returns:

tuple of two lists of two floats - ([xmin, xmax],[ymin, ymax])

read_txt_header(filename: str)[source]

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

write_txt_header(filename: str, wolftype: int, forceupdate: bool = False)[source]

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

is_like(other: header_wolf, check_mb: bool = False) bool[source]

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

align2grid(x1: float, y1: float, eps: float = 0.0001) tuple[float, float][source]

Align coordinates to nearest grid point where the grid is defined by the borders of the array.

_rasterize_segment(x1: float, y1: float, x2: float, y2: float, xstart: float = None, ystart: float = None) list[list[float]][source]

Rasterize a segment according to the grid where the grid is defined by the borders of the array.

Parameters:
  • x1 – x coordinate of the first point

  • y1 – y coordinate of the first point

  • x2 – x coordinate of the second point

  • y2 – y coordinate of the second point

  • xstart – x coordinate of the starting point

  • ystart – y coordinate of the starting point

Returns:

numpy array of the rasterized segment

rasterize_vector(vector2raster: wolfhece.PyVertexvectors.vector, outformat: numpy.ndarray | wolfhece.PyVertexvectors.vector = vector) numpy.ndarray | wolfhece.PyVertexvectors.vector[source]

Rasterize a vector according to the grid

Parameters:
  • vector2raster – vector to rasterize

  • outformat – output format (np.ndarray or vector)

get_xy_infootprint_vect(myvect: wolfhece.PyVertexvectors.vector | shapely.geometry.Polygon, eps: float = 0.0) tuple[numpy.ndarray, numpy.ndarray][source]

Return the coordinates of the cells in the footprint of a vector

:param myvect = target vector :return: tuple of two numpy arrays - (coordinates, indices)

get_ij_infootprint_vect(myvect: wolfhece.PyVertexvectors.vector | shapely.geometry.Polygon, eps: float = 0.0) numpy.ndarray[source]

Return the indices of the cells in the footprint of a vector

:param myvect = target vector :return : numpy array of indices

convert_xy2ij_np(xy)[source]

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

convert_ij2xy_np(ij)[source]

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

class wolfhece.wolf_array.NewArray(parent)[source]

Bases: wx.Dialog

Inheritance diagram of wolfhece.wolf_array.NewArray

wx GUI interaction to create a new WolfArray

Once filled, user/__init__ must call “init_from_new”

class wolfhece.wolf_array.CropDialog(parent)[source]

Bases: wx.Dialog

Inheritance diagram of wolfhece.wolf_array.CropDialog

wx GUI interaction to crop 2D array’s data

Used in “read_data” of a WolfArray

get_header()[source]

Return a header_wolf object with the values of the dialog

class wolfhece.wolf_array.IntValidator[source]

Bases: wx.Validator

Inheritance diagram of wolfhece.wolf_array.IntValidator

Validates data as it is entered into the text controls.

Clone()[source]

Required Validator method

Validate(win)[source]
TransferToWindow()[source]
TransferFromWindow()[source]
OnChar(event)[source]
class wolfhece.wolf_array.Ops_Array(parentarray: WolfArray, mapviewer=None)[source]

Bases: wx.Frame

Inheritance diagram of wolfhece.wolf_array.Ops_Array

Operations wx.Frame on WolfArray class

This class is used to perform operations on a WolfArray

property idx[source]

Return the idx of the parentarray

property is_shared[source]

Check if the vector manager is shared

get_mapviewer()[source]

Retourne l’instance WolfMapViewer

get_linked_arrays()[source]

Pour compatibilité avec la gestion de vecteur et WolfMapViewer

set_GUI()[source]

Set the wx GUI

OnBlockSelect(event)[source]

Select block

interpolation2D(event: wx.MouseEvent)[source]

calling Interpolation 2D

Unmaskall(event: wx.MouseEvent)[source]

Unmask all values in the current array @author Pierre Archambeau

Unmasksel(event: wx.MouseEvent)[source]

Enlève le masque des éléments sélectionnés @author Pierre Archambeau

InvertMask(event: wx.MouseEvent)[source]

Invert mask

interp2Dpolygons(event: wx.MouseEvent)[source]

Bouton d’interpolation sous tous les polygones d’une zone cf WolfArray.interp2Dpolygon

interp2Dpolygon(event: wx.MouseEvent)[source]

Bouton d’interpolation sous un polygone cf WolfArray.interp2Dpolygon

interp2Dpolylines(event: wx.MouseEvent)[source]

Bouton d’interpolation sous toutes les polylignes de la zone cf parent.interp2Dpolyline

interp2Dpolyline(event: wx.MouseEvent)[source]

Bouton d’interpolation sous la polyligne active cf parent.interp2Dpolyline

volumesurface(event)[source]

Click on evaluation of stage-storage-surface relation

OnAllSelect(event)[source]

Select all –> just put “all” in “myselection”

OnReselectMemory(event)[source]

Reselect from memory

OnMoveSelect(event)[source]

Transfert de la sélection courante dans un dictionnaire

OnContractSelection(event)[source]

Contract selection

OnExpandSelection(event)[source]

Expand selection

OnExpandUnselectInterior(event)[source]

Expand contour

OnUnselectInterior(event)[source]

Contract contour

reset_selection()[source]

Reset of current selection

reset_all_selection()[source]

Reset of current selection and stored ones

OnResetSelect(event)[source]

Click on Reset of current selection

OnResetAllSelect(event)[source]

Click on reset all

OnSaveSelection(event)[source]

Save the current selection

OnLoadSelection(event)[source]

Load a selection

OnToClipboardStr(event)[source]

Copy the current selection to the clipboard as a string

OnApplyOpSelect(event)[source]

Select nodes based on condition

OnApplyNullvalue(event: wx.MouseEvent)[source]

Apply null value to the array

refresh_array()[source]

Force refresh of the parent array

OnNullBorder(event: wx.MouseEvent)[source]

Nullify the border of the array

OnFilterZone(event: wx.MouseEvent)[source]

Filter the array based on contiguous zones

OnLabelling(event: wx.MouseEvent)[source]

Labelling of contiguous zones

OnExtractSelection(event: wx.MouseEvent)[source]

Extract the current selection

OnApplyOpMath(event: wx.MouseEvent)[source]

Apply math operator to the array

Onmask(event: wx.MouseEvent)[source]

Mask nodes based on condition

OnManageVectors(event: wx.MouseEvent)[source]

Open vector manager

show_structure_OpsVectors()[source]

Show the structure of the vector manager

hide_properties()[source]

Hide the properties panel

_get_comp_elts_diff()[source]

Get the elements and the differences of the linked arrays

Link the same vector manager to all the linked arrays

OnLoadvec(event: wx.MouseEvent)[source]

Load vector file

OnSaveasvec(event: wx.MouseEvent)[source]

Save vector file

OnSavevec(event: wx.MouseEvent)[source]

Save vector file

select_node_by_node()[source]

Select nodes by individual clicks

Set the right action in the mapviewer who will attend the clicks

select_zone_inside_manager()[source]

Select nodes inside the active zone (manager)

select_vector_inside_manager()[source]

Select nodes inside the active vector (manager)

_select_vector_inside_manager(vect: wolfhece.PyVertexvectors.vector)[source]

Select nodes inside a vector or set action to add vertices to a vector by clicks

select_zone_under_manager()[source]

Select nodes along the active zone (manager)

select_vector_under_manager()[source]

Select nodes along the active vector (manager)

_select_vector_under_manager(vect: wolfhece.PyVertexvectors.vector)[source]

Select nodes along a vector or set action to add vertices to a vector by clicks

select_vector_inside_tmp()[source]

Select nodes inside the temporary vector

select_vector_under_tmp()[source]

Select nodes along the temporary vector

OnLaunchSelect(event: wx.MouseEvent)[source]

Action button

onclose(event: wx.MouseEvent)[source]

Hide the window

onshow(event: wx.MouseEvent)[source]

Show the window - set string with null value and update palette

Active_vector(vect: wolfhece.PyVertexvectors.vector, copyall: bool = True)[source]

Set the active vector to vect and forward to mapviewer

Active_zone(target_zone: wolfhece.PyVertexvectors.zone)[source]

Set the active zone to target_zone and forward to mapviewer

update_palette()[source]

Update palette

Redraw the palette with Matplotlib and fill the grid with the values and RGB components

Onsavepal(event: wx.MouseEvent)[source]

Save palette to file

Onloadpal(event: wx.MouseEvent)[source]

Load palette from file

Onloaddefaultpal(event: wx.MouseEvent)[source]

Load default palette

Onpalimage(event: wx.MouseEvent)[source]

Create image from palette

Onpaldistribute(event: wx.MouseEvent)[source]

Evenly spaced values in palette

Onupdatepal(event: wx.MouseEvent)[source]

Apply options to palette

OnClickHistoUpdate(event: wx.Event)[source]

Create a histogram of the current array

OnClickColorPal(event: wx.Event)[source]

Edit color of a palette item

class wolfhece.wolf_array.SelectionData(parent: WolfArray)[source]

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.

property dx: float[source]

Resolution in x

property dy: float[source]

Resolution in y

property nb: int[source]

Number of selected nodes

myselection: list[tuple[float, float]][source]
selections: dict[str:dict['select':list[tuple[float, float]], 'idgllist':int, 'color':list[float]]][source]
set_selection_from_list_xy(xylist: list[tuple[float, float]])[source]

Set the current selection from a list of (x, y) coordinates

Unmasksel(resetplot: bool = True)[source]

Unmask selection

reset()[source]

Reset the selection

reset_all()[source]

Reset the selection

get_string(which: str = None, all_memories: bool = False) str[source]

Get string of the current selection or of a stored one

get_script(which: int = None) str[source]

Get script of the current selection or of a stored one

copy_to_clipboard(which: int = None, typestr: Literal[string, script] = 'string')[source]

Copy current selection to clipboard

reselect_from_memory(idx: list[str] = None)[source]

Reselect a stored selection

Parameters:

idx – id/key of the selection

move_selectionto(idx: str, color: list[float], resetplot: bool = True)[source]

Transfer current selection to dictionary

Parameters:
  • idx – id/key of the selection

  • color – color of the selection - list of 4 integers between 0 and 255

plot_selection()[source]

Plot current selection and stored selections

_plot_selection(curlist: list[float], color: list[float], loclist: int = 0)[source]

Plot a selection

Parameters:
  • curlist – list of selected nodes – list of tuples (x,y)

  • color – color of the selection - list of 3 floats between 0 and 1

  • loclist – index of OpenGL list

add_node_to_selection(x: float, y: float, verif: bool = True)[source]

Add one coordinate to the selection

Parameters:
  • x – x coordinate

  • y – y coordinate

  • verif – if True, the coordinates are checked to avoid duplicates

add_nodes_to_selection(xy: list[float], verif: bool = True)[source]

Add multiple coordinates to the selection

Parameters:
  • xy – list of coordinates

  • verif – if True, the coordinates are checked to avoid duplicates

_add_node_to_selectionij(i: int, j: int, verif=True)[source]

Add one ij coordinate to the selection

Parameters:
  • i – i coordinate

  • j – j coordinate

  • verif – if True, the coordinates are checked to avoid duplicates

_add_nodes_to_selectionij(ij: list[tuple[float, float]], verif: bool = True)[source]

Add multiple ij coordinates to the selection

Parameters:
  • ij – list of ij coordinates

  • verif – if True, the coordinates are checked to avoid duplicates

select_insidepoly(myvect: wolfhece.PyVertexvectors.vector)[source]

Select nodes inside a polygon

select_underpoly(myvect: wolfhece.PyVertexvectors.vector)[source]

Select nodes along a polyline

dilate_selection(nb_iterations: int, use_mask: bool = True, structure: numpy.ndarray = None)[source]

Extend the selection

erode_selection(nb_iterations: int, use_mask: bool = True, structure: numpy.ndarray = None)[source]

Reduce the selection

dilate_contour_selection(nbiter: int = 1, use_mask: bool = True, structure: numpy.ndarray = np.ones((3, 3)))[source]

Dilate the contour of the selection

erode_contour_selection()[source]

Erode the contour of the selection

save_selection(filename: str = None)[source]

Save the selection to a file

load_selection(filename: str = None)[source]

Load a selection from a file

update_nb_nodes_selection()[source]

Update the number of selected nodes

condition_select(cond, condval, condval2=0, usemask=False)[source]
treat_select(op, cond, opval, condval)[source]
refresh_parantarray()[source]

Refresh the parent array after a selection

mask_condition(op, cond, opval, condval)[source]
get_values_sel()[source]
_get_header()[source]

Header corresponding to the selection

get_newarray()[source]

Create a new array from the selection

select_all()[source]

Select all nodes

interp2Dpolygons(working_zone: wolfhece.PyVertexvectors.zone, method: Literal[nearest, linear, cubic] = None, resetplot: bool = True)[source]

Interpolation sous tous les polygones d’une zone cf parent.interp2Dpolygon

interp2Dpolygon(working_vector: wolfhece.PyVertexvectors.vector, method: Literal[nearest, linear, cubic] = None, resetplot: bool = True)[source]

Interpolation sous un polygone cf parent.interp2Dpolygon

interp2Dpolylines(working_zone: wolfhece.PyVertexvectors.zone, resetplot: bool = True)[source]

Interpolation sous toutes les polylignes de la zone cf parent.interp2Dpolyline

interp2Dpolyline(working_vector: wolfhece.PyVertexvectors.vector, resetplot: bool = True)[source]

Interpolation sous la polyligne active cf parent.interp2Dpolyline

copy(source: SelectionData)[source]
volumesurface(show=True)[source]

Evaluation of stage-storage-surface relation

class wolfhece.wolf_array.SelectionDataMB(parent: WolfArrayMB)[source]

Bases: SelectionData

Inheritance diagram of wolfhece.wolf_array.SelectionDataMB

Extension of SelectionData to manage multiple blocks

property nb[source]

Number of selected nodes

Unmasksel()[source]

Unmask selection

reset()[source]

Reset the selection

select_all()[source]

Select all nodes

reset_all()[source]

Reset the selection

get_string(which: str = None) str[source]

Get string of the current selection or of a stored one

save_selection(filename: str = None, which: str = None)[source]

Save the selection to a file

load_selection(filename: str = None, which: str = None)[source]

Load a selection from a file

get_script(which: int = None) str[source]

Get script of the current selection or of a stored one

get_newarray()[source]

Create a new array from the selection

add_node_to_selection(x: float, y: float, verif: bool = True)[source]

Add a node to the selection

add_nodes_to_selection(xy: list[float], verif: bool = True)[source]

Add nodes to the selection

select_insidepoly(myvect: wolfhece.PyVertexvectors.vector)[source]

Select nodes inside a polygon

select_underpoly(myvect: wolfhece.PyVertexvectors.vector)[source]

Select nodes along a polyline

dilate_selection(nb_iterations: int, use_mask: bool = True, structure: numpy.ndarray = None)[source]

Extend the selection

erode_selection(nb_iterations: int, use_mask: bool = True, structure: numpy.ndarray = None)[source]

Reduce the selection

update_nb_nodes_selection()[source]

Update the number of nodes selected

condition_select(cond, condval, condval2=0, usemask=False)[source]
treat_select(op, cond, opval, condval)[source]
mask_condition(op, cond, opval, condval)[source]
plot_selection()[source]

Plot current selection and stored selections

move_selectionto(idx: str, color: list[float])[source]

Transfer current selection to dictionary

Parameters:
  • idx – id/key of the selection

  • color – color of the selection - list of 4 integers between 0 and 255

copy_to_clipboard(which: int = None, typestr: Literal[string, script] = 'string')[source]

Copy current selection to clipboard

interp2Dpolygons(working_zone: wolfhece.PyVertexvectors.zone, method: Literal[nearest, linear, cubic] = None)[source]

Interpolation sous tous les polygones d’une zone cf parent.interp2Dpolygon

interp2Dpolygon(working_vector: wolfhece.PyVertexvectors.vector, method: Literal[nearest, linear, cubic] = None)[source]

Interpolation sous un polygone cf parent.interp2Dpolygon

interp2Dpolylines(working_zone: wolfhece.PyVertexvectors.zone, resetplot: bool = True)[source]

Interpolation sous toutes les polylignes de la zone cf parent.interp2Dpolyline

interp2Dpolyline(working_vector: wolfhece.PyVertexvectors.vector, resetplot: bool = True)[source]

Interpolation sous la polyligne active cf parent.interp2Dpolyline

volumesurface(show=True)[source]

Evaluation of stage-storage-surface relation

class wolfhece.wolf_array.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)[source]

Bases: wolfhece.drawing_obj.Element_To_Draw, header_wolf

Inheritance diagram of wolfhece.wolf_array.WolfArray

Classe pour l’importation de WOLF arrays

simple précision, double précision, entier…

property memory_usage[source]

Return the memory usage of the header

property memory_usage_mask[source]

Return the memory usage of the mask

property nullvalue: float[source]

Return the null value

property nodata: float[source]

alias for nullvalue

property SelectionData: SelectionData[source]

Return the data of the selection

property Operations: Ops_Array[source]

Return the operations on the array

property active_blocks: list[WolfArray][source]

Return the active blocks

property dtype[source]

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

property dtype_str[source]

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

array: numpy.ma.masked_array[source]
mygrid: dict[source]
linkedvec: wolfhece.PyVertexvectors.vector[source]
linkedarrays: list[WolfArray][source]
origx: float[source]
origy: float[source]
origz: float[source]
translx: float[source]
transly: float[source]
translz: float[source]
myops: Ops_Array[source]
set_opacity(alpha: float)[source]

Set the transparency of the array

extract_selection()[source]

Extract the current selection

crop_array(bbox: list[list[float], list[float]]) WolfArray[source]

Crop the data based on the bounding box

get_centers(usenap: bool = True)[source]

Get the centers of the cells

prepare_3D()[source]

Prepare the array for 3D display

check_bounds_ij(i: int, j: int)[source]

Check if i and j are inside the array bounds

check_bounds_xy(x: float, y: float)[source]

Check if i and j are inside the array bounds

show_properties()[source]

Affichage des propriétés de la matrice dans une fenêtre wxPython

hide_properties()[source]

Hide the properties window

loadnap_and_apply()[source]

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.

add_crosslinked_array(newlink: WolfArray)[source]

Ajout d’une matrice liée croisée

share_palette()[source]

Partage de la palette de couleurs entre matrices liées

filter_inundation(epsilon: float = None, mask: numpy.ndarray = None)[source]
Apply filter on array :
  • mask data below eps

  • mask data outisde linkedvec

Parameters:
  • epsilon – value under which data are masked

  • mask – mask to apply if eps is None

If all params are None, the function will mask NaN values

filter_independent_zones(n_largest: int = 1, reset_plot: bool = True)[source]

Filtre des zones indépendantes et conservation des n plus grandes

filter_zone(set_null: bool = False, reset_plot: bool = True)[source]

Filtre des zones et conservation de celles pour lesquelles des mailles sont sélectionnées

labelling(reset_plot: bool = True)[source]

Labelling of the array using Scipy

export_geotif(outdir='', extent='', EPSG: int = 31370)[source]

Export de la matrice au format Geotiff (Lambert 72 - EPSG:31370)

Formats supportés :
  • Int32

  • Float32

  • Float64

Parameters:
  • outdir – directory

  • extent – suffix to add to the filename before the extension ‘.tif’

  • EPSG – EPSG code, by default 31370 (Lambert 72)

_import_npy(fn: str = '', crop: list[float] = None)[source]

Import a numpy file.

Must be called after the header is initialized, e.g. read_txt_header.

Parameters:
  • fn – filename

  • crop – crop the data - [xmin, xmax, ymin, ymax]

import_geotif(fn: str = '', which: int = None, crop: list[float] = None)[source]

Import de la matrice au format Geotiff

Formats supportés :
  • Int32

  • Float32

  • Float64

Parameters:
  • fn – filename

  • which – band to import

  • crop – crop the data - [xmin, xmax, ymin, ymax]

add_ops_sel()[source]

Adding selection manager and operations array

  • Ops_Array (GUI) if mapviewer is not None

  • create SelectionData (Selection manager) if None

change_gui(newparentgui)[source]

Move GUI to another instance

Parameters:

newparentgui – WolfMapViewer instance

compare_cloud(mycloud: wolfhece.PyVertex.cloud_vertices, delta: list[float] = [0.15, 0.5, 1.0])[source]

Graphique de comparaison des valeurs d’un nuage de points et des valeurs de la matrice sous les mêmes positions

Parameters:
  • mycloud – cloud_vertices

  • delta – list of tolerance for the comparison

compare_tri(mytri: wolfhece.PyVertexvectors.Triangulation)[source]

Graphique de comparaison des valeurs d’un nuage de points et des valeurs de la matrice sous les mêmes positions

interpolate_on_polygon(working_vector: wolfhece.PyVertexvectors.vector, method: Literal[nearest, linear, cubic] = 'linear')[source]

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

interpolate_on_polygons(working_zone: wolfhece.PyVertexvectors.zone, method: Literal[nearest, linear, cubic] = 'linear')[source]

Interpolation sous plusieurs polygones d’une même zone

interpolate_on_polyline(working_vector: wolfhece.PyVertexvectors.vector, usemask=True)[source]

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

interpolate_on_polylines(working_zone: wolfhece.PyVertexvectors.zone, usemask=True)[source]
interpolate_on_cloud(xy: numpy.ndarray, z: numpy.ndarray, method='linear')[source]

See : https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.griddata.html

method == nearest, linear or cubic

interpolate_on_triangulation(coords, triangles, grid_x=None, grid_y=None, mask_tri=None, interp_method='matplotlib')[source]
import_from_gltf(fn: str = '', fnpos: str = '', interp_method: Literal[matplotlib, numpy] = 'matplotlib')[source]

interp_method == ‘matplotlib’ or ‘griddata’

export_to_gltf(bounds: list[float] = None, fn: str = '')[source]

Export to GLTF/GLB format

Parameters:
  • bounds – [[xmin,xmax],[ymin,ymax]]

  • fn – filename

get_triangulation(bounds: list[float] = None)[source]

Traingulation of the array

Parameters:

bounds – [[xmin,xmax],[ymin,ymax]]

hillshade(azimuth: float, angle_altitude: float)[source]

Create a hillshade array – see “hillshade” function accelerated by JIT

get_gradient_norm()[source]

Compute and return the norm of the gradient

get_laplace()[source]

Compute and return the laplacian

volume_estimation(axs=None)[source]

Estimation of the volume of the selected zone

paste_all(fromarray: WolfArray, mask_after: bool = True)[source]

Paste all the values from another WolfArray

set_values_sel(xy: list[float], z: list[float], update: bool = True)[source]

Set values at the selected positions

Parameters:
  • xy – [[x1,y1],[x2,y2],…]

  • z – [z1,z2,…]

  • update – update the plot

init_from_new(dlg: NewArray)[source]

Initialize the array properties from the NewArray dialog

init_from_header(myhead: header_wolf, dtype: numpy.dtype = None, force_type_from_header: bool = False)[source]

Initialize the array properties from a header_wolf object

Parameters:
  • myhead – header_wolf object

  • dtype – numpy dtype

  • force_type_from_header – force the type from the header passed as argument

interpolation2D(key: str = '1')[source]

Interpolation 2D basde on selected points in key 1

copy_mask(source: WolfArray, forcenullvalue: bool = False, link: bool = True)[source]

Copy/Link the mask from another WolfArray

Parameters:
  • source – WolfArray source

  • forcenullvalue – force nullvalue in the masked zone

  • link – link the mask if True (default), copy it otherwise

mask_union(source: WolfArray, link: bool = True)[source]

Union of the mask with another WolfArray

Parameters:
  • source – WolfArray source

  • link – link the mask if True (default), copy it otherwise

mask_unions(sources: list[WolfArray], link: bool = True)[source]

Union of the mask with another WolfArrays

Parameters:
  • source – list of WolfArray sourceq

  • link – link the mask if True (default), copy it otherwise

copy_mask_log(mask: numpy.ndarray, link: bool = True)[source]

Copy the mask from a numpy array

Parameters:
  • mask – numpy array

  • link – link the mask if True (default), copy it otherwise

check_plot()[source]

Make sure the array is plotted

uncheck_plot(unload: bool = True, forceresetOGL: bool = False, askquestion: bool = True)[source]

Make sure the array is not plotted

Parameters:
  • unload – unload the data if True (default), keep it otherwise

  • forceresetOGL – force the reset of the OpenGL lists

  • askquestion – ask the question if True and a wx App is running (default), don’t ask it otherwise

get_header(abs: bool = True) header_wolf[source]

Return a header_wolf object - different from the self object header

Parameters:

abs – if True (default), return an absolute header (shifted origin) and translation set to 0.

set_header(header: header_wolf)[source]

Set the header from a header_wolf object

concatenate(list_arr: list[WolfArray], nullvalue: float = 0.0)[source]

Concatenate the values from another WolfArrays into a new one

Parameters:

list_arr – list of WolfArray objects

Returns:

a new WolfArray

Return_type:

WolfArray

mask_outsidepoly(myvect: wolfhece.PyVertexvectors.vector, eps: float = 0.0)[source]

Mask nodes outside a polygon and set values to nullvalue

Parameters:

myvect – target vector in global coordinates

mask_insidepoly(myvect: wolfhece.PyVertexvectors.vector, eps: float = 0.0)[source]

Mask nodes inside a polygon and set values to nullvalue

Parameters:

myvect – target vector in global coordinates

get_xy_inside_polygon(myvect: wolfhece.PyVertexvectors.vector | shapely.geometry.Polygon, usemask: bool = True)[source]

Return the coordinates inside a polygon

:param myvect : target vector :param usemask : limit potential nodes to unmaksed nodes

get_xy_inside_polygon_shapely(myvect: wolfhece.PyVertexvectors.vector | shapely.geometry.Polygon, usemask: bool = True)[source]

Return the coordinates inside a polygon

:param myvect : target vector :param usemask : limit potential nodes to unmaksed nodes

get_xy_under_polyline(myvect: wolfhece.PyVertexvectors.vector, usemask: bool = True)[source]

Return the coordinates along a polyline

:param myvect : target vector :param usemask : limit potential nodes to unmaksed nodes

get_ij_inside_polygon(myvect: wolfhece.PyVertexvectors.vector, usemask: bool = True, eps: float = 0.0)[source]

Return the indices inside a polygon

:param myvect : target vector :param usemask : limit potential nodes to unmaksed nodes

intersects_polygon(myvect: wolfhece.PyVertexvectors.vector | shapely.geometry.Polygon, usemask: bool = True)[source]

Return True if the array intersects the polygon

:param myvect : target vector :param usemask : limit potential nodes to unmaksed nodes

intersects_polygon_shapely(myvect: wolfhece.PyVertexvectors.vector | shapely.geometry.Polygon, eps: float = 0.0, usemask: bool = True)[source]

Return True if the array intersects the polygon

:param myvect : target vector :param usemask : limit potential nodes to unmaksed nodes

get_ij_under_polyline(myvect: wolfhece.PyVertexvectors.vector, usemask: bool = True)[source]

Return the indices along a polyline

:param myvect = target vector :param usedmask = limit potential nodes to unmaksed nodes

get_values_insidepoly(myvect: wolfhece.PyVertexvectors.vector, usemask: bool = True, getxy: bool = False)[source]

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

get_values_underpoly(myvect: wolfhece.PyVertexvectors.vector, usemask: bool = True, getxy: bool = False)[source]

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

get_all_values_insidepoly(myvect: wolfhece.PyVertexvectors.vector, usemask: bool = True, getxy: bool = False)[source]

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

get_all_values_underpoly(myvect: wolfhece.PyVertexvectors.vector, usemask: bool = True, getxy: bool = False)[source]

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

reset()[source]

Reset the array to nullvalue

allocate_ressources()[source]

Memory Allocation according to dtype/wolftype

read_all(which_band=None)[source]

Lecture d’un Wolf aray depuis le nom de fichier

write_all(newpath: str = None, EPSG: int = 31370)[source]

Ecriture de tous les fichiers d’un Wolf array

Parameters:
  • newpath – new path and filename with extension – if None, use the current filename

  • EPSG – EPSG code for geotiff

get_rebin_shape_size(factor: float) tuple[tuple[int, int], tuple[float, float]][source]

Return the new shape after rebinning.

newdx = dx * factor newdy = dy * factor

The shape is adjusted to be a multiple of the factor.

Parameters:

factor (float) – factor of resolution change – > 1.0 : decrease resolution, < 1.0 : increase resolution

Returns:

new shape

Return type:

Tuple[int, int]

get_rebin_header(factor: float) header_wolf[source]

Return a new header after rebinning.

Parameters:

factor (float) – factor of resolution change – > 1.0 : decrease resolution, < 1.0 : increase resolution

Returns:

new header

Return type:

header_wolf

rebin(factor: float, operation: Literal[mean, sum, min, max, median] = 'mean', operation_matrix: WolfArray = None) None[source]

Change resolution - in place.

If you want to keep current data, copy the WolfArray into a new variable -> newWA = Wolfarray(mold=curWA).

Parameters:
  • factor (float) – factor of resolution change – > 1.0 : decrease resolution, < 1.0 : increase resolution

  • operation (str, Rebin_Ops) – operation to apply on the blocks (‘mean’, ‘sum’, ‘min’, ‘max’, ‘median’)

  • operation_matrix (WolfArray) – 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

read_txt_header()[source]

Read header from txt file Supercharged by WolfArray to avoid explicit call to read_txt_header with parameters

write_txt_header()[source]

Write header to txt file Supercharged by WolfArray to avoid explicit call to write_txt_header with parameters

read_data()[source]

Opération de lecture des données depuis le fichier connu

_read_binary_data(f, seek=0)[source]

Read binary data from file

write_array()[source]

Ecriture du tableau en binaire

write_xyz(fname: str)[source]

Ecriture d un fichier xyz avec toutes les données du Wolf Array

get_xyz(which='all') numpy.ndarray[source]

Return an array of xyz coordinates and values

set_general_frame_from_xyz(fname: str, dx: float, dy: float, border_size: int = 5)[source]

Lecture d’un fichier texte xyz et initialisation des données de base

Parameters:
  • fname – nom du fichier xyz

  • dx – pas en x

  • dy – pas en y

  • border_size – nombre de mailles de bordure en plus de l’extension spatiale du fichier

fillin_from_xyz(xyz: numpy.ndarray)[source]

Remplissage du tableau à partir d’un tableau xyz

fillin_from_ijz(ijz: numpy.ndarray)[source]

Remplissage du tableau à partir d’un tableau ijz

mask_force_null()[source]

Force to unmask all and mask null value

unmask()[source]

alias to mask_reset

mask_clear()[source]

alias to mask_reset

mask_reset()[source]

Unmask everything

count()[source]

Count the number of not masked values

mask_data(value)[source]

Mask cell where values are equal to value

mask_lower(value)[source]

Mask cell where values are strictly lower than value

mask_lowerequal(value)[source]

Mask cell where values are lower or equal than value

mask_greater(value)[source]

Mask cell where values are strictly greater than value

mask_greaterequal(value)[source]

Mask cell where values are greater or equal than value

set_nullvalue_in_mask()[source]

Set nullvalue in masked cells

reset_plot(whichpal=0, mimic=True)[source]

Reset plot of the array

mask_allexceptdata(value)[source]

Mask cell where values are different from value

mask_invert()[source]

Invert the mask

meshgrid(mode: Literal[gc, borders] = 'gc')[source]

Création d’un maillage 2D

Parameters:

mode – ‘gc’ pour les centres de mailles, ‘borders’ pour les bords de mailles

crop_masked_at_edges()[source]

Crop the array to remove masked cells at the edges of the array :return: cropped array, WolfArray instance

crop(i_start: int, j_start: int, nbx: int, nby: int, k_start: int = 1, nbz: int = 1)[source]

Crop the array

Parameters:
  • i_start – start index in x

  • j_start – start index in y

  • nbx – number of cells in x

  • nby – number of cells in y

  • k_start – start index in z

  • nbz – number of cells in z

Returns:

cropped array, WolfArray instance

extend(x_ext: int, y_ext: int)[source]

Extend the array

Crop is the opposite

extremum(which: Literal[min, max] = 'min')[source]

Return the extremum value

get_value(x: float, y: float, z: float = 0.0, nullvalue: float = -99999)[source]

Return the value at given coordinates

Parameters:
  • x – x coordinate

  • y – y coordinate

  • z – z coordinate

  • nullvalue – value to return if the point is outside the array

get_xlim(window_x: float, window_y: float)[source]

Return the limits in x for a given window size

Parameters:
  • window_x – window size in x

  • window_y – window size in y

get_ylim(window_x: float, window_y: float)[source]

Retrun the limits in y for a given window size

Parameters:
  • window_x – window size in x

  • window_y – window size in y

get_working_array(onzoom: list[float] = [])[source]

Return the part of the array in the zoom window

Parameters:

onzoom – zoom window – [xmin, xmax, ymin, ymax]

updatepalette(which: int = 0, onzoom=[])[source]

Update the palette/colormap

Parameters:
  • which – which palette to update

  • onzoom – zoom window – [xmin, xmax, ymin, ymax]

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

Plot the array - OpenGL

Parameters:
  • sx – scale along X

  • sy – scale along Y

  • xmin – Lower-Left coordinates in X

  • ymin – Lower-Left coordinates in Y

  • xmax – Upper-Right coordinates in X

  • ymax – Upper-Right coordinates in Y

  • size – size of the window (not used here but necessary for compatibility with Element_To_Draw)

delete_lists()[source]

Delete OpenGL lists

plot_matplotlib()[source]

Plot the array - Matplotlib version

Using imshow and RGB array

fillonecellgrid(curscale, loci, locj, force=False)[source]

Fill one cell of the plotted grid

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][source]

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

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][source]

Create Matplotlib image from WolfArray

set_array_from_numpy(array: numpy.ndarray, nullvalue: float = None)[source]

Set array from numpy array

nullify_border(width: int = 1)[source]

Set border to nullvalue

as_WolfArray(abs: bool = True) WolfArray[source]

Return a WolfArray object from this WolfArray

get_unique_values()[source]

Return unique values in the array

map_values(keys_vals: dict, default: float = None)[source]

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.

Parameters:
  • keys_vals – dictionary of values to map

  • default – default value if key not found

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

Reprojects and resamples a raster file from an other EPSG coordinates and return it as a WolfArray.

Parameters:
  • input_raster_path (str) – The path to the input raster file.

  • input_srs (str) – The input spatial reference system (SRS) in the format ‘EPSG:XXXX’. Defaults to Lambert 2008 ‘EPSG:3812’.

  • output_srs (str) – The output spatial reference system (SRS) in the format ‘EPSG:XXXX’. Defaults to Belgian Lambert 72 ‘EPSG:31370’.

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

  • RuntimeError – If the input raster file cannot be opened.

  • PermissionError – If there is a permission error while trying to delete the output raster file.

  • Exception – If an unexpected error occurs while trying to delete the output raster file.

  • RuntimeError – If the reprojection fails for the input raster file.

Returns:

WolfArray

class wolfhece.wolf_array.WolfArrayMB(fname=None, mold=None, masknull=True, crop=None, whichtype=WOLF_ARRAY_MB_SINGLE, preload=True, create=False, mapviewer=None, nullvalue=0, srcheader=None)[source]

Bases: WolfArray

Inheritance diagram of wolfhece.wolf_array.WolfArrayMB

Matrice multiblocks

Les blocs (objets WolfArray) sont stockés dans un dictionnaire “myblocks”

property nullvalue: float[source]

Return the null value

myblocks: dict[str, WolfArray][source]
extract_selection()[source]

Extract the current selection

add_ops_sel()[source]

Add operations and selection manager to all blocks

filter_zone(set_null: bool = False)[source]

Filtre des zones et conservation de celles pour lesquelles des mailles sont sélectionnées

labelling()[source]

Labelling of the array using Scipy

interpolate_on_polygon(working_vector: wolfhece.PyVertexvectors.vector, method: Literal[nearest, linear, cubic] = 'linear')[source]

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

interpolate_on_polygons(working_zone: wolfhece.PyVertexvectors.zone, method: Literal[nearest, linear, cubic] = 'linear')[source]

Interpolation sous plusieurs polygones d’une même zone

interpolate_on_polyline(working_vector: wolfhece.PyVertexvectors.vector, usemask=True)[source]

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

interpolate_on_polylines(working_zone: wolfhece.PyVertexvectors.zone, usemask=True)[source]

Interpolation sous les polylignes d’une même zone

check_bounds_ij(i: int, j: int)[source]

Check if i and j are inside the array bounds

check_bounds_xy(x: float, y: float)[source]

Check if i and j are inside the array bounds

add_block(arr: WolfArray, force_idx: bool = False, copyarray=False)[source]

Adds a properly configured block this multiblock.

Parameters:
  • arr – The block to add.

  • force_idx – If True, the index/key will be set on arr. If False, the index/key must already be set on arr.

share_palette()[source]

Partage de la palette de couleurs entre matrices liées

copy_mask(source: WolfArrayMB, forcenullvalue: bool = False)[source]

Copy the mask of two arrays

count()[source]

Count the number of not null cells

check_plot()[source]

Check plot and apply to each block

uncheck_plot(unload: bool = True, forceresetOGL: bool = False, askquestion: bool = True)[source]

Uncheck plot and apply to each block

mask_data(value)[source]

Mask cells where values are equal to value

mask_union(source: WolfArrayMB)[source]

Union of the masks of two arrays

Applying for each block iteratively.

read_data()[source]

Lecture du tableau en binaire

write_array()[source]

Ecriture du tableau en binaire

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

alias for get_ij_from_xy for the block `which_block

Parameters:
  • x – x coordinate

  • y – y coordinate

  • z – z coordinate

  • scale – scale factor

  • aswolf – if True, then the indices are 1-based like Fortran, otherwise 0-based like Python

  • abs – if True, then the translation is taken into account

  • which_block – block index 1-based

get_values_as_wolf(i: int, j: int, which_block: int = 1)[source]

Return the value at indices (i,j) of the block `which_block.

Parameters:
  • i – i index

  • j – j index

  • which_block – block index 1-based

get_value(x: float, y: float, abs: bool = True)[source]

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

Parameters:
  • x – x coordinate

  • y – y coordinate

  • abs – if True, then the translation is taken into account

Returns:

the value at (x,y) or np.NaN if no block covers the coordinate

get_xy_from_ij(i: int, j: int, which_block: int, aswolf: bool = False, abs: bool = True)[source]

Return the world coordinates (x,y) of the indices (i,j) of the block `which_block.

Parameters:
  • i – i index – 1-based like Fortran or 0-based like Python, see ‘aswolf’ parameter

  • j – j index – 1-based like Fortran or 0-based like Python, see ‘aswolf’ parameter

  • which_block – block index 1-based

  • aswolf – if True, (i,j) are 1-based like Fortran, otherwise 0-based like Python

  • abs – if True, then the translation is taken into account

get_blockij_from_xy(x: float, y: float, abs: bool = True)[source]

Return the block indices (i,j) of the block covering the world coordinate (x,y)

Parameters:
  • x – x coordinate

  • y – y coordinate

  • abs – if True, then the translation is taken into account

Returns:

the block indices (i,j,[k]) or (-1,-1,-1) if no block covers the coordinate

Lier les palettes des blocs à la palette de l’objet parent

updatepalette(which: int = 0, onzoom: list[float] = [])[source]

Update the palette/colormap of the array

Parameters:
  • which – which colormap to use

  • onzoom – if not empty, then only the values within the zoom are used to update the palette – [xmin,xmax,ymin,ymax]

delete_lists()[source]

Delete OpenGL lists

mimic_plotdata()[source]

Copy plot flags to children

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

Plot the array

fillonecellgrid(curscale, loci, locj, force=False)[source]

Fill one cell of the plotted grid

check_consistency(other)[source]

Vérifie la cohérence entre deux matrices

reset()[source]

Reset each block

mask_reset()[source]

Reset mask – mask = False everywhere

mask_lower(value)[source]

Mask cell where values are strictly lower than value

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][source]

Create Matplotlib image from MultiBlock array

allocate_ressources()[source]

Allocate memory ressources

set_header_from_added_blocks()[source]

Set header from blocks

as_WolfArray(abs: bool = True, forced_header: header_wolf = None) WolfArray[source]

Convert to WolfArray

Rebin blocks if necessary

class wolfhece.wolf_array.WolfArrayMNAP(fname=None, mold=None, masknull=True, crop=None)[source]

Bases: WolfArrayMB

Inheritance diagram of wolfhece.wolf_array.WolfArrayMNAP

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.

contour: wolfhece.PyVertexvectors.Zones[source]
write_all()[source]

Ecriture de tous les fichiers d’un Wolf array

Parameters:
  • newpath – new path and filename with extension – if None, use the current filename

  • EPSG – EPSG code for geotiff

read_data()[source]

Lecture du tableau en binaire

read_txt_header()[source]

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”

get_one_mask(which: int | str)[source]

Return the mask of the block which

get_all_masks()[source]

Return all masks