wolfhece 2.0.17__py3-none-any.whl → 2.0.19__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 (42) hide show
  1. wolfhece/CpGrid.py +10 -13
  2. wolfhece/PyCrosssections.py +18 -13
  3. wolfhece/PyDraw.py +80 -8
  4. wolfhece/PyHydrographs.py +2 -2
  5. wolfhece/PyParams.py +113 -35
  6. wolfhece/PyPictures.py +48 -45
  7. wolfhece/PyVertex.py +149 -18
  8. wolfhece/PyVertexvectors.py +40 -33
  9. wolfhece/apps/curvedigitizer.py +4 -1
  10. wolfhece/apps/wolfcompare2Darrays.py +11 -7
  11. wolfhece/clientserver/clientserver.py +62 -0
  12. wolfhece/friction_law.py +39 -34
  13. wolfhece/ftp/downloader.py +8 -7
  14. wolfhece/gpuview.py +14 -13
  15. wolfhece/hydrology/Catchment.py +2 -2
  16. wolfhece/hydrology/PyWatershed.py +2 -2
  17. wolfhece/hydrology/SubBasin.py +13 -11
  18. wolfhece/hydrometry/kiwis_gui.py +9 -9
  19. wolfhece/irm_qdf.py +12 -10
  20. wolfhece/lazviewer/laz_viewer.py +4 -1
  21. wolfhece/mar/Interface_MAR_WOLF_objet.py +260 -161
  22. wolfhece/opengl/py3d.py +4 -4
  23. wolfhece/pyshields.py +4 -4
  24. wolfhece/pythonfortran/example_makendarray.py +46 -41
  25. wolfhece/pythonfortran/example_numpy_memory.py +87 -83
  26. wolfhece/pythonfortran/tools.py +1 -1
  27. wolfhece/scenario/imposebc_void.py +2 -3
  28. wolfhece/scenario/update_void.py +6 -6
  29. wolfhece/wolf_array.py +47 -18
  30. wolfhece/wolfresults_2D.py +2 -4
  31. {wolfhece-2.0.17.dist-info → wolfhece-2.0.19.dist-info}/METADATA +7 -1
  32. {wolfhece-2.0.17.dist-info → wolfhece-2.0.19.dist-info}/RECORD +36 -41
  33. wolfhece/apps/wolfBernoulli.py +0 -18
  34. wolfhece/bernoulli/ModelJockgrim.py +0 -226
  35. wolfhece/bernoulli/NetworkOpenGL.py +0 -6461
  36. wolfhece/bernoulli/ReadNeupotzData.py +0 -223
  37. wolfhece/bernoulli/opti_results_interactive_plot.py +0 -212
  38. wolfhece/debug.py +0 -8
  39. /wolfhece/{bernoulli → clientserver}/__init__.py +0 -0
  40. {wolfhece-2.0.17.dist-info → wolfhece-2.0.19.dist-info}/WHEEL +0 -0
  41. {wolfhece-2.0.17.dist-info → wolfhece-2.0.19.dist-info}/entry_points.txt +0 -0
  42. {wolfhece-2.0.17.dist-info → wolfhece-2.0.19.dist-info}/top_level.txt +0 -0
wolfhece/PyPictures.py CHANGED
@@ -19,48 +19,51 @@ class Picture(wx.Frame):
19
19
  def __init__(self, *args, **kw):
20
20
  super().__init__(*args, **kw)
21
21
 
22
-
23
- # Spatial Reference System
24
- inputEPSG = 4326 #WGS84
25
- outputEPSG = 31370 #Lambert72
26
-
27
- # create coordinate transformation
28
- inSpatialRef = osr.SpatialReference()
29
- inSpatialRef.ImportFromEPSG(inputEPSG)
30
-
31
- outSpatialRef = osr.SpatialReference()
32
- outSpatialRef.ImportFromEPSG(outputEPSG)
33
-
34
- coordTransform = osr.CoordinateTransformation(inSpatialRef, outSpatialRef)
35
-
36
- dir = path.normpath(r'D:\OneDrive\OneDrive - Universite de Liege\Crues\2021-07 Vesdre\CSC - Convention - ARNE\3 noeuds critiques\tronçon 34')
37
-
38
- for curfile in listdir(dir):
39
- filename,fileextent = path.splitext(curfile)
40
- if fileextent.lower()=='.jpg':
41
- img = Image(path.join(dir,curfile))
42
-
43
- if img.get('Lambert72X'):
44
- x = img.get('Lambert72X')
45
- y = img.get('Lambert72Y')
46
-
47
- elif img.get('gps_latitude'):
48
- lat=img.gps_latitude
49
- lon=img.gps_longitude
50
- alt=img.gps_altitude
51
-
52
- # create a geometry from coordinates
53
- point = ogr.Geometry(ogr.wkbPoint)
54
- if len(lat)==3:
55
- lat = lat[0]+lat[1]/60+lat[2]/(60*60)
56
- lon = lon[0]+lon[1]/60+lon[2]/(60*60)
57
- point.AddPoint(lat, lon)
58
- # transform point
59
- point.Transform(coordTransform)
60
- # print point in EPSG 31370
61
- print(point.GetX(), point.GetY())
62
- img.set('Lambert72X',point.GetX())
63
- img.set('Lambert72Y',point.GetY())
64
-
65
- with open(path.join(dir,'modified_image.jpg'), 'wb') as new_image_file:
66
- new_image_file.write(img.get_file())
22
+ def main():
23
+ # Spatial Reference System
24
+ inputEPSG = 4326 #WGS84
25
+ outputEPSG = 31370 #Lambert72
26
+
27
+ # create coordinate transformation
28
+ inSpatialRef = osr.SpatialReference()
29
+ inSpatialRef.ImportFromEPSG(inputEPSG)
30
+
31
+ outSpatialRef = osr.SpatialReference()
32
+ outSpatialRef.ImportFromEPSG(outputEPSG)
33
+
34
+ coordTransform = osr.CoordinateTransformation(inSpatialRef, outSpatialRef)
35
+
36
+ dir = path.normpath(r'D:\OneDrive\OneDrive - Universite de Liege\Crues\2021-07 Vesdre\CSC - Convention - ARNE\3 noeuds critiques\tronçon 34')
37
+
38
+ for curfile in listdir(dir):
39
+ filename,fileextent = path.splitext(curfile)
40
+ if fileextent.lower()=='.jpg':
41
+ img = Image(path.join(dir,curfile))
42
+
43
+ if img.get('Lambert72X'):
44
+ x = img.get('Lambert72X')
45
+ y = img.get('Lambert72Y')
46
+
47
+ elif img.get('gps_latitude'):
48
+ lat=img.gps_latitude
49
+ lon=img.gps_longitude
50
+ alt=img.gps_altitude
51
+
52
+ # create a geometry from coordinates
53
+ point = ogr.Geometry(ogr.wkbPoint)
54
+ if len(lat)==3:
55
+ lat = lat[0]+lat[1]/60+lat[2]/(60*60)
56
+ lon = lon[0]+lon[1]/60+lon[2]/(60*60)
57
+ point.AddPoint(lat, lon)
58
+ # transform point
59
+ point.Transform(coordTransform)
60
+ # print point in EPSG 31370
61
+ print(point.GetX(), point.GetY())
62
+ img.set('Lambert72X',point.GetX())
63
+ img.set('Lambert72Y',point.GetY())
64
+
65
+ with open(path.join(dir,'modified_image.jpg'), 'wb') as new_image_file:
66
+ new_image_file.write(img.get_file())
67
+
68
+ if __name__ == '__main__':
69
+ main()
wolfhece/PyVertex.py CHANGED
@@ -9,12 +9,13 @@ except:
9
9
  raise Exception(msg)
10
10
 
11
11
  import math
12
- from shapely.geometry import Point, LineString
12
+ from shapely.geometry import Point, LineString, MultiPoint
13
13
  from os.path import exists
14
14
  import wx
15
15
  import re
16
16
  import logging
17
17
  from scipy.spatial import KDTree
18
+ from pathlib import Path
18
19
 
19
20
  from .PyParams import Wolf_Param, key_Param, Type_Param
20
21
  from .PyTranslate import _
@@ -121,6 +122,10 @@ class wolfvertex:
121
122
  self.y = min(self.y, bounds[1][1])
122
123
 
123
124
  class cloudproperties:
125
+ """
126
+ Properties of a cloud of vertices
127
+
128
+ """
124
129
  used: bool
125
130
 
126
131
  color: int
@@ -148,7 +153,7 @@ class cloudproperties:
148
153
 
149
154
  myprops: Wolf_Param = None
150
155
 
151
- def __init__(self, lines=[], parent=None) -> None:
156
+ def __init__(self, lines=[], parent:"cloud_vertices"=None) -> None:
152
157
 
153
158
  self.parent = parent
154
159
 
@@ -251,8 +256,10 @@ class cloudproperties:
251
256
  if 'Draw' in curdict.keys():
252
257
  keysactive = curdict['Draw'].keys()
253
258
  if 'Color' in keysactive:
254
- self.color = getIfromRGB(
255
- curdict['Draw']['Color'][key_Param.VALUE].replace('(', '').replace(')', '').split(', '))
259
+ if isinstance(curdict['Draw']['Color'][key_Param.VALUE], str):
260
+ self.color = getIfromRGB(curdict['Draw']['Color'][key_Param.VALUE].replace('(', '').replace(')', '').split(', '))
261
+ elif isinstance(curdict['Draw']['Color'][key_Param.VALUE], tuple):
262
+ self.color = getIfromRGB(curdict['Draw']['Color'][key_Param.VALUE])
256
263
  if 'Width' in keysactive:
257
264
  self.width = int(curdict['Draw']['Width'][key_Param.VALUE])
258
265
  if 'Style' in keysactive:
@@ -277,8 +284,10 @@ class cloudproperties:
277
284
  if 'Font size' in keysactive:
278
285
  self.legendfontsize = int(curdict['Legend']['Font size'][key_Param.VALUE])
279
286
  if 'Color' in keysactive:
280
- self.legendcolor = getIfromRGB(
281
- curdict['Legend']['Color'][key_Param.VALUE].replace('(', '').replace(')', '').split(', '))
287
+ if isinstance(curdict['Legend']['Color'][key_Param.VALUE], str):
288
+ self.legendcolor = getIfromRGB(curdict['Draw']['Color'][key_Param.VALUE].replace('(', '').replace(')', '').split(', '))
289
+ elif isinstance(curdict['Legend']['Color'][key_Param.VALUE], tuple):
290
+ self.v = getIfromRGB(curdict['Draw']['Color'][key_Param.VALUE])
282
291
  if 'Italic' in keysactive:
283
292
  self.legenditalic = bool(curdict['Legend']['Italic'][key_Param.VALUE])
284
293
  if 'relative Position' in keysactive:
@@ -294,9 +303,17 @@ class cloudproperties:
294
303
 
295
304
  self.parent.forceupdategl = True
296
305
 
306
+ if self.parent.mapviewer is not None:
307
+ self.parent.mapviewer.Refresh()
308
+
297
309
  def defaultprop(self):
310
+ """
311
+ Default properties
312
+
313
+ """
298
314
  if self.myprops is None:
299
- self.myprops = Wolf_Param(title='Cloud Properties', to_read=False)
315
+ self.myprops = Wolf_Param(title='Cloud Properties', to_read=False, force_even_if_same_default=True)
316
+ self.myprops.hide_selected_buttons()
300
317
  self.myprops._callbackdestroy = self.destroyprop
301
318
  self.myprops._callback = self.fill_property
302
319
  self.myprops.saveme.Disable()
@@ -383,7 +400,7 @@ class cloud_vertices(Element_To_Draw):
383
400
 
384
401
  """
385
402
  filename: str
386
- myvertices: dict
403
+ myvertices: dict[int, dict['vertex':wolfvertex, str:float]]
387
404
 
388
405
  xbounds: tuple
389
406
  ybounds: tuple
@@ -392,7 +409,28 @@ class cloud_vertices(Element_To_Draw):
392
409
  myprop: cloudproperties
393
410
  mytree : KDTree
394
411
 
395
- def __init__(self, fname: str = '', fromxls: str = '', header: bool = False, toload=True, idx: str = '', plotted: bool = True, mapviewer=None, need_for_wx: bool = False) -> None:
412
+ def __init__(self,
413
+ fname: str = '',
414
+ fromxls: str = '',
415
+ header: bool = False,
416
+ toload=True,
417
+ idx: str = '',
418
+ plotted: bool = True,
419
+ mapviewer=None,
420
+ need_for_wx: bool = False) -> None:
421
+ """
422
+ Init cloud of vertices
423
+
424
+ :param fname: file name
425
+ :param fromxls: string read from xls file and to be parsed
426
+ :param header: header in file (first line with column names)
427
+ :param toload: load file at init
428
+ :param idx: identifier -- see Element_To_Draw
429
+ :param plotted: plot at init -- see Element_To_Draw
430
+ :param mapviewer: mapviewer -- see Element_To_Draw
431
+ :param need_for_wx: see Element_To_Draw
432
+ """
433
+
396
434
  super().__init__(idx, plotted, mapviewer, need_for_wx)
397
435
 
398
436
  self.myvertices = {}
@@ -416,8 +454,11 @@ class cloud_vertices(Element_To_Draw):
416
454
 
417
455
  if fname != '':
418
456
  if toload:
419
- if fname[-4:].lower()=='.dxf':
457
+ if Path(fname).suffix.lower() == '.dxf':
458
+ # if fname[-4:].lower()=='.dxf':
420
459
  self.import_from_dxf(fname)
460
+ elif Path(fname).suffix.lower() == '.shp':
461
+ self.import_shapefile(fname)
421
462
  else:
422
463
  self.readfile(fname, header)
423
464
 
@@ -592,7 +633,14 @@ class cloud_vertices(Element_To_Draw):
592
633
  self.loaded = True
593
634
 
594
635
  def import_from_dxf(self,fn=''):
636
+ """
637
+ Importing DXF file using ezdxf library
638
+
639
+ :param fn: file name
640
+
641
+ """
595
642
  if fn == '' or not exists(fn):
643
+ logging.error(_('File not found : ')+fn)
596
644
  return
597
645
 
598
646
  import ezdxf
@@ -622,6 +670,57 @@ class cloud_vertices(Element_To_Draw):
622
670
 
623
671
  return k
624
672
 
673
+ def import_shapefile(self, fn='', targetcolumn:str = 'X1_Y1_Z1'):
674
+ """
675
+ Importing Shapefile using geopandas library
676
+
677
+ :param fn: file name
678
+ :param targetcolumn: column name to be used for XYZ coordinates -- 'X1_Y1_Z1' is used by SPW-ARNE-DCENN
679
+
680
+ """
681
+
682
+ if fn == '' or not exists(fn):
683
+ logging.error(_('File not found : ')+fn)
684
+ return
685
+
686
+ import geopandas as gpd
687
+
688
+ # read data
689
+ gdf = gpd.read_file(fn)
690
+
691
+ # Bouclage sur les éléments du Shapefile
692
+ if not targetcolumn in gdf.columns:
693
+
694
+ if self.wx_exists:
695
+
696
+ dlg = wx.SingleChoiceDialog(None, _('Choose the column to be used for XYZ coordinates'), _('Column choice'), gdf.columns)
697
+ if dlg.ShowModal() == wx.ID_OK:
698
+ targetcolumn = dlg.GetStringSelection()
699
+ dlg.Destroy()
700
+ else:
701
+ dlg.Destroy()
702
+ return
703
+
704
+ k=0
705
+ for index, row in gdf.iterrows():
706
+ x, y, z = row[targetcolumn].split(',')
707
+ x = float(x)
708
+ y = float(y)
709
+ z = float(z)
710
+
711
+ curvert = wolfvertex(x, y, z)
712
+ curdict = self.myvertices[k] = {}
713
+ curdict['vertex'] = curvert
714
+ k += 1
715
+
716
+ self.find_minmax(True)
717
+ self.loaded = True
718
+
719
+ logging.info(_('Number of imported points : ')+str(k))
720
+
721
+ return k
722
+
723
+
625
724
  def add_vertex(self, vertextoadd: wolfvertex = None, id=None, cloud: dict = None):
626
725
  if vertextoadd is not None:
627
726
  curid = id
@@ -639,6 +738,7 @@ class cloud_vertices(Element_To_Draw):
639
738
  pass
640
739
 
641
740
  def plot(self, update=False, *args, **kwargs):
741
+ """ OpenGL plot of the cloud of vertices """
642
742
 
643
743
  if update or self.gllist == 0 or self.forceupdategl and not self.ongoing:
644
744
  curvert: wolfvertex
@@ -790,21 +890,48 @@ class cloud_vertices(Element_To_Draw):
790
890
  xyz = self.get_xyz(key)
791
891
  myarray.interpolate_on_cloud(xyz[:,:2],xyz[:,2],method)
792
892
 
793
- def projectontrace(self, trace):
893
+ def iter_on_vertices(self):
894
+ """ Iteration on vertices """
895
+ for cur in self.myvertices.values():
896
+ yield cur['vertex']
897
+
898
+ def get_multipoint(self):
899
+ return MultiPoint([cur.as_shapelypoint() for cur in self.iter_on_vertices()])
900
+
901
+ def projectontrace(self, trace, return_cloud:bool = True, proximity:float = 99999.):
794
902
  """
795
903
  Projection du nuage sur une trace (type 'vector')
796
904
 
905
+ :param trace: classe vector
906
+ :param proximity: distance de recherche pour la projection
907
+
797
908
  Return :
798
- Nouveau nuage contenant les infos de position sur la trace et d'altitude (s,z)
909
+ if return_cloud:
910
+ Nouveau nuage contenant les infos de position sur la trace et d'altitude (s,z)
911
+ else:
912
+ s,z : list[float], list[float]
799
913
  """
914
+
800
915
  # trace:vector
801
916
  tracels:LineString
802
917
  tracels = trace.asshapely_ls() # conversion en linestring Shapely
803
918
 
804
- all_s = [tracels.project(Point(cur['vertex'].x,cur['vertex'].y)) for cur in self.myvertices.values()] # Projection des points sur la trace et récupération de la coordonnées curviligne
805
- all_z = [cur['vertex'].z for cur in self.myvertices.values()]
806
- # création d'un nouveau nuage
807
- newcloud = cloud_vertices(idx=_('Projection on ')+trace.myname)
919
+ if proximity == 99999.:
920
+ # on garde tous les points
921
+
922
+ all_s = [tracels.project(Point(cur['vertex'].x,cur['vertex'].y)) for cur in self.myvertices.values()] # Projection des points sur la trace et récupération de la coordonnées curviligne
923
+ all_z = [cur['vertex'].z for cur in self.myvertices.values()]
924
+
925
+ else:
926
+
927
+ buffer = tracels.buffer(proximity) # buffer de la trace
928
+
929
+ multipoints = self.get_multipoint() # conversion en multipoint Shapely
930
+
931
+ mp = multipoints.intersection(buffer) # intersection avec le buffer
932
+
933
+ all_s = [tracels.project(Point(cur.x,cur.y)) for cur in mp.geoms] # Projection des points sur la trace et récupération de la coordonnées curviligne
934
+ all_z = [cur.z for cur in mp.geoms] # récupération de l'altitude
808
935
 
809
936
  new_dict = {}
810
937
  k=0
@@ -812,6 +939,10 @@ class cloud_vertices(Element_To_Draw):
812
939
  new_dict[k] = {'vertex':wolfvertex(s,z)}
813
940
  k+=1
814
941
 
815
- newcloud.add_vertex(cloud=new_dict)
942
+ if return_cloud:
943
+ newcloud = cloud_vertices(idx=_('Projection on ')+trace.myname)
944
+ newcloud.add_vertex(cloud=new_dict)
816
945
 
817
- return newcloud
946
+ return newcloud
947
+ else:
948
+ return all_s, all_z
@@ -311,7 +311,7 @@ class Triangulation(Element_To_Draw):
311
311
 
312
312
  self.id_list = -99999
313
313
 
314
- def plot(self):
314
+ def plot(self, sx=None, sy=None, xmin=None, ymin=None, xmax=None, ymax=None, size=None ):
315
315
 
316
316
  if self.id_list == -99999:
317
317
  self.id_list = glGenLists(1)
@@ -341,10 +341,10 @@ class Triangulation(Element_To_Draw):
341
341
  def find_minmax(self,force):
342
342
  if force:
343
343
  if self.nb_pts>0:
344
- self.minx=np.min(self.pts[:,0])
345
- self.miny=np.min(self.pts[:,1])
346
- self.maxx=np.max(self.pts[:,0])
347
- self.maxy=np.max(self.pts[:,1])
344
+ self.xmin=np.min(self.pts[:,0])
345
+ self.ymin=np.min(self.pts[:,1])
346
+ self.xmax=np.max(self.pts[:,0])
347
+ self.ymax=np.max(self.pts[:,1])
348
348
 
349
349
  def import_dxf(self,fn):
350
350
  import ezdxf
@@ -2268,8 +2268,8 @@ class zone:
2268
2268
  Création d'une triangulation sur base des vecteurs
2269
2269
  Tient compte de l'ordre
2270
2270
 
2271
- nb : nombre de points de découpe des vecteurs
2272
- nb2 : nombre de points en perpendiculaire
2271
+ :param nb : nombre de points de découpe des vecteurs
2272
+ :param nb2 : nombre de points en perpendiculaire
2273
2273
 
2274
2274
  return :
2275
2275
  - instance de 'Triangulation'
@@ -2284,8 +2284,14 @@ class zone:
2284
2284
  myls.append(curv.asshapely_ls())
2285
2285
 
2286
2286
  if nb is None and wx_exists:
2287
- dlg=wx.NumberEntryDialog(None,_('How many points along polylines ?')+'\n'+
2288
- _('Length size is {} meters').format(myls[0].length),'nb','dl size',100,1,10000.)
2287
+ dlg=wx.NumberEntryDialog(None,
2288
+ _('How many points along polylines ?')+'\n'+
2289
+ _('Length size is {} meters').format(myls[0].length),
2290
+ 'nb',
2291
+ 'dl size',
2292
+ 100,
2293
+ 1,
2294
+ 10000)
2289
2295
  ret=dlg.ShowModal()
2290
2296
  if ret==wx.ID_CANCEL:
2291
2297
  dlg.Destroy()
@@ -2304,7 +2310,13 @@ class zone:
2304
2310
  newls.append(LineString([curls.interpolate(curs,True) for curs in s]))
2305
2311
 
2306
2312
  if nb2==0 and wx_exists:
2307
- dlg=wx.NumberEntryDialog(None,_('How many points between two polylines ?'), 'nb2','perpendicular',0,1,10000.)
2313
+ dlg=wx.NumberEntryDialog(None,
2314
+ _('How many points between two polylines ?'),
2315
+ 'nb2',
2316
+ 'perpendicular',
2317
+ 0,
2318
+ 1,
2319
+ 10000)
2308
2320
  ret=dlg.ShowModal()
2309
2321
  if ret==wx.ID_CANCEL:
2310
2322
  dlg.Destroy()
@@ -2370,8 +2382,8 @@ class zone:
2370
2382
  Création d'une triangulation sur base des vecteurs par projection au plus proche du veteur central
2371
2383
  Tient compte de l'ordre
2372
2384
 
2373
- nb : nombre de points de découpe des vecteurs
2374
- nb2 : nombre de points en perpendiculaire
2385
+ :param nb : nombre de points de découpe des vecteurs
2386
+ :param nb2 : nombre de points en perpendiculaire
2375
2387
 
2376
2388
  return :
2377
2389
  - instance de 'Triangulation'
@@ -2387,7 +2399,7 @@ class zone:
2387
2399
 
2388
2400
  if nb is None and wx_exists:
2389
2401
  dlg=wx.NumberEntryDialog(None,_('How many points along polylines ?')+'\n'+
2390
- _('Length size is {} meters').format(myls[0].length),'nb','dl size',100,1,10000.)
2402
+ _('Length size is {} meters').format(myls[0].length),'nb','dl size',100,1,10000)
2391
2403
  ret=dlg.ShowModal()
2392
2404
  if ret==wx.ID_CANCEL:
2393
2405
  dlg.Destroy()
@@ -2411,7 +2423,7 @@ class zone:
2411
2423
  newls.append(LineString([curls.interpolate(curs) for curs in news]))
2412
2424
 
2413
2425
  if nb2==0 and wx_exists:
2414
- dlg=wx.NumberEntryDialog(None,_('How many points between two polylines ?'), 'nb2','perpendicular',0,0,10000.)
2426
+ dlg=wx.NumberEntryDialog(None,_('How many points between two polylines ?'), 'nb2','perpendicular',0,0,10000)
2415
2427
  ret=dlg.ShowModal()
2416
2428
  if ret==wx.ID_CANCEL:
2417
2429
  dlg.Destroy()
@@ -2928,12 +2940,10 @@ class zone:
2928
2940
 
2929
2941
  Retourne un dictionnaire contenant les valeurs pour chaque polygone
2930
2942
 
2931
- *****
2932
2943
  ATTENTION :
2933
2944
  Il est possible de choisir comme clé soit l'index du vecteur dans la zone, soit non nom
2934
2945
  Si le nom est choisi, cela peut aboutir à une perte d'information car il n'y a pas de certitude que les noms de vecteur soient uniques
2935
2946
  --> il est nécessaire que l'utilisateur soit conscient de cette possibilité
2936
- *****
2937
2947
 
2938
2948
  Les valeurs de chaque entrée du dict peuvent contenir une ou plusieurs listes en fonction du retour de la fonction de l'objet matriciel appelé
2939
2949
  """
@@ -3006,15 +3016,13 @@ class zone:
3006
3016
  def plot_linked_polygons(self, fig, ax, linked_arrays:dict, linked_vec:dict=None, linestyle='-', onlymedian=False, withtopography = True, ds:float = None):
3007
3017
  """
3008
3018
  Création d'un graphique sur base des polygones
3019
+
3009
3020
  Chaque polygone se positionnera sur base de la valeur Z de ses vertices
3010
- --> façon conventionnelle de définir une longueur
3011
- --> ceci est normalement fait lors de l'appel à 'create_polygon_from_parallel'
3012
- --> si les polygones sont créés manuellement, il faut donc prendre soin de fournir l'information adhoc ou alors utiliser l'rgument 'ds'
3021
+ - façon conventionnelle de définir une longueur
3022
+ - ceci est normalement fait lors de l'appel à 'create_polygon_from_parallel'
3023
+ - si les polygones sont créés manuellement, il faut donc prendre soin de fournir l'information adhoc ou alors utiliser l'rgument 'ds'
3013
3024
 
3014
- ***
3015
- ATTENTION :
3016
- Les coordonnées Z ne sont sauvegardées sur disque que si le fichier est 3D, autrement dit au format '.vecz'
3017
- ***
3025
+ ATTENTION : Les coordonnées Z ne sont sauvegardées sur disque que si le fichier est 3D, autrement dit au format '.vecz'
3018
3026
 
3019
3027
  """
3020
3028
  colors=['red','blue','green','darkviolet','fuchsia','lime']
@@ -3202,19 +3210,18 @@ class Zones(wx.Frame, Element_To_Draw):
3202
3210
  def __init__(self, filename='', ox:float=0., oy:float=0., tx:float=0., ty:float=0., parent=None, is2D=True, idx: str = '', plotted: bool = True, mapviewer=None, need_for_wx: bool = False) -> None:
3203
3211
  """
3204
3212
  parent : soit une instance 'WolfMapViewer', soit une instance 'Ops_Array'
3205
- --> est utile pour transférer la propriété 'active_vector'
3206
- et obtenir diverses informations ou lancer des actions
3213
+ --> est utile pour transférer la propriété 'active_vector' et obtenir diverses informations ou lancer des actions
3207
3214
 
3208
- wx_exists : si True --> permet l'affichage de la structure via WX car une app WX existe
3209
- et est en cours d'exécution
3215
+ wx_exists : si True --> permet l'affichage de la structure via WX car une app WX existe et est en cours d'exécution
3210
3216
 
3211
3217
  Si wx_exists alors on cherche une instance WolfMapViewer depuis le 'parent' --> set_mapviewer()
3212
3218
  Dans ce cas, le parent doit posséder une routine du type 'get_mapviewer()'
3213
3219
 
3214
3220
  Exemple :
3215
- def get_mapviewer(self):
3216
- # Retourne une instance WolfMapViewer
3217
- return self.mapviewer
3221
+
3222
+ def get_mapviewer(self):
3223
+ # Retourne une instance WolfMapViewer
3224
+ return self.mapviewer
3218
3225
  """
3219
3226
 
3220
3227
  Element_To_Draw.__init__(self, idx, plotted, mapviewer, need_for_wx)
@@ -4220,9 +4227,9 @@ class Zones(wx.Frame, Element_To_Draw):
4220
4227
  """
4221
4228
  Récupération des valeurs sous toutes les matrices liées pour le vecteur actif
4222
4229
 
4223
- Crée une nouvelle zone contenant une copie du vecteur
4224
- Le nombre de vertices est adapté pour correspondre au mieux à la matrice de liée
4225
- et ne pas perdre, si possible, d'information
4230
+ Crée une nouvelle zone contenant une copie du vecteur.
4231
+
4232
+ Le nombre de vertices est adapté pour correspondre au mieux à la matrice de liée et ne pas perdre, si possible, d'information.
4226
4233
  """
4227
4234
  if self.parent is not None:
4228
4235
  if self.verify_activevec():
@@ -11,6 +11,7 @@ import matplotlib.image as mpimg
11
11
  def main():
12
12
  """
13
13
  Main function of curve digitizer
14
+
14
15
  """
15
16
  plt.ion()
16
17
  ex = wx.App()
@@ -110,7 +111,9 @@ def getReferenceLength(index):
110
111
  Get the reference length in the requested direction
111
112
 
112
113
  USAGE: factor = getReferenceLength(index)
113
- index = 0 for x-direction or 1 for y-direction
114
+
115
+ :param index : 0 for x-direction or 1 for y-direction
116
+
114
117
  """
115
118
 
116
119
  # define a 'direction' string
@@ -16,10 +16,11 @@ except:
16
16
  from wolfhece.wolf_array import WolfArray
17
17
 
18
18
  def main(mydir:Path=None, ListArrays:list[WolfArray]=None):
19
- """Comparaison de 2 cartes WOLF
20
- args :
21
- - mydir : répertoire contenant 2 matrices WOLF (ref.bin et comp.bin) et leurs fichiers accompagant
22
- - ListArrays : liste de 2 objets WolfArray
19
+ """
20
+ Comparaison de 2 cartes WOLF
21
+
22
+ :param mydir : répertoire contenant 2 matrices WOLF (ref.bin et comp.bin) et leurs fichiers accompagant
23
+ :param ListArrays : liste de 2 objets WolfArray
23
24
  """
24
25
  if mydir is not None:
25
26
  assert isinstance(mydir,Path), _('mydir must be a Path object')
@@ -32,7 +33,7 @@ def main(mydir:Path=None, ListArrays:list[WolfArray]=None):
32
33
  assert isinstance(ListArrays,list), _('ListArrays must be a list')
33
34
  assert len(ListArrays)==2, _('ListArrays must contain 2 WolfArray objects')
34
35
  assert isinstance(ListArrays[0],WolfArray), _('ListArrays must contain 2 WolfArray objects')
35
- assert isinstance(ListArrays[1],WolfArray), _('ListArrays must contain 2 WolfArray objects')
36
+ assert isinstance(ListArrays[1],WolfArray), _('ListArrays must contain 2 WolfArray objects')
36
37
 
37
38
  #Déclaration de l'App WX
38
39
  ex = wx.App()
@@ -76,13 +77,16 @@ def main(mydir:Path=None, ListArrays:list[WolfArray]=None):
76
77
  ex.MainLoop()
77
78
 
78
79
  if __name__=='__main__':
79
- """gestion de l'éxécution du module en tant que code principal"""
80
+ """
81
+ Gestion de l'éxécution du module en tant que code principal
82
+
83
+ """
80
84
  # total arguments
81
85
  n = len(sys.argv)
82
86
  # arguments
83
87
  print("Total arguments passed:", n)
84
88
  assert n in [2,3], _('Usage : wolfcompare <directory> or wolfcompare <file1> <file2>')
85
-
89
+
86
90
  if n==2:
87
91
  mydir = Path(sys.argv[1])
88
92
  if mydir.exists():
@@ -0,0 +1,62 @@
1
+ import wx
2
+ import numpy as np
3
+ import socket
4
+
5
+ class Server(wx.Frame):
6
+
7
+ def __init__(self, parent, title):
8
+ super(Server, self).__init__(parent, title=title, size=(300, 200))
9
+ self.panel = wx.Panel(self)
10
+ self.text_ctrl = wx.TextCtrl(self.panel, style=wx.TE_MULTILINE)
11
+ self.button = wx.Button(self.panel, label="Send Matrix")
12
+ self.button.Bind(wx.EVT_BUTTON, self.on_send_matrix)
13
+ self.sizer = wx.BoxSizer(wx.VERTICAL)
14
+ self.sizer.Add(self.text_ctrl, proportion=1, flag=wx.EXPAND)
15
+ self.sizer.Add(self.button, proportion=0, flag=wx.EXPAND)
16
+ self.panel.SetSizer(self.sizer)
17
+ self.Show()
18
+
19
+ def on_send_matrix(self, event):
20
+ matrix = np.random.rand(3, 3) # Example of a random matrix
21
+ self.text_ctrl.SetValue(str(matrix))
22
+
23
+ # Send matrix to client
24
+ host = '192.168.0.100' # Replace with the IP address of the client PC
25
+ port = 12345 # Choose a suitable port number
26
+ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
27
+ s.connect((host, port))
28
+ s.sendall(str(matrix).encode())
29
+
30
+ class Client(wx.Frame):
31
+ def __init__(self, parent, title):
32
+ super(Client, self).__init__(parent, title=title, size=(300, 200))
33
+ self.panel = wx.Panel(self)
34
+ self.text_ctrl = wx.TextCtrl(self.panel, style=wx.TE_MULTILINE)
35
+ self.button = wx.Button(self.panel, label="Receive Matrix")
36
+ self.button.Bind(wx.EVT_BUTTON, self.on_receive_matrix)
37
+ self.sizer = wx.BoxSizer(wx.VERTICAL)
38
+ self.sizer.Add(self.text_ctrl, proportion=1, flag=wx.EXPAND)
39
+ self.sizer.Add(self.button, proportion=0, flag=wx.EXPAND)
40
+ self.panel.SetSizer(self.sizer)
41
+ self.Show()
42
+
43
+ def on_receive_matrix(self, event):
44
+ host = '192.168.0.100' # Replace with the IP address of the server PC
45
+ port = 12345 # Choose the same port number used by the server
46
+ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
47
+ s.connect((host, port))
48
+ matrix_str = s.recv(1024).decode()
49
+ try:
50
+ matrix = np.array(eval(matrix_str))
51
+ self.text_ctrl.SetValue(str(matrix))
52
+ except:
53
+ self.text_ctrl.SetValue("Invalid matrix format")
54
+
55
+ def main():
56
+ app = wx.App()
57
+ Server(None, "Server")
58
+ Client(None, "Client")
59
+ app.MainLoop()
60
+
61
+ if __name__ == '__main__':
62
+ main()