wolfhece 2.1.54__py3-none-any.whl → 2.1.55__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/apps/version.py CHANGED
@@ -5,7 +5,7 @@ class WolfVersion():
5
5
 
6
6
  self.major = 2
7
7
  self.minor = 1
8
- self.patch = 54
8
+ self.patch = 55
9
9
 
10
10
  def __str__(self):
11
11
 
wolfhece/wolf_array.py CHANGED
@@ -40,7 +40,7 @@ import wx
40
40
  from scipy.interpolate import interp2d, griddata
41
41
  from scipy.ndimage import laplace, label, sum_labels
42
42
  import pygltflib
43
- from shapely.geometry import Point, LineString, MultiLineString
43
+ from shapely.geometry import Point, LineString, MultiLineString, Polygon, MultiPolygon, MultiPoint
44
44
  from shapely.ops import linemerge, substring, polygonize_full
45
45
  from os.path import dirname,basename,join
46
46
  import logging
@@ -1137,7 +1137,7 @@ class header_wolf():
1137
1137
 
1138
1138
  return newvector
1139
1139
 
1140
- def get_xy_infootprint_vect(self, myvect: vector, eps:float = 0.) -> tuple[np.ndarray,np.ndarray]:
1140
+ def get_xy_infootprint_vect(self, myvect: vector | Polygon, eps:float = 0.) -> tuple[np.ndarray,np.ndarray]:
1141
1141
  """
1142
1142
  Return the coordinates of the cells in the footprint of a vector
1143
1143
 
@@ -1154,7 +1154,7 @@ class header_wolf():
1154
1154
 
1155
1155
  return mypts,myptsij
1156
1156
 
1157
- def get_ij_infootprint_vect(self, myvect: vector, eps:float = 0.) -> np.ndarray:
1157
+ def get_ij_infootprint_vect(self, myvect: vector | Polygon, eps:float = 0.) -> np.ndarray:
1158
1158
  """
1159
1159
  Return the indices of the cells in the footprint of a vector
1160
1160
 
@@ -1162,8 +1162,16 @@ class header_wolf():
1162
1162
  :return : numpy array of indices
1163
1163
  """
1164
1164
 
1165
- i1, j1 = self.get_ij_from_xy(myvect.xmin+eps, myvect.ymin+eps)
1166
- i2, j2 = self.get_ij_from_xy(myvect.xmax-eps, myvect.ymax-eps)
1165
+ if isinstance(myvect, Polygon):
1166
+ xmin, ymin, xmax, ymax = myvect.bounds
1167
+ elif isinstance(myvect, vector):
1168
+ xmin, ymin, xmax, ymax = myvect.xmin, myvect.ymin, myvect.xmax, myvect.ymax
1169
+ else:
1170
+ logging.error(_('The object must be a vector or a Polygon'))
1171
+ return np.array([])
1172
+
1173
+ i1, j1 = self.get_ij_from_xy(xmin+eps, ymin+eps)
1174
+ i2, j2 = self.get_ij_from_xy(xmax-eps, ymax-eps)
1167
1175
 
1168
1176
  i1 = max(i1,0) # FIXME Why ??? How could i,j be negative ? --> because this fucntion can be called with a vector that is not in the array (e.g. a vector defined by clicks in the UI)
1169
1177
  j1 = max(j1,0)
@@ -6610,7 +6618,7 @@ class WolfArray(Element_To_Draw, header_wolf):
6610
6618
  # These functions can not be stored in header_wolf, because wa can use the mask of the array to limit the search
6611
6619
  # These functions are also present in WolfResults_2D, but they are not exactly the same due to the structure of the results
6612
6620
  # *************************************************************************************************************************
6613
- def get_xy_inside_polygon(self, myvect: vector, usemask:bool=True):
6621
+ def get_xy_inside_polygon(self, myvect: vector | Polygon, usemask:bool=True):
6614
6622
  """
6615
6623
  Return the coordinates inside a polygon
6616
6624
 
@@ -6618,9 +6626,15 @@ class WolfArray(Element_To_Draw, header_wolf):
6618
6626
  :param usemask : limit potential nodes to unmaksed nodes
6619
6627
  """
6620
6628
 
6621
- myvect.find_minmax()
6629
+ if isinstance(myvect, vector):
6630
+ # force la mise à jour des min/max
6631
+ myvect.find_minmax()
6632
+ # Conversion des coordonnées en numpy pour plus d'efficacité (du moins on espère)
6633
+ myvert = myvect.asnparray()
6634
+ elif isinstance(myvect, Polygon):
6635
+ myvert = myvect.exterior.coords[:-1]
6636
+
6622
6637
  mypointsxy, mypointsij = self.get_xy_infootprint_vect(myvect)
6623
- myvert = myvect.asnparray()
6624
6638
  path = mpltPath.Path(myvert)
6625
6639
  inside = path.contains_points(mypointsxy)
6626
6640
 
@@ -6633,6 +6647,34 @@ class WolfArray(Element_To_Draw, header_wolf):
6633
6647
 
6634
6648
  return mypointsxy
6635
6649
 
6650
+ def get_xy_inside_polygon_shapely(self, myvect: vector | Polygon, usemask:bool=True):
6651
+ """
6652
+ Return the coordinates inside a polygon
6653
+
6654
+ :param myvect : target vector
6655
+ :param usemask : limit potential nodes to unmaksed nodes
6656
+ """
6657
+
6658
+ if isinstance(myvect, vector):
6659
+ # force la mise à jour des min/max
6660
+ myvect.find_minmax()
6661
+ polygon = myvect.asshapely_pol()
6662
+ elif isinstance(myvect, Polygon):
6663
+ polygon = myvect
6664
+
6665
+ mypointsxy, mypointsij = self.get_xy_infootprint_vect(myvect)
6666
+
6667
+ inside = np.asarray([polygon.contains(Point(x,y)) for x,y in mypointsxy])
6668
+
6669
+ mypointsxy = mypointsxy[np.where(inside)]
6670
+
6671
+ if usemask:
6672
+ mypointsij = mypointsij[np.where(inside)]
6673
+ mymask = np.logical_not(self.array.mask[mypointsij[:, 0], mypointsij[:, 1]])
6674
+ mypointsxy = mypointsxy[np.where(mymask)]
6675
+
6676
+ return mypointsxy
6677
+
6636
6678
  def get_xy_under_polyline(self, myvect: vector, usemask:bool=True):
6637
6679
  """
6638
6680
  Return the coordinates along a polyline
@@ -6673,6 +6715,23 @@ class WolfArray(Element_To_Draw, header_wolf):
6673
6715
 
6674
6716
  return mypointsij
6675
6717
 
6718
+ def intersects_polygon(self, myvect: vector | Polygon, usemask:bool=True):
6719
+ """ Return True if the array intersects the polygon
6720
+
6721
+ :param myvect : target vector
6722
+ :param usemask : limit potential nodes to unmaksed nodes
6723
+ """
6724
+
6725
+ return self.get_xy_inside_polygon(myvect, usemask).shape[0] > 0
6726
+
6727
+ def intersects_polygon_shapely(self, myvect: vector | Polygon, eps:float = 0., usemask:bool=True):
6728
+ """ Return True if the array intersects the polygon
6729
+
6730
+ :param myvect : target vector
6731
+ :param usemask : limit potential nodes to unmaksed nodes
6732
+ """
6733
+ return self.get_xy_inside_polygon_shapely(myvect, usemask).shape[0] > 0
6734
+
6676
6735
  def get_ij_under_polyline(self, myvect: vector, usemask:bool=True):
6677
6736
  """
6678
6737
  Return the indices along a polyline
@@ -7034,6 +7093,8 @@ class WolfArray(Element_To_Draw, header_wolf):
7034
7093
  else:
7035
7094
  self.array = np.kron(self.array, np.ones((int(1/factor), int(1/factor)), dtype=self.array.dtype))
7036
7095
 
7096
+ self.mask_data(self.nullvalue)
7097
+
7037
7098
  self.count()
7038
7099
 
7039
7100
  # rebin must not change the type of the array
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: wolfhece
3
- Version: 2.1.54
3
+ Version: 2.1.55
4
4
  Author-email: Pierre Archambeau <pierre.archambeau@uliege.be>
5
5
  License: Copyright (c) 2024 University of Liege. All rights reserved.
6
6
  Project-URL: Homepage, https://uee.uliege.be/hece
@@ -48,7 +48,7 @@ wolfhece/pywalous.py,sha256=yRaWJjKckXef1d9D5devP0yFHC9uc6kRV4G5x9PNq9k,18972
48
48
  wolfhece/rain_SPWMI.py,sha256=qCfcmF7LajloOaCwnTrrSMzyME03YyilmRUOqrPrv3U,13846
49
49
  wolfhece/textpillow.py,sha256=map7HsGYML_o5NHRdFg2s_TVQed_lDnpYNDv27MM0Vw,14130
50
50
  wolfhece/tools_mpl.py,sha256=gQ3Jg1iuZiecmMqa5Eli2ZLSkttu68VXL8YmMDBaEYU,564
51
- wolfhece/wolf_array.py,sha256=VRy6F5ChUfqB8ziDAI8XrE54XWrtAicYVQyMieLaIXU,372460
51
+ wolfhece/wolf_array.py,sha256=Yg3iX0hPXkdJTuwu6rXlRee2w6hL595_4RZWCUrFWKc,374869
52
52
  wolfhece/wolf_hist.py,sha256=7jeVrgSkM3ErJO6SRMH_PGzfLjIdw8vTy87kesldggk,3582
53
53
  wolfhece/wolf_texture.py,sha256=DS5eobLxrq9ljyebYfpMSQPn8shkUAZZVfqrOKN_QUU,16951
54
54
  wolfhece/wolf_tiles.py,sha256=2Ho2I20rHRY81KXxjgLOYISdF4OkJ2d6omeY4shDoGI,10386
@@ -72,7 +72,7 @@ wolfhece/apps/check_install.py,sha256=SG024u18G7VRLKynbp7DKD1jImtHwuWwN4bJWHm-YH
72
72
  wolfhece/apps/curvedigitizer.py,sha256=_hRR2PWow7PU7rTHIbc6ykZ08tCXcK9uy7RFrb4EKkE,5196
73
73
  wolfhece/apps/isocurrent.py,sha256=MuwTodHxdc6PrqNpphR2ntYf1NLL2n9klTPndGrOHDQ,4109
74
74
  wolfhece/apps/splashscreen.py,sha256=SrustmIQeXnsiD-92OzjdGhBi-S7c_j-cSvuX4T6rtg,2929
75
- wolfhece/apps/version.py,sha256=CMpY0e6nzRUMGj9Dheyh-mTZLDI1l4fvptoARGgcN9I,388
75
+ wolfhece/apps/version.py,sha256=POD15Cc2AZYe1VXE08EaduFN-zrnSaxN6wGC-H49Xoo,388
76
76
  wolfhece/apps/wolf.py,sha256=mM6Tyi4DlKQILmO49cDUCip9fYVy-hLXkY3YhZgIeUQ,591
77
77
  wolfhece/apps/wolf2D.py,sha256=yPQGee7fsegoQ8GfWKrWEjX1Az_ApL-UWlBiqPvaIyY,565
78
78
  wolfhece/apps/wolf_logo.bmp,sha256=ruJ4MA51CpGO_AYUp_dB4SWKHelvhOvd7Q8NrVOjDJk,3126
@@ -280,8 +280,8 @@ wolfhece/ui/wolf_multiselection_collapsiblepane.py,sha256=8PlMYrb_8jI8h9F0_EagpM
280
280
  wolfhece/ui/wolf_times_selection_comparison_models.py,sha256=ORy7fz4dcp691qKzaOZHrRLZ0uXNhL-LIHxmpDGL6BI,5007
281
281
  wolfhece/wintab/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
282
282
  wolfhece/wintab/wintab.py,sha256=8A-JNONV6ujgsgG3lM5Uw-pVgglPATwKs86oBzzljoc,7179
283
- wolfhece-2.1.54.dist-info/METADATA,sha256=7QrfsLJM8f7GK2x3Gg8xH6vJfGWupV1EmqcST4rlVw8,2541
284
- wolfhece-2.1.54.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
285
- wolfhece-2.1.54.dist-info/entry_points.txt,sha256=Q5JuIWV4odeIJI3qc6fV9MwRoz0ezqPVlFC1Ppm_vdQ,395
286
- wolfhece-2.1.54.dist-info/top_level.txt,sha256=EfqZXMVCn7eILUzx9xsEu2oBbSo9liWPFWjIHik0iCI,9
287
- wolfhece-2.1.54.dist-info/RECORD,,
283
+ wolfhece-2.1.55.dist-info/METADATA,sha256=RauQP3GnJ5Y_HTZ_79bVAZVYSVulNhDpEsPp1dPVLHc,2541
284
+ wolfhece-2.1.55.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
285
+ wolfhece-2.1.55.dist-info/entry_points.txt,sha256=Q5JuIWV4odeIJI3qc6fV9MwRoz0ezqPVlFC1Ppm_vdQ,395
286
+ wolfhece-2.1.55.dist-info/top_level.txt,sha256=EfqZXMVCn7eILUzx9xsEu2oBbSo9liWPFWjIHik0iCI,9
287
+ wolfhece-2.1.55.dist-info/RECORD,,