wolfhece 2.0.55__py3-none-any.whl → 2.1.1__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/GraphProfile.py +1 -1
- wolfhece/PyDraw.py +1197 -361
- wolfhece/PyGui.py +1924 -661
- wolfhece/PyPalette.py +47 -0
- wolfhece/PyParams.py +377 -76
- wolfhece/PyVertex.py +14 -1
- wolfhece/PyVertexvectors.py +171 -22
- wolfhece/Results2DGPU.py +1 -2
- wolfhece/apps/version.py +2 -2
- wolfhece/bernoulli/__init__.py +0 -0
- wolfhece/bernoulli/chamber.py +93 -0
- wolfhece/bernoulli/fluids.py +10 -0
- wolfhece/bernoulli/losses.py +100 -0
- wolfhece/bernoulli/network.py +128 -0
- wolfhece/bernoulli/pipe.py +194 -0
- wolfhece/lagrangian/example_domain.py +1 -1
- wolfhece/mesh2d/bc_manager.py +66 -5
- wolfhece/mesh2d/config_manager.py +1 -1
- wolfhece/mesh2d/cst_2D_boundary_conditions.py +59 -2
- wolfhece/mesh2d/wolf2dprev.py +11606 -2678
- wolfhece/models/walous_niv1.pal +29 -0
- wolfhece/models/walous_niv2.pal +77 -0
- wolfhece/pywalous.py +400 -46
- wolfhece/scenario/config_manager.py +14 -5
- wolfhece/wolf_array.py +1487 -458
- wolfhece/wolf_vrt.py +31 -8
- wolfhece/wolfresults_2D.py +230 -91
- {wolfhece-2.0.55.dist-info → wolfhece-2.1.1.dist-info}/METADATA +3 -2
- {wolfhece-2.0.55.dist-info → wolfhece-2.1.1.dist-info}/RECORD +32 -24
- {wolfhece-2.0.55.dist-info → wolfhece-2.1.1.dist-info}/WHEEL +0 -0
- {wolfhece-2.0.55.dist-info → wolfhece-2.1.1.dist-info}/entry_points.txt +0 -0
- {wolfhece-2.0.55.dist-info → wolfhece-2.1.1.dist-info}/top_level.txt +0 -0
wolfhece/wolf_vrt.py
CHANGED
@@ -9,7 +9,15 @@ from .PyVertexvectors import Zones
|
|
9
9
|
def create_vrt(wdir:str, fout:str='out.vrt', format:str='tif'):
|
10
10
|
"""
|
11
11
|
Agglomération de tous les fichiers .tif dans un layer virtuel .vrt
|
12
|
+
|
13
|
+
:param wdir: working directory
|
14
|
+
:type wdir: str
|
15
|
+
:param fout: output file
|
16
|
+
:type fout: str
|
17
|
+
:param format: format of the files to process
|
18
|
+
:type format: str
|
12
19
|
"""
|
20
|
+
|
13
21
|
curdir = os.getcwd()
|
14
22
|
os.chdir(wdir)
|
15
23
|
|
@@ -24,7 +32,14 @@ def create_vrt(wdir:str, fout:str='out.vrt', format:str='tif'):
|
|
24
32
|
def _get_relative_path(path:Path, base:Path):
|
25
33
|
"""
|
26
34
|
Get relative path from base to path
|
35
|
+
|
36
|
+
:param path: path to get relative path
|
37
|
+
:type path: Path
|
38
|
+
:param base: base path
|
39
|
+
:type base: Path
|
40
|
+
|
27
41
|
"""
|
42
|
+
|
28
43
|
if base in path.parents:
|
29
44
|
return path.relative_to(base)
|
30
45
|
elif path.parent in base.parents:
|
@@ -36,7 +51,13 @@ def _get_relative_path(path:Path, base:Path):
|
|
36
51
|
def create_vrt_from_files(files:list[Path]=[], fout:Path='assembly.vrt'):
|
37
52
|
"""
|
38
53
|
Agglomération de tous les fichiers énumérés dans files dans un layer virtuel .vrt
|
54
|
+
|
55
|
+
:param files: list of files to process
|
56
|
+
:type files: list[Path]
|
57
|
+
:param fout: output file
|
58
|
+
:type fout: Path
|
39
59
|
"""
|
60
|
+
|
40
61
|
if isinstance(fout, str):
|
41
62
|
fout = Path(fout)
|
42
63
|
|
@@ -60,6 +81,7 @@ def create_vrt_from_files_first_based(files:list[Path]=[], fout:Path='assembly.v
|
|
60
81
|
|
61
82
|
Restreint l'emprise et force la résolution sur le premier fichier listé
|
62
83
|
"""
|
84
|
+
|
63
85
|
if isinstance(fout, str):
|
64
86
|
fout = Path(fout)
|
65
87
|
|
@@ -108,9 +130,8 @@ def translate_vrt2tif(fn:str, fout:str=None):
|
|
108
130
|
"""
|
109
131
|
Translate vrt file to tif file
|
110
132
|
|
111
|
-
|
112
|
-
|
113
|
-
fout (str, optional): '.tif' file out. Defaults to None --> fn+'.tif'
|
133
|
+
:param fn: (str) '.vrt' file to translate
|
134
|
+
:param fout: (str, optional) '.tif' file out. Defaults to None --> fn+'.tif'
|
114
135
|
"""
|
115
136
|
if isinstance(fn,Path):
|
116
137
|
fn = str(fn)
|
@@ -139,10 +160,12 @@ def crop_vrt(fn:str, crop:list, fout:str=None):
|
|
139
160
|
"""
|
140
161
|
Crop vrt file
|
141
162
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
163
|
+
:param fn: (str) '.vrt' file to crop
|
164
|
+
:type fn: str
|
165
|
+
:param crop: (list) Bounds [[xmin, xmax], [ymin,ymax]] aka [[xLL, xUR], [yLL,yUR]]
|
166
|
+
:type crop: list
|
167
|
+
:param fout: (str, optional) '.tif' file out. Defaults to None --> fn+'_crop.tif'
|
168
|
+
:type fout: str
|
146
169
|
"""
|
147
170
|
if os.path.exists(fn):
|
148
171
|
|
@@ -173,7 +196,7 @@ def create_contours(files:list[Path]=[],
|
|
173
196
|
create_intern:bool = True,
|
174
197
|
force_mask_border:bool = True) -> Zones:
|
175
198
|
"""
|
176
|
-
Create contour from files
|
199
|
+
Create contour/footprint from files
|
177
200
|
|
178
201
|
:param files: list of files to process
|
179
202
|
:type files: list[Path]
|
wolfhece/wolfresults_2D.py
CHANGED
@@ -27,7 +27,7 @@ from .PyTranslate import _
|
|
27
27
|
from .gpuview import GRID_N, Rectangle, VectorField
|
28
28
|
from .pyshields import get_d_cr, get_d_cr_susp, izbach_d_cr, get_Shields_2D_Manning
|
29
29
|
from .pyviews import WolfViews
|
30
|
-
from .mesh2d.wolf2dprev import prev_parameters_simul,
|
30
|
+
from .mesh2d.wolf2dprev import prev_parameters_simul, blocks_file
|
31
31
|
from .GraphNotebook import PlotPanel
|
32
32
|
from .CpGrid import CpGrid
|
33
33
|
|
@@ -63,7 +63,7 @@ except Exception as ex:
|
|
63
63
|
|
64
64
|
raise Exception(msg)
|
65
65
|
|
66
|
-
from .wolf_array import WolfArray, getkeyblock, header_wolf, WolfArrayMB, WolfArrayMNAP, header_wolf, SelectionData
|
66
|
+
from .wolf_array import WolfArray, getkeyblock, header_wolf, WolfArrayMB, WolfArrayMNAP, header_wolf, SelectionData, SelectionDataMB
|
67
67
|
from .mesh2d import wolf2dprev
|
68
68
|
from .PyVertexvectors import vector, zone, Zones
|
69
69
|
|
@@ -74,6 +74,7 @@ def outside_domain(val):
|
|
74
74
|
|
75
75
|
def q_splitting(q_left, q_right):
|
76
76
|
""" Splitting of the normal flow between two nodes """
|
77
|
+
|
77
78
|
prod_q = q_left * q_right
|
78
79
|
sum_q = q_left + q_right
|
79
80
|
if prod_q > 0.:
|
@@ -98,6 +99,7 @@ def q_splitting(q_left, q_right):
|
|
98
99
|
|
99
100
|
def u_splitting(q_left, q_right, h_left, h_right):
|
100
101
|
""" Splitting of the normal flow velocity between two nodes """
|
102
|
+
|
101
103
|
prod_q = q_left * q_right
|
102
104
|
sum_q = q_left + q_right
|
103
105
|
if prod_q > 0.:
|
@@ -1432,6 +1434,14 @@ class OneWolfResult:
|
|
1432
1434
|
self._sedimentdensity = 2.65
|
1433
1435
|
self._force_update_shields = True # Force la MAJ du Shields si le diametre ou la densité change
|
1434
1436
|
|
1437
|
+
self.mngselection = SelectionData(self.current)
|
1438
|
+
|
1439
|
+
@property
|
1440
|
+
def SelectionData(self) -> SelectionDataMB:
|
1441
|
+
""" Return the data of the selection """
|
1442
|
+
|
1443
|
+
return self.mngselection
|
1444
|
+
|
1435
1445
|
@property
|
1436
1446
|
def sediment_diameter(self):
|
1437
1447
|
""" Diamètre des particules de sédiment [m] """
|
@@ -1962,7 +1972,7 @@ class Wolfresults_2D(Element_To_Draw):
|
|
1962
1972
|
head_blocks:dict[str, header_wolf]
|
1963
1973
|
|
1964
1974
|
myparam:prev_parameters_simul
|
1965
|
-
myblocfile:
|
1975
|
+
myblocfile:blocks_file
|
1966
1976
|
mymnap:WolfArrayMNAP
|
1967
1977
|
|
1968
1978
|
def __init__(self,
|
@@ -2154,9 +2164,94 @@ class Wolfresults_2D(Element_To_Draw):
|
|
2154
2164
|
self.properties:Props_Res_2D = None
|
2155
2165
|
self.set_properties()
|
2156
2166
|
|
2157
|
-
self.mngselection =
|
2158
|
-
self.mngselection.dx, self.mngselection.dy = self[0].dx, self[0].dy
|
2167
|
+
self.mngselection = SelectionDataMB(self)
|
2159
2168
|
self.myops = None
|
2169
|
+
self._active_blocks = 0
|
2170
|
+
|
2171
|
+
@property
|
2172
|
+
def SelectionData(self) -> SelectionDataMB:
|
2173
|
+
""" Return the data of the selection """
|
2174
|
+
|
2175
|
+
return self.mngselection
|
2176
|
+
|
2177
|
+
@property
|
2178
|
+
def common_mask_MB(self) -> list[np.ndarray]:
|
2179
|
+
""" Common mask for multiblock arrays """
|
2180
|
+
|
2181
|
+
if self.mymnap is not None:
|
2182
|
+
return [cur.array.mask for cur in self.mymnap.myblocks.values()]
|
2183
|
+
else:
|
2184
|
+
return None
|
2185
|
+
|
2186
|
+
@property
|
2187
|
+
def active_blocks(self) -> list["WolfArray"]:
|
2188
|
+
""" Return the active blocks """
|
2189
|
+
|
2190
|
+
if self.nb_blocks>0 and self._active_blocks is not None:
|
2191
|
+
|
2192
|
+
if isinstance(self._active_blocks, list):
|
2193
|
+
return [self.myblocks[cur] for cur in self._active_blocks]
|
2194
|
+
elif self._active_blocks == 0:
|
2195
|
+
return [k for k in self.myblocks.values()]
|
2196
|
+
elif self._active_blocks in self.myblocks:
|
2197
|
+
return [self.myblocks[self._active_blocks]]
|
2198
|
+
else:
|
2199
|
+
return None
|
2200
|
+
|
2201
|
+
else:
|
2202
|
+
return [self]
|
2203
|
+
|
2204
|
+
@active_blocks.setter
|
2205
|
+
def active_blocks(self, value:Union[str, int, list[int]]):
|
2206
|
+
"""
|
2207
|
+
Set the active blocks
|
2208
|
+
|
2209
|
+
:param value: name of the block or index 1-based or list of index 1-based
|
2210
|
+
|
2211
|
+
"""
|
2212
|
+
|
2213
|
+
if isinstance(value, str):
|
2214
|
+
if value in self.myblocks:
|
2215
|
+
self._active_blocks = value
|
2216
|
+
logging.info(_(f'Block found - {value}'))
|
2217
|
+
else:
|
2218
|
+
self._active_blocks = None
|
2219
|
+
logging.info(_('Block not found'))
|
2220
|
+
|
2221
|
+
elif isinstance(value, int):
|
2222
|
+
|
2223
|
+
if value == 0:
|
2224
|
+
self._active_blocks = 0
|
2225
|
+
logging.info(_('All blocks selected'))
|
2226
|
+
else:
|
2227
|
+
value = getkeyblock(value, addone=False)
|
2228
|
+
|
2229
|
+
if value in self.myblocks:
|
2230
|
+
self._active_blocks = value
|
2231
|
+
logging.info(_(f'Block found - {value}'))
|
2232
|
+
else:
|
2233
|
+
self._active_blocks = None
|
2234
|
+
logging.info(_('Block not found'))
|
2235
|
+
|
2236
|
+
elif isinstance(value, list):
|
2237
|
+
|
2238
|
+
if 0 in value:
|
2239
|
+
self._active_blocks = 0
|
2240
|
+
logging.info(_('All blocks selected'))
|
2241
|
+
else:
|
2242
|
+
value = [getkeyblock(cur, addone=False) for cur in value]
|
2243
|
+
value = [cur for cur in value if cur in self.myblocks]
|
2244
|
+
|
2245
|
+
if len(value)>0:
|
2246
|
+
self._active_blocks = value
|
2247
|
+
logging.info(_('List of blocks selected'))
|
2248
|
+
else:
|
2249
|
+
self._active_blocks = None
|
2250
|
+
logging.info(_('No block found'))
|
2251
|
+
|
2252
|
+
else:
|
2253
|
+
logging.error(_('Unknown type for active_blocks'))
|
2254
|
+
|
2160
2255
|
|
2161
2256
|
def default16(self):
|
2162
2257
|
""" Mise à jour de la palette par défaut """
|
@@ -2326,6 +2421,7 @@ class Wolfresults_2D(Element_To_Draw):
|
|
2326
2421
|
if _key in self.myblocks.keys():
|
2327
2422
|
return self.myblocks[_key].current
|
2328
2423
|
else:
|
2424
|
+
logging.error(_('Block not found in Wolfresults_2D'))
|
2329
2425
|
return None
|
2330
2426
|
|
2331
2427
|
""" Iterator """
|
@@ -2338,15 +2434,22 @@ class Wolfresults_2D(Element_To_Draw):
|
|
2338
2434
|
return self[self._iter]
|
2339
2435
|
""" End Iterator """
|
2340
2436
|
|
2341
|
-
def as_WolfArray(self, copyarray:bool=True) -> Union[WolfArray, WolfArrayMB]:
|
2342
|
-
"""
|
2437
|
+
def as_WolfArray(self, copyarray:bool=True, force_mb = False) -> Union[WolfArray, WolfArrayMB]:
|
2438
|
+
"""
|
2439
|
+
Récupération d'une matrice MB ou Mono sur base du résultat courant
|
2440
|
+
|
2441
|
+
:param copyarray : si True alors on copie les données
|
2442
|
+
:param force_mb : if True then return a WolfArrayMB even if there is only one block
|
2343
2443
|
|
2344
|
-
|
2444
|
+
"""
|
2445
|
+
|
2446
|
+
if self.nb_blocks>1 or force_mb:
|
2345
2447
|
|
2346
2448
|
retarray = WolfArrayMB()
|
2347
2449
|
retarray.set_header(self.get_header())
|
2348
2450
|
for i in range(self.nb_blocks):
|
2349
2451
|
retarray.add_block(self[i], copyarray=copyarray)
|
2452
|
+
|
2350
2453
|
else:
|
2351
2454
|
if copyarray :
|
2352
2455
|
retarray = WolfArray(mold=self[0])
|
@@ -2393,82 +2496,6 @@ class Wolfresults_2D(Element_To_Draw):
|
|
2393
2496
|
if self.get_currentview() == views_2D.SHIELDS_NUMBER and force:
|
2394
2497
|
self.set_currentview()
|
2395
2498
|
|
2396
|
-
# def _gpu_loader(self, fname:str):
|
2397
|
-
|
2398
|
-
# # 2D GPU
|
2399
|
-
# nb_blocks = 1
|
2400
|
-
# self.myblocks = {}
|
2401
|
-
# curblock = OneWolfResult(0, parent=self)
|
2402
|
-
# self.myblocks[getkeyblock(0)] = curblock
|
2403
|
-
|
2404
|
-
# if exists(join(dirname(fname), 'simul.top')):
|
2405
|
-
# curblock.top = WolfArray(join(dirname(fname), 'simul.top'), nullvalue=99999.)
|
2406
|
-
# curblock.waterdepth = WolfArray(join(dirname(fname), 'simul.hbin'))
|
2407
|
-
# curblock.qx = WolfArray(join(dirname(fname), 'simul.qxbin'))
|
2408
|
-
# curblock.qy = WolfArray(join(dirname(fname), 'simul.qybin'))
|
2409
|
-
# curblock.rough_n = WolfArray(join(dirname(fname), 'simul.frot'))
|
2410
|
-
# elif exists(join(dirname(fname), 'bathymetry.npy')):
|
2411
|
-
# curblock.top = WolfArray(join(dirname(fname), 'bathymetry.npy'), nullvalue=99999.)
|
2412
|
-
# curblock.waterdepth = WolfArray(join(dirname(fname), 'h.npy'))
|
2413
|
-
# curblock.qx = WolfArray(join(dirname(fname), 'qx.npy'))
|
2414
|
-
# curblock.qy = WolfArray(join(dirname(fname), 'qy.npy'))
|
2415
|
-
# curblock.rough_n = WolfArray(join(dirname(fname), 'manning.npy'))
|
2416
|
-
|
2417
|
-
# if exists(join(dirname(fname), 'parameters.json')):
|
2418
|
-
# import json
|
2419
|
-
# with open(join(dirname(fname), 'parameters.json'), 'r') as fp:
|
2420
|
-
|
2421
|
-
# params = json.load(fp)
|
2422
|
-
|
2423
|
-
# try:
|
2424
|
-
# curblock.top.dx = params["parameters"]["dx"]
|
2425
|
-
# curblock.top.dy = params["parameters"]["dy"]
|
2426
|
-
# except:
|
2427
|
-
# logging.error(_('No spatial resolution (dx,dy) in parameters.json -- Results will not be shown in viewer'))
|
2428
|
-
|
2429
|
-
# try:
|
2430
|
-
# curblock.top.origx = params["parameters"]["base_coord_x"]
|
2431
|
-
# curblock.top.origy = params["parameters"]["base_coord_y"]
|
2432
|
-
# except:
|
2433
|
-
# logging.error(_('No spatial position (base_coord_x,base_coord_y) in parameters.json -- Results will not be spatially based'))
|
2434
|
-
|
2435
|
-
# self.loaded_rough = True
|
2436
|
-
|
2437
|
-
# to_check =[curblock.waterdepth, curblock.qx, curblock.qy, curblock.rough_n]
|
2438
|
-
# check = False
|
2439
|
-
# for curarray in to_check:
|
2440
|
-
# check |= curarray.dx != curblock.top.dx
|
2441
|
-
# check |= curarray.dy != curblock.top.dy
|
2442
|
-
# check |= curarray.origx != curblock.top.origx
|
2443
|
-
# check |= curarray.origy != curblock.top.origy
|
2444
|
-
# check |= curarray.translx != curblock.top.translx
|
2445
|
-
# check |= curarray.transly != curblock.top.transly
|
2446
|
-
|
2447
|
-
# if check:
|
2448
|
-
# if exists(join(dirname(fname), 'simul.top')):
|
2449
|
-
# logging.error(_("Inconsistent header file in .top, .qxbin, .qybin or .frot files"))
|
2450
|
-
# logging.error(_("Forcing information into memory from the .top file -- May corrupt spatial positionning -- Please check your data !"))
|
2451
|
-
|
2452
|
-
# for curarray in to_check:
|
2453
|
-
# curarray.dx = curblock.top.dx
|
2454
|
-
# curarray.dy = curblock.top.dy
|
2455
|
-
# curarray.origx = curblock.top.origx
|
2456
|
-
# curarray.origy = curblock.top.origy
|
2457
|
-
# curarray.translx = curblock.top.translx
|
2458
|
-
# curarray.transly = curblock.top.transly
|
2459
|
-
|
2460
|
-
# if exists(join(dirname(fname), 'simul.trl')):
|
2461
|
-
# with open(join(dirname(fname), 'simul.trl')) as f:
|
2462
|
-
# trl=f.read().splitlines()
|
2463
|
-
# self.translx=float(trl[1])
|
2464
|
-
# self.transly=float(trl[2])
|
2465
|
-
|
2466
|
-
# curblock.set_current(views_2D.WATERDEPTH)
|
2467
|
-
|
2468
|
-
# self.myparam = None
|
2469
|
-
# self.mymnap = None
|
2470
|
-
# self.myblocfile = None
|
2471
|
-
|
2472
2499
|
def load_default_colormap(self, which:str):
|
2473
2500
|
"""
|
2474
2501
|
Lecture d'une palette disponible dans le répertoire "models"
|
@@ -2493,7 +2520,8 @@ class Wolfresults_2D(Element_To_Draw):
|
|
2493
2520
|
"""
|
2494
2521
|
Récupération des temps réels et des pas de calcul de chaque résultat sur disque
|
2495
2522
|
|
2496
|
-
:param nb : nombre de résultats à lire
|
2523
|
+
:param nb : nombre de résultats à lire - si None alors on lit tous les résultats
|
2524
|
+
:return : tuple (liste des temps, liste des pas de calcul)
|
2497
2525
|
"""
|
2498
2526
|
if nb is None:
|
2499
2527
|
if self._nb_results is None:
|
@@ -2577,8 +2605,8 @@ class Wolfresults_2D(Element_To_Draw):
|
|
2577
2605
|
self.myparam = prev_parameters_simul(self)
|
2578
2606
|
self.myparam.read_file(self.filename)
|
2579
2607
|
|
2580
|
-
self.myblocfile =
|
2581
|
-
self.myblocfile.read_file()
|
2608
|
+
self.myblocfile = blocks_file(self)
|
2609
|
+
# self.myblocfile.read_file()
|
2582
2610
|
|
2583
2611
|
self.mymnap = WolfArrayMNAP(self.filename)
|
2584
2612
|
|
@@ -2690,6 +2718,9 @@ class Wolfresults_2D(Element_To_Draw):
|
|
2690
2718
|
def read_topography(self):
|
2691
2719
|
"""Lecture de la topographie de modélisation"""
|
2692
2720
|
if exists(self.filename.strip() + '.topini'):
|
2721
|
+
|
2722
|
+
all_masks = self.common_mask_MB
|
2723
|
+
|
2693
2724
|
with open(self.filename.strip() + '.topini','rb') as f:
|
2694
2725
|
for i in range(self.nb_blocks):
|
2695
2726
|
nbx=self.myblocks[getkeyblock(i)].top.nbx
|
@@ -2697,9 +2728,14 @@ class Wolfresults_2D(Element_To_Draw):
|
|
2697
2728
|
nbbytes=nbx*nby*4
|
2698
2729
|
self.myblocks[getkeyblock(i)].top.array = ma.masked_equal(np.frombuffer(f.read(nbbytes),dtype=np.float32),0.)
|
2699
2730
|
self.myblocks[getkeyblock(i)].top.array = self.myblocks[getkeyblock(i)].top.array.reshape(nbx,nby,order='F')
|
2731
|
+
self.myblocks[getkeyblock(i)].top.array.mask[:,:] = all_masks[i][:,:]
|
2732
|
+
|
2700
2733
|
|
2701
2734
|
def read_ini_mb(self):
|
2702
2735
|
"""Lecture des conditions initiales"""
|
2736
|
+
|
2737
|
+
# all_masks = self.common_mask_MB()
|
2738
|
+
|
2703
2739
|
if exists(self.filename.strip() + '.hbinb'):
|
2704
2740
|
with open(self.filename.strip() + '.hbinb','rb') as f:
|
2705
2741
|
for i in range(self.nb_blocks):
|
@@ -2708,6 +2744,7 @@ class Wolfresults_2D(Element_To_Draw):
|
|
2708
2744
|
nbbytes=nbx*nby*4
|
2709
2745
|
self.myblocks[getkeyblock(i)].waterdepth.array = ma.masked_equal(np.frombuffer(f.read(nbbytes),dtype=np.float32),0.)
|
2710
2746
|
self.myblocks[getkeyblock(i)].waterdepth.array = self.myblocks[getkeyblock(i)].waterdepth.array.reshape(nbx,nby,order='F')
|
2747
|
+
# self.myblocks[getkeyblock(i)].waterdepth.array.mask = all_masks[i].copy()
|
2711
2748
|
|
2712
2749
|
if exists(self.filename.strip() + '.qxbinb'):
|
2713
2750
|
with open(self.filename.strip() + '.qxbinb','rb') as f:
|
@@ -2717,6 +2754,7 @@ class Wolfresults_2D(Element_To_Draw):
|
|
2717
2754
|
nbbytes=nbx*nby*4
|
2718
2755
|
self.myblocks[getkeyblock(i)].qx.array = ma.masked_equal(np.frombuffer(f.read(nbbytes),dtype=np.float32),0.)
|
2719
2756
|
self.myblocks[getkeyblock(i)].qx.array = self.myblocks[getkeyblock(i)].qx.array.reshape(nbx,nby,order='F')
|
2757
|
+
# self.myblocks[getkeyblock(i)].qx.array.mask = all_masks[i].copy()
|
2720
2758
|
|
2721
2759
|
if exists(self.filename.strip() + '.qybinb'):
|
2722
2760
|
with open(self.filename.strip() + '.qybinb','rb') as f:
|
@@ -2726,6 +2764,7 @@ class Wolfresults_2D(Element_To_Draw):
|
|
2726
2764
|
nbbytes=nbx*nby*4
|
2727
2765
|
self.myblocks[getkeyblock(i)].qy.array = ma.masked_equal(np.frombuffer(f.read(nbbytes),dtype=np.float32),0.)
|
2728
2766
|
self.myblocks[getkeyblock(i)].qy.array = self.myblocks[getkeyblock(i)].qy.array.reshape(nbx,nby,order='F')
|
2767
|
+
# self.myblocks[getkeyblock(i)].qy.array.mask = all_masks[i].copy()
|
2729
2768
|
|
2730
2769
|
def read_roughness_param(self):
|
2731
2770
|
"""Lecture du frottement de modélisation"""
|
@@ -2812,7 +2851,7 @@ class Wolfresults_2D(Element_To_Draw):
|
|
2812
2851
|
"""
|
2813
2852
|
Lecture d'un pas de sauvegarde
|
2814
2853
|
|
2815
|
-
which: result number to read; 0-based; -1 == last one
|
2854
|
+
:param which: result number to read; 0-based; -1 == last one
|
2816
2855
|
"""
|
2817
2856
|
|
2818
2857
|
which = self._sanitize_result_step(which)
|
@@ -2835,11 +2874,13 @@ class Wolfresults_2D(Element_To_Draw):
|
|
2835
2874
|
"""
|
2836
2875
|
Lecture du pas suivant
|
2837
2876
|
"""
|
2877
|
+
|
2838
2878
|
self.current_result += 1
|
2839
2879
|
self._update_result_view()
|
2840
2880
|
|
2841
2881
|
def _sanitize_result_step(self, which_step:int=-1):
|
2842
2882
|
""" Sanitize result step index -- 0-based """
|
2883
|
+
|
2843
2884
|
nb = self.get_nbresults()
|
2844
2885
|
while which_step<0:
|
2845
2886
|
which_step += nb
|
@@ -2864,10 +2905,106 @@ class Wolfresults_2D(Element_To_Draw):
|
|
2864
2905
|
|
2865
2906
|
self.loaded=True
|
2866
2907
|
|
2908
|
+
def set_hqxqy_as_initial_conditions(self, idx:int = None, as_multiblocks:bool = True):
|
2909
|
+
"""
|
2910
|
+
Set the result as IC
|
2911
|
+
|
2912
|
+
:param idx : 0-based index
|
2913
|
+
"""
|
2914
|
+
|
2915
|
+
if idx is not None:
|
2916
|
+
if idx>=0 and idx<self.get_nbresults():
|
2917
|
+
self.read_oneresult(idx)
|
2918
|
+
elif idx ==-1:
|
2919
|
+
self.read_oneresult(-1) # last one
|
2920
|
+
else:
|
2921
|
+
logging.error(_('Bad index for initial conditions'))
|
2922
|
+
return
|
2923
|
+
|
2924
|
+
self.set_currentview(views_2D.WATERDEPTH)
|
2925
|
+
|
2926
|
+
hini = self.as_WolfArray()
|
2927
|
+
|
2928
|
+
self.set_currentview(views_2D.QX)
|
2929
|
+
|
2930
|
+
qxini = self.as_WolfArray()
|
2931
|
+
|
2932
|
+
self.set_currentview(views_2D.QY)
|
2933
|
+
|
2934
|
+
qyini = self.as_WolfArray()
|
2935
|
+
|
2936
|
+
if (hini is not None) and (qxini is not None) and (qyini is not None):
|
2937
|
+
|
2938
|
+
if as_multiblocks:
|
2939
|
+
hini.write_all(self.filename.strip() + '.hbinb')
|
2940
|
+
qxini.write_all(self.filename.strip() + '.qxbinb')
|
2941
|
+
qyini.write_all(self.filename.strip() + '.qybinb')
|
2942
|
+
|
2943
|
+
logging.info(_('Initial conditions saved as MB binary files'))
|
2944
|
+
|
2945
|
+
else:
|
2946
|
+
|
2947
|
+
hini = hini.as_WolfArray()
|
2948
|
+
qxini = qxini.as_WolfArray()
|
2949
|
+
qyini = qyini.as_WolfArray()
|
2950
|
+
|
2951
|
+
hini.write_all(self.filename.strip() + '.hbin')
|
2952
|
+
qxini.write_all(self.filename.strip() + '.qxbin')
|
2953
|
+
qyini.write_all(self.filename.strip() + '.qybin')
|
2954
|
+
|
2955
|
+
logging.info(_('Initial conditions saved as binary files'))
|
2956
|
+
else:
|
2957
|
+
logging.error(_('No initial conditions saved'))
|
2958
|
+
|
2959
|
+
def set_keps_as_initial_conditions(self, idx:int = None, as_multiblocks:bool = True):
|
2960
|
+
"""
|
2961
|
+
Set the turbulent result as IC
|
2962
|
+
|
2963
|
+
:param idx : 0-based index
|
2964
|
+
"""
|
2965
|
+
|
2966
|
+
if idx is not None:
|
2967
|
+
if idx>=0 and idx<self.get_nbresults():
|
2968
|
+
self.read_oneresult(idx)
|
2969
|
+
elif idx ==-1:
|
2970
|
+
self.read_oneresult(-1) # last one
|
2971
|
+
else:
|
2972
|
+
logging.error(_('Bad index for initial conditions'))
|
2973
|
+
return
|
2974
|
+
|
2975
|
+
self.set_currentview(views_2D.KINETIC_ENERGY)
|
2976
|
+
|
2977
|
+
kini = self.as_WolfArray()
|
2978
|
+
|
2979
|
+
self.set_currentview(views_2D.EPSILON)
|
2980
|
+
|
2981
|
+
epsini = self.as_WolfArray()
|
2982
|
+
|
2983
|
+
if (kini is not None) and (epsini is not None):
|
2984
|
+
|
2985
|
+
if as_multiblocks:
|
2986
|
+
kini.write_all(self.filename.strip() + '.kbinb')
|
2987
|
+
epsini.write_all(self.filename.strip() + '.epsbinb')
|
2988
|
+
|
2989
|
+
logging.info(_('Initial conditions saved as MB binary files'))
|
2990
|
+
|
2991
|
+
else:
|
2992
|
+
|
2993
|
+
kini = kini.as_WolfArray()
|
2994
|
+
epsini = epsini.as_WolfArray()
|
2995
|
+
|
2996
|
+
kini.write_all(self.filename.strip() + '.kbin')
|
2997
|
+
epsini.write_all(self.filename.strip() + '.epsbin')
|
2998
|
+
|
2999
|
+
logging.info(_('Initial conditions saved as binary files'))
|
3000
|
+
else:
|
3001
|
+
logging.error(_('No initial conditions saved'))
|
3002
|
+
|
2867
3003
|
def read_previous(self):
|
2868
3004
|
"""
|
2869
3005
|
Lecture du pas suivant
|
2870
3006
|
"""
|
3007
|
+
|
2871
3008
|
# if self.current_result > 0:
|
2872
3009
|
self.current_result -= 1
|
2873
3010
|
self._update_result_view()
|
@@ -2889,6 +3026,7 @@ class Wolfresults_2D(Element_To_Draw):
|
|
2889
3026
|
|
2890
3027
|
block : numéro du bloc; 1-based;
|
2891
3028
|
"""
|
3029
|
+
|
2892
3030
|
if isinstance(block,str):
|
2893
3031
|
return self.myblocks[block].qx
|
2894
3032
|
else:
|
@@ -2900,6 +3038,7 @@ class Wolfresults_2D(Element_To_Draw):
|
|
2900
3038
|
|
2901
3039
|
block : numéro du bloc; 1-based;
|
2902
3040
|
"""
|
3041
|
+
|
2903
3042
|
if isinstance(block,str):
|
2904
3043
|
return self.myblocks[block].qy
|
2905
3044
|
else:
|
@@ -2916,6 +3055,7 @@ class Wolfresults_2D(Element_To_Draw):
|
|
2916
3055
|
Les indices sont passés comme WOLF --> en numérotation Fortran (démarrage à 1 et non à 0)
|
2917
3056
|
***
|
2918
3057
|
"""
|
3058
|
+
|
2919
3059
|
h=-1
|
2920
3060
|
qx=-1
|
2921
3061
|
qy=-1
|
@@ -2974,11 +3114,10 @@ class Wolfresults_2D(Element_To_Draw):
|
|
2974
3114
|
|
2975
3115
|
return self.head_blocks[getkeyblock(which_block,False)]
|
2976
3116
|
|
2977
|
-
def get_xy_infootprint_vect(self, myvect: vector, which_block=1) -> np.ndarray:
|
3117
|
+
def get_xy_infootprint_vect(self, myvect: vector, which_block=1) -> tuple[np.ndarray,np.ndarray]:
|
2978
3118
|
|
2979
3119
|
"""
|
2980
|
-
|
2981
|
-
numpy array content les coordonnées xy des mailles dans l'empreinte du vecteur
|
3120
|
+
:return numpy array content les coordonnées (x,y) des mailles dans l'empreinte du vecteur
|
2982
3121
|
"""
|
2983
3122
|
|
2984
3123
|
myptsij = self.get_ij_infootprint_vect(myvect, which_block)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: wolfhece
|
3
|
-
Version: 2.
|
3
|
+
Version: 2.1.1
|
4
4
|
Author-email: Pierre Archambeau <pierre.archambeau@uliege.be>
|
5
5
|
License: AGPL-v3 License
|
6
6
|
Project-URL: Homepage, https://uee.uliege.be/hece
|
@@ -8,8 +8,9 @@ Project-URL: Issues, https://uee.uliege.be/hece
|
|
8
8
|
Classifier: Programming Language :: Python :: 3.10
|
9
9
|
Classifier: Operating System :: Microsoft :: Windows :: Windows 10
|
10
10
|
Classifier: Operating System :: Microsoft :: Windows :: Windows 11
|
11
|
+
Classifier: Operating System :: POSIX :: Linux
|
11
12
|
Classifier: Topic :: Scientific/Engineering :: Physics
|
12
|
-
Requires-Python: <3.11,>=3.
|
13
|
+
Requires-Python: <3.11,>=3.10
|
13
14
|
Description-Content-Type: text/markdown
|
14
15
|
Requires-Dist: wxpython
|
15
16
|
Requires-Dist: numpy
|