wolfhece 2.2.7__py3-none-any.whl → 2.2.8__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 = 2
8
- self.patch = 7
8
+ self.patch = 8
9
9
 
10
10
  def __str__(self):
11
11
 
wolfhece/lifewatch.py CHANGED
@@ -72,6 +72,10 @@ class LifeWatch_Legend(Enum):
72
72
  # NODATA46 = (46, (246,146,246,255)) # Not used
73
73
  NODATA_BLACK = (100, (0, 0, 0), 'Nodata', '') # Outside Belgium/Wallonia
74
74
 
75
+ @property
76
+ def code(self) -> int:
77
+ return self.value[0]
78
+
75
79
  @classmethod
76
80
  def reference(cls) -> str:
77
81
  """
wolfhece/wolf_array.py CHANGED
@@ -1256,7 +1256,9 @@ class header_wolf():
1256
1256
  def _rasterize_segment(self,
1257
1257
  x1:float, y1:float,
1258
1258
  x2:float, y2:float,
1259
- xstart:float=None, ystart:float=None) -> list[list[float]]:
1259
+ xstart:float=None,
1260
+ ystart:float=None,
1261
+ n_packet:int = 10) -> list[list[float]]:
1260
1262
  """
1261
1263
  Rasterize a segment according to the grid
1262
1264
  where the grid is defined by the borders of the array.
@@ -1288,11 +1290,55 @@ class header_wolf():
1288
1290
  while length >= prec:
1289
1291
 
1290
1292
  if np.abs(direction[0])>= np.abs(direction[1]):
1291
- xstart += self.dx * np.sign(direction[0])
1293
+
1294
+ if length > n_packet*prec:
1295
+ # I we are far from the end of the segment, we can use the n_packet to rasterize
1296
+ # this will be used to avoid to many straight lines
1297
+ nx = np.abs(int(direction[0] * (n_packet-1))) # number of points in x direction
1298
+ ny = np.abs(int(direction[1] * (n_packet-1))) # number of points in y direction
1299
+
1300
+ n_common = min(nx, ny) # number of common points
1301
+
1302
+ for i in range(n_common):
1303
+ xstart += self.dx * np.sign(direction[0])
1304
+ points.append([xstart, ystart])
1305
+ ystart += self.dy * np.sign(direction[1])
1306
+ points.append([xstart, ystart])
1307
+
1308
+ for i in range(nx - n_common):
1309
+ xstart += self.dx * np.sign(direction[0])
1310
+ points.append([xstart, ystart])
1311
+
1312
+ for j in range(ny - n_common):
1313
+ ystart += self.dy * np.sign(direction[1])
1314
+ points.append([xstart, ystart])
1315
+ else:
1316
+ xstart += self.dx * np.sign(direction[0])
1317
+ points.append([xstart, ystart])
1292
1318
  else:
1293
- ystart += self.dy * np.sign(direction[1])
1319
+ if length > n_packet*prec:
1320
+ nx = np.abs(int(direction[0] * (n_packet-1)))
1321
+ ny = np.abs(int(direction[1] * (n_packet-1)))
1294
1322
 
1295
- points.append([xstart, ystart])
1323
+ n_common = min(nx, ny)
1324
+
1325
+ for j in range(n_common):
1326
+ ystart += self.dy * np.sign(direction[1])
1327
+ points.append([xstart, ystart])
1328
+ xstart += self.dx * np.sign(direction[0])
1329
+ points.append([xstart, ystart])
1330
+
1331
+ for j in range(ny - n_common):
1332
+ ystart += self.dy * np.sign(direction[1])
1333
+ points.append([xstart, ystart])
1334
+
1335
+ for i in range(nx - n_common):
1336
+ xstart += self.dx * np.sign(direction[0])
1337
+ points.append([xstart, ystart])
1338
+
1339
+ else:
1340
+ ystart += self.dy * np.sign(direction[1])
1341
+ points.append([xstart, ystart])
1296
1342
 
1297
1343
  direction = np.array([x2-xstart, y2-ystart])
1298
1344
 
@@ -1302,7 +1348,7 @@ class header_wolf():
1302
1348
 
1303
1349
  return points
1304
1350
 
1305
- def rasterize_vector(self, vector2raster:vector, outformat:Union[np.ndarray, vector]=vector) -> Union[np.ndarray,vector]:
1351
+ def rasterize_vector_along_grid(self, vector2raster:vector, outformat:Union[np.ndarray, vector]=vector) -> Union[np.ndarray,vector]:
1306
1352
  """
1307
1353
  Rasterize a vector according to the grid
1308
1354
 
@@ -1337,6 +1383,14 @@ class header_wolf():
1337
1383
 
1338
1384
  return newvector
1339
1385
 
1386
+ def rasterize_vector(self, vector2raster:vector, outformat:Union[np.ndarray, vector]=vector) -> Union[np.ndarray,vector]:
1387
+ """ DEPRECATED since 2.2.8 -- use rasterize_vector_along_grid instead.
1388
+
1389
+ Will be removed in 2.3.0
1390
+ """
1391
+ logging.warning(_('rasterize_vector is deprecated since 2.2.8 -- use rasterize_vector_along_grid instead'))
1392
+ return self.rasterize_vector_along_grid(vector2raster, outformat=outformat)
1393
+
1340
1394
  def get_xy_infootprint_vect(self, myvect: vector | Polygon, eps:float = 0.) -> tuple[np.ndarray,np.ndarray]:
1341
1395
  """
1342
1396
  Return the coordinates of the cells in the footprint of a vector
@@ -5397,7 +5451,7 @@ class WolfArray(Element_To_Draw, header_wolf):
5397
5451
  assert np_source.shape == (self.nbx, self.nby), _('Shape of np_source is not compatible with header')
5398
5452
 
5399
5453
  if self.dtype != np_source.dtype:
5400
- logging.warning(_('dtype of np_source is not compatible with header -- Conversion will be done'))
5454
+ logging.warning(_(f"dtype of np_source is not compatible with header -- Conversion will be done to match wolf header's type {self.dtype}"))
5401
5455
  np_source = np_source.astype(self.dtype)
5402
5456
 
5403
5457
  self.array = ma.MaskedArray(np_source, mask= np_source[:,:] == self.nullvalue, copy=False, order='C')
@@ -6771,6 +6825,7 @@ class WolfArray(Element_To_Draw, header_wolf):
6771
6825
  return
6772
6826
 
6773
6827
  destij = self.xy2ij_np(destxy)
6828
+
6774
6829
  elif self.mngselection.myselection == 'all':
6775
6830
  destij = np.where(self.array.mask == False)
6776
6831
  destij = np.array(destij).transpose()
@@ -6792,9 +6847,6 @@ class WolfArray(Element_To_Draw, header_wolf):
6792
6847
 
6793
6848
  destij = self.xy2ij_np(destxy)
6794
6849
 
6795
- # if convert_xy2ij:
6796
- # destij = np.asarray([list(self.get_ij_from_xy(x, y)) for x, y in destxy])
6797
-
6798
6850
  xyz = working_vector.asnparray3d()
6799
6851
 
6800
6852
  newvalues = griddata(xyz[:, :2], xyz[:, 2], destxy, method=method, fill_value=-99999.)
@@ -6802,6 +6854,62 @@ class WolfArray(Element_To_Draw, header_wolf):
6802
6854
  locmask = np.where(newvalues != -99999.)
6803
6855
  self.array.data[destij[locmask][:, 0], destij[locmask][:, 1]] = newvalues[locmask]
6804
6856
 
6857
+ def rasterize_vector_valuebyid(self, working_vector: vector, id,
6858
+ method:Literal["nearest", "linear", "cubic"]="linear"):
6859
+ """
6860
+ Rasterize a vector using the value of the id
6861
+ """
6862
+
6863
+ if not isinstance(working_vector, vector):
6864
+ logging.error(_('working_vector must be a vector. You provided a {}').format(type(working_vector)))
6865
+ return
6866
+
6867
+ if working_vector.get_value(id) is None:
6868
+ logging.error(_('No value for id {}').format(id))
6869
+ return
6870
+
6871
+ val = working_vector.get_value(id)
6872
+ if val is None:
6873
+ logging.error(_('No value for id {}').format(id))
6874
+ return
6875
+
6876
+ try:
6877
+ val = float(val)
6878
+ except:
6879
+ logging.error(_('Value for id {} is not a number').format(id))
6880
+ return
6881
+
6882
+ newvec = working_vector.deepcopy()
6883
+ newvec.z = val
6884
+
6885
+ self.interpolate_on_polygon(newvec, method)
6886
+
6887
+ def rasterize_zone_valuebyid(self, working_zone: zone, id,
6888
+ method:Literal["nearest", "linear", "cubic"]="linear"):
6889
+ """
6890
+ Rasterize a zone using the value of the id
6891
+ """
6892
+
6893
+ if not isinstance(working_zone, zone):
6894
+ logging.error(_('working_zone must be a zone. You provided a {}').format(type(working_zone)))
6895
+ return
6896
+
6897
+ for curvec in working_zone.myvectors:
6898
+ self.rasterize_vector_valuebyid(curvec, id, method)
6899
+
6900
+ def rasterize_zones_valuebyid(self, working_zones: Zones, id,
6901
+ method:Literal["nearest", "linear", "cubic"]="linear"):
6902
+ """
6903
+ Rasterize a zone using the value of the id
6904
+ """
6905
+
6906
+ if not isinstance(working_zones, Zones):
6907
+ logging.error(_('working_zone must be a zone. You provided a {}').format(type(working_zones)))
6908
+ return
6909
+
6910
+ for curzone in working_zones.myzones:
6911
+ self.rasterize_zone_valuebyid(curzone, id, method)
6912
+
6805
6913
  def interpolate_on_polygons(self, working_zone:zone, method:Literal["nearest", "linear", "cubic"]="linear"):
6806
6914
  """
6807
6915
  Interpolation sous plusieurs polygones d'une même zone
@@ -3797,7 +3797,7 @@ class Wolfresults_2D(Element_To_Draw):
3797
3797
 
3798
3798
  myhead = self.get_header_block(1)
3799
3799
  if to_rasterize:
3800
- myvect = myhead.rasterize_vector(myvect)
3800
+ myvect = myhead.rasterize_vector_along_grid(myvect)
3801
3801
 
3802
3802
  mynormals = myvect.get_normal_segments()
3803
3803
  xy_center = myvect.get_center_segments()
@@ -3877,7 +3877,7 @@ class Wolfresults_2D(Element_To_Draw):
3877
3877
  for i in tqdm(range(nb)):
3878
3878
  if i == 0:
3879
3879
  myhead = self.get_header_block(1)
3880
- vect_raster = myhead.rasterize_vector(vect)
3880
+ vect_raster = myhead.rasterize_vector_along_grid(vect)
3881
3881
  self.read_oneresult(i)
3882
3882
  q.append(self._plot_one_q_raster_splitting(vect_raster, True, to_rasterize=False))
3883
3883
 
@@ -3892,7 +3892,7 @@ class Wolfresults_2D(Element_To_Draw):
3892
3892
 
3893
3893
  for i in range(len(vect)):
3894
3894
  q[vect[i].myname] = []
3895
- vect_raster.append(myhead.rasterize_vector(vect[i]))
3895
+ vect_raster.append(myhead.rasterize_vector_along_grid(vect[i]))
3896
3896
 
3897
3897
  for i in tqdm(range(nb)):
3898
3898
  self.read_oneresult(i)
@@ -3982,7 +3982,7 @@ class Wolfresults_2D(Element_To_Draw):
3982
3982
  elif x_or_y == 'border':
3983
3983
  if i==0:
3984
3984
  myhead = self.get_header_block(1)
3985
- vect_raster = myhead.rasterize_vector(vect)
3985
+ vect_raster = myhead.rasterize_vector_along_grid(vect)
3986
3986
  q.append(self._plot_one_q_raster_splitting(vect_raster, absolute, to_rasterize = False))
3987
3987
 
3988
3988
  ax.plot(times,q, c='blue', label=vect.myname)
@@ -4000,7 +4000,7 @@ class Wolfresults_2D(Element_To_Draw):
4000
4000
  for i in range(len(vect)):
4001
4001
  q[i]= []
4002
4002
  if x_or_y[i] == 'border':
4003
- vect_raster.append(myhead.rasterize_vector(vect[i]))
4003
+ vect_raster.append(myhead.rasterize_vector_along_grid(vect[i]))
4004
4004
 
4005
4005
  for i in tqdm(range(nb)):
4006
4006
  self.read_oneresult(i)
@@ -4063,7 +4063,7 @@ class Wolfresults_2D(Element_To_Draw):
4063
4063
  elif x_or_y == 'border':
4064
4064
  if i==0:
4065
4065
  myhead = self.get_header_block(1)
4066
- vect_raster = myhead.rasterize_vector(vect)
4066
+ vect_raster = myhead.rasterize_vector_along_grid(vect)
4067
4067
  q.append(self._plot_one_q_raster_splitting(vect_raster, absolute, to_rasterize = False))
4068
4068
 
4069
4069
  fig.plot(times,q, c='blue', label=vect.myname)
@@ -4081,7 +4081,7 @@ class Wolfresults_2D(Element_To_Draw):
4081
4081
  for i in range(len(vect)):
4082
4082
  q[i]= []
4083
4083
  if x_or_y[i] == 'border':
4084
- vect_raster.append(myhead.rasterize_vector(vect[i]))
4084
+ vect_raster.append(myhead.rasterize_vector_along_grid(vect[i]))
4085
4085
 
4086
4086
  for i in tqdm(range(nb)):
4087
4087
  self.read_oneresult(i)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: wolfhece
3
- Version: 2.2.7
3
+ Version: 2.2.8
4
4
  Author-email: Pierre Archambeau <pierre.archambeau@uliege.be>
5
5
  Project-URL: Homepage, https://uee.uliege.be/hece
6
6
  Project-URL: Issues, https://uee.uliege.be/hece
@@ -41,7 +41,7 @@ wolfhece/ins.py,sha256=uUeLMS1n3GPnfJhxl0Z2l-UXpmPUgthuwct282OOEzk,36184
41
41
  wolfhece/irm_qdf.py,sha256=DMdDEAYbgYxApObm6w-dZbBmA8ec6PghBLXR2lUEZLc,27457
42
42
  wolfhece/ismember.py,sha256=fkLvaH9fhx-p0QrlEzqa6ySO-ios3ysjAgXVXzLgSpY,2482
43
43
  wolfhece/lagrange_multiplier.py,sha256=0G-M7b2tGzLx9v0oNYYq4_tLAiHcs_39B4o4W3TUVWM,6567
44
- wolfhece/lifewatch.py,sha256=AszCItQCq3Z3d-gznsjtYU9FIKJaWAcr1gafBxb-qHs,16265
44
+ wolfhece/lifewatch.py,sha256=Q_Wy6VGkrD-xxY0fv3PKpT8U8oXxNMgiLlrAE3bMheo,16340
45
45
  wolfhece/matplotlib_fig.py,sha256=vnFI6sghw9N9jKhR8X1Z4aWli_5fPNylZQtFuujFJDY,84075
46
46
  wolfhece/multiprojects.py,sha256=Sd6Bl6YP33jlR79A6rvSLu23vq8sqbFYL8lWuVPkEpE,21549
47
47
  wolfhece/picc.py,sha256=0X_pzhSBoVxgtTfJ37pkOQO3Vbr9yurPaD1nVeurx8k,8531
@@ -58,13 +58,13 @@ wolfhece/rain_SPWMI.py,sha256=qCfcmF7LajloOaCwnTrrSMzyME03YyilmRUOqrPrv3U,13846
58
58
  wolfhece/textpillow.py,sha256=map7HsGYML_o5NHRdFg2s_TVQed_lDnpYNDv27MM0Vw,14130
59
59
  wolfhece/tools2d_dll.py,sha256=oU0m9XYAf4CZsMoB68IuKeE6SQh-AqY7O5NVED8r9uw,13125
60
60
  wolfhece/tools_mpl.py,sha256=gQ3Jg1iuZiecmMqa5Eli2ZLSkttu68VXL8YmMDBaEYU,564
61
- wolfhece/wolf_array.py,sha256=8ZM75yOInSkoJQsKaCABmgP_j2KLevO5BgxsSmvRvi8,491510
61
+ wolfhece/wolf_array.py,sha256=HwOejG8kYTQ1l6c3RX8nuFwMAuySTWfgsxIvZl_Ivcg,496150
62
62
  wolfhece/wolf_hist.py,sha256=7jeVrgSkM3ErJO6SRMH_PGzfLjIdw8vTy87kesldggk,3582
63
63
  wolfhece/wolf_texture.py,sha256=IvFtekT5iLU2sivZOOlJXpE4CevjTQYSxHaOp4cH_wI,17723
64
64
  wolfhece/wolf_tiles.py,sha256=v-HohqaWuMYdn75XLnA22dlloAG90iwnIqrgnB0ASQ4,10488
65
65
  wolfhece/wolf_vrt.py,sha256=wbxXVN7TL9zgdyF79S-4e3pje6wJEAgBEfF_Y8kkzxs,14271
66
66
  wolfhece/wolf_zi_db.py,sha256=baE0niMCzybWGSvPJc5FNxo9ZxsGfU4p-FmfiavFHAs,12967
67
- wolfhece/wolfresults_2D.py,sha256=5Ser0lcfoGbsHLASx_1UtxmanYDGSuOCMgaadSNTHzs,218154
67
+ wolfhece/wolfresults_2D.py,sha256=N-L9gmurQEMUjrC23HJjWRRaIxvcdhk6R8KKcb94LJw,218231
68
68
  wolfhece/xyz_file.py,sha256=1pzLFmmdHca4yBVR9Jitic6N82rY28mRytGC1zMbY28,6615
69
69
  wolfhece/acceptability/Parallels.py,sha256=2wVkfJYor4yl7VYiAZiGGTFwtAab2z66ZfRtBliVweE,4088
70
70
  wolfhece/acceptability/__init__.py,sha256=hfgoPKLDpX7drN1Vpvux-_5Lfyc_7feT2C2zQr5v-Os,258
@@ -86,7 +86,7 @@ wolfhece/apps/curvedigitizer.py,sha256=lEJJwgAfulrrWQc-U6ij6sj59hWN3SZl4Yu1kQxVz
86
86
  wolfhece/apps/hydrometry.py,sha256=lhhJsFeb4zGL4bNQTs0co85OQ_6ssL1Oy0OUJCzhfYE,656
87
87
  wolfhece/apps/isocurrent.py,sha256=dagmGR8ja9QQ1gwz_8fU-N052hIw-W0mWGVkzLu6C7I,4247
88
88
  wolfhece/apps/splashscreen.py,sha256=eCPAUYscZPWDYKBHDBWum_VIcE7WXOCBe1GLHL3KUmU,3088
89
- wolfhece/apps/version.py,sha256=UGz-NV4qzN96AWCtJsnDr27SQMMZUOgYsoje1cRxP8s,387
89
+ wolfhece/apps/version.py,sha256=VLekoececzg7H4Z0hu97fb37nDVx-7ndJhfqA8urYqc,387
90
90
  wolfhece/apps/wolf.py,sha256=j_CgvsL8rwixbVvVD5Z0s7m7cHZ86gmFLojKGuetMls,729
91
91
  wolfhece/apps/wolf2D.py,sha256=4z_OPQ3IgaLtjexjMKX9ppvqEYyjFLt1hcfFABy3-jU,703
92
92
  wolfhece/apps/wolf_logo.bmp,sha256=ruJ4MA51CpGO_AYUp_dB4SWKHelvhOvd7Q8NrVOjDJk,3126
@@ -314,8 +314,8 @@ wolfhece/ui/wolf_multiselection_collapsiblepane.py,sha256=8PlMYrb_8jI8h9F0_EagpM
314
314
  wolfhece/ui/wolf_times_selection_comparison_models.py,sha256=ORy7fz4dcp691qKzaOZHrRLZ0uXNhL-LIHxmpDGL6BI,5007
315
315
  wolfhece/wintab/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
316
316
  wolfhece/wintab/wintab.py,sha256=8A-JNONV6ujgsgG3lM5Uw-pVgglPATwKs86oBzzljoc,7179
317
- wolfhece-2.2.7.dist-info/METADATA,sha256=L3cl2QpOoOfUeWa8ox5Y41HslP4ad6In6xbQi1Ydk5U,2744
318
- wolfhece-2.2.7.dist-info/WHEEL,sha256=pxyMxgL8-pra_rKaQ4drOZAegBVuX-G_4nRHjjgWbmo,91
319
- wolfhece-2.2.7.dist-info/entry_points.txt,sha256=ZZ-aSfbpdcmo-wo84lRFzBN7LaSnD1XRGSaAKVX-Gpc,522
320
- wolfhece-2.2.7.dist-info/top_level.txt,sha256=EfqZXMVCn7eILUzx9xsEu2oBbSo9liWPFWjIHik0iCI,9
321
- wolfhece-2.2.7.dist-info/RECORD,,
317
+ wolfhece-2.2.8.dist-info/METADATA,sha256=SZScGuzekEdz_ReMj94rQMIwrfNH3QMhDq0eEb-of9k,2744
318
+ wolfhece-2.2.8.dist-info/WHEEL,sha256=pxyMxgL8-pra_rKaQ4drOZAegBVuX-G_4nRHjjgWbmo,91
319
+ wolfhece-2.2.8.dist-info/entry_points.txt,sha256=ZZ-aSfbpdcmo-wo84lRFzBN7LaSnD1XRGSaAKVX-Gpc,522
320
+ wolfhece-2.2.8.dist-info/top_level.txt,sha256=EfqZXMVCn7eILUzx9xsEu2oBbSo9liWPFWjIHik0iCI,9
321
+ wolfhece-2.2.8.dist-info/RECORD,,