wolfhece 2.2.45__py3-none-any.whl → 2.2.46__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.
@@ -616,22 +616,45 @@ class xyz_laz_grids():
616
616
 
617
617
  import asyncio
618
618
 
619
- dirs = listdir(dir_grids)
620
-
621
- logging.info(_('Reading grids information -- {} grids'.format(len(dirs))))
622
-
623
619
  def init_grid(curdir):
624
620
  if (Path(dir_grids) / Path(curdir)).is_dir():
625
621
  return xyz_laz_grid(join(dir_grids, curdir))
626
622
 
627
623
  return None
628
624
 
625
+ # check if an event loop is running
626
+ # If it is the case, read data in a single thread
627
+ try:
628
+ asyncio.get_running_loop()
629
+ logging.info(_('Event loop detected - reading grids in single thread'))
630
+ use_async = False
631
+ except RuntimeError:
632
+ use_async = True
633
+
634
+ if not use_async:
635
+ dirs = listdir(dir_grids)
636
+
637
+ logging.info(_('Reading grids information -- {} grids'.format(len(dirs))))
638
+
639
+ self.grids = [init_grid(curdir) for curdir in dirs if (Path(dir_grids) / Path(curdir)).is_dir()]
640
+ self.grids = list(filter(None, self.grids))
641
+
642
+ logging.info(_('Grids initialized'))
643
+ return
644
+
645
+ # else use asyncio to read in parallel
646
+ dirs = listdir(dir_grids)
647
+
648
+ logging.info(_('Reading grids information -- {} grids'.format(len(dirs))))
649
+
629
650
  async def init_grid_async(curdir):
630
651
  return init_grid(curdir)
631
652
 
632
- loop = asyncio.get_event_loop()
653
+ loop = asyncio.new_event_loop()
654
+ asyncio.set_event_loop(loop)
633
655
  tasks = [init_grid_async(curdir) for curdir in dirs]
634
656
  self.grids = list(filter(None, loop.run_until_complete(asyncio.gather(*tasks))))
657
+ loop.close()
635
658
 
636
659
  logging.info(_('Grids initialized'))
637
660
 
@@ -1472,7 +1495,7 @@ class Wolf_LAZ_Data(Element_To_Draw):
1472
1495
  self._xlsFrame.Show()
1473
1496
 
1474
1497
  icon = wx.Icon()
1475
- icon_path = Path(__file__).parent.parent / "apps/wolf_logo2.bmp"
1498
+ icon_path = Path(__file__).parent.parent / "apps/wolf.ico"
1476
1499
  icon.CopyFromBitmap(wx.Bitmap(str(icon_path), wx.BITMAP_TYPE_ANY))
1477
1500
  self._xlsFrame.SetIcon(icon)
1478
1501
 
@@ -64,7 +64,7 @@ class Calculator(wx.Frame):
64
64
  self._disp.SetFocus()
65
65
 
66
66
  icon = wx.Icon()
67
- icon_path = Path(__file__).parent.parent / "apps/wolf_logo2.bmp"
67
+ icon_path = Path(__file__).parent.parent / "apps/wolf.ico"
68
68
  icon.CopyFromBitmap(wx.Bitmap(str(icon_path), wx.BITMAP_TYPE_ANY))
69
69
  self.SetIcon(icon)
70
70
 
@@ -246,7 +246,7 @@ class Matplotlib_ax_properties():
246
246
  self._myprops.SetTitle(_('Ax properties'))
247
247
 
248
248
  icon = wx.Icon()
249
- icon_path = Path(__file__).parent / "apps/wolf_logo2.bmp"
249
+ icon_path = Path(__file__).parent / "apps/wolf.ico"
250
250
  icon.CopyFromBitmap(wx.Bitmap(str(icon_path), wx.BITMAP_TYPE_ANY))
251
251
  self._myprops.SetIcon(icon)
252
252
 
@@ -970,7 +970,7 @@ class Matplolib_line_properties():
970
970
  self._myprops.SetTitle(_('Line properties'))
971
971
 
972
972
  icon = wx.Icon()
973
- icon_path = Path(__file__).parent / "apps/wolf_logo2.bmp"
973
+ icon_path = Path(__file__).parent / "apps/wolf.ico"
974
974
  icon.CopyFromBitmap(wx.Bitmap(str(icon_path), wx.BITMAP_TYPE_ANY))
975
975
  self._myprops.SetIcon(icon)
976
976
 
@@ -1402,7 +1402,7 @@ class Matplotlib_Figure(wx.Frame):
1402
1402
  def set_wx(self):
1403
1403
  """ Set the wx Frame Design """
1404
1404
 
1405
- self.SetIcon(wx.Icon(str(Path(__file__).parent / "apps/wolf_logo2.bmp")))
1405
+ self.SetIcon(wx.Icon(str(Path(__file__).parent / "apps/wolf.ico")))
1406
1406
 
1407
1407
  self._sizer = wx.BoxSizer(wx.VERTICAL)
1408
1408
 
@@ -2325,7 +2325,7 @@ class Matplotlib_figure_properties():
2325
2325
  self._myprops.SetTitle(_('Figure properties'))
2326
2326
 
2327
2327
  icon = wx.Icon()
2328
- icon_path = Path(__file__).parent / "apps/wolf_logo2.bmp"
2328
+ icon_path = Path(__file__).parent / "apps/wolf.ico"
2329
2329
  icon.CopyFromBitmap(wx.Bitmap(str(icon_path), wx.BITMAP_TYPE_ANY))
2330
2330
  self._myprops.SetIcon(icon)
2331
2331
 
@@ -8928,30 +8928,22 @@ class block_contour(vector):
8928
8928
  def __init__(self, lines: list = ..., is2D=True, name='', parentzone=None) -> None:
8929
8929
  super().__init__(lines, is2D, name, parentzone)
8930
8930
 
8931
- def set_limits(self):
8932
- """ Retain current limits before any modification """
8933
-
8934
- # Set self.minx, self.maxx), (self.miny, self.maxy)
8935
- # on basis of the self.myvertices
8936
-
8937
- self.find_minmax()
8938
- self.mylimits = ((self.xmin, self.xmax), (self.ymin, self.ymax))
8939
8931
 
8940
8932
  def verify_limits(self):
8941
8933
  """ Verify that the current vertices are inside the set block's limits """
8942
8934
 
8943
- if self.mylimits is None:
8935
+ if self._mylimits is None:
8944
8936
  return
8945
8937
 
8946
8938
  self.find_minmax()
8947
8939
 
8948
- if self.xmin < self.mylimits[0][0] or self.xmax > self.mylimits[0][1] or \
8949
- self.ymin < self.mylimits[1][0] or self.ymax > self.mylimits[1][1]:
8940
+ if self.xmin < self._mylimits[0][0] or self.xmax > self._mylimits[0][1] or \
8941
+ self.ymin < self._mylimits[1][0] or self.ymax > self._mylimits[1][1]:
8950
8942
 
8951
8943
  for curv in self.myvertices:
8952
8944
  curv: wolfvertex
8953
8945
  # Force the vertex inside self.mylimits
8954
- curv.limit2bounds(self.mylimits)
8946
+ curv.limit2bounds(self._mylimits)
8955
8947
 
8956
8948
 
8957
8949
  COLOURS_BLOCKS=[(0,0,255),(255,0,0),(0,255,0),(255,255,0),(255,0,255),(0,255,255),(0,125,255),(255,125,0),(125,0,255),(25,25,255)]
@@ -9032,7 +9024,7 @@ class block_description:
9032
9024
  self.contour.add_vertex(curvert)
9033
9025
 
9034
9026
  self.contour.close_force() ##on force la fermeture du contour extérieur des blocs
9035
- self.contour.set_limits() # on retient les limites en cas de modifications
9027
+ self.contour._set_limits() # on retient les limites en cas de modifications
9036
9028
 
9037
9029
  ##emprise du bloc en accord avec le grid magnétique et
9038
9030
  # l'extension de surface utile pour les relations de voisinage entre blocs
wolfhece/pydike.py CHANGED
@@ -1,276 +1,5 @@
1
- """
2
- Author: HECE - University of Liege, Pierre Archambeau
3
- Date: 2024
4
-
5
- Copyright (c) 2024 University of Liege. All rights reserved.
6
-
7
- This script and its content are protected by copyright law. Unauthorized
8
- copying or distribution of this file, via any medium, is strictly prohibited.
9
- """
10
-
11
- import logging
12
-
13
- import numpy as np
14
- from shapely.geometry import Point, LineString
15
-
16
- from.drawing_obj import Element_To_Draw
17
- from .PyVertexvectors import Triangulation, vector,Zones, zone
18
- from .wolf_array import WolfArray, header_wolf
19
-
20
- class SyntheticDike(Element_To_Draw):
21
- """ Dike class for synthetic dikes based on a trace vector, width of the crest and lateral slopes.
22
- """
23
-
24
- def __init__(self, idx:str = '', plotted:bool = True, mapviewer = None, need_for_wx:bool = False):
25
-
26
- super().__init__(idx, plotted, mapviewer, need_for_wx)
27
-
28
- self._triangulation = None
29
- self._zones = Zones()
30
- newzone = zone(name='dike')
31
-
32
- self._zones.add_zone(newzone, forceparent=True)
33
-
34
- @property
35
- def triangulation(self) -> Triangulation:
36
- """ Return the triangulation of the dike """
37
- return self._triangulation
38
-
39
- @property
40
- def zones(self) -> Zones:
41
- """ Return the zones of the dike """
42
- return self._zones
43
-
44
- def create_from_slopes(self, trace:vector,
45
- slope_up:float, slope_down:float,
46
- width_up:float, width_down:float,
47
- zmin:float, zmax:float, ds:float):
48
-
49
- """ Create the dike triangulation based on the trace vector and the width of the dike.
50
-
51
- :param trace: Trace vector of the dike
52
- :param slope_up: Slope of the dike on the upstream side [slope = dz/dx]
53
- :param slope_down: Slope of the dike on the downstream side [slope = dz/dx]
54
- :param width_up: Width of the dike on the upstream side [m]
55
- :param width_down: Width of the dike on the downstream side [m]
56
- :param zmin: Minimum elevation of the dike [m]
57
- :param zmax: Maximum elevation of the dike [m]
58
- :param ds: Distance for rebinning [m]
59
- """
60
-
61
- assert ds > 0.0, "Distance for rebinning must be positive"
62
- assert slope_up > 0.0, "Slope must be positive"
63
- assert slope_down > 0.0, "Slope must be positive"
64
- assert width_up >= 0.0, "Width must be positive"
65
- assert width_down >= 0.0, "Width must be positive"
66
- assert zmin < zmax, "zmin must be less than zmax"
67
-
68
- myzone = self._zones.myzones[0]
69
- myzone.myvectors = []
70
-
71
- # Impose altimetry of the crest
72
- trace.z = zmax
73
-
74
- # add the trace vector to the zone
75
- myzone.add_vector(trace, forceparent=True)
76
-
77
- # CREST of the dike
78
- # create parallel vectors to the trace vector - right and left
79
-
80
- if width_up > 0.0:
81
- distances_up = list(np.linspace(0, width_up, int(width_up/ds)+1, endpoint=True))[1:]
82
- for curds in distances_up:
83
- # create a new vector parallel to the trace vector
84
- parup = trace.parallel_offset(curds, 'right')
85
- myzone.add_vector(parup, 0, forceparent=True)
86
- # impose altimetry of the dike
87
- parup.z = zmax
88
- else:
89
- # no width on the upstream side -> use the trace vector
90
- parup = trace
91
-
92
- if width_down > 0.0:
93
- distances_down = list(np.linspace(0, width_down, int(width_down/ds)+1, endpoint=True))[1:]
94
- for curds in distances_down:
95
- pardown = trace.parallel_offset(curds, 'left')
96
- myzone.add_vector(pardown, forceparent=True)
97
- # impose altimetry of the dike
98
- pardown.z = zmax
99
- else:
100
- # no width on the downstream side -> use the trace vector
101
- pardown = trace
102
-
103
- # distances to the crest
104
- distances_up = (zmax-zmin) / slope_up
105
- distances_up = list(np.linspace(0, distances_up, int(distances_up/ds)+1, endpoint=True))[1:]
106
- # distances_up.reverse()
107
- # iterate over the distup basd on ds
108
- for curds in distances_up:
109
- # create a new vector parallel to the trace vector
110
- parup_new = parup.parallel_offset(curds, 'right')
111
- myzone.add_vector(parup_new, 0, forceparent=True)
112
- # impose altimetry of the dike
113
- parup_new.z = zmax - slope_up * curds
114
-
115
- distances_down = (zmax-zmin) / slope_down
116
- distances_down = list(np.linspace(0, distances_down, int(distances_down/ds)+1, endpoint=True))[1:]
117
- for curds in distances_down:
118
- pardown_new = pardown.parallel_offset(curds, 'left')
119
- myzone.add_vector(pardown_new, forceparent=True) # append
120
- # impose altimetry of the dike
121
- pardown_new.z = zmax - slope_down * curds
122
-
123
- # on dispose de multiples vecteurs dans la zone, orientés de l'amont vers l'aval
124
- trace.update_lengths()
125
-
126
- nb_along_trace = int(trace.length3D / ds) # nombre de points sur la trace
127
-
128
- self._triangulation = myzone.create_multibin(nb_along_trace)
129
-
130
- def create_from_shape(self, trace:vector, shape:vector, ds:float):
131
- """ create the dike triangulation based on the trace vector and the shape vector
132
-
133
- :param trace: Trace vector of the dike
134
- :param shape: Transversal shape of the dike in (s,z) coordinates, s=0.0 is on the trace vector, elevations are relative to the trace vector
135
- :param ds: Distance for rebinning [m]
136
- """
137
-
138
- myzone = self._zones.myzones[0]
139
- myzone.myvectors = []
140
-
141
- # add the trace vector to the zone
142
- myzone.add_vector(trace, forceparent=True)
143
-
144
- # get the shapely linestring of the trace -> projection
145
- ref_ls = trace.linestring
146
-
147
- # Create parallels of the crest according to the shape vector
148
- # -----------------------------------------------------------
149
-
150
- # get coordinates of the shape vector
151
- shape_vertices = shape.xy
152
-
153
- # Separate the upstream and downstream vertices
154
- up_vertices = shape_vertices[shape_vertices[:, 0] > 0.0]
155
- down_vertices = shape_vertices[shape_vertices[:, 0] < 0.0]
156
-
157
- # reverse the order of downstream vertices
158
- down_vertices = down_vertices[::-1]
159
-
160
- # Altitude au droit de la trace
161
- z_shape_trace = shape_vertices[shape_vertices[:, 0] == 0.0][0][1]
162
-
163
- # UPSTREAM PART
164
-
165
- # Loop over the upstream vertices
166
- z_previous = z_shape_trace
167
- s_previous = 0.0
168
- distance_cum = 0.0 # useful for the cumulated distance -> parallel offset
169
- for cur_sz in up_vertices:
170
-
171
- ds_loc = cur_sz[0] - s_previous # distance between the two points in the shape
172
- slope_loc = (z_previous - cur_sz[1]) / ds_loc # local slope of the shape
173
-
174
- # rebin the distance
175
- distances_up = list(np.linspace(0, ds_loc, int(ds_loc/ds)+1, endpoint=True))[1:]
176
-
177
- deltaz_cum = 0.0 # Cumulated elevation difference
178
-
179
- # iterate over the distup basd on ds
180
- for curds in distances_up:
181
- # create a new vector parallel to the trace vector
182
- # need to add the cumulated distance to the current distance as we
183
- parup = trace.parallel_offset(curds + distance_cum, 'right')
184
-
185
- if parup is None:
186
- logging.warning("No parallel vector found for distance %f", curds + distance_cum)
187
- continue
188
-
189
- myzone.add_vector(parup, 0, forceparent=True)
190
-
191
- # local delta elevation
192
- deltaz_loc = -slope_loc * curds - deltaz_cum # local difference
193
-
194
- parup_z = []
195
-
196
- # we need to interpolate the elevation according to the trace
197
-
198
- # Iterate over the vertices
199
- for vert in parup.myvertices:
200
- # project the vertex on the previous trace
201
- proj = ref_ls.project(Point(vert.x, vert.y), normalized=True)
202
- # get the elevation of the trace at the projection point
203
- z_loc = ref_ls.interpolate(proj, normalized= True).z
204
- # add the local delta elevation
205
- z_loc += deltaz_loc
206
- parup_z.append(z_loc)
207
-
208
- parup.z = parup_z
209
- ref_ls = parup.linestring
210
- deltaz_cum += deltaz_loc
211
- z_previous = cur_sz[1]
212
- s_previous = cur_sz[0] # update the elevation of the trace
213
-
214
- distance_cum += distances_up[-1] # cumulate the distance
215
-
216
- # create downstream
217
- ref_ls = trace.linestring
218
-
219
- z_previous = z_shape_trace
220
- s_previous = 0.0
221
- distance_cum = 0.0
222
- # Loop over the downstream vertices
223
- for cur_sz in down_vertices:
224
-
225
- ds_loc = -(cur_sz[0] - s_previous)
226
- slope_loc = (z_previous - cur_sz[1]) / ds_loc
227
-
228
- # rebin the distance
229
- distances_down = list(np.linspace(0, ds_loc, int(ds_loc/ds)+1, endpoint=True))[1:]
230
-
231
- deltaz_cum = 0.0
232
-
233
- # iterate over the distup basd on ds
234
- for curds in distances_down:
235
- pardown = trace.parallel_offset(curds + distance_cum, 'left')
236
-
237
- if pardown is None:
238
- logging.warning("No parallel vector found for distance %f", curds + distance_cum)
239
- continue
240
-
241
- myzone.add_vector(pardown, forceparent=True)
242
-
243
- # impose local elevation
244
- deltaz_loc = -slope_loc * curds - deltaz_cum # local difference
245
-
246
- pardown_z = []
247
- # we need to interpolate the elevation according to the trace
248
- for vert in pardown.myvertices:
249
- # project the vertex on the trace
250
- proj = ref_ls.project(Point(vert.x, vert.y), normalized=True)
251
- # get the elevation of the trace at the projection point
252
- z_loc = ref_ls.interpolate(proj, normalized= True).z
253
- # add the local delta elevation
254
- z_loc += deltaz_loc
255
- pardown_z.append(z_loc)
256
-
257
- # impose the elevation
258
- pardown.z = pardown_z
259
- ref_ls = pardown.linestring
260
- deltaz_cum += deltaz_loc
261
- z_previous =cur_sz[1] # update the elevation of the trace
262
- s_previous = cur_sz[0]
263
-
264
- distance_cum += distances_down[-1]
265
-
266
- # on dispose de multiples vecteurs dans la zone, orientés de l'amont vers l'aval
267
- trace.update_lengths()
268
-
269
- nb_along_trace = int(trace.length3D / ds) # nombre de points sur la trace
270
-
271
- self._triangulation = myzone.create_multibin(nb_along_trace)
272
-
273
- for curvect in myzone.myvectors:
274
- curvect.reset_linestring()
1
+ import warnings
275
2
 
3
+ warnings.warn("The module wolfhece.pydike is deprecated. Please use wolfhece.synthetic_dike instead.", DeprecationWarning, stacklevel=2)
276
4
 
5
+ import synthetic_dike