wolfhece 2.1.129__py3-none-any.whl → 2.2.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- wolfhece/PyDraw.py +110 -47
- wolfhece/PyGui.py +3 -0
- wolfhece/PyGuiHydrology.py +24 -24
- wolfhece/PyHydrographs.py +2 -3
- wolfhece/PyPalette.py +27 -11
- wolfhece/PyParams.py +2 -3
- wolfhece/PyVertex.py +7 -7
- wolfhece/PyVertexvectors.py +1 -0
- wolfhece/Results2DGPU.py +17 -0
- wolfhece/acceptability/Parallels.py +25 -19
- wolfhece/acceptability/acceptability_gui.py +85 -45
- wolfhece/acceptability/func.py +34 -26
- wolfhece/apps/version.py +2 -2
- wolfhece/eikonal.py +1 -1
- wolfhece/hydrology/Catchment.py +2 -2
- wolfhece/hydrology/Comparison.py +26 -28
- wolfhece/hydrology/plot_hydrology.py +2 -2
- wolfhece/lagrangian/particle_system_ui.py +1 -1
- wolfhece/lagrangian/particles.py +1 -1
- wolfhece/lazviewer/processing/estimate_normals/estimate_normals.cp310-win_amd64.pyd +0 -0
- wolfhece/lazviewer/vfuncsdir/vfuncs.cp310-win_amd64.pyd +0 -0
- wolfhece/lazviewer/viewer/viewer.exe +0 -0
- wolfhece/lazviewer/viewer/viewer_np1_23_5.exe +0 -0
- wolfhece/libs/Wolf_tools.dll +0 -0
- wolfhece/libs/get_infos.cp310-win_amd64.pyd +0 -0
- wolfhece/libs/verify_wolf.cp310-win_amd64.pyd +0 -0
- wolfhece/libs/wolfogl.cp310-win_amd64.pyd +0 -0
- wolfhece/tools2d_dll.py +359 -0
- wolfhece/wolf_array.py +27 -24
- wolfhece/wolfresults_2D.py +162 -33
- {wolfhece-2.1.129.dist-info → wolfhece-2.2.2.dist-info}/METADATA +14 -9
- {wolfhece-2.1.129.dist-info → wolfhece-2.2.2.dist-info}/RECORD +35 -33
- wolfhece/libs/wolfpy.cp310-win_amd64.pyd +0 -0
- {wolfhece-2.1.129.dist-info → wolfhece-2.2.2.dist-info}/WHEEL +0 -0
- {wolfhece-2.1.129.dist-info → wolfhece-2.2.2.dist-info}/entry_points.txt +0 -0
- {wolfhece-2.1.129.dist-info → wolfhece-2.2.2.dist-info}/top_level.txt +0 -0
wolfhece/wolf_array.py
CHANGED
@@ -10,13 +10,15 @@ copying or distribution of this file, via any medium, is strictly prohibited.
|
|
10
10
|
|
11
11
|
import os
|
12
12
|
import sys
|
13
|
+
|
14
|
+
import numpy as np
|
15
|
+
import numpy.ma as ma
|
16
|
+
|
13
17
|
from typing import Union, Literal
|
14
18
|
from matplotlib.axis import Axis
|
15
19
|
from matplotlib.figure import Figure
|
16
20
|
import matplotlib.pyplot as plt
|
17
21
|
from matplotlib.colors import Colormap
|
18
|
-
import numpy as np
|
19
|
-
import numpy.ma as ma
|
20
22
|
import math as m
|
21
23
|
import logging
|
22
24
|
import json
|
@@ -40,7 +42,6 @@ import re
|
|
40
42
|
import wx
|
41
43
|
from scipy.interpolate import interp2d, griddata
|
42
44
|
from scipy.ndimage import laplace, label, sum_labels
|
43
|
-
import pygltflib
|
44
45
|
from shapely.geometry import Point, LineString, MultiLineString, Polygon, MultiPolygon, MultiPoint
|
45
46
|
from shapely.ops import linemerge, substring, polygonize_full
|
46
47
|
from shapely import contains, contains_properly, contains_xy, touches, prepare, destroy_prepared, is_prepared
|
@@ -56,12 +57,6 @@ except ImportError as e:
|
|
56
57
|
print(e)
|
57
58
|
raise Exception(_('Error importing modules'))
|
58
59
|
|
59
|
-
try:
|
60
|
-
from osgeo import gdal
|
61
|
-
except ImportError as e:
|
62
|
-
print(e)
|
63
|
-
raise Exception(_('Error importing GDAL library'))
|
64
|
-
|
65
60
|
try:
|
66
61
|
from .Coordinates_operations import reproject_and_resample_raster
|
67
62
|
except ImportError as e:
|
@@ -132,6 +127,13 @@ VERSION_RGB = 3
|
|
132
127
|
|
133
128
|
from numba import jit
|
134
129
|
|
130
|
+
try:
|
131
|
+
from osgeo import gdal, osr
|
132
|
+
gdal.UseExceptions()
|
133
|
+
except ImportError as e:
|
134
|
+
print(e)
|
135
|
+
raise Exception(_('Error importing GDAL library'))
|
136
|
+
|
135
137
|
@jit(nopython=True)
|
136
138
|
def custom_gradient(array: np.ndarray):
|
137
139
|
""" Calculate the gradient manually """
|
@@ -878,7 +880,7 @@ class header_wolf():
|
|
878
880
|
locpath = Path(filename)
|
879
881
|
|
880
882
|
if filename.endswith('.tif') or filename.endswith('.tiff') :
|
881
|
-
from osgeo import gdal
|
883
|
+
# from osgeo import gdal
|
882
884
|
|
883
885
|
raster:gdal.Dataset
|
884
886
|
raster = gdal.Open(filename)
|
@@ -932,7 +934,7 @@ class header_wolf():
|
|
932
934
|
|
933
935
|
elif filename.endswith('.vrt'):
|
934
936
|
# Virtual raster
|
935
|
-
from osgeo import gdal
|
937
|
+
# from osgeo import gdal
|
936
938
|
|
937
939
|
raster:gdal.Dataset
|
938
940
|
raster = gdal.Open(filename)
|
@@ -6058,7 +6060,7 @@ class WolfArray(Element_To_Draw, header_wolf):
|
|
6058
6060
|
Statistics on Selected data or the whole array if no selection
|
6059
6061
|
|
6060
6062
|
:param inside_polygon: vector or Polygon to select data inside the polygon
|
6061
|
-
:return: mean, std, median, sum, values
|
6063
|
+
:return: mean, std, median, sum, volume (sum*dx*dy), values
|
6062
6064
|
"""
|
6063
6065
|
|
6064
6066
|
if inside_polygon is not None:
|
@@ -6074,8 +6076,9 @@ class WolfArray(Element_To_Draw, header_wolf):
|
|
6074
6076
|
std = np.std(vals)
|
6075
6077
|
median = np.median(vals)
|
6076
6078
|
sum = np.sum(vals)
|
6079
|
+
vol = sum * self.dx * self.dy
|
6077
6080
|
|
6078
|
-
return {_('Mean'): mean, _('Std'): std, _('Median'): median, _('Sum'): sum, _('Values'): vals}
|
6081
|
+
return {_('Mean'): mean, _('Std'): std, _('Median'): median, _('Sum'): sum, _('Volume'): vol, _('Values'): vals}
|
6079
6082
|
|
6080
6083
|
def export_geotif(self, outdir:str= '', extent:str= '', EPSG:int = 31370):
|
6081
6084
|
"""
|
@@ -6098,7 +6101,7 @@ class WolfArray(Element_To_Draw, header_wolf):
|
|
6098
6101
|
:param extent: suffix to add to the filename before the extension '.tif' (only if outdir is provided)
|
6099
6102
|
:param EPSG: EPSG code, by default 31370 (Lambert 72)
|
6100
6103
|
"""
|
6101
|
-
from osgeo import gdal, osr, gdalconst
|
6104
|
+
# from osgeo import gdal, osr, gdalconst
|
6102
6105
|
|
6103
6106
|
outdir = str(outdir)
|
6104
6107
|
extent = str(extent)
|
@@ -6377,7 +6380,7 @@ class WolfArray(Element_To_Draw, header_wolf):
|
|
6377
6380
|
:param which: band to import
|
6378
6381
|
:param crop: crop the data - [xmin, xmax, ymin, ymax]
|
6379
6382
|
"""
|
6380
|
-
from osgeo import gdal, osr, gdalconst
|
6383
|
+
# from osgeo import gdal, osr, gdalconst
|
6381
6384
|
|
6382
6385
|
if fn !='':
|
6383
6386
|
pass
|
@@ -7830,9 +7833,9 @@ class WolfArray(Element_To_Draw, header_wolf):
|
|
7830
7833
|
|
7831
7834
|
if type(other) == float:
|
7832
7835
|
if other != 0.:
|
7833
|
-
newArray.array = np.ma.masked_array(self.array + other, self.array.mask)
|
7836
|
+
newArray.array = np.ma.masked_array(self.array + other, self.array.mask, dtype=self.array.dtype)
|
7834
7837
|
else:
|
7835
|
-
newArray.array = np.ma.masked_array(self.array + other.array, self.array.mask)
|
7838
|
+
newArray.array = np.ma.masked_array(self.array + other.array, self.array.mask, dtype=self.array.dtype)
|
7836
7839
|
newArray.count()
|
7837
7840
|
|
7838
7841
|
assert newArray.array.dtype == self.array.dtype, _('Bad dtype')
|
@@ -7859,9 +7862,9 @@ class WolfArray(Element_To_Draw, header_wolf):
|
|
7859
7862
|
|
7860
7863
|
if type(other) == float:
|
7861
7864
|
if other != 0.:
|
7862
|
-
newArray.array = np.ma.masked_array(self.array * other, self.array.mask)
|
7865
|
+
newArray.array = np.ma.masked_array(self.array * other, self.array.mask, dtype=self.array.dtype)
|
7863
7866
|
else:
|
7864
|
-
newArray.array = np.ma.masked_array(self.array * other.array, self.array.mask)
|
7867
|
+
newArray.array = np.ma.masked_array(self.array * other.array, self.array.mask, dtype=self.array.dtype)
|
7865
7868
|
newArray.count()
|
7866
7869
|
|
7867
7870
|
assert newArray.array.dtype == self.array.dtype, _('Bad dtype')
|
@@ -7888,9 +7891,9 @@ class WolfArray(Element_To_Draw, header_wolf):
|
|
7888
7891
|
|
7889
7892
|
if type(other) == float:
|
7890
7893
|
if other != 0.:
|
7891
|
-
newArray.array = np.ma.masked_array(self.array - other, self.array.mask)
|
7894
|
+
newArray.array = np.ma.masked_array(self.array - other, self.array.mask, dtype=self.array.dtype)
|
7892
7895
|
else:
|
7893
|
-
newArray.array = np.ma.masked_array(self.array - other.array, self.array.mask)
|
7896
|
+
newArray.array = np.ma.masked_array(self.array - other.array, self.array.mask, dtype=self.array.dtype)
|
7894
7897
|
newArray.count()
|
7895
7898
|
|
7896
7899
|
assert newArray.array.dtype == self.array.dtype, _('Bad dtype')
|
@@ -7915,7 +7918,7 @@ class WolfArray(Element_To_Draw, header_wolf):
|
|
7915
7918
|
newArray.origz = self.origz
|
7916
7919
|
newArray.translz = self.translz
|
7917
7920
|
|
7918
|
-
newArray.array = np.ma.masked_array(self.array ** other, self.array.mask)
|
7921
|
+
newArray.array = np.ma.masked_array(self.array ** other, self.array.mask, dtype=self.array.dtype)
|
7919
7922
|
newArray.count()
|
7920
7923
|
|
7921
7924
|
assert newArray.array.dtype == self.array.dtype, _('Bad dtype')
|
@@ -7942,9 +7945,9 @@ class WolfArray(Element_To_Draw, header_wolf):
|
|
7942
7945
|
|
7943
7946
|
if type(other) == float:
|
7944
7947
|
if other != 0.:
|
7945
|
-
newArray.array = np.ma.masked_array(self.array / other, self.array.mask)
|
7948
|
+
newArray.array = np.ma.masked_array(self.array / other, self.array.mask, dtype=self.array.dtype)
|
7946
7949
|
else:
|
7947
|
-
newArray.array = np.ma.masked_array(np.where(other == 0., 0., self.array / other.array), self.array.mask)
|
7950
|
+
newArray.array = np.ma.masked_array(np.where(other == 0., 0., self.array / other.array), self.array.mask, dtype=self.array.dtype)
|
7948
7951
|
newArray.count()
|
7949
7952
|
|
7950
7953
|
assert newArray.array.dtype == self.array.dtype, _('Bad dtype')
|
wolfhece/wolfresults_2D.py
CHANGED
@@ -45,31 +45,32 @@ from .mesh2d.wolf2dprev import prev_parameters_simul, blocks_file
|
|
45
45
|
from .GraphNotebook import PlotPanel
|
46
46
|
from .CpGrid import CpGrid
|
47
47
|
from .matplotlib_fig import Matplotlib_Figure
|
48
|
+
from .tools2d_dll import Tools2DFortran
|
48
49
|
|
49
50
|
|
50
|
-
try:
|
51
|
-
|
52
|
-
except Exception as ex:
|
53
|
-
|
54
|
-
|
55
|
-
|
51
|
+
# try:
|
52
|
+
# from .libs import wolfpy
|
53
|
+
# except Exception as ex:
|
54
|
+
# # This convoluted error handling is here to catch an issue
|
55
|
+
# # which was difficult to track down: wolfpy was there
|
56
|
+
# # but its DLL were not available.
|
56
57
|
|
57
|
-
|
58
|
-
|
58
|
+
# from importlib.util import find_spec
|
59
|
+
# s = find_spec('wolfhece.libs.wolfpy')
|
59
60
|
|
60
|
-
|
61
|
-
|
62
|
-
|
61
|
+
# # Not too sure about this find_spec. If the root
|
62
|
+
# # directory is not the good one, the import search may
|
63
|
+
# # end up in the site packages, loading the wrong wolfpy.
|
63
64
|
|
64
|
-
|
65
|
-
|
66
|
-
|
65
|
+
# base = Path(__file__).parent.parts
|
66
|
+
# package = Path(s.origin).parent.parts
|
67
|
+
# is_submodule = (len(base) <= len(package)) and all(i==j for i, j in zip(base, package))
|
67
68
|
|
68
|
-
|
69
|
-
|
70
|
-
|
69
|
+
# if is_submodule:
|
70
|
+
# msg = _("wolfpy was found but we were not able to load it. It may be an issue with its DLL dependencies")
|
71
|
+
# msg += _("The actual error was: {}").format(str(ex))
|
71
72
|
|
72
|
-
|
73
|
+
# raise Exception(msg)
|
73
74
|
|
74
75
|
from .wolf_array import WolfArray, getkeyblock, header_wolf, WolfArrayMB, WolfArrayMNAP, header_wolf, SelectionData, SelectionDataMB, VERSION_RGB
|
75
76
|
from .mesh2d import wolf2dprev
|
@@ -130,6 +131,12 @@ def u_splitting(q_left, q_right, h_left, h_right):
|
|
130
131
|
else:
|
131
132
|
return (q_left/h_left + q_right/h_right) / 2.
|
132
133
|
|
134
|
+
def _process_danger_map_chunk(chunk):
|
135
|
+
import pickle
|
136
|
+
obj, start, end, every = chunk
|
137
|
+
# Create a new instance of the class for each chunk
|
138
|
+
new:Wolfresults_2D = pickle.loads(pickle.dumps(obj))
|
139
|
+
return new.danger_map(start, end, every)
|
133
140
|
|
134
141
|
class Props_Res_2D(wx.Frame):
|
135
142
|
"""
|
@@ -2213,6 +2220,7 @@ class Wolfresults_2D(Element_To_Draw):
|
|
2213
2220
|
self.filename = fname
|
2214
2221
|
|
2215
2222
|
self.filenamegen=self.filename
|
2223
|
+
self._dll_tools = Tools2DFortran(self.filenamegen) # DLL de calculs de la classe Tools2DFortran
|
2216
2224
|
|
2217
2225
|
if exists(self.filename + '.trl'):
|
2218
2226
|
with open(self.filename + '.trl') as f:
|
@@ -2224,14 +2232,16 @@ class Wolfresults_2D(Element_To_Draw):
|
|
2224
2232
|
self.read_param_simul()
|
2225
2233
|
|
2226
2234
|
if exists(self.filename+'.head') or exists(join(dirname(self.filename),'bloc1.head')):
|
2227
|
-
wolfpy.r2d_init(self.filename.ljust(255).encode('ansi'))
|
2228
|
-
nb_blocks = wolfpy.r2d_nbblocks()
|
2235
|
+
# wolfpy.r2d_init(self.filename.ljust(255).encode('ansi'))
|
2236
|
+
# nb_blocks = wolfpy.r2d_nbblocks()
|
2229
2237
|
|
2238
|
+
nb_blocks = self._dll_tools.r2D_get_number_of_blocks()
|
2230
2239
|
for i in range(nb_blocks):
|
2231
2240
|
curblock = OneWolfResult(i, parent=self)
|
2232
2241
|
self.myblocks[getkeyblock(i)] = curblock
|
2233
2242
|
|
2234
|
-
nbx,nby,dx,dy,ox,oy,tx,ty = wolfpy.r2d_hblock(i+1)
|
2243
|
+
# nbx,nby,dx,dy,ox,oy,tx,ty = wolfpy.r2d_hblock(i+1)
|
2244
|
+
nbx, nby,dx,dy,ox,oy,tx,ty = self._dll_tools.r2D_get_header_one_block(i+1)
|
2235
2245
|
|
2236
2246
|
curhead = self.head_blocks[getkeyblock(i)]=header_wolf()
|
2237
2247
|
curhead.nbx = nbx
|
@@ -2745,8 +2755,10 @@ class Wolfresults_2D(Element_To_Draw):
|
|
2745
2755
|
if nb == 0:
|
2746
2756
|
self.times, self.timesteps = [],[]
|
2747
2757
|
else:
|
2748
|
-
wolfpy.r2d_init(self.filename.ljust(255).encode('ansi'))
|
2749
|
-
self.times, self.timesteps = wolfpy.get_times_steps(nb)
|
2758
|
+
# wolfpy.r2d_init(self.filename.ljust(255).encode('ansi'))
|
2759
|
+
# self.times, self.timesteps = wolfpy.get_times_steps(nb)
|
2760
|
+
|
2761
|
+
self.times, self.timesteps = self._dll_tools.r2D_get_times_steps()
|
2750
2762
|
|
2751
2763
|
return self.times, self.timesteps
|
2752
2764
|
|
@@ -2996,8 +3008,10 @@ class Wolfresults_2D(Element_To_Draw):
|
|
2996
3008
|
"""Récupération du nombre de pas sauvegardés --> utilisation de la librairie Fortran"""
|
2997
3009
|
|
2998
3010
|
if exists(self.filename+'.head'):
|
2999
|
-
wolfpy.r2d_init(self.filename.ljust(255).encode('ansi'))
|
3000
|
-
nb = wolfpy.r2d_getnbresults()
|
3011
|
+
# wolfpy.r2d_init(self.filename.ljust(255).encode('ansi'))
|
3012
|
+
# nb = wolfpy.r2d_getnbresults()
|
3013
|
+
|
3014
|
+
nb = self._dll_tools.r2D_get_number_of_results()
|
3001
3015
|
self._nb_results = nb
|
3002
3016
|
|
3003
3017
|
if force_update_timessteps:
|
@@ -3021,8 +3035,12 @@ class Wolfresults_2D(Element_To_Draw):
|
|
3021
3035
|
nby = block.waterdepth.nby
|
3022
3036
|
|
3023
3037
|
# Fortran is 1-based --> which_step+1
|
3024
|
-
block.waterdepth.array, block.qx.array, block.qy.array = wolfpy.r2d_getresults(which_step+1, nbx, nby, whichblock)
|
3025
|
-
block.k.array, block.eps.array = wolfpy.r2d_getturbresults(which_step+1, nbx, nby, whichblock)
|
3038
|
+
# block.waterdepth.array, block.qx.array, block.qy.array = wolfpy.r2d_getresults(which_step+1, nbx, nby, whichblock)
|
3039
|
+
# block.k.array, block.eps.array = wolfpy.r2d_getturbresults(which_step+1, nbx, nby, whichblock)
|
3040
|
+
|
3041
|
+
block.waterdepth.array, block.qx.array, block.qy.array = self._dll_tools.r2D_get_one_result(which_step+1, whichblock)
|
3042
|
+
block.k.array, block.eps.array = self._dll_tools.r2D_get_one_turbulent_result(which_step+1, whichblock)
|
3043
|
+
|
3026
3044
|
block._force_update_shields = True
|
3027
3045
|
|
3028
3046
|
def _read_oneblockresult_withoutmask_only_h(self, which_step:int=-1,whichblock:int=-1):
|
@@ -3040,7 +3058,9 @@ class Wolfresults_2D(Element_To_Draw):
|
|
3040
3058
|
nby = block.waterdepth.nby
|
3041
3059
|
|
3042
3060
|
# Fortran is 1-based --> which_step+1
|
3043
|
-
block.waterdepth.array, block.qx.array, block.qy.array = wolfpy.r2d_getresults(which_step+1, nbx, nby, whichblock)
|
3061
|
+
# block.waterdepth.array, block.qx.array, block.qy.array = wolfpy.r2d_getresults(which_step+1, nbx, nby, whichblock)
|
3062
|
+
|
3063
|
+
block.waterdepth.array, block.qx.array, block.qy.array = self._dll_tools.r2D_get_one_result(which_step+1, whichblock)
|
3044
3064
|
block._force_update_shields = True
|
3045
3065
|
|
3046
3066
|
def read_oneblockresult(self, which_step:int=-1, whichblock:int=-1):
|
@@ -3114,7 +3134,7 @@ class Wolfresults_2D(Element_To_Draw):
|
|
3114
3134
|
|
3115
3135
|
if exists(self.filename+'.head'):
|
3116
3136
|
logging.info(_('Reading from results - step :{}'.format(which+1)))
|
3117
|
-
wolfpy.r2d_init(self.filename.ljust(255).encode('ansi'))
|
3137
|
+
# wolfpy.r2d_init(self.filename.ljust(255).encode('ansi'))
|
3118
3138
|
for i in range(self.nb_blocks):
|
3119
3139
|
self.read_oneblockresult(which, i+1)
|
3120
3140
|
else:
|
@@ -3137,7 +3157,7 @@ class Wolfresults_2D(Element_To_Draw):
|
|
3137
3157
|
|
3138
3158
|
if exists(self.filename+'.head'):
|
3139
3159
|
logging.info(_('Reading from results - step :{}'.format(which+1)))
|
3140
|
-
wolfpy.r2d_init(self.filename.ljust(255).encode('ansi'))
|
3160
|
+
# wolfpy.r2d_init(self.filename.ljust(255).encode('ansi'))
|
3141
3161
|
for i in range(self.nb_blocks):
|
3142
3162
|
self._read_oneblockresult_only_h(which, i+1)
|
3143
3163
|
else:
|
@@ -3175,7 +3195,7 @@ class Wolfresults_2D(Element_To_Draw):
|
|
3175
3195
|
if exists(self.filename+'.head'):
|
3176
3196
|
|
3177
3197
|
logging.info(_('Reading result step :{}'.format(self.current_result)))
|
3178
|
-
wolfpy.r2d_init(self.filename.ljust(255).encode('ansi'))
|
3198
|
+
# wolfpy.r2d_init(self.filename.ljust(255).encode('ansi'))
|
3179
3199
|
|
3180
3200
|
for i in range(self.nb_blocks):
|
3181
3201
|
self.read_oneblockresult(self.current_result, i+1)
|
@@ -4989,7 +5009,11 @@ class Wolfresults_2D(Element_To_Draw):
|
|
4989
5009
|
curdanger.reset()
|
4990
5010
|
curdanger.mask_reset()
|
4991
5011
|
|
4992
|
-
|
5012
|
+
to_compute = np.arange(start, end, every)
|
5013
|
+
#add the end
|
5014
|
+
if end not in to_compute:
|
5015
|
+
to_compute = np.append(to_compute, end)
|
5016
|
+
for time_step in tqdm(to_compute):
|
4993
5017
|
|
4994
5018
|
if callback is not None:
|
4995
5019
|
callback(time_step, "Step {} / {}".format(time_step+1, end))
|
@@ -5066,6 +5090,111 @@ class Wolfresults_2D(Element_To_Draw):
|
|
5066
5090
|
|
5067
5091
|
return (danger_map_matrix_h, danger_map_matrix_v, danger_map_matrix_mom, danger_map_matrix_z, danger_map_matrix_head)
|
5068
5092
|
|
5093
|
+
def __getstate__(self):
|
5094
|
+
"""Get the state of the object for pickling"""
|
5095
|
+
state = self.__dict__.copy()
|
5096
|
+
# Remove unpicklable attributes
|
5097
|
+
|
5098
|
+
topop = ['mapviewer', 'properties', 'mngselection', 'myops']
|
5099
|
+
|
5100
|
+
for cur_pop in topop:
|
5101
|
+
if cur_pop in state:
|
5102
|
+
state.pop(cur_pop)
|
5103
|
+
return state
|
5104
|
+
|
5105
|
+
def __setstate__(self, state):
|
5106
|
+
"""Set the state of the object after unpickling"""
|
5107
|
+
# Restore the state of the object
|
5108
|
+
self.__dict__.update(state)
|
5109
|
+
# Reinitialize any attributes that were removed during pickling
|
5110
|
+
self.mapviewer = None
|
5111
|
+
self.properties = None
|
5112
|
+
self.mngselection = None
|
5113
|
+
self.myops = None
|
5114
|
+
|
5115
|
+
def danger_map_multiprocess(self, start:int=0, end:int=-1, every:int=1, callback=None, nb_processors:int = -1) -> Union[tuple[WolfArray, WolfArray, WolfArray, WolfArray], tuple[WolfArrayMB, WolfArrayMB, WolfArrayMB, WolfArrayMB]]:
|
5116
|
+
"""
|
5117
|
+
Create Danger Maps using multiprocessing
|
5118
|
+
|
5119
|
+
:param start: start time step - 0-based
|
5120
|
+
:param end: end time step - 0-based
|
5121
|
+
:param every: step interval
|
5122
|
+
:param callback: optional callback to update progress
|
5123
|
+
"""
|
5124
|
+
|
5125
|
+
from multiprocessing import Pool, cpu_count
|
5126
|
+
|
5127
|
+
if nb_processors == -1:
|
5128
|
+
nb_processors = cpu_count()
|
5129
|
+
|
5130
|
+
if nb_processors > self.get_nbresults():
|
5131
|
+
nb_processors = self.get_nbresults()
|
5132
|
+
|
5133
|
+
# Split the range of time steps into chunks for multiprocessing
|
5134
|
+
if end == -1:
|
5135
|
+
end = self.get_nbresults()
|
5136
|
+
|
5137
|
+
starts = [start + i * every for i in range(nb_processors)]
|
5138
|
+
ends = [end - i * every for i in range(nb_processors-1,-1,-1)]
|
5139
|
+
|
5140
|
+
# pop all start above end
|
5141
|
+
for i in range(nb_processors-1,0,-1):
|
5142
|
+
if starts[i] >= end:
|
5143
|
+
starts.pop(i)
|
5144
|
+
ends.pop(i)
|
5145
|
+
|
5146
|
+
# set end above start
|
5147
|
+
for i in range(len(starts)):
|
5148
|
+
if starts[i] >= ends[i]:
|
5149
|
+
ends[i] = starts[i] + every
|
5150
|
+
|
5151
|
+
chunks = [(self, start + i * every, end - (nb_processors - i) * every + 1, nb_processors) for i in range(min(nb_processors, len(starts)))]
|
5152
|
+
|
5153
|
+
# Create a pool of workers
|
5154
|
+
with Pool(processes=nb_processors) as pool:
|
5155
|
+
results = pool.map(_process_danger_map_chunk, chunks)
|
5156
|
+
|
5157
|
+
danger_map_matrix_h = self.as_WolfArray(copyarray=True)
|
5158
|
+
danger_map_matrix_v = self.as_WolfArray(copyarray=True)
|
5159
|
+
danger_map_matrix_mom = self.as_WolfArray(copyarray=True)
|
5160
|
+
danger_map_matrix_z = self.as_WolfArray(copyarray=True)
|
5161
|
+
danger_map_matrix_head= self.as_WolfArray(copyarray=True)
|
5162
|
+
|
5163
|
+
danger = [danger_map_matrix_h, danger_map_matrix_v, danger_map_matrix_mom, danger_map_matrix_z, danger_map_matrix_head]
|
5164
|
+
|
5165
|
+
for curdanger in danger:
|
5166
|
+
curdanger.nullvalue = 0.
|
5167
|
+
curdanger.reset()
|
5168
|
+
curdanger.mask_reset()
|
5169
|
+
|
5170
|
+
if self.nb_blocks>1:
|
5171
|
+
for result in results:
|
5172
|
+
for idx, curdanger in enumerate(danger):
|
5173
|
+
for i in range(self.nb_blocks):
|
5174
|
+
curdanger[i].array.data = np.maximum(curdanger[i].array.data, result[idx][i].array.data)
|
5175
|
+
curdanger[i].array.mask = np.logical_or(curdanger[i].array.mask, result[idx][i].array.mask)
|
5176
|
+
else:
|
5177
|
+
for result in results:
|
5178
|
+
for idx, curdanger in enumerate(danger):
|
5179
|
+
curdanger.array.data[:,:] = np.maximum(curdanger.array.data, result[idx].array.data)
|
5180
|
+
curdanger.array.mask[:,:] = np.logical_or(curdanger.array.mask, result[idx].array.mask)
|
5181
|
+
|
5182
|
+
danger_map_matrix_h.mask_lower(self.epsilon)
|
5183
|
+
|
5184
|
+
if self.nb_blocks>1:
|
5185
|
+
for i in range(self.nb_blocks):
|
5186
|
+
danger_map_matrix_v[i].array.mask[:,:] = danger_map_matrix_h[i].array.mask[:,:]
|
5187
|
+
danger_map_matrix_mom[i].array.mask[:,:] = danger_map_matrix_h[i].array.mask[:,:]
|
5188
|
+
danger_map_matrix_z[i].array.mask[:,:] = danger_map_matrix_h[i].array.mask[:,:]
|
5189
|
+
danger_map_matrix_head[i].array.mask[:,:] = danger_map_matrix_h[i].array.mask[:,:]
|
5190
|
+
else:
|
5191
|
+
danger_map_matrix_v.array.mask[:,:] = danger_map_matrix_h.array.mask[:,:]
|
5192
|
+
danger_map_matrix_mom.array.mask[:,:] = danger_map_matrix_h.array.mask[:,:]
|
5193
|
+
danger_map_matrix_z.array.mask[:,:] = danger_map_matrix_h.array.mask[:,:]
|
5194
|
+
danger_map_matrix_head.array.mask[:,:] = danger_map_matrix_h.array.mask[:,:]
|
5195
|
+
|
5196
|
+
return (danger_map_matrix_h, danger_map_matrix_v, danger_map_matrix_mom, danger_map_matrix_z, danger_map_matrix_head)
|
5197
|
+
|
5069
5198
|
def danger_map_only_h(self, start:int=0, end:int=-1, every:int=1) -> WolfArray:
|
5070
5199
|
"""
|
5071
5200
|
Create Danger Maps
|
@@ -5431,7 +5560,7 @@ class Wolfresults_2D(Element_To_Draw):
|
|
5431
5560
|
curavg.mask_reset()
|
5432
5561
|
|
5433
5562
|
for time_step in tqdm(range(start, end, every)):
|
5434
|
-
|
5563
|
+
|
5435
5564
|
if callback is not None:
|
5436
5565
|
callback(time_step, "Step {} / {}".format(time_step+1, end))
|
5437
5566
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: wolfhece
|
3
|
-
Version: 2.
|
3
|
+
Version: 2.2.2
|
4
4
|
Author-email: Pierre Archambeau <pierre.archambeau@uliege.be>
|
5
5
|
Project-URL: Homepage, https://uee.uliege.be/hece
|
6
6
|
Project-URL: Issues, https://uee.uliege.be/hece
|
@@ -19,9 +19,9 @@ Requires-Dist: colorlog==6.7.*
|
|
19
19
|
Requires-Dist: intel-fortran-rt
|
20
20
|
Requires-Dist: scikit-learn
|
21
21
|
Requires-Dist: cryptography
|
22
|
-
Requires-Dist: jax==0.
|
22
|
+
Requires-Dist: jax==0.5.3
|
23
23
|
Requires-Dist: triangle
|
24
|
-
Requires-Dist: numpy==1
|
24
|
+
Requires-Dist: numpy==2.1.*
|
25
25
|
Requires-Dist: pyopengl==3.1.*
|
26
26
|
Requires-Dist: pandas
|
27
27
|
Requires-Dist: geopandas
|
@@ -35,11 +35,10 @@ Requires-Dist: graphviz
|
|
35
35
|
Requires-Dist: owslib
|
36
36
|
Requires-Dist: beautifulsoup4
|
37
37
|
Requires-Dist: requests
|
38
|
-
Requires-Dist:
|
39
|
-
Requires-Dist: matplotlib
|
38
|
+
Requires-Dist: matplotlib==3.10.*
|
40
39
|
Requires-Dist: mkl
|
41
40
|
Requires-Dist: python-gettext
|
42
|
-
Requires-Dist: shapely==2.
|
41
|
+
Requires-Dist: shapely==2.1.*
|
43
42
|
Requires-Dist: openpyxl
|
44
43
|
Requires-Dist: xlrd
|
45
44
|
Requires-Dist: openkmi
|
@@ -52,13 +51,13 @@ Requires-Dist: python-docx
|
|
52
51
|
Requires-Dist: pygltflib
|
53
52
|
Requires-Dist: ezdxf
|
54
53
|
Requires-Dist: pyvista
|
55
|
-
Requires-Dist: tqdm==4.
|
54
|
+
Requires-Dist: tqdm==4.67.*
|
56
55
|
Requires-Dist: tifffile
|
57
|
-
Requires-Dist: numba==0.
|
56
|
+
Requires-Dist: numba==0.61.*
|
58
57
|
Requires-Dist: xmltodict
|
59
58
|
Requires-Dist: opencv-python
|
60
59
|
Requires-Dist: xarray
|
61
|
-
Requires-Dist: rasterio==1.3
|
60
|
+
Requires-Dist: rasterio==1.4.3
|
62
61
|
Requires-Dist: h5py
|
63
62
|
Requires-Dist: exif
|
64
63
|
Requires-Dist: pyglm
|
@@ -75,9 +74,15 @@ Ce paquet contient l'interface graphique Python du logiciel WOLF (HECE - ULiège
|
|
75
74
|
|
76
75
|
Les codes de calcul ne sont pas contenus dans ce paquet.
|
77
76
|
|
77
|
+
Version 2.1.x compatible Numpy 1.23.5
|
78
|
+
Version 2.2.x compatible Numpy 2.1.3
|
79
|
+
|
78
80
|
--
|
79
81
|
|
80
82
|
|
81
83
|
This package contains the Python graphical interface of the WOLF software (HECE - ULiège), as well as several topographic, hydraulic, and hydrological processing tools.
|
82
84
|
|
83
85
|
The numerical codes are not included in this package.
|
86
|
+
|
87
|
+
Version 2.1.x compatible Numpy 1.23.5
|
88
|
+
Version 2.2.x compatible Numpy 2.1.3
|