wolfhece 2.0.50__py3-none-any.whl → 2.0.52__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/PyGui.py CHANGED
@@ -871,14 +871,14 @@ class Wolf2DModel(GenMapManager):
871
871
  fname = self.filenamegen + curextent
872
872
  if exists(fname):
873
873
  fname += '.txt'
874
- fhead.write_txt_header(fname,wolftype)
874
+ fhead.write_txt_header(fname, wolftype, forceupdate=True)
875
875
 
876
876
  mb = self.files_MB_array['Initial Conditions']
877
877
  for curextent,text,wolftype in mb:
878
878
  fname = self.filenamegen + curextent
879
879
  if exists(fname):
880
880
  fname += '.txt'
881
- mbhead.write_txt_header(fname,wolftype)
881
+ mbhead.write_txt_header(fname, wolftype, forceupdate=True)
882
882
 
883
883
  fname = self.filenamegen + '.lst'
884
884
  if not exists(fname):
wolfhece/apps/version.py CHANGED
@@ -5,7 +5,7 @@ class WolfVersion():
5
5
 
6
6
  self.major = 2
7
7
  self.minor = 0
8
- self.patch = 50
8
+ self.patch = 52
9
9
 
10
10
  def __str__(self):
11
11
 
wolfhece/wolf_vrt.py CHANGED
@@ -4,6 +4,8 @@ from osgeo import osr, gdal
4
4
  import logging
5
5
  from pathlib import Path
6
6
 
7
+ from .PyVertexvectors import Zones
8
+
7
9
  def create_vrt(wdir:str, fout:str='out.vrt', format:str='tif'):
8
10
  """
9
11
  Agglomération de tous les fichiers .tif dans un layer virtuel .vrt
@@ -38,6 +40,9 @@ def create_vrt_from_files(files:list[Path]=[], fout:Path='assembly.vrt'):
38
40
  if isinstance(fout, str):
39
41
  fout = Path(fout)
40
42
 
43
+ if isinstance(files[0], str):
44
+ files = [Path(file) for file in files]
45
+
41
46
  # retain current working directory
42
47
  oldcwd = os.getcwd()
43
48
  # change working directory to the parent of the output file
@@ -49,7 +54,7 @@ def create_vrt_from_files(files:list[Path]=[], fout:Path='assembly.vrt'):
49
54
  # restore working directory
50
55
  os.chdir(oldcwd)
51
56
 
52
- def create_vrt_from_files_first_based(files:list[Path]=[], fout:Path='assembly.vrt'):
57
+ def create_vrt_from_files_first_based(files:list[Path]=[], fout:Path='assembly.vrt', Nodata:float=99999.):
53
58
  """
54
59
  Agglomération de tous les fichiers énumérés dans files dans un layer virtuel .vrt
55
60
 
@@ -58,6 +63,9 @@ def create_vrt_from_files_first_based(files:list[Path]=[], fout:Path='assembly.v
58
63
  if isinstance(fout, str):
59
64
  fout = Path(fout)
60
65
 
66
+ if isinstance(files[0], str):
67
+ files = [Path(file) for file in files]
68
+
61
69
  first = files[0]
62
70
  raster:gdal.Dataset
63
71
  raster = gdal.Open(str(first))
@@ -82,7 +90,7 @@ def create_vrt_from_files_first_based(files:list[Path]=[], fout:Path='assembly.v
82
90
  yRes=abs(geotr[5]),
83
91
  outputBounds=[xmin,ymin,xmax,ymax],
84
92
  resampleAlg='bilinear',
85
- srcNodata=99999.)
93
+ srcNodata=Nodata)
86
94
 
87
95
  # retain current working directory
88
96
  oldcwd = os.getcwd()
@@ -155,6 +163,126 @@ def crop_vrt(fn:str, crop:list, fout:str=None):
155
163
  else:
156
164
  logging.warning('The file does not exist !')
157
165
 
166
+ def create_contours(files:list[Path]=[],
167
+ fout:Path = 'assembly.vec',
168
+ color_exterior:tuple=(255,0,0),
169
+ color_interior:tuple=(0,0,255),
170
+ width:int=3,
171
+ ignore_first:bool=True,
172
+ create_extern:bool = True,
173
+ create_intern:bool = True,
174
+ force_mask_border:bool = True) -> Zones:
175
+ """
176
+ Create contour from files
177
+
178
+ :param files: list of files to process
179
+ :type files: list[Path]
180
+ :param fout: output file
181
+ :type fout: Path - if None, no output file
182
+ :param color_exterior: RGB color for exterior contour
183
+ :type color_exterior: tuple
184
+ :param color_interior: RGB color for interior contour
185
+ :type color_interior: tuple
186
+ :param width: width of the contour
187
+ :type width: int
188
+ :param ignore_first: ignore the first file in the list
189
+ :type ignore_first: bool
190
+ :param create_extern: create exterior contour
191
+ :type create_extern: bool
192
+ :param create_intern: create interior contour
193
+ :type create_intern: bool
194
+ :param force_mask_border: force masked data along borders -- [0,:], [-1,:], [:,0], [:,-1
195
+ :type force_mask_border: bool
196
+
197
+ """
198
+
199
+ from tqdm import tqdm
200
+ from .wolf_array import WolfArray
201
+ from .PyVertexvectors import Zones, zone, vector, wolfvertex, getIfromRGB
202
+
203
+ if isinstance(fout, str):
204
+ fout = Path(fout)
205
+
206
+ if not(create_extern or create_intern):
207
+ logging.warning('No contour to create !')
208
+ return None
209
+
210
+ emprises = Zones()
211
+
212
+ start = 1 if ignore_first else 0
213
+
214
+ for file in tqdm(files[start:]):
215
+
216
+ curzone = zone(name = str(file.name))
217
+ emprises.add_zone(curzone, forceparent=True)
218
+
219
+ curarray = WolfArray(str(file))
220
+
221
+ if force_mask_border:
222
+ curarray.array.mask[0,:] = True
223
+ curarray.array.mask[-1,:] = True
224
+ curarray.array.mask[:,0] = True
225
+ curarray.array.mask[:,-1] = True
226
+ else:
227
+ print_name = False
228
+ if (~curarray.array.mask[0,:]).any():
229
+ logging.warning('\nNon masked data along border -- [0,:]\n')
230
+ print_name = True
231
+
232
+ if (~curarray.array.mask[-1,:]).any():
233
+ pre = '' if print_name else '\n'
234
+ logging.warning(pre+'Non masked data along border -- [-1,:]\n')
235
+ print_name = True
236
+
237
+ if (~curarray.array.mask[:,0]).any():
238
+ pre = '' if print_name else '\n'
239
+ logging.warning(pre+'Non masked data along border -- [:,0]\n')
240
+ print_name = True
241
+
242
+ if (~curarray.array.mask[:,-1]).any():
243
+ pre = '' if print_name else '\n'
244
+ logging.warning(pre+'Non masked data along border -- [:,-1]\n')
245
+ print_name = True
246
+
247
+ if print_name:
248
+ logging.warning(f'File: {file}\n')
249
+
250
+ if create_intern:
251
+ ret = curarray.suxsuy_contour(abs = True)
252
+
253
+ curvec = ret[2]
254
+ curvec.myname = 'contour_utile'
255
+ curzone.add_vector(curvec, forceparent=True)
256
+
257
+ curvec.myprop.color = getIfromRGB(color_interior)
258
+ curvec.myprop.width = width
259
+
260
+ if create_extern:
261
+
262
+ bounds = curarray.get_bounds(True)
263
+ vecrect = vector(name = 'contour_externe')
264
+
265
+ curzone.add_vector(vecrect, forceparent=True)
266
+
267
+ vecrect.add_vertex((wolfvertex(bounds[0][0], bounds[1][0])))
268
+ vecrect.add_vertex((wolfvertex(bounds[0][1], bounds[1][0])))
269
+ vecrect.add_vertex((wolfvertex(bounds[0][1], bounds[1][1])))
270
+ vecrect.add_vertex((wolfvertex(bounds[0][0], bounds[1][1])))
271
+ vecrect.close_force()
272
+
273
+ vecrect.myprop.color = getIfromRGB(color_exterior)
274
+ vecrect.myprop.width = width
275
+ vecrect.myprop.legendvisible = True
276
+ vecrect.myprop.legendtext = file.name
277
+
278
+ sh = vecrect.asshapely_ls()
279
+ vecrect.myprop.legendx = sh.centroid.x
280
+ vecrect.myprop.legendy = sh.centroid.y
281
+
282
+ if fout is not None:
283
+ emprises.saveas(str(fout))
284
+
285
+ return emprises
158
286
 
159
287
  if __name__=='__main__':
160
288
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: wolfhece
3
- Version: 2.0.50
3
+ Version: 2.0.52
4
4
  Author-email: Pierre Archambeau <pierre.archambeau@uliege.be>
5
5
  License: AGPL-v3 License
6
6
  Project-URL: Homepage, https://uee.uliege.be/hece
@@ -7,7 +7,7 @@ wolfhece/Model1D.py,sha256=-cMz-ePSYzrKVVDidiDOz6cojEZ3y6u9gIb7RPwT6Y8,476593
7
7
  wolfhece/PyConfig.py,sha256=oGSL1WsLM9uinlNP4zGBLK3uHPmBfduUi7R-VtWuRFA,8034
8
8
  wolfhece/PyCrosssections.py,sha256=f4dNYRUGZKePruaaBiTcn5vlrw8TFTj9XwTDrdiF_uU,112450
9
9
  wolfhece/PyDraw.py,sha256=nUHEMpTG0zJvBJYOnreTvAISeP7cLsx14Qyrv-y32OY,344956
10
- wolfhece/PyGui.py,sha256=LZtmQuEa0p-67iYyvLHJRK8uBs1zKmA3UqDzejWogy8,59795
10
+ wolfhece/PyGui.py,sha256=-LTnUVkRsqJw41DPN0jvhBOmDyygw6GgdGsno78cI_o,59833
11
11
  wolfhece/PyGuiHydrology.py,sha256=wKhR-KthPRyzJ887NmsozmUpm2CIQIwO3IbYORCYjrE,7290
12
12
  wolfhece/PyHydrographs.py,sha256=GKK8U0byI45H9O_e4LAOOi7Aw0Tg7Q0Lx322stPg5IQ,3453
13
13
  wolfhece/PyPalette.py,sha256=SYKYx_vxF_FVuceLhcIqFQsivGD6EoO_Xu-EGN9Ivko,22252
@@ -52,7 +52,7 @@ wolfhece/wolf_array.py,sha256=E6u0d6kABsegIZxPUZjtWS88lOrVc2d-lyW0uJgj6qo,289157
52
52
  wolfhece/wolf_hist.py,sha256=JpRXvzJLUP-RkSkvth3DQWglgTMFI2ZEUDb4RYOfeeI,3284
53
53
  wolfhece/wolf_texture.py,sha256=llQ7aV8scWXIkhpri9XjaPejzoBJsGfsln2ZnlRbFkU,16270
54
54
  wolfhece/wolf_tiles.py,sha256=F2JsJHdAP8fIffNJdG_J26bonCIRtIwMmxKFqdSCRDA,10088
55
- wolfhece/wolf_vrt.py,sha256=wuMPAXNYTByNGNtvWhwW1fQelPstAPTQZECgXHZ0oTM,5180
55
+ wolfhece/wolf_vrt.py,sha256=5z6astjCCg2-6BgR6qlNpk043kxOZCClcqNPAMowljk,9707
56
56
  wolfhece/wolf_zi_db.py,sha256=Ok0MxQYZMMLRJN1QY-HSplLhUzzb6gkXgBQ3ihhLQHk,12669
57
57
  wolfhece/wolfresults_2D.py,sha256=5IlGh8MGXKiuzs0de_B73rDC0C9tdAsgXQWhcSMmH8M,155823
58
58
  wolfhece/xyz_file.py,sha256=aQOcTHkHRhXHxL_WxTHwzygp6e47San7SHSpxKQU0dw,5457
@@ -66,7 +66,7 @@ wolfhece/apps/check_install.py,sha256=jrKR-njqnpIh6ZJqvP6KbDUPVCfwTNQj4glQhcyzs9
66
66
  wolfhece/apps/curvedigitizer.py,sha256=avWERHuVxPnJBOD_ibczwW_XG4vAenqWS8W1zjhBox8,4898
67
67
  wolfhece/apps/isocurrent.py,sha256=4XnNWPa8mYUK7V4zdDRFrHFIXNG2AN2og3TqWKKcqjY,3811
68
68
  wolfhece/apps/splashscreen.py,sha256=m9hMTqzhSUcTudApyNNjoAK9e2u5vgEkJVV79xmfM1s,2118
69
- wolfhece/apps/version.py,sha256=UgOyKKZeqMHM9SHuLgbqUwonY2i_7DM-vnaX7DYSfFE,388
69
+ wolfhece/apps/version.py,sha256=8oE3JduZOrh37rUOmSaJni3r3iRiovCtoxD28-Iwbn0,388
70
70
  wolfhece/apps/wolf.py,sha256=gqfm-ZaUJqNsfCzmdtemSeqLw-GVdSVix-evg5WArJI,293
71
71
  wolfhece/apps/wolf2D.py,sha256=gWD9ee2-1pw_nUxjgRaJMuSe4kUT-RWhOeoTt_Lh1mM,267
72
72
  wolfhece/apps/wolf_logo.bmp,sha256=ruJ4MA51CpGO_AYUp_dB4SWKHelvhOvd7Q8NrVOjDJk,3126
@@ -256,8 +256,8 @@ wolfhece/sounds/sonsw2.wav,sha256=pFLVt6By0_EPQNt_3KfEZ9a1uSuYTgQSX1I_Zurv9Rc,11
256
256
  wolfhece/ui/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
257
257
  wolfhece/ui/wolf_multiselection_collapsiblepane.py,sha256=yGbU_JsF56jsmms0gh7mxa7tbNQ_SxqhpAZxhm-mTy4,14860
258
258
  wolfhece/ui/wolf_times_selection_comparison_models.py,sha256=wCxGRnE3kzEkWlWA6-3X8ADOFux_B0a5QWJ2GnXTgJw,4709
259
- wolfhece-2.0.50.dist-info/METADATA,sha256=qy49InLZbsZEYnSKj_5fYK31CxxJZHDDHlA_1Y3Y16c,2233
260
- wolfhece-2.0.50.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
261
- wolfhece-2.0.50.dist-info/entry_points.txt,sha256=AIu1KMswrdsqNq_2jPtrRIU4tLjuTnj2dCY-pxIlshw,276
262
- wolfhece-2.0.50.dist-info/top_level.txt,sha256=EfqZXMVCn7eILUzx9xsEu2oBbSo9liWPFWjIHik0iCI,9
263
- wolfhece-2.0.50.dist-info/RECORD,,
259
+ wolfhece-2.0.52.dist-info/METADATA,sha256=fl0p2rqonKJIadsbbzLXDsXQgp6l3Z1a7cGZuL13Lc0,2233
260
+ wolfhece-2.0.52.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
261
+ wolfhece-2.0.52.dist-info/entry_points.txt,sha256=AIu1KMswrdsqNq_2jPtrRIU4tLjuTnj2dCY-pxIlshw,276
262
+ wolfhece-2.0.52.dist-info/top_level.txt,sha256=EfqZXMVCn7eILUzx9xsEu2oBbSo9liWPFWjIHik0iCI,9
263
+ wolfhece-2.0.52.dist-info/RECORD,,