wolfhece 2.0.52__py3-none-any.whl → 2.0.54__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/PyGui.py CHANGED
@@ -615,7 +615,7 @@ class Wolf2DModel(GenMapManager):
615
615
  self.files_others={'Generic file':[
616
616
  ('','First parametric file - historical'),
617
617
  ('.par','Parametric file - multiblocks')],
618
- 'Charachteristics':[
618
+ 'Characteristics':[
619
619
  ('.fil','Infiltration hydrographs [m³/s]'),
620
620
  ('.mnap','Resulting mesh [-]'),
621
621
  ('.trl','Translation to real world [m]')
@@ -1147,7 +1147,7 @@ class Wolf2DModel(GenMapManager):
1147
1147
  self.myblocfile.write_file()
1148
1148
 
1149
1149
  def get_header_MB(self, abs=False):
1150
- """#> Renvoit un header avec les infos multi-blocs"""
1150
+ """Renvoi d'un header avec les infos multi-blocs"""
1151
1151
  myheader:header_wolf
1152
1152
  myheader = self.mymnap.get_header(abs=abs)
1153
1153
  for curblock in self.mymnap.myblocks.values():
@@ -1298,7 +1298,7 @@ class Wolf2DModel(GenMapManager):
1298
1298
  ret= _('Text files\n')
1299
1299
  ret+= ('----------\n')
1300
1300
 
1301
- for key, val in self.files_others['Charachteristics']:
1301
+ for key, val in self.files_others['Characteristics']:
1302
1302
  ret += f"{val} : {key}\n"
1303
1303
 
1304
1304
  ret +='\n\n'
wolfhece/PyParams.py CHANGED
@@ -640,7 +640,7 @@ class Wolf_Param(wx.Frame):
640
640
  if(genGroup != ""):
641
641
  dict_param_def = self.myIncParam[genGroup][genParam]["Dict"][genParam]
642
642
  else:
643
- dict_param_def = self.myIncParam[group][genParam]["Dict"]
643
+ dict_param_def = self.myIncParam[group][genParam]["Dict"][genParam]
644
644
 
645
645
  elif(genGroup != ""):
646
646
  dict_param_def = self.myIncGroup[genGroup]["Dict"][param_name]
@@ -1239,7 +1239,7 @@ class Wolf_Param(wx.Frame):
1239
1239
  curdict["Saved"] = {}
1240
1240
 
1241
1241
  #pointage du param courant dans le dict de référence
1242
- curparam=curdict["Dict"]
1242
+ curparam = curdict["Dict"][paramloc[0]] = {}
1243
1243
  else:
1244
1244
  #création d'un dict sur base du nom de paramètre
1245
1245
  curparam=groupdict[paramloc[0]]={}
@@ -1916,6 +1916,12 @@ class Wolf_Param(wx.Frame):
1916
1916
  savedDict[curGroup] = {}
1917
1917
 
1918
1918
  templateDict = self.myIncParam[genGroup][curIncParam]["Dict"]
1919
+
1920
+ if curIncParam in templateDict.keys():
1921
+ templateDict = templateDict[curIncParam]
1922
+ else:
1923
+ logging.error(_("ERROR : the template of the incrementable parameter does not exist!"))
1924
+
1919
1925
  if(nbElements is None):
1920
1926
  if self.wx_exists:
1921
1927
  wx.MessageBox(_('The reference of the incrementable group does not exist!'), _('Error'), wx.OK|wx.ICON_ERROR)
@@ -1943,11 +1949,11 @@ class Wolf_Param(wx.Frame):
1943
1949
  else:
1944
1950
  self.myparams[curGroup][curParam] = {}
1945
1951
  self.myparams[curGroup][curParam][key_Param.NAME] = curParam
1946
- self.myparams[curGroup][curParam][key_Param.VALUE] = templateDict[curIncParam][key_Param.VALUE]
1947
- self.myparams[curGroup][curParam][key_Param.COMMENT] = templateDict[curIncParam][key_Param.COMMENT]
1948
- self.myparams[curGroup][curParam][key_Param.TYPE] = templateDict[curIncParam][key_Param.TYPE]
1949
- if key_Param.ADDED_JSON in templateDict[curIncParam]:
1950
- self.myparams[curGroup][curParam][key_Param.ADDED_JSON] = templateDict[curIncParam][key_Param.ADDED_JSON]
1952
+ self.myparams[curGroup][curParam][key_Param.VALUE] = templateDict[key_Param.VALUE]
1953
+ self.myparams[curGroup][curParam][key_Param.COMMENT] = templateDict[key_Param.COMMENT]
1954
+ self.myparams[curGroup][curParam][key_Param.TYPE] = templateDict[key_Param.TYPE]
1955
+ if key_Param.ADDED_JSON in templateDict:
1956
+ self.myparams[curGroup][curParam][key_Param.ADDED_JSON] = templateDict[key_Param.ADDED_JSON]
1951
1957
 
1952
1958
  # transfert des paramètres en surplus dans le dictionnaire savedDict
1953
1959
  for i in range(nbElements+1, iterMax+1):
wolfhece/apps/version.py CHANGED
@@ -5,7 +5,7 @@ class WolfVersion():
5
5
 
6
6
  self.major = 2
7
7
  self.minor = 0
8
- self.patch = 52
8
+ self.patch = 54
9
9
 
10
10
  def __str__(self):
11
11
 
@@ -12,6 +12,7 @@ except:
12
12
  import numpy as np
13
13
  import shutil
14
14
  from os.path import exists
15
+ from os import makedirs
15
16
  import matplotlib.pyplot as plt
16
17
  import matplotlib.path as mpltPath
17
18
  import wx
@@ -19,7 +20,7 @@ import logging
19
20
  from enum import Enum
20
21
 
21
22
  from ..wolf_array import WOLF_ARRAY_FULL_INTEGER, WOLF_ARRAY_FULL_SINGLE, WolfArray, WolfArrayMB, WolfArrayMNAP, \
22
- header_wolf, WolfArray_Sim2D, WolfArrayMNAP, WOLF_ARRAY_MB_SINGLE, WOLF_ARRAY_FULL_LOGICAL, WOLF_ARRAY_FULL_SINGLE, getkeyblock
23
+ header_wolf, WolfArray_Sim2D, WolfArrayMNAP, WOLF_ARRAY_MB_SINGLE, WOLF_ARRAY_FULL_LOGICAL, WOLF_ARRAY_FULL_SINGLE, getkeyblock, WOLF_ARRAY_MB_INTEGER
23
24
 
24
25
  from ..PyVertexvectors import *
25
26
  from ..PyVertex import getIfromRGB
@@ -2998,11 +2999,27 @@ class xy_file():
2998
2999
 
2999
3000
 
3000
3001
  class prev_sim2D():
3002
+ """
3003
+ Modélisation 2D CPU -- version 2D originale non OO
3004
+
3005
+ Cette classe est en construction et ne contient pas encore toutes les fonctionnalités.
3006
+
3007
+ Elle devrait à terme être utilisée dans l'objet Wolf2DModel de PyGui afin de séparer
3008
+ le stockage des données de la visualisation et interface WX.
3009
+
3010
+ """
3001
3011
 
3002
3012
  def __init__(self, fname:str) -> None:
3013
+ """
3014
+ Initialisation de la classe
3015
+
3016
+ :param fname: nom du fichier générique de simulation - sans extension
3017
+ """
3003
3018
 
3004
3019
  from pathlib import Path
3005
3020
 
3021
+ fname = str(fname)
3022
+
3006
3023
  self.filename = fname
3007
3024
  self.mydir = Path(fname).parent.as_posix()
3008
3025
  self.filenamegen = self.filename
@@ -3032,7 +3049,7 @@ class prev_sim2D():
3032
3049
  self.files_others={'Generic file':[
3033
3050
  ('','First parametric file - historical'),
3034
3051
  ('.par','Parametric file - multiblocks')],
3035
- 'Charachteristics':[
3052
+ 'Characteristics':[
3036
3053
  ('.fil','Infiltration hydrographs [m³/s]'),
3037
3054
  ('.mnap','Resulting mesh [-]'),
3038
3055
  ('.trl','Translation to real world [m]')
@@ -3048,7 +3065,16 @@ class prev_sim2D():
3048
3065
  ]}
3049
3066
 
3050
3067
 
3051
- def get_header(self):
3068
+ def get_header(self,abs=False):
3069
+ """
3070
+ Renvoi d'un header avec les infos géométriques de la simulation
3071
+
3072
+ Version monobloc et résolution fine
3073
+
3074
+ :param abs: si True, les origines sont décalées des translations et les translations sont mises à 0
3075
+ :type abs: bool
3076
+ """
3077
+
3052
3078
  curhead = header_wolf()
3053
3079
 
3054
3080
  curhead.nbx = self.myparam.nxfin
@@ -3063,10 +3089,22 @@ class prev_sim2D():
3063
3089
  curhead.translx = self.myparam.translx
3064
3090
  curhead.transly = self.myparam.transly
3065
3091
 
3092
+ if abs:
3093
+ curhead.origx += curhead.translx
3094
+ curhead.origy += curhead.transly
3095
+ curhead.translx = 0.
3096
+ curhead.transly = 0.
3097
+
3066
3098
  return curhead
3067
3099
 
3068
3100
  def get_header_MB(self,abs=False):
3069
- """#> Renvoit un header avec les infos multi-blocs"""
3101
+ """
3102
+ Renvoi d'un header avec les infos multi-blocs
3103
+
3104
+ :param abs: si True, les origines sont décalées des translations et les translations sont mises à 0
3105
+ :type abs: bool
3106
+ """
3107
+
3070
3108
  myheader:header_wolf
3071
3109
  myheader = self.mymnap.get_header(abs=abs)
3072
3110
  for curblock in self.mymnap.myblocks.values():
@@ -3075,7 +3113,12 @@ class prev_sim2D():
3075
3113
 
3076
3114
  def verify_files(self):
3077
3115
  """
3078
- Vérification de la présence des en-têtes dans les différents fichiers
3116
+ Vérification de la présence des en-têtes dans les différents fichiers présents sur disque.
3117
+
3118
+ Cette routine est nécessaire pour s'assurer de la cohérence des headers. Certaines versions de l'interface VB6
3119
+ présentaient un bug lors de la sauvegarde des fichiers ce qui peut avoir comme conséquence de décaler les données
3120
+ (double application des translations vers le monde réel).
3121
+
3079
3122
  """
3080
3123
 
3081
3124
  fhead = self.get_header()
@@ -3087,7 +3130,7 @@ class prev_sim2D():
3087
3130
  if exists(fname):
3088
3131
  logging.info(f'Verifying header for {fname}')
3089
3132
  fname += '.txt'
3090
- fhead.write_txt_header(fname,wolftype)
3133
+ fhead.write_txt_header(fname, wolftype, forceupdate=True)
3091
3134
 
3092
3135
  mb = self.files_MB_array['Initial Conditions']
3093
3136
  for curextent,text,wolftype in mb:
@@ -3095,10 +3138,228 @@ class prev_sim2D():
3095
3138
  if exists(fname):
3096
3139
  logging.info(f'Verifying header for {fname}')
3097
3140
  fname += '.txt'
3098
- mbhead.write_txt_header(fname,wolftype)
3141
+ mbhead.write_txt_header(fname, wolftype, forceupdate=True)
3099
3142
 
3100
3143
  fname = self.filenamegen + '.lst'
3101
3144
  if not exists(fname):
3102
3145
  logging.warning(f'File {fname} does not exist -- Creating it')
3103
3146
  with open(fname,'w') as f:
3104
- f.write('0\n')
3147
+ f.write('0\n')
3148
+
3149
+ @property
3150
+ def is_multiblock(self):
3151
+ return self.mymnap.nb_blocks>1
3152
+
3153
+ @property
3154
+ def nb_blocks(self):
3155
+ return self.mymnap.nb_blocks
3156
+
3157
+ def read_fine_array(self, which:Literal['.top', '.hbin', '.qxbin', '.qybin', '.napbin', '.topini_fine', '.frot', '.inf']='') -> WolfArray:
3158
+ """
3159
+ Lecture d'une matrice fine
3160
+
3161
+ :param which: suffixe du fichier
3162
+ :type which: str -- extension with point (e.g. '.hbin')
3163
+ :return: WolfArray
3164
+ """
3165
+ which = str(which)
3166
+ if not which.startswith('.'):
3167
+ which = '.' + which
3168
+
3169
+ if Path(self.filenamegen + which).exists():
3170
+ myarray = WolfArray(fname = self.filenamegen + which)
3171
+ myarray.mask_reset()
3172
+
3173
+ else:
3174
+ logging.error(f"File {self.filenamegen + which} does not exist")
3175
+ myarray = None
3176
+
3177
+ return myarray
3178
+
3179
+ def read_MB_array(self, which:Literal['.hbinb', '.qxbinb', '.qybinb', '.frotini', '.topini']='') -> WolfArrayMB:
3180
+ """
3181
+ Lecture d'une matrice MB
3182
+
3183
+ :param which: suffixe du fichier
3184
+ :type which: str -- extension with point (e.g. '.hbinb')
3185
+ :return: WolfArrayMB
3186
+ """
3187
+
3188
+ which = str(which)
3189
+ if not which.startswith('.'):
3190
+ which = '.' + which
3191
+
3192
+ if Path(self.filenamegen + which).exists():
3193
+ myarray =WolfArrayMB()
3194
+ myarray.set_header(self.get_header_MB())
3195
+ myarray.filename = self.filenamegen+which
3196
+ myarray.read_data()
3197
+ myarray.mask_reset()
3198
+ else:
3199
+ logging.error(f"File {self.filenamegen + which} does not exist")
3200
+ myarray = None
3201
+
3202
+ return myarray
3203
+
3204
+ def help_files(self) -> str:
3205
+ """
3206
+ Informations sur les fichiers et les types de données qu'ils contiennent.
3207
+ """
3208
+
3209
+ ret= _('Text files\n')
3210
+ ret+= ('----------\n')
3211
+
3212
+ for key, val in self.files_others['Characteristics']:
3213
+ ret += f"{val} : {key}\n"
3214
+
3215
+ ret +='\n\n'
3216
+
3217
+ ret += _('Fine array - monoblock\n')
3218
+ ret += ('----------------------\n')
3219
+
3220
+ for key, val, dtype in self.files_fine_array['Characteristics']:
3221
+
3222
+ if dtype == WOLF_ARRAY_FULL_LOGICAL:
3223
+ ret += f"{val} : {key} [int16]\n"
3224
+ elif dtype == WOLF_ARRAY_FULL_INTEGER:
3225
+ ret += f"{val} : {key} [int32]\n"
3226
+ elif dtype == WOLF_ARRAY_FULL_SINGLE:
3227
+ ret += f"{val} : {key} [float32]\n"
3228
+ else:
3229
+ ret += f"{val} : {key} error - check code\n"
3230
+
3231
+ ret +='\n\n'
3232
+
3233
+ ret += _('Multiblock arrays\n')
3234
+ ret += ('-----------------\n')
3235
+
3236
+ for key, val, dtype in self.files_MB_array['Initial Conditions']:
3237
+
3238
+ if dtype == WOLF_ARRAY_MB_INTEGER:
3239
+ ret += f"{val} : {key} [int32]\n"
3240
+ elif dtype == WOLF_ARRAY_MB_SINGLE:
3241
+ ret += f"{val} : {key} [float32]\n"
3242
+ else:
3243
+ ret += f"{val} : {key} error - check code\n"
3244
+
3245
+ return ret
3246
+
3247
+ def check_infiltration(self) -> str:
3248
+ """
3249
+ Informations sur les zones d'infiltration :
3250
+ - nombre de zones dans le fichier .inf et .fil
3251
+ - nombre de cellules de chaque zone
3252
+ - première maille de chaque zone
3253
+ - nombre de temps énumérés dans le fichier .fil
3254
+ - Warning si le nombre de zones est différent entre les fichiers .inf et .fil
3255
+
3256
+ """
3257
+
3258
+ ret = _('inside .inf binary file') + '\n'
3259
+ ret += ('-----------------------') + '\n'
3260
+
3261
+ inf = self.read_fine_array('.inf')
3262
+
3263
+ maxinf = inf.array.data.max()
3264
+ ret += _('Maximum infiltration zone : ') + str(maxinf) + '\n'
3265
+ for i in range(1,maxinf+1):
3266
+
3267
+ nb = np.sum(inf.array.data == i)
3268
+ if nb>0:
3269
+ indices = np.where(inf.array.data == i)
3270
+ ret += f"Zone {i} : {nb} cells -- Indices (i,j) of the zone's first cell ({indices[0][0]+1} ; {indices[1][0]+1}) (1-based)\n"
3271
+ else:
3272
+ ret += f"Zone {i} : 0 cells\n"
3273
+
3274
+ ret += '\n'
3275
+
3276
+ ret += _('inside .fil text file') + '\n'
3277
+ ret += ('----------------------') + '\n'
3278
+
3279
+ ret += f"Zones {self.myinfil.nb_zones}" + '\n'
3280
+ ret += f"Time steps {self.myinfil.nb_steps}" + '\n'
3281
+
3282
+ if maxinf != self.myinfil.nb_zones:
3283
+ ret += _('Warning : number of zones in .inf and .fil files are different') + '\n'
3284
+
3285
+ return ret
3286
+
3287
+
3288
+ def copy2gpu(self, dirout:str='') -> str:
3289
+ """
3290
+ Copie des matrices d'une simulation CPU pour le code GPU
3291
+
3292
+ :param dirout: répertoire de sortie
3293
+ :type dirout: str
3294
+ """
3295
+
3296
+ def to_absolute(array:WolfArray):
3297
+ array.origx += array.translx
3298
+ array.origy += array.transly
3299
+ array.translx = 0.
3300
+ array.transly = 0.
3301
+
3302
+ ret = ''
3303
+
3304
+ dirout = Path(dirout)
3305
+ makedirs(dirout, exist_ok=True)
3306
+
3307
+ inf = self.read_fine_array('.inf')
3308
+ to_absolute(inf)
3309
+ inf.write_all(dirout / 'infiltration_zones.npy')
3310
+ del(inf)
3311
+
3312
+ ret += '.inf --> infiltration_zones.npy [np.int32]\n'
3313
+
3314
+ frot = self.read_fine_array('.frot')
3315
+ to_absolute(frot)
3316
+ frot.write_all(dirout / 'manning.npy')
3317
+ del(frot)
3318
+
3319
+ ret += '.frot --> manning.npy [np.float32]\n'
3320
+
3321
+ hbin = self.read_fine_array('.hbin')
3322
+ to_absolute(hbin)
3323
+ hbin.write_all(dirout / 'h.npy')
3324
+ del(hbin)
3325
+
3326
+ ret += '.hbin --> h.npy [np.float32]\n'
3327
+
3328
+ qxbin = self.read_fine_array('.qxbin')
3329
+ to_absolute(qxbin)
3330
+ qxbin.write_all(dirout / 'qx.npy')
3331
+ del(qxbin)
3332
+
3333
+ ret += '.qxbin --> qx.npy [np.float32]\n'
3334
+
3335
+ qybin = self.read_fine_array('.qybin')
3336
+ to_absolute(qybin)
3337
+ qybin.write_all(dirout / 'qy.npy')
3338
+ del(qybin)
3339
+
3340
+ ret += '.qybin --> qy.npy [np.float32]\n'
3341
+
3342
+ nap = self.read_fine_array('.napbin')
3343
+ napgpu = np.zeros_like(nap.array.data, dtype = np.uint8)
3344
+ napgpu[np.where(nap.array.data != 0)] = 1
3345
+ np.save(dirout / 'nap.npy', napgpu)
3346
+
3347
+ ret += '.napbin --> nap.npy [np.uint8]\n'
3348
+
3349
+ top = self.read_fine_array('.top')
3350
+ to_absolute(top)
3351
+ top.array.data[np.where(napgpu != 1)] = 99999.
3352
+ top.nullvalue = 99999.
3353
+ top.write_all(dirout / 'bathymetry.npy')
3354
+
3355
+ ret += '.top --> bathymetry.npy [np.float32]\n'
3356
+ ret += _('Force a value 99999. outside nap')
3357
+
3358
+ nb = np.sum(top.array.data != 99999.)
3359
+ assert nb == np.sum(napgpu == 1), 'Error in couting active cells'
3360
+
3361
+ ret += f'\n{nb} active cells in bathymetry.npy'
3362
+
3363
+ del(top)
3364
+
3365
+ return ret
wolfhece/wolf_array.py CHANGED
@@ -5248,6 +5248,11 @@ class WolfArray(Element_To_Draw, header_wolf):
5248
5248
  self.wolftype = WOLF_ARRAY_FULL_INTEGER16
5249
5249
  elif locarray.dtype == np.int8:
5250
5250
  self.wolftype = WOLF_ARRAY_FULL_INTEGER8
5251
+ else:
5252
+ logging.error(_('Unsupported type in numpy file -- Abort loading'))
5253
+ return
5254
+
5255
+ tmp_wolftype = self.wolftype
5251
5256
 
5252
5257
  # Il y de fortes chances que cette matrice numpy provienne d'une modélisation GPU
5253
5258
  # et donc que les coordonnées et la résolution soient disponibles dans un fichier parameters.json
@@ -5270,6 +5275,13 @@ class WolfArray(Element_To_Draw, header_wolf):
5270
5275
  elif (locpath.parent / (locpath.name + '.txt')).exists():
5271
5276
  self.read_txt_header()
5272
5277
 
5278
+ # Le header contient également un type
5279
+ # Vérification de la cohérence
5280
+ if self.wolftype != tmp_wolftype:
5281
+ logging.warning(_('Inconsistent type in header and numpy file'))
5282
+ logging.warning(_('Forcing type from Numpy file'))
5283
+ self.wolftype = tmp_wolftype
5284
+
5273
5285
  self.mask_data(self.nullvalue)
5274
5286
  self.loaded = True
5275
5287
 
@@ -5296,8 +5308,34 @@ class WolfArray(Element_To_Draw, header_wolf):
5296
5308
  if self.filename.endswith('.tif'):
5297
5309
  self.export_geotif()
5298
5310
  elif self.filename.endswith('.npy'):
5311
+
5312
+ writing_header = True
5313
+ if self.dtype != self.array.data.dtype:
5314
+ logging.warning(_('Data type changed -- Force conversion to internal numpy array'))
5315
+ locarray = self.array.data
5316
+ if locarray.dtype == np.float32:
5317
+ self.wolftype = WOLF_ARRAY_FULL_SINGLE
5318
+ logging.warning(_('Data type changed to float32'))
5319
+ elif locarray.dtype == np.float64:
5320
+ self.wolftype = WOLF_ARRAY_FULL_DOUBLE
5321
+ logging.warning(_('Data type changed to float64'))
5322
+ elif locarray.dtype == np.int32:
5323
+ self.wolftype = WOLF_ARRAY_FULL_INTEGER
5324
+ logging.warning(_('Data type changed to int32'))
5325
+ elif locarray.dtype == np.int16:
5326
+ self.wolftype = WOLF_ARRAY_FULL_INTEGER16
5327
+ logging.warning(_('Data type changed to int16'))
5328
+ elif locarray.dtype == np.int8:
5329
+ self.wolftype = WOLF_ARRAY_FULL_INTEGER8
5330
+ logging.warning(_('Data type changed to int8'))
5331
+ else:
5332
+ logging.error(_('Unsupported type in numpy file -- Abort wrting header file'))
5333
+ writing_header = False
5334
+
5299
5335
  np.save(self.filename, self.array.data)
5300
- self.write_txt_header()
5336
+
5337
+ if writing_header:
5338
+ self.write_txt_header()
5301
5339
  else:
5302
5340
  self.write_txt_header()
5303
5341
  self.write_array()
@@ -5306,6 +5344,8 @@ class WolfArray(Element_To_Draw, header_wolf):
5306
5344
  """
5307
5345
  Change resolution - in place
5308
5346
 
5347
+ :param factor: factor of resolution change -- > 1.0 : decrease resolution, < 1.0 : increase resolution
5348
+
5309
5349
  If you want to keep current data, copy the WolfArray into a new variable -> newWA = Wolfarray(mold=curWA)
5310
5350
  """
5311
5351
  operation = operation.lower()
@@ -5345,6 +5385,8 @@ class WolfArray(Element_To_Draw, header_wolf):
5345
5385
  else:
5346
5386
  self.array = np.kron(self.array, np.ones((int(1/factor), int(1/factor)), dtype=self.array.dtype))
5347
5387
 
5388
+ self.mask_reset()
5389
+
5348
5390
  self.count()
5349
5391
 
5350
5392
  def read_txt_header(self):
@@ -7035,6 +7077,142 @@ class WolfArrayMB(WolfArray):
7035
7077
  self.myblocks[key].isblock = True
7036
7078
  self.myblocks[key].blockindex = id
7037
7079
  self.myblocks[key].idx = key
7080
+
7081
+ def set_header_from_added_blocks(self):
7082
+ """ Set header from blocks """
7083
+
7084
+ if len(self.myblocks) > 0:
7085
+
7086
+ origx = min([curblock.origx + curblock.translx for curblock in self.myblocks.values()])
7087
+ origy = min([curblock.origy + curblock.transly for curblock in self.myblocks.values()])
7088
+ endx = max([curblock.origx + curblock.translx + curblock.nbx*curblock.dx for curblock in self.myblocks.values()])
7089
+ endy = max([curblock.origy + curblock.transly + curblock.nby*curblock.dy for curblock in self.myblocks.values()])
7090
+
7091
+ self.dx = endx - origx
7092
+ self.dy = endy - origy
7093
+
7094
+ self.nbx = 1
7095
+ self.nby = 1
7096
+
7097
+ self.origx = origx
7098
+ self.origy = origy
7099
+
7100
+ self.translx = 0.
7101
+ self.transly = 0.
7102
+
7103
+ def as_WolfArray(self, abs:bool=True, forced_header:header_wolf = None) -> WolfArray:
7104
+ """
7105
+ Convert to WolfArray
7106
+
7107
+ Rebin blocks if necessary
7108
+ """
7109
+
7110
+ newArray = WolfArray()
7111
+
7112
+ if forced_header is None:
7113
+ myhead = self.get_header(abs=abs)
7114
+ else:
7115
+ myhead = forced_header
7116
+ myhead.wolftype = self.wolftype
7117
+
7118
+ dx = set([curblock.get_header().dx for curblock in iter(self.myblocks.values())])
7119
+ dy = set([curblock.get_header().dy for curblock in iter(self.myblocks.values())])
7120
+
7121
+ if len(dx) == 1 and len(dy) == 1:
7122
+ # only one resolution
7123
+
7124
+ newArray.dx = list(dx)[0]
7125
+ newArray.dy = list(dy)[0]
7126
+
7127
+ newArray.origx = myhead.origx
7128
+ newArray.origy = myhead.origy
7129
+ newArray.nbx = int((myhead.nbx*myhead.dx)//newArray.dx)
7130
+ newArray.nby = int((myhead.nby*myhead.dy)//newArray.dy)
7131
+ newArray.translx = myhead.translx
7132
+ newArray.transly = myhead.transly
7133
+
7134
+ newArray.wolftype = WOLF_ARRAY_FULL_SINGLE if myhead.wolftype == WOLF_ARRAY_MB_SINGLE else WOLF_ARRAY_FULL_INTEGER
7135
+
7136
+ newArray.allocate_ressources()
7137
+ newArray.array[:,:] = 0
7138
+
7139
+ for curblock in self.myblocks.values():
7140
+
7141
+ ij = np.where(~curblock.array.mask)
7142
+ if len(ij[0]) > 0:
7143
+ if len(ij[0])>0:
7144
+ i = ij[0]
7145
+ j = ij[1]
7146
+
7147
+ x0, y0 = curblock.get_xy_from_ij(0,0, abs=True)
7148
+ i0, j0 = newArray.get_ij_from_xy(x0, y0, abs=True)
7149
+
7150
+ i_dest = i + i0
7151
+ j_dest = j + j0
7152
+
7153
+ newArray.array[i_dest,j_dest] = curblock.array[i,j]
7154
+ newArray.array.mask[i_dest,j_dest] = False
7155
+ else:
7156
+ logging.debug(f"Block {curblock.idx} is empty or totally masked.")
7157
+ else:
7158
+ logging.debug(f"Block {curblock.idx} is empty or totally masked.")
7159
+
7160
+ else:
7161
+ # multiple resolutions
7162
+
7163
+ dx = list(dx)
7164
+ dy = list(dy)
7165
+
7166
+ dx.sort()
7167
+ dy.sort()
7168
+
7169
+ newArray.dx = dx[0]
7170
+ newArray.dy = dy[0]
7171
+ newArray.origx = myhead.origx
7172
+ newArray.origy = myhead.origy
7173
+ newArray.nbx = int((myhead.nbx*myhead.dx)//newArray.dx)
7174
+ newArray.nby = int((myhead.nby*myhead.dy)//newArray.dy)
7175
+ newArray.translx = myhead.translx
7176
+ newArray.transly = myhead.transly
7177
+
7178
+ newArray.wolftype = WOLF_ARRAY_FULL_SINGLE if myhead.wolftype == WOLF_ARRAY_MB_SINGLE else WOLF_ARRAY_FULL_INTEGER
7179
+
7180
+ newArray.allocate_ressources()
7181
+ newArray.array[:,:] = 0
7182
+
7183
+ for curblock in self.myblocks.values():
7184
+
7185
+ if curblock.dx == dx[0] and curblock.dy == dy[0]:
7186
+ # same resolution
7187
+ blockArray = curblock
7188
+ else:
7189
+ # rebin
7190
+
7191
+ factor = dx[0]/curblock.dx
7192
+ blockArray = WolfArray(mold=curblock)
7193
+ blockArray.rebin(factor)
7194
+
7195
+
7196
+ ij = np.where(~blockArray.array.mask)
7197
+ if len(ij[0]) > 0:
7198
+ if len(ij[0])>0:
7199
+ i = ij[0]
7200
+ j = ij[1]
7201
+
7202
+ x0, y0 = blockArray.get_xy_from_ij(0,0, abs=True)
7203
+ i0, j0 = newArray.get_ij_from_xy(x0, y0, abs=True)
7204
+
7205
+ i_dest = i + i0
7206
+ j_dest = j + j0
7207
+
7208
+ newArray.array[i_dest,j_dest] = blockArray.array[i,j]
7209
+ newArray.array.mask[i_dest,j_dest] = False
7210
+ else:
7211
+ logging.debug(f"Block {curblock.idx} is empty or totally masked.")
7212
+ else:
7213
+ logging.debug(f"Block {curblock.idx} is empty or totally masked.")
7214
+
7215
+ return newArray
7038
7216
  class WolfArrayMNAP(WolfArrayMB):
7039
7217
  """
7040
7218
  Matrice MNAP d'une modélisation WOLF2D
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: wolfhece
3
- Version: 2.0.52
3
+ Version: 2.0.54
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
@@ -7,11 +7,11 @@ wolfhece/Model1D.py,sha256=-cMz-ePSYzrKVVDidiDOz6cojEZ3y6u9gIb7RPwT6Y8,476593
7
7
  wolfhece/PyConfig.py,sha256=oGSL1WsLM9uinlNP4zGBLK3uHPmBfduUi7R-VtWuRFA,8034
8
8
  wolfhece/PyCrosssections.py,sha256=f4dNYRUGZKePruaaBiTcn5vlrw8TFTj9XwTDrdiF_uU,112450
9
9
  wolfhece/PyDraw.py,sha256=nUHEMpTG0zJvBJYOnreTvAISeP7cLsx14Qyrv-y32OY,344956
10
- wolfhece/PyGui.py,sha256=-LTnUVkRsqJw41DPN0jvhBOmDyygw6GgdGsno78cI_o,59833
10
+ wolfhece/PyGui.py,sha256=fx66rJ6vw2m7fw_vElqO8AVDUGlaHG0FgAVwgsbH8NU,59829
11
11
  wolfhece/PyGuiHydrology.py,sha256=wKhR-KthPRyzJ887NmsozmUpm2CIQIwO3IbYORCYjrE,7290
12
12
  wolfhece/PyHydrographs.py,sha256=GKK8U0byI45H9O_e4LAOOi7Aw0Tg7Q0Lx322stPg5IQ,3453
13
13
  wolfhece/PyPalette.py,sha256=SYKYx_vxF_FVuceLhcIqFQsivGD6EoO_Xu-EGN9Ivko,22252
14
- wolfhece/PyParams.py,sha256=-0cax_Db6kFTe46BAgT24Ga2Xyp2Dm3gpuI-5uUSMxw,84758
14
+ wolfhece/PyParams.py,sha256=SMmITkuZ4JYgF7ng3sj7TLUyDbD78mX7Am9ceCkCowg,84945
15
15
  wolfhece/PyPictures.py,sha256=-mJB0JL2YYiEK3D7_ssDkvYiMWK4ve9kXhozQXNeSx8,2216
16
16
  wolfhece/PyTranslate.py,sha256=4appkmNeHHZLFmUtaA_k5_5QL-5ymxnbVN4R2OblmtE,622
17
17
  wolfhece/PyVertex.py,sha256=OFo8VFxTSViWSTzv2paHeJ9O5BkFUyamXrRPFamlWoU,39630
@@ -48,7 +48,7 @@ wolfhece/rain_SPWMI.py,sha256=YqsF-yFro3y_a6MfVRFfr-Rxi7NR1gl_i8VX7scmzes,13548
48
48
  wolfhece/test_Results2DGPU.py,sha256=NOJ_hFXrcLSQXS1dtsqXRQltqIZtDSHMz_EgAJ2_FHU,307
49
49
  wolfhece/textpillow.py,sha256=zEfLrKhfCDyMaVuQOUjHqz6MGKeQ4aewMxOsWi5-wKI,13832
50
50
  wolfhece/tools_mpl.py,sha256=q8Yc4aukPPiUcEzREvZRM_em67XqXaahdoaNt0DETfE,266
51
- wolfhece/wolf_array.py,sha256=E6u0d6kABsegIZxPUZjtWS88lOrVc2d-lyW0uJgj6qo,289157
51
+ wolfhece/wolf_array.py,sha256=WMiA4VvBsh_Dcabubs8tpi5hxvhZ9V_0vU1v2JjRmX0,296214
52
52
  wolfhece/wolf_hist.py,sha256=JpRXvzJLUP-RkSkvth3DQWglgTMFI2ZEUDb4RYOfeeI,3284
53
53
  wolfhece/wolf_texture.py,sha256=llQ7aV8scWXIkhpri9XjaPejzoBJsGfsln2ZnlRbFkU,16270
54
54
  wolfhece/wolf_tiles.py,sha256=F2JsJHdAP8fIffNJdG_J26bonCIRtIwMmxKFqdSCRDA,10088
@@ -66,7 +66,7 @@ wolfhece/apps/check_install.py,sha256=jrKR-njqnpIh6ZJqvP6KbDUPVCfwTNQj4glQhcyzs9
66
66
  wolfhece/apps/curvedigitizer.py,sha256=avWERHuVxPnJBOD_ibczwW_XG4vAenqWS8W1zjhBox8,4898
67
67
  wolfhece/apps/isocurrent.py,sha256=4XnNWPa8mYUK7V4zdDRFrHFIXNG2AN2og3TqWKKcqjY,3811
68
68
  wolfhece/apps/splashscreen.py,sha256=m9hMTqzhSUcTudApyNNjoAK9e2u5vgEkJVV79xmfM1s,2118
69
- wolfhece/apps/version.py,sha256=8oE3JduZOrh37rUOmSaJni3r3iRiovCtoxD28-Iwbn0,388
69
+ wolfhece/apps/version.py,sha256=FjEAtmzKqev0MbA4BjHe-KyxIU3rJR3DImx2XMupK2A,388
70
70
  wolfhece/apps/wolf.py,sha256=gqfm-ZaUJqNsfCzmdtemSeqLw-GVdSVix-evg5WArJI,293
71
71
  wolfhece/apps/wolf2D.py,sha256=gWD9ee2-1pw_nUxjgRaJMuSe4kUT-RWhOeoTt_Lh1mM,267
72
72
  wolfhece/apps/wolf_logo.bmp,sha256=ruJ4MA51CpGO_AYUp_dB4SWKHelvhOvd7Q8NrVOjDJk,3126
@@ -211,7 +211,7 @@ wolfhece/mesh2d/bc_manager.py,sha256=vSVogXy1x3A6fZKWA6mPZSGX2e3EAUVmEjD9Bgww_hU
211
211
  wolfhece/mesh2d/cell_tracker.py,sha256=AR-Bty-QnrY1ni8Lwak2kU2UWMAJSBCF2ugl2YpfsB4,8660
212
212
  wolfhece/mesh2d/config_manager.py,sha256=vrxLku4isZJTxbHOACEEIEEjQB9pkLpaVPteJz9GhnE,14417
213
213
  wolfhece/mesh2d/cst_2D_boundary_conditions.py,sha256=BaJeKHyJiKEFWBkTQeYsDBW86703ooj65MFVpPMgjLg,2810
214
- wolfhece/mesh2d/wolf2dprev.py,sha256=q-5dwegcBjNy2IAn511Uuktnl8zt3cTtSowardpml2g,137113
214
+ wolfhece/mesh2d/wolf2dprev.py,sha256=b1l4iKtptXkuzgx3Bp-fSZOJy-nPLN2aMy24IA3w3kA,145621
215
215
  wolfhece/models/HECE_169.pptx,sha256=OWJtsWz504A-REFaaxw8lwStHyQU2l7KEeiE7IZvtbk,3396930
216
216
  wolfhece/models/blue.pal,sha256=NnjJnjnYVdQkG54RyPXvo4Tl9ytB0cN7zpiHtj1N6bw,33
217
217
  wolfhece/models/diff16.pal,sha256=Pkp9kQ1GvmAKz3lgwohsw8eQySjVVKHbjhoWw-gZ6Nc,303
@@ -256,8 +256,8 @@ wolfhece/sounds/sonsw2.wav,sha256=pFLVt6By0_EPQNt_3KfEZ9a1uSuYTgQSX1I_Zurv9Rc,11
256
256
  wolfhece/ui/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
257
257
  wolfhece/ui/wolf_multiselection_collapsiblepane.py,sha256=yGbU_JsF56jsmms0gh7mxa7tbNQ_SxqhpAZxhm-mTy4,14860
258
258
  wolfhece/ui/wolf_times_selection_comparison_models.py,sha256=wCxGRnE3kzEkWlWA6-3X8ADOFux_B0a5QWJ2GnXTgJw,4709
259
- wolfhece-2.0.52.dist-info/METADATA,sha256=fl0p2rqonKJIadsbbzLXDsXQgp6l3Z1a7cGZuL13Lc0,2233
260
- wolfhece-2.0.52.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
261
- wolfhece-2.0.52.dist-info/entry_points.txt,sha256=AIu1KMswrdsqNq_2jPtrRIU4tLjuTnj2dCY-pxIlshw,276
262
- wolfhece-2.0.52.dist-info/top_level.txt,sha256=EfqZXMVCn7eILUzx9xsEu2oBbSo9liWPFWjIHik0iCI,9
263
- wolfhece-2.0.52.dist-info/RECORD,,
259
+ wolfhece-2.0.54.dist-info/METADATA,sha256=zSkV1unWFdQ-xAGkEZ_TAd8VfacBKdRc4ysmWkOjKS4,2233
260
+ wolfhece-2.0.54.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
261
+ wolfhece-2.0.54.dist-info/entry_points.txt,sha256=AIu1KMswrdsqNq_2jPtrRIU4tLjuTnj2dCY-pxIlshw,276
262
+ wolfhece-2.0.54.dist-info/top_level.txt,sha256=EfqZXMVCn7eILUzx9xsEu2oBbSo9liWPFWjIHik0iCI,9
263
+ wolfhece-2.0.54.dist-info/RECORD,,