wolfhece 1.8.13__py3-none-any.whl → 2.0.0__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.
Files changed (38) hide show
  1. wolfhece/GraphNotebook.py +0 -1
  2. wolfhece/PyCrosssections.py +591 -5
  3. wolfhece/PyDraw.py +1151 -413
  4. wolfhece/PyGui.py +2 -4
  5. wolfhece/PyParams.py +1515 -852
  6. wolfhece/PyVertex.py +73 -73
  7. wolfhece/PyVertexvectors.py +226 -808
  8. wolfhece/RatingCurve.py +19 -6
  9. wolfhece/apps/wolf2D.py +11 -0
  10. wolfhece/apps/wolfcompare2Darrays.py +51 -22
  11. wolfhece/bernoulli/NetworkOpenGL.py +337 -341
  12. wolfhece/drawing_obj.py +25 -0
  13. wolfhece/hydrology/Catchment.py +77 -77
  14. wolfhece/hydrology/Optimisation.py +206 -53
  15. wolfhece/hydrology/PostProcessHydrology.py +22 -22
  16. wolfhece/hydrology/SubBasin.py +17 -17
  17. wolfhece/hydrology/constant.py +4 -0
  18. wolfhece/hydrology/cst_exchanges.py +2 -1
  19. wolfhece/lazviewer/processing/estimate_normals/estimate_normals.cp310-win_amd64.pyd +0 -0
  20. wolfhece/lazviewer/vfuncs/vfuncs.cp310-win_amd64.pyd +0 -0
  21. wolfhece/libs/WolfDll.dll +0 -0
  22. wolfhece/libs/wolfogl.cp310-win_amd64.pyd +0 -0
  23. wolfhece/libs/wolfpy.cp310-win_amd64.pyd +0 -0
  24. wolfhece/mesh2d/wolf2dprev.py +4 -4
  25. wolfhece/multiprojects.py +13 -13
  26. wolfhece/pylogging.py +1 -1
  27. wolfhece/pyviews.py +23 -23
  28. wolfhece/wolf_array.py +69 -152
  29. wolfhece/wolf_texture.py +39 -16
  30. wolfhece/wolfresults_2D.py +1 -1
  31. {wolfhece-1.8.13.dist-info → wolfhece-2.0.0.dist-info}/METADATA +3 -2
  32. {wolfhece-1.8.13.dist-info → wolfhece-2.0.0.dist-info}/RECORD +37 -33
  33. wolfhece/apps/wolfgpu.py +0 -19
  34. /wolfhece/lazviewer/processing/estimate_normals/{estimate_normals.pyd → estimate_normals.cp39-win_amd64.pyd} +0 -0
  35. /wolfhece/lazviewer/vfuncs/{vfuncs.pyd → vfuncs.cp39-win_amd64.pyd} +0 -0
  36. {wolfhece-1.8.13.dist-info → wolfhece-2.0.0.dist-info}/LICENCE +0 -0
  37. {wolfhece-1.8.13.dist-info → wolfhece-2.0.0.dist-info}/WHEEL +0 -0
  38. {wolfhece-1.8.13.dist-info → wolfhece-2.0.0.dist-info}/top_level.txt +0 -0
wolfhece/multiprojects.py CHANGED
@@ -6,7 +6,7 @@ from typing import Literal
6
6
  from concurrent.futures import ThreadPoolExecutor
7
7
  import logging
8
8
 
9
- from .PyParams import Wolf_Param
9
+ from .PyParams import Wolf_Param, key_Param
10
10
  from .PyVertexvectors import Zones, vector, zone
11
11
  from .PyPalette import wolfpalette
12
12
  from .PyTranslate import _
@@ -88,7 +88,7 @@ class Wolf2D_Project(Project):
88
88
  if verbose:
89
89
  print(key)
90
90
 
91
- cursim = self.mysims[key] = Wolfresults_2D(join(self.wdir, val['value']), eps=epsilon, idx=key)
91
+ cursim = self.mysims[key] = Wolfresults_2D(join(self.wdir, val[key_Param.VALUE]), eps=epsilon, idx=key)
92
92
  cursim.plotted=True
93
93
 
94
94
  self.set_vectors()
@@ -125,10 +125,10 @@ class Wolf2D_Project(Project):
125
125
  for curkey,curvec in vec.items():
126
126
 
127
127
  filename=''
128
- if exists(curvec['value']):
128
+ if exists(curvec[key_Param.VALUE]):
129
129
  filename = curvec
130
- elif exists(join(self.wdir,curvec['value'])):
131
- filename = join(self.wdir,curvec['value'])
130
+ elif exists(join(self.wdir,curvec[key_Param.VALUE])):
131
+ filename = join(self.wdir,curvec[key_Param.VALUE])
132
132
 
133
133
  if filename!='':
134
134
  self.mycontours[curkey] = Zones(filename)
@@ -140,8 +140,8 @@ class Wolf2D_Project(Project):
140
140
  locvec = None
141
141
  cursim = None
142
142
 
143
- if curname['value'] in self.mycontours.keys():
144
- locvec = self.mycontours[curname['value']]
143
+ if curname[key_Param.VALUE] in self.mycontours.keys():
144
+ locvec = self.mycontours[curname[key_Param.VALUE]]
145
145
 
146
146
  if curid in self.mysims.keys():
147
147
  cursim = self.mysims[curid]
@@ -160,10 +160,10 @@ class Wolf2D_Project(Project):
160
160
 
161
161
  for curid, curname in pals.items():
162
162
  filename=''
163
- if exists(curname['value']):
164
- filename = curname['value']
165
- elif exists(join(self.wdir, curname['value'])):
166
- filename=join(self.wdir, curname['value'])
163
+ if exists(curname[key_Param.VALUE]):
164
+ filename = curname[key_Param.VALUE]
165
+ elif exists(join(self.wdir, curname[key_Param.VALUE])):
166
+ filename=join(self.wdir, curname[key_Param.VALUE])
167
167
 
168
168
  if filename!='':
169
169
  mypal = wolfpalette(None, '')
@@ -175,10 +175,10 @@ class Wolf2D_Project(Project):
175
175
  palsarrays = self.get_group('palette-array')
176
176
  if palsarrays is not None:
177
177
  for curid, curname in palsarrays.items():
178
- if curname['value'] in self.set_colormap.keys():
178
+ if curname[key_Param.VALUE] in self.set_colormap.keys():
179
179
  if curid in self.mysims.keys():
180
180
  curarray = self.mysims[curid]
181
- mypal = self.mycolormaps[curname['value']]
181
+ mypal = self.mycolormaps[curname[key_Param.VALUE]]
182
182
  curarray.mypal = mypal
183
183
  curarray.mypal.automatic = False
184
184
 
wolfhece/pylogging.py CHANGED
@@ -58,7 +58,7 @@ def create_wxlogwindow(winTitle='Log') -> wx.LogWindow:
58
58
  logging.getLogger().addHandler(log_bridge_handler)
59
59
 
60
60
  # Set some logging level, just to show up.
61
- logging.getLogger().setLevel(logging.DEBUG)
61
+ logging.getLogger().setLevel(logging.INFO)
62
62
  log_bridge_handler.setLevel(logging.INFO)
63
63
  wx.Log.SetVerbose(True)
64
64
 
wolfhece/pyviews.py CHANGED
@@ -2,7 +2,7 @@ import logging
2
2
 
3
3
  from .drawing_obj import Element_To_Draw
4
4
  from .wolf_array import WolfArray,WolfArrayMB
5
- from .PyParams import Wolf_Param
5
+ from .PyParams import Wolf_Param, key_Param, Type_Param
6
6
 
7
7
  class WolfViews(Element_To_Draw):
8
8
 
@@ -24,62 +24,62 @@ class WolfViews(Element_To_Draw):
24
24
  # for curid, curname in zip(myproject.myparams['cross_sections'].keys(),
25
25
  # myproject.myparams['cross_sections'].values()):
26
26
  # if curid != 'format' and curid != 'dirlaz':
27
- # mycs = crosssections(curname['value'],
28
- # format=myproject.myparams['cross_sections']['format']['value'],
29
- # dirlaz=myproject.myparams['cross_sections']['dirlaz']['value'])
27
+ # mycs = crosssections(curname[key_Param.VALUE],
28
+ # format=myproject.myparams['cross_sections']['format'][key_Param.VALUE],
29
+ # dirlaz=myproject.myparams['cross_sections']['dirlaz'][key_Param.VALUE])
30
30
 
31
31
  # self.add_object('cross_sections', newobj=mycs, id=curid)
32
32
 
33
33
  # if 'vector' in myproject.myparams.keys():
34
34
  # for curid, curname in zip(myproject.myparams['vector'].keys(), myproject.myparams['vector'].values()):
35
- # if exists(curname['value']):
36
- # myvec = Zones(curname['value'])
35
+ # if exists(curname[key_Param.VALUE]):
36
+ # myvec = Zones(curname[key_Param.VALUE])
37
37
  # self.add_object('vector', newobj=myvec, id=curid)
38
38
  # else:
39
- # wx.LogMessage(_('Bad parameter in project file - vector : ')+ curname['value'])
39
+ # wx.LogMessage(_('Bad parameter in project file - vector : ')+ curname[key_Param.VALUE])
40
40
 
41
41
  # if 'array' in myproject.myparams.keys():
42
42
  # for curid, curname in zip(myproject.myparams['array'].keys(), myproject.myparams['array'].values()):
43
43
 
44
- # if exists(curname['value']):
45
- # curarray = WolfArray(curname['value'])
44
+ # if exists(curname[key_Param.VALUE]):
45
+ # curarray = WolfArray(curname[key_Param.VALUE])
46
46
  # self.add_object('array', newobj=curarray, id=curid)
47
47
  # else:
48
- # wx.LogMessage(_('Bad parameter in project file - array : ')+ curname['value'])
48
+ # wx.LogMessage(_('Bad parameter in project file - array : ')+ curname[key_Param.VALUE])
49
49
 
50
50
 
51
51
  # if 'wolf2d' in myproject.myparams.keys():
52
52
  # for curid, curname in zip(myproject.myparams['wolf2d'].keys(), myproject.myparams['wolf2d'].values()):
53
- # if exists(curname['value']):
54
- # curwolf = Wolfresults_2D(curname['value'])
53
+ # if exists(curname[key_Param.VALUE]):
54
+ # curwolf = Wolfresults_2D(curname[key_Param.VALUE])
55
55
  # self.add_object('res2d', newobj=curwolf, id=curid)
56
56
  # else:
57
- # wx.LogMessage(_('Bad parameter in project file - wolf2d : ')+ curname['value'])
57
+ # wx.LogMessage(_('Bad parameter in project file - wolf2d : ')+ curname[key_Param.VALUE])
58
58
 
59
59
  # self.menu_wolf2d()
60
60
 
61
61
  # if 'palette' in myproject.myparams.keys():
62
62
  # self.project_pal = {}
63
63
  # for curid, curname in zip(myproject.myparams['palette'].keys(), myproject.myparams['palette'].values()):
64
- # if exists(curname['value']):
64
+ # if exists(curname[key_Param.VALUE]):
65
65
  # mypal = wolfpalette(None, '')
66
- # mypal.readfile(curname['value'])
66
+ # mypal.readfile(curname[key_Param.VALUE])
67
67
  # mypal.automatic = False
68
68
 
69
69
  # self.project_pal[curid] = mypal
70
70
  # else:
71
- # wx.LogMessage(_('Bad parameter in project file - palette : ')+ curname['value'])
71
+ # wx.LogMessage(_('Bad parameter in project file - palette : ')+ curname[key_Param.VALUE])
72
72
 
73
73
  # if 'palette-array' in myproject.myparams.keys():
74
74
  # curarray: WolfArray
75
75
  # if self.project_pal is not None:
76
76
  # for curid, curname in zip(myproject.myparams['palette-array'].keys(),
77
77
  # myproject.myparams['palette-array'].values()):
78
- # if curname['value'] in self.project_pal.keys():
78
+ # if curname[key_Param.VALUE] in self.project_pal.keys():
79
79
  # curarray = self.getobj(curid)
80
80
  # if curarray is not None:
81
81
  # mypal:wolfpalette
82
- # mypal = self.project_pal[curname['value']]
82
+ # mypal = self.project_pal[curname[key_Param.VALUE]]
83
83
  # curarray.mypal = mypal
84
84
  # if mypal.automatic:
85
85
  # curarray.myops.palauto.SetValue(1)
@@ -92,7 +92,7 @@ class WolfViews(Element_To_Draw):
92
92
 
93
93
  # if 'cross_sections_link' in myproject.myparams.keys():
94
94
  # if 'linkzones' in myproject.myparams['cross_sections_link'].keys():
95
- # idx = myproject.myparams['cross_sections_link']['linkzones']['value']
95
+ # idx = myproject.myparams['cross_sections_link']['linkzones'][key_Param.VALUE]
96
96
 
97
97
  # for curvect in self.added['vectors']:
98
98
  # myzones: Zones
@@ -104,9 +104,9 @@ class WolfViews(Element_To_Draw):
104
104
  # vecname = ''
105
105
 
106
106
  # if 'sortzone' in myproject.myparams['cross_sections_link'].keys():
107
- # zonename = myproject.myparams['cross_sections_link']['sortzone']['value']
107
+ # zonename = myproject.myparams['cross_sections_link']['sortzone'][key_Param.VALUE]
108
108
  # if 'sortname' in myproject.myparams['cross_sections_link'].keys():
109
- # vecname = myproject.myparams['cross_sections_link']['sortname']['value']
109
+ # vecname = myproject.myparams['cross_sections_link']['sortname'][key_Param.VALUE]
110
110
 
111
111
  # if zonename != '' and vecname != '':
112
112
  # names = [cur.myname for cur in myzones.myzones]
@@ -126,7 +126,7 @@ class WolfViews(Element_To_Draw):
126
126
  # locvec = None
127
127
  # locarray = None
128
128
  # for curvec in self.myvectors:
129
- # if curvec.idx == curname['value'].lower():
129
+ # if curvec.idx == curname[key_Param.VALUE].lower():
130
130
  # locvec=curvec
131
131
  # break
132
132
 
@@ -143,7 +143,7 @@ class WolfViews(Element_To_Draw):
143
143
 
144
144
  # wx.LogWarning(_('Bad vec-array association in project file !'))
145
145
  # wx.LogWarning(curid)
146
- # wx.LogWarning(curname['value'])
146
+ # wx.LogWarning(curname[key_Param.VALUE])
147
147
  # del wait
148
148
 
149
149
  def change_gui(self, newmapviewer):
wolfhece/wolf_array.py CHANGED
@@ -404,8 +404,15 @@ class header_wolf():
404
404
  if isinstance(filename, Path):
405
405
  filename = str(filename)
406
406
 
407
+ if filename.endswith('.tif'):
408
+ return
409
+
407
410
  if filename.endswith('.flt'):
408
411
  # Fichier .flt
412
+ if not os.path.exists(filename[:-4] + '.hdr'):
413
+ logging.warning(_('File {} does not exist -- Retry!'.format(filename[:-4] + '.hdr')))
414
+ return
415
+
409
416
  f = open(filename[:-4] + '.hdr', 'r')
410
417
  lines = f.read().splitlines()
411
418
  f.close()
@@ -449,7 +456,7 @@ class header_wolf():
449
456
 
450
457
  else:
451
458
  if not os.path.exists(filename + '.txt'):
452
- logging.info(_(f'File {os.path.curdir} does not exist -- Retry!'))
459
+ logging.info(_('File {} does not exist -- Retry!'.format(filename + '.txt')))
453
460
  return
454
461
 
455
462
  with open(filename + '.txt', 'r') as f:
@@ -513,7 +520,10 @@ class header_wolf():
513
520
 
514
521
  self.head_blocks[getkeyblock(i)] = curhead
515
522
 
516
- def write_txt_header(self,filename,wolftype,forceupdate=False):
523
+ def write_txt_header(self,
524
+ filename:str,
525
+ wolftype:int,
526
+ forceupdate:bool=False):
517
527
  """
518
528
  Ecriture du header dans un fichier texte
519
529
 
@@ -521,6 +531,9 @@ class header_wolf():
521
531
  wolftype : type de la matrice WOLF_ARRAY_*
522
532
 
523
533
  """
534
+
535
+ assert wolftype in [WOLF_ARRAY_CSR_DOUBLE, WOLF_ARRAY_FULL_SINGLE, WOLF_ARRAY_FULL_DOUBLE, WOLF_ARRAY_SYM_DOUBLE, WOLF_ARRAY_FULL_LOGICAL, WOLF_ARRAY_CSR_DOUBLE, WOLF_ARRAY_FULL_INTEGER, WOLF_ARRAY_FULL_SINGLE_3D, WOLF_ARRAY_FULL_INTEGER8, WOLF_ARRAY_MB_SINGLE, WOLF_ARRAY_MB_INTEGER, WOLF_ARRAY_FULL_INTEGER16, WOLF_ARRAY_MNAP_INTEGER]
536
+
524
537
  if not os.path.exists(filename) or forceupdate:
525
538
  with open(filename,'w') as f:
526
539
 
@@ -1946,6 +1959,7 @@ class SelectionData():
1946
1959
 
1947
1960
  def plot_selection(self):
1948
1961
 
1962
+ update_select = self.update_plot_selection
1949
1963
  if self.myselection != 'all':
1950
1964
  if len(self.myselection) > 0:
1951
1965
  self.numlist_select = self._plot_selection(self.myselection, (1., 0., 0.), self.numlist_select)
@@ -1953,6 +1967,7 @@ class SelectionData():
1953
1967
  if len(self.selections) > 0:
1954
1968
  for cur in self.selections.values():
1955
1969
  if cur['select'] != 'all':
1970
+ self.update_plot_selection = update_select
1956
1971
  col = cur['color']
1957
1972
  cur['idgllist'] = self._plot_selection(cur['select'],
1958
1973
  (float(col[0]) / 255., float(col[1]) / 255.,
@@ -4124,7 +4139,7 @@ class WolfArray(Element_To_Draw, header_wolf):
4124
4139
  self.loaded = True
4125
4140
 
4126
4141
  else:
4127
- self.read_txt_header(self.filename)
4142
+ self.read_txt_header()
4128
4143
  if self.preload:
4129
4144
  self.read_data()
4130
4145
  self.loaded = True
@@ -4187,147 +4202,22 @@ class WolfArray(Element_To_Draw, header_wolf):
4187
4202
 
4188
4203
  self.count()
4189
4204
 
4190
- # def read_txt_header(self):
4191
- # """ Lecture du header .txt """
4192
- # if self.filename.endswith('.flt'):
4193
- # # Fichier .flt
4194
- # f = open(self.filename[:-4] + '.hdr', 'r')
4195
- # lines = f.read().splitlines()
4196
- # f.close()
4197
-
4198
- # for curline in lines:
4199
- # if 'NCOLS' in curline.upper():
4200
- # tmp = curline.split(' ')
4201
- # self.nbx = int(tmp[-1])
4202
- # elif 'NROWS' in curline.upper():
4203
- # tmp = curline.split(' ')
4204
- # self.nby = int(tmp[-1])
4205
- # elif 'XLLCORNER' in curline.upper():
4206
- # tmp = curline.split(' ')
4207
- # self.origx = float(tmp[-1])
4208
- # elif 'YLLCORNER' in curline.upper():
4209
- # tmp = curline.split(' ')
4210
- # self.origy = float(tmp[-1])
4211
- # elif 'ULXMAP' in curline.upper():
4212
- # tmp = curline.split(' ')
4213
- # self.origx = float(tmp[-1])
4214
- # self.flipupd=True
4215
- # elif 'ULYMAP' in curline.upper():
4216
- # tmp = curline.split(' ')
4217
- # self.origy = float(tmp[-1])
4218
- # self.flipupd=True
4219
- # elif 'CELLSIZE' in curline.upper():
4220
- # tmp = curline.split(' ')
4221
- # self.dx = self.dy = float(tmp[-1])
4222
- # elif 'XDIM' in curline.upper():
4223
- # tmp = curline.split(' ')
4224
- # self.dx = float(tmp[-1])
4225
- # elif 'YDIM' in curline.upper():
4226
- # tmp = curline.split(' ')
4227
- # self.dy = float(tmp[-1])
4228
- # elif 'NODATA' in curline.upper():
4229
- # tmp = curline.split(' ')
4230
- # self.nullvalue = float(tmp[-1])
4231
-
4232
- # if self.flipupd:
4233
- # self.origy -= self.dy*float(self.nby)
4234
-
4235
- # else:
4236
- # if not os.path.exists(self.filename + '.txt'):
4237
- # logging.info(_(f'File {os.path.curdir} does not exist -- Retry!'))
4238
- # return
4239
-
4240
- # with open(self.filename + '.txt', 'r') as f:
4241
- # lines = f.read().splitlines()
4242
-
4243
- # tmp = lines[0].split(':')
4244
- # self.nbx = int(tmp[1])
4245
- # tmp = lines[1].split(':')
4246
- # self.nby = int(tmp[1])
4247
- # tmp = lines[2].split(':')
4248
- # self.origx = float(tmp[1])
4249
- # tmp = lines[3].split(':')
4250
- # self.origy = float(tmp[1])
4251
- # tmp = lines[4].split(':')
4252
- # self.dx = float(tmp[1])
4253
- # tmp = lines[5].split(':')
4254
- # self.dy = float(tmp[1])
4255
- # tmp = lines[6].split(':')
4256
- # self.wolftype = int(tmp[1])
4257
- # tmp = lines[7].split(':')
4258
- # self.translx = float(tmp[1])
4259
- # tmp = lines[8].split(':')
4260
- # self.transly = float(tmp[1])
4261
-
4262
- # decal = 9
4263
- # if self.wolftype == WOLF_ARRAY_FULL_SINGLE_3D:
4264
- # self.nbdims = 3
4265
- # tmp = lines[9].split(':')
4266
- # self.nbz = int(tmp[1])
4267
- # tmp = lines[10].split(':')
4268
- # self.origz = float(tmp[1])
4269
- # tmp = lines[11].split(':')
4270
- # self.dz = float(tmp[1])
4271
- # tmp = lines[12].split(':')
4272
- # self.translz = float(tmp[1])
4273
- # decal = 13
4274
-
4275
- # if self.wolftype in WOLF_ARRAY_MB:
4276
- # tmp = lines[decal].split(':')
4277
- # nb_blocks = int(tmp[1])
4278
-
4279
- # decal += 1
4280
- # for i in range(nb_blocks):
4281
- # curhead = header_wolf()
4282
- # tmp = lines[decal].split(':')
4283
- # curhead.nbx = int(tmp[1])
4284
- # tmp = lines[decal + 1].split(':')
4285
- # curhead.nby = int(tmp[1])
4286
- # tmp = lines[decal + 2].split(':')
4287
- # curhead.origx = float(tmp[1])
4288
- # tmp = lines[decal + 3].split(':')
4289
- # curhead.origy = float(tmp[1])
4290
- # tmp = lines[decal + 4].split(':')
4291
- # curhead.dx = float(tmp[1])
4292
- # tmp = lines[decal + 5].split(':')
4293
- # curhead.dy = float(tmp[1])
4294
- # decal += 6
4295
-
4296
- # curhead.translx = self.translx + self.origx
4297
- # curhead.transly = self.transly + self.origy
4298
-
4299
- # self.head_blocks[getkeyblock(i)] = curhead
4300
-
4301
- # def write_txt_header(self):
4302
- # """ Ecriture de l'en-tête de Wolf array """
4303
- # f = open(self.filename + '.txt', 'w')
4304
- # f.write('NbX :\t{0}\n'.format(str(self.nbx)))
4305
- # f.write('NbY :\t{0}\n'.format(str(self.nby)))
4306
- # f.write('OrigX :\t{0}\n'.format(str(self.origx)))
4307
- # f.write('OrigY :\t{0}\n'.format(str(self.origy)))
4308
- # f.write('DX :\t{0}\n'.format(str(self.dx)))
4309
- # f.write('DY :\t{0}\n'.format(str(self.dy)))
4310
- # f.write('TypeEnregistrement :\t{0}\n'.format(str(self.wolftype)))
4311
- # f.write('TranslX :\t{0}\n'.format(str(self.translx)))
4312
- # f.write('TranslY :\t{0}\n'.format(str(self.transly)))
4313
- # if self.wolftype == WOLF_ARRAY_FULL_SINGLE_3D:
4314
- # f.write('NbZ :\t{0}\n'.format(str(self.nbz)))
4315
- # f.write('OrigZ :\t{0}\n'.format(str(self.origz)))
4316
- # f.write('DZ :\t{0}\n'.format(str(self.dz)))
4317
- # f.write('TranslZ :\t{0}\n'.format(str(self.translz)))
4318
-
4319
- # if self.wolftype in WOLF_ARRAY_MB:
4320
- # f.write('Nb Blocs :\t{0}\n'.format(str(self.nb_blocks)))
4321
- # for i in range(self.nb_blocks):
4322
- # curhead = self.head_blocks[getkeyblock(i)]
4323
- # f.write('NbX :\t{0}\n'.format(str(curhead.nbx)))
4324
- # f.write('NbY :\t{0}\n'.format(str(curhead.nby)))
4325
- # f.write('OrigX :\t{0}\n'.format(str(curhead.origx)))
4326
- # f.write('OrigY :\t{0}\n'.format(str(curhead.origy)))
4327
- # f.write('DX :\t{0}\n'.format(str(curhead.dx)))
4328
- # f.write('DY :\t{0}\n'.format(str(curhead.dy)))
4329
-
4330
- # f.close()
4205
+ def read_txt_header(self):
4206
+ """
4207
+ Read header from txt file
4208
+ Supercharged by WolfArray to avoid explicit call to read_txt_header with parameters
4209
+ """
4210
+
4211
+ super().read_txt_header(self.filename)
4212
+
4213
+
4214
+ def write_txt_header(self):
4215
+ """
4216
+ Write header to txt file
4217
+ Supercharged by WolfArray to avoid explicit call to write_txt_header with parameters
4218
+ """
4219
+
4220
+ super().write_txt_header(self.filename+'.txt', self.wolftype, forceupdate=True)
4331
4221
 
4332
4222
  def read_data(self):
4333
4223
  """Opération de lecture des données depuis le fichier connu"""
@@ -4513,7 +4403,10 @@ class WolfArray(Element_To_Draw, header_wolf):
4513
4403
  # as expected, then we do: self.array.mask.fill(0.0)
4514
4404
  # to avoid replacing the linked mask by a (non linked) one.
4515
4405
 
4516
- self.array.mask.fill(False) # False == not masked
4406
+ if isinstance(self.array.mask, np.bool_):
4407
+ self.array.mask = np.zeros(self.array.shape)
4408
+ else:
4409
+ self.array.mask.fill(False) # False == not masked
4517
4410
  self.nbnotnull = self.nbx * self.nby
4518
4411
  elif self.nbdims == 3:
4519
4412
  self.array.mask = np.zeros((self.nbx, self.nby, self.nbz))
@@ -4769,7 +4662,7 @@ class WolfArray(Element_To_Draw, header_wolf):
4769
4662
  if self.myops is not None:
4770
4663
  self.myops.update_palette()
4771
4664
 
4772
- def plot(self, sx=None, sy=None, xmin=None, ymin=None, xmax=None, ymax=None):
4665
+ def plot(self, sx=None, sy=None, xmin=None, ymin=None, xmax=None, ymax=None, size=None):
4773
4666
 
4774
4667
  if not self.plotted:
4775
4668
  return
@@ -5132,6 +5025,30 @@ class WolfArray(Element_To_Draw, header_wolf):
5132
5025
  ax.set_yticklabels(y_pos)
5133
5026
 
5134
5027
  return fig,ax
5028
+
5029
+ def set_array_from_numpy(self, array:np.ndarray, nullvalue:float = None):
5030
+ """
5031
+ Set array from numpy array
5032
+ """
5033
+ if array.shape != (self.nbx, self.nby):
5034
+ logging.warning(f"Array shape {array.shape} is not compatible with WolfArray shape {self.nbx, self.nby}")
5035
+ return
5036
+
5037
+ def wolftype_from_npz(curarray:np.ndarray):
5038
+ if curarray.dtype == np.float64:
5039
+ return WOLF_ARRAY_FULL_DOUBLE
5040
+ elif curarray.dtype == np.float32:
5041
+ return WOLF_ARRAY_FULL_SINGLE
5042
+ elif curarray.dtype == np.int32:
5043
+ return WOLF_ARRAY_FULL_INTEGER
5044
+
5045
+ self.array = np.ma.array(array.copy())
5046
+ self.wolftype = wolftype_from_npz(array)
5047
+
5048
+ if nullvalue is not None:
5049
+ self.nullvalue = nullvalue
5050
+ self.mask_data(self.nullvalue)
5051
+ self.reset_plot()
5135
5052
  class WolfArrayMB(WolfArray):
5136
5053
  """
5137
5054
  Matrice multiblocks
@@ -5819,16 +5736,16 @@ class WolfArrayMNAP(WolfArrayMB):
5819
5736
  curhead.translx = curarray.translx
5820
5737
  curhead.transly = curarray.transly
5821
5738
 
5822
- def read_txt_header(self, filename:str):
5739
+ def read_txt_header(self):
5823
5740
 
5824
- if os.path.exists(filename + '.trl'):
5825
- with open(filename + '.trl') as f:
5741
+ if os.path.exists(self.filename + '.trl'):
5742
+ with open(self.filename + '.trl') as f:
5826
5743
  lines = f.read().splitlines()
5827
5744
  self.translx = float(lines[1])
5828
5745
  self.transly = float(lines[2])
5829
5746
 
5830
- if os.path.exists(filename + '.par'):
5831
- with open(filename + '.par') as f:
5747
+ if os.path.exists(self.filename + '.par'):
5748
+ with open(self.filename + '.par') as f:
5832
5749
  lines = f.read().splitlines()
5833
5750
  self.dx = float(lines[7])
5834
5751
  self.dy = float(lines[8])
@@ -5886,7 +5803,7 @@ class WolfArray_Sim2D(WolfArray):
5886
5803
  if not os.path.exists(self.filename):
5887
5804
  return
5888
5805
 
5889
- self.read_txt_header(self.filename)
5806
+ self.read_txt_header()
5890
5807
  self.filename = fileold
5891
5808
  self.read_data()
5892
5809
  else:
wolfhece/wolf_texture.py CHANGED
@@ -18,17 +18,14 @@ import numpy as np
18
18
  from .PyTranslate import _
19
19
  from .PyWMS import getIGNFrance, getWalonmap
20
20
  from .textpillow import Font_Priority, Text_Image,Text_Infos
21
+ from .drawing_obj import Element_To_Draw
21
22
 
22
- class genericImagetexture():
23
+ class genericImagetexture(Element_To_Draw):
23
24
  """
24
25
  Affichage d'une image en OpenGL via une texture
25
26
  """
26
27
  name: str
27
28
  idtexture: int
28
- xmin: float
29
- xmax: float
30
- ymin: float
31
- ymax: float
32
29
 
33
30
  width: int
34
31
  height: int
@@ -40,8 +37,12 @@ class genericImagetexture():
40
37
  def __init__(self, which: str, label: str, mapviewer, xmin, xmax, ymin, ymax, imageFile="",
41
38
  imageObj=None) -> None:
42
39
 
43
- mapviewer.canvas.SetCurrent(mapviewer.context)
44
- self.mapviewer = mapviewer
40
+ super().__init__(label, True, mapviewer, False)
41
+
42
+ try:
43
+ self.mapviewer.canvas.SetCurrent(mapviewer.context)
44
+ except:
45
+ logging.error(_('Opengl setcurrent -- Do you have a active canvas ?'))
45
46
 
46
47
  self.xmin = xmin
47
48
  self.xmax = xmax
@@ -53,6 +54,7 @@ class genericImagetexture():
53
54
  except:
54
55
  raise NameError(
55
56
  'Opengl glGenTextures -- maybe a conflict with an existing opengl32.dll file - please rename the opengl32.dll in the libs directory and retry')
57
+
56
58
  self.which = which.lower()
57
59
  self.name = label
58
60
  self.imageFile = imageFile
@@ -133,6 +135,17 @@ class genericImagetexture():
133
135
  self.load()
134
136
  self.oldview = self.newview
135
137
 
138
+ def plot(self, sx=None, sy=None, xmin=None, ymin=None, xmax=None, ymax=None, size=None):
139
+ """ alias for paint"""
140
+ self.paint()
141
+
142
+ def find_minmax(self,update=False):
143
+ """
144
+ Generic function to find min and max spatial extent in data
145
+ """
146
+ # Nothing to do, set during initialization phase
147
+ pass
148
+
136
149
  def paint(self):
137
150
 
138
151
  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
@@ -160,17 +173,13 @@ class genericImagetexture():
160
173
  glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)
161
174
 
162
175
 
163
- class imagetexture():
176
+ class imagetexture(Element_To_Draw):
164
177
  """
165
178
  Affichage d'une image, obtenue depuis un Web service, en OpenGL via une texture
166
179
  """
167
180
 
168
181
  name: str
169
182
  idtexture: int
170
- xmin: float
171
- xmax: float
172
- ymin: float
173
- ymax: float
174
183
 
175
184
  width: int
176
185
  height: int
@@ -185,13 +194,16 @@ class imagetexture():
185
194
  def __init__(self, which: str, label: str, cat: str, subc: str, mapviewer, xmin, xmax, ymin, ymax, width=1000,
186
195
  height=1000, France=False, epsg='31370') -> None:
187
196
 
188
- mapviewer.canvas.SetCurrent(mapviewer.context)
189
- self.mapviewer = mapviewer
197
+ super().__init__(label+cat+subc, plotted=False, mapviewer=mapviewer, need_for_wx=False)
198
+
199
+ try:
200
+ mapviewer.canvas.SetCurrent(mapviewer.context)
201
+ except:
202
+ logging.error(_('Opengl setcurrent -- Do you have a active canvas ?'))
203
+
190
204
  self.France = France
191
205
  self.epsg = epsg
192
206
 
193
- self.plotted = False
194
-
195
207
  self.xmin = xmin
196
208
  self.xmax = xmax
197
209
  self.ymin = ymin
@@ -267,6 +279,17 @@ class imagetexture():
267
279
  self.load()
268
280
  self.oldview = self.newview
269
281
 
282
+ def plot(self, sx=None, sy=None, xmin=None, ymin=None, xmax=None, ymax=None, size=None):
283
+ """ alias for paint"""
284
+ self.paint()
285
+
286
+ def find_minmax(self,update=False):
287
+ """
288
+ Generic function to find min and max spatial extent in data
289
+ """
290
+ # Nothing to do, set during initialization phase
291
+ pass
292
+
270
293
  def paint(self):
271
294
 
272
295
  glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)
@@ -3366,7 +3366,7 @@ class Wolfresults_2D(Element_To_Draw):
3366
3366
  curblock.set_linkedvec(self.linkedvec)
3367
3367
  curblock.set_epsilon(self.epsilon)
3368
3368
 
3369
- def plot(self, sx=None, sy=None,xmin=None,ymin=None,xmax=None,ymax=None):
3369
+ def plot(self, sx=None, sy=None,xmin=None,ymin=None,xmax=None,ymax=None, size=None):
3370
3370
  """Dessin OpenGL"""
3371
3371
  self.mimic_plotdata(True)
3372
3372