wolfhece 2.1.50__py3-none-any.whl → 2.1.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/rem/REMMaker.py CHANGED
@@ -1,13 +1,3 @@
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
1
  #!/usr/bin/env python
12
2
  import os
13
3
  import sys
@@ -228,8 +218,8 @@ class REMMaker(object):
228
218
  if self.count is not None and self.centerline_shp is None:
229
219
  raise ValueError(f'Obligation de donner un shapefile pour en sélectionner une géométrie.')
230
220
  if self.pres is not None:
231
- gdal.Warp(f'{self.dem_name}_warp.tif', self.dem, xRes=self.pres, yRes=self.pres)
232
- r = gdal.Open(f'{self.dem_name}_warp.tif', gdal.GA_ReadOnly)
221
+ gdal.Warp(os.path.join(self.out_dir, f'{self.dem_name}_warp.tif'), self.dem, xRes=self.pres, yRes=self.pres)
222
+ r = gdal.Open(os.path.join(self.out_dir, f'{self.dem_name}_warp.tif'), gdal.GA_ReadOnly)
233
223
  if self.bounds is not None:
234
224
  band = r.GetRasterBand(1)
235
225
  self.dem_array = band.ReadAsArray()
@@ -240,19 +230,19 @@ class REMMaker(object):
240
230
  min_x, max_x = sorted([upper_left_x, upper_left_x + x_size * cols])
241
231
  min_y, max_y = sorted([upper_left_y, upper_left_y + y_size * rows])
242
232
  if self.bounds[0] > min_x and self.bounds[1] > min_y and self.bounds[2] < max_x and self.bounds[3] < max_y:
243
- gdal.Translate(f'{self.dem_name}_crop.tif', r, projWin=(self.bounds[0],self.bounds[3],self.bounds[2],self.bounds[1]))
244
- r = gdal.Open(f'{self.dem_name}_crop.tif', gdal.GA_ReadOnly)
233
+ gdal.Translate(os.path.join(self.out_dir, f'{self.dem_name}_crop.tif'), r, projWin=(self.bounds[0],self.bounds[3],self.bounds[2],self.bounds[1]))
234
+ r = gdal.Open(os.path.join(self.out_dir, f'{self.dem_name}_crop.tif'), gdal.GA_ReadOnly)
245
235
  else:
246
236
  raise ValueError(f"bounds choisi hors DEM. Redéfinir des limites contenues dans x={min_x,max_x:.3f} et y={min_y,max_y:.3f}")
247
237
  if self.count is not None:
248
238
  self.rivers:gpd.GeoDataFrame
249
239
  self.rivers = read_file(self.centerline_shp)
250
240
  upper_left_x, x_size, x_rot, upper_left_y, y_rot, y_size = r.GetGeoTransform()
251
- gdal.Translate(f'{self.dem_name}_crop.tif', r, projWin=(self.rivers.bounds.iloc[self.count].minx-50*x_size,
241
+ gdal.Translate(os.path.join(self.out_dir, f'{self.dem_name}_crop.tif'), r, projWin=(self.rivers.bounds.iloc[self.count].minx-50*x_size,
252
242
  self.rivers.bounds.iloc[self.count].maxy-50*y_size,
253
243
  self.rivers.bounds.iloc[self.count].maxx+50*x_size,
254
244
  self.rivers.bounds.iloc[self.count].miny+50*y_size))
255
- r = gdal.Open(f'{self.dem_name}_crop.tif', gdal.GA_ReadOnly)
245
+ r = gdal.Open(os.path.join(self.out_dir, f'{self.dem_name}_crop.tif'), gdal.GA_ReadOnly)
256
246
  self.proj = osr.SpatialReference(wkt=r.GetProjection())
257
247
  self.epsg_code = self.proj.GetAttrValue('AUTHORITY', 1)
258
248
  self.h_unit = self.proj.GetAttrValue('UNIT')
@@ -426,9 +416,9 @@ class REMMaker(object):
426
416
  self.river_coords = self.ix2coords(self.river_indices)
427
417
  self.river_wses = self.dem_array[self.river_indices]
428
418
  else:
429
- self.rivers = read_file(f'{self.dem_name}_river_pts.shp')
419
+ self.rivers = os.path.join(self.out_dir, f'{self.dem_name}_river_pts.shp')
430
420
  self.rivers['curvi'] = self.river_curvi
431
- self.rivers.to_file(f'{self.dem_name}_river_pts.shp', driver='ESRI Shapefile')
421
+ self.rivers.to_file(os.path.join(self.out_dir, f'{self.dem_name}_river_pts.shp'), driver='ESRI Shapefile')
432
422
  self.river_coords = np.array([curpt.xy for curpt in self.rivers.geometry])
433
423
  self.river_wses = np.array([curpt.z for curpt in self.rivers.geometry])
434
424
  return
@@ -463,9 +453,9 @@ class REMMaker(object):
463
453
  logging.info("Interpolating river elevation across DEM extent.")
464
454
  if not self.k:
465
455
  self.k = self.estimate_k()
466
- self.rivers = read_file(f'{self.dem_name}_river_pts.shp')
456
+ self.rivers = read_file(self.river_shp)
467
457
  self.rivers['curvi'] = self.river_curvi
468
- self.rivers.to_file(f'{self.dem_name}_river_pts.shp', driver='ESRI Shapefile')
458
+ self.rivers.to_file(self.river_shp, driver='ESRI Shapefile')
469
459
  logging.info(f"Using k = {self.k} nearest neighbors.")
470
460
  # coords to interpolate over (don't interpolate where DEM is null or on centerline where REM = 0)
471
461
  interp_indices = np.where(~(np.isnan(self.dem_array) | (self.centerline_array == 1)))
@@ -513,9 +503,9 @@ class REMMaker(object):
513
503
  if self.bounds is None and self.count is None:
514
504
  r = gdal.Open(self.dem, gdal.GA_ReadOnly)
515
505
  if self.bounds is not None or self.count is not None:
516
- r = gdal.Open(f'{self.dem_name}_crop.tif', gdal.GA_ReadOnly)
506
+ r = gdal.Open(os.path.join(self.out_dir, f'{self.dem_name}_crop.tif'), gdal.GA_ReadOnly)
517
507
  if self.pres is not None and self.bounds is None and self.count is None:
518
- r = gdal.Open(f'{self.dem_name}_warp.tif', gdal.GA_ReadOnly)
508
+ r = gdal.Open(os.path.join(self.out_dir, f'{self.dem_name}_warp.tif'), gdal.GA_ReadOnly)
519
509
  driver = gdal.GetDriverByName("GTiff")
520
510
  rem = driver.CreateCopy(self.rem_ras, r, strict=0)
521
511
  # fill with REM array
@@ -565,9 +555,9 @@ class REMMaker(object):
565
555
  if self.bounds is None and self.count is None:
566
556
  dem_viz = RasterViz(self.dem, out_dir=self.cache_dir, out_ext=".tif")
567
557
  if self.bounds is not None or self.count is not None:
568
- dem_viz = RasterViz(f'{self.dem_name}_crop.tif', out_dir=self.cache_dir, out_ext=".tif")
558
+ dem_viz = RasterViz(os.path.join(self.out_dir, f'{self.dem_name}_crop.tif'), out_dir=self.cache_dir, out_ext=".tif")
569
559
  if self.pres is not None and self.bounds is None and self.count is None:
570
- dem_viz = RasterViz(f'{self.dem_name}_warp.tif', out_dir=self.cache_dir, out_ext=".tif")
560
+ dem_viz = RasterViz(os.path.join(self.out_dir, f'{self.dem_name}_warp.tif'), out_dir=self.cache_dir, out_ext=".tif")
571
561
  dem_viz.make_hillshade(multidirectional=True, z=z)
572
562
  # make color-relief of REM in cache dir
573
563
  rem_viz = RasterViz(self.rem_ras, out_dir=self.cache_dir, out_ext=".tif", make_png=make_png, make_kmz=make_kmz, *args, **kwargs)
wolfhece/rem/RasterViz.py CHANGED
@@ -1,13 +1,3 @@
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
1
  #!/usr/bin/env python
12
2
  import os
13
3
  import sys
@@ -26,46 +16,46 @@ This script can be called from Python using its class/methods or as a CLI utilit
26
16
 
27
17
  CLI Usage:
28
18
 
29
- "python RasterViz.py viz_type [-z (default=1)] [-alt (default=45)] [-azim (default=315)] [-multidirectional]
30
- [-cmap (default=terrain)] [-out_ext tif | img (default=tif)] [-make_png] [-make_kmz] [-docker] [-shell]
19
+ "python RasterViz.py viz_type [-z (default=1)] [-alt (default=45)] [-azim (default=315)] [-multidirectional]
20
+ [-cmap (default=terrain)] [-out_ext tif | img (default=tif)] [-make_png] [-make_kmz] [-docker] [-shell]
31
21
  /path/to/dem"
32
22
 
33
23
  Options:
34
-
35
- viz_type: string corresponding to raster product to be produced, one of the following strings:
24
+
25
+ viz_type: string corresponding to raster product to be produced, one of the following strings:
36
26
  ["hillshade", "slope", "aspect", "roughness", "color-relief", "hillshade-color"]
37
-
27
+
38
28
  -z: only if using "hillshade" or "hillshade-color" viz_type,
39
29
  factor to scale/exaggerate vertical topographic differences. Default 1 (no rescale).
40
-
41
- -alt: only if using "hillshade" or "hillshade-color" viz_type,
30
+
31
+ -alt: only if using "hillshade" or "hillshade-color" viz_type,
42
32
  altitude of light source in degrees [0-90]. Default 45.
43
-
44
- -azim: only if using "hillshade" or "hillshade-color" viz_type,
33
+
34
+ -azim: only if using "hillshade" or "hillshade-color" viz_type,
45
35
  azimuth of light source in degrees [0-360]. Default 315.
46
-
47
- -multidirectional: only if using "hillshade" or "hillshade-color" viz_type.
36
+
37
+ -multidirectional: only if using "hillshade" or "hillshade-color" viz_type.
48
38
  Makes multidirectional hillshade, overriding alt and azim args.
49
-
39
+
50
40
  -cmap: only if using "color-relief" viz_type, name of a matplotlib or seaborn colormap. Default "terrain".
51
41
  (see https://matplotlib.org/stable/gallery/color/colormap_reference.html)
52
-
42
+
53
43
  -out_ext: the extension/file format to use for geodata outputs (tif or img). Default "tif".
54
-
44
+
55
45
  -make_png: output a png version (EPSG:3857) of the viz_type in addition to the viz raster in source projection.
56
-
46
+
57
47
  -make_kmz: output a kmz version of the viz_type in addition to the viz raster in source projection.
58
-
48
+
59
49
  -docker: run GDAL commands from within the osgeo/gdal docker container. This makes it run slightly slower but will
60
50
  be needed to run all features if gdal install is on a version <2.2. If using docker, input path must be
61
51
  within the working directory path or a subdirectory.
62
-
52
+
63
53
  -shell: call GDAL functions (gdaldem, gdal_translate, gdalwarp) as shell commands instead of using Python bindings.
64
54
  This may be faster than using pure Python but requires additional environment configuration.
65
55
 
66
56
  /path/to/dem.tif: path to input DEM, currently assumed to be in GeoTIFF format.
67
57
 
68
- Notes: Output file naming convention uses the DEM basename as a prefix, then viz_type and file extension.
58
+ Notes: Output file naming convention uses the DEM basename as a prefix, then viz_type and file extension.
69
59
  E.g. output.tin.tif --> output_hillshade.tif, output_hillshade.png, output_hillshade.kmz.
70
60
  Outputs are saved to the working directory.
71
61
 
wolfhece/wolf_array.py CHANGED
@@ -95,6 +95,39 @@ WOLF_ARRAY_MB = [WOLF_ARRAY_MB_SINGLE, WOLF_ARRAY_MB_INTEGER, WOLF_ARRAY_MNAP_IN
95
95
 
96
96
  VERSION_RGB = 2
97
97
 
98
+ from numba import jit
99
+
100
+ @jit(nopython=True)
101
+ def custom_gradient(array: np.ndarray):
102
+ """ Calculate the gradient manually """
103
+ grad_x = np.zeros_like(array)
104
+ grad_y = np.zeros_like(array)
105
+
106
+ for i in range(1, array.shape[0] - 1):
107
+ for j in range(1, array.shape[1] - 1):
108
+ grad_x[i, j] = (array[i + 1, j] - array[i - 1, j]) / 2.0
109
+ grad_y[i, j] = (array[i, j + 1] - array[i, j - 1]) / 2.0
110
+
111
+ return grad_x, grad_y
112
+
113
+ @jit(nopython=True)
114
+ def hillshade(array:np.ndarray, azimuth:float, angle_altitude:float) -> np.ndarray:
115
+ """ Create a hillshade array """
116
+
117
+ azimuth = 360.0 - azimuth
118
+
119
+ x, y = custom_gradient(array)
120
+ slope = np.pi / 2. - np.arctan(np.sqrt(x * x + y * y))
121
+ aspect = np.arctan2(-x, y)
122
+ azimuthrad = azimuth * np.pi / 180.
123
+ altituderad = angle_altitude * np.pi / 180.
124
+
125
+ shaded = np.sin(altituderad) * np.sin(slope) + np.cos(altituderad) * \
126
+ np.cos(slope) * np.cos((azimuthrad - np.pi / 2.) - aspect)
127
+ shaded += 1.
128
+ shaded *= .5
129
+
130
+ return shaded.astype(np.float32)
98
131
  class Rebin_Ops(Enum):
99
132
  MIN = 0
100
133
  MEAN = 1
@@ -1488,7 +1521,7 @@ class Ops_Array(wx.Frame):
1488
1521
 
1489
1522
  self.palimage = wx.Button(self.Palette, wx.ID_ANY, _("Create image"), wx.DefaultPosition, wx.DefaultSize, 0)
1490
1523
  self.palimage.SetToolTip(_('Generate colormap image (horizontal, vertical or both) and save to disk'))
1491
- self.paldistribute = wx.Button(self.Palette, wx.ID_ANY, _("Distribute"), wx.DefaultPosition, wx.DefaultSize, 0)
1524
+ self.paldistribute = wx.Button(self.Palette, wx.ID_ANY, _("Evenly spaced"), wx.DefaultPosition, wx.DefaultSize, 0)
1492
1525
  self.paldistribute.SetToolTip(_('Set colormap values based on minimum+maximum or minimum+step'))
1493
1526
  if self.parentarray.mypal.automatic:
1494
1527
  self.palauto.SetValue(1)
@@ -2648,7 +2681,8 @@ class Ops_Array(wx.Frame):
2648
2681
  myarray.mypal.export_image()
2649
2682
 
2650
2683
  def Onpaldistribute(self, event:wx.MouseEvent):
2651
- """ Distribute values in palette """
2684
+ """ Evenly spaced values in palette """
2685
+
2652
2686
  myarray: WolfArray
2653
2687
  myarray = self.parentarray
2654
2688
  myarray.mypal.distribute_values()
@@ -4566,7 +4600,6 @@ class WolfArray(Element_To_Draw, header_wolf):
4566
4600
  @property
4567
4601
  def nullvalue(self) -> float:
4568
4602
  """ Return the null value """
4569
-
4570
4603
  return self._nullvalue
4571
4604
 
4572
4605
  @nullvalue.setter
@@ -4575,6 +4608,16 @@ class WolfArray(Element_To_Draw, header_wolf):
4575
4608
 
4576
4609
  self._nullvalue = value
4577
4610
 
4611
+ @property
4612
+ def nodata(self) -> float:
4613
+ """ alias for nullvalue """
4614
+ return self._nullvalue
4615
+
4616
+ @nodata.setter
4617
+ def nodata(self, value:float):
4618
+ """ alias for nullvalue """
4619
+ self._nullvalue = value
4620
+
4578
4621
  @property
4579
4622
  def SelectionData(self) -> SelectionData:
4580
4623
  """ Return the data of the selection """
@@ -5757,23 +5800,10 @@ class WolfArray(Element_To_Draw, header_wolf):
5757
5800
  return mytri, znull
5758
5801
 
5759
5802
  def hillshade(self, azimuth:float, angle_altitude:float):
5760
- """ Create a hillshade array """
5761
-
5762
- azimuth = 360.0 - azimuth
5763
-
5764
- x, y = np.gradient(self.array)
5765
- slope = np.pi / 2. - np.arctan(np.sqrt(x * x + y * y))
5766
- aspect = np.arctan2(-x, y)
5767
- azimuthrad = azimuth * np.pi / 180.
5768
- altituderad = angle_altitude * np.pi / 180.
5769
-
5770
- shaded = np.sin(altituderad) * np.sin(slope) + np.cos(altituderad) * np.cos(slope) * np.cos(
5771
- (azimuthrad - np.pi / 2.) - aspect)
5772
- shaded += 1.
5773
- shaded *= .5
5803
+ """ Create a hillshade array -- see "hillshade" function accelerated by JIT"""
5774
5804
 
5775
5805
  self.shaded.set_header(self.get_header())
5776
- self.shaded.array = shaded
5806
+ self.shaded.array = hillshade(self.array.data, azimuth, angle_altitude)
5777
5807
  self.shaded.delete_lists()
5778
5808
 
5779
5809
  def get_gradient_norm(self):
@@ -7616,20 +7646,22 @@ class WolfArray(Element_To_Draw, header_wolf):
7616
7646
  WOLF_ARRAY_FULL_INTEGER16,
7617
7647
  WOLF_ARRAY_FULL_INTEGER16_2,
7618
7648
  WOLF_ARRAY_FULL_INTEGER,
7619
- WOLF_ARRAY_FULL_DOUBLE]:
7649
+ WOLF_ARRAY_FULL_DOUBLE,
7650
+ WOLF_ARRAY_HILLSHAPE]:
7620
7651
  # FIXME: Currently, only some types are supported in Cython/OpenGL library
7621
7652
  self._tmp_float32 = self.array.astype(dtype=np.float32)
7622
7653
  else:
7623
7654
  self._tmp_float32 = None
7624
7655
 
7625
7656
 
7626
- # if self.shading:
7627
- # pond = (self.shaded.array-.5)*2.
7628
- # pmin = (1. - self.shaded.alpha) * self.rgb
7629
- # pmax = self.shaded.alpha * np.ones(self.rgb.shape) + (1. - self.shaded.alpha) * self.rgb
7630
- # for i in range(4):
7631
- # self.rgb[pond<0,i] = self.rgb[pond<0,i] * (1.+pond[pond<0]) - pmin[pond<0,i] * pond[pond<0]
7632
- # self.rgb[pond>0,i] = self.rgb[pond>0,i] * (1.-pond[pond>0]) + pmax[pond>0,i] * pond[pond>0]
7657
+ if VERSION_RGB==1 :
7658
+ if self.shading:
7659
+ pond = (self.shaded.array-.5)*2.
7660
+ pmin = (1. - self.shaded.alpha) * self.rgb
7661
+ pmax = self.shaded.alpha * np.ones(self.rgb.shape) + (1. - self.shaded.alpha) * self.rgb
7662
+ for i in range(4):
7663
+ self.rgb[pond<0,i] = self.rgb[pond<0,i] * (1.+pond[pond<0]) - pmin[pond<0,i] * pond[pond<0]
7664
+ self.rgb[pond>0,i] = self.rgb[pond>0,i] * (1.-pond[pond>0]) + pmax[pond>0,i] * pond[pond>0]
7633
7665
 
7634
7666
  if VERSION_RGB==1 : self.rgb[self.array.mask] = [1., 1., 1., 0.]
7635
7667
 
@@ -7719,11 +7751,15 @@ class WolfArray(Element_To_Draw, header_wolf):
7719
7751
 
7720
7752
  if self.wolftype != WOLF_ARRAY_HILLSHAPE and self.shading:
7721
7753
  self.hillshade(self.azimuthhill, self.altitudehill)
7722
- self.updatepalette(0)
7723
- self.shaded.updatepalette(0)
7754
+
7755
+ if VERSION_RGB==1 :
7756
+ self.updatepalette(0)
7757
+ self.shaded.updatepalette(0)
7758
+
7724
7759
  self.shading=False
7725
7760
  if self.mapviewer is not None:
7726
- if not self.idx + '_hillshade' in self.mapviewer.get_list_keys(self.mapviewer.ARRAYS, False) :# .added['arrays'].keys():
7761
+ from .PyDraw import draw_type
7762
+ if not self.idx + '_hillshade' in self.mapviewer.get_list_keys(drawing_type=draw_type.ARRAYS, checked_state= None) :# .added['arrays'].keys():
7727
7763
  self.mapviewer.add_object('array', newobj=self.shaded, ToCheck=True, id=self.idx + '_hillshade')
7728
7764
 
7729
7765
  try:
@@ -7739,12 +7775,14 @@ class WolfArray(Element_To_Draw, header_wolf):
7739
7775
  mylist = self.mygrid[cursize]['mylists'][i, j]
7740
7776
  if mylist > 0:
7741
7777
  glCallList(self.mygrid[cursize]['mylists'][i, j])
7742
- except:
7743
- pass
7778
+ except Exception as e:
7779
+ logging.error(_('OpenGL error in WolfArray.plot 1 -- Please report this case with the data file and the context in which the error occured'))
7780
+ logging.error(e)
7744
7781
 
7745
7782
  glDisable(GL_BLEND)
7746
- except:
7747
- logging.error(_('OpenGL error in WolfArray.plot -- Please report this case with the data file and the context in which the error occured'))
7783
+ except Exception as e:
7784
+ logging.error(_('OpenGL error in WolfArray.plot 2 -- Please report this case with the data file and the context in which the error occured'))
7785
+ logging.error(e)
7748
7786
 
7749
7787
  self.plotting = False
7750
7788
 
@@ -7793,9 +7831,7 @@ class WolfArray(Element_To_Draw, header_wolf):
7793
7831
  def fillonecellgrid(self, curscale, loci, locj, force=False):
7794
7832
  """ Fill one cell of the plotted grid """
7795
7833
 
7796
-
7797
-
7798
- cursize = curscale # 2**curscale
7834
+ cursize = curscale
7799
7835
 
7800
7836
  if not cursize in self.mygrid.keys():
7801
7837
  return
@@ -7875,22 +7911,28 @@ class WolfArray(Element_To_Draw, header_wolf):
7875
7911
  elif self.nbnotnull > 0:
7876
7912
  wolfogl.addmeall_double_pal(self.array, self.mypal.colorsflt, self.mypal.values, ox, oy, dx, dy, jstart,
7877
7913
  jend, istart, iend, cursize, self.nullvalue, self.alpha, int(self.mypal.interval_cst))
7878
- elif self.wolftype != WOLF_ARRAY_FULL_SINGLE:
7914
+ elif self.wolftype not in [WOLF_ARRAY_FULL_SINGLE, WOLF_ARRAY_HILLSHAPE]:
7879
7915
  if self.nbnotnull != self.nbx * self.nby:
7880
7916
  if self.nbnotnull > 0:
7881
7917
  wolfogl.addme_pal(self._tmp_float32, self.mypal.colorsflt, self.mypal.values, ox, oy, dx, dy, jstart,
7882
- jend, istart, iend, cursize, self.nullvalue, self.alpha, int(self.mypal.interval_cst))
7918
+ jend, istart, iend, cursize, self.nullvalue, self.alpha, int(self.mypal.interval_cst), -1.)
7883
7919
  elif self.nbnotnull > 0:
7884
7920
  wolfogl.addmeall_pal(self._tmp_float32, self.mypal.colorsflt, self.mypal.values, ox, oy, dx, dy, jstart,
7885
- jend, istart, iend, cursize, self.nullvalue, self.alpha, int(self.mypal.interval_cst))
7921
+ jend, istart, iend, cursize, self.nullvalue, self.alpha, int(self.mypal.interval_cst), -1.)
7886
7922
  else:
7923
+ clr_float = self.mypal.colorsflt.copy()
7924
+ clr_float[:,3] = self.alpha
7925
+ if '_hillshade' in self.idx:
7926
+ clr_float[1,3] = 0.
7927
+
7887
7928
  if self.nbnotnull != self.nbx * self.nby:
7888
7929
  if self.nbnotnull > 0:
7889
- wolfogl.addme_pal(self.array, self.mypal.colorsflt, self.mypal.values, ox, oy, dx, dy, jstart, jend, istart, iend, cursize,
7890
- self.nullvalue, self.alpha, int(self.mypal.interval_cst))
7930
+
7931
+ wolfogl.addme_pal(self.array, clr_float, self.mypal.values, ox, oy, dx, dy, jstart, jend, istart, iend, cursize,
7932
+ self.nullvalue, self.alpha, int(self.mypal.interval_cst), -1.)
7891
7933
  elif self.nbnotnull > 0:
7892
- wolfogl.addmeall_pal(self.array, self.mypal.colorsflt, self.mypal.values, ox, oy, dx, dy, jstart, jend, istart, iend, cursize,
7893
- self.nullvalue, self.alpha, int(self.mypal.interval_cst))
7934
+ wolfogl.addmeall_pal(self.array, clr_float, self.mypal.values, ox, oy, dx, dy, jstart, jend, istart, iend, cursize,
7935
+ self.nullvalue, self.alpha, int(self.mypal.interval_cst), -1.)
7894
7936
 
7895
7937
  except Exception as e:
7896
7938
  logging.error(repr(e))
@@ -243,8 +243,13 @@ class Props_Res_2D(wx.Frame):
243
243
 
244
244
  self._cm_save = wx.Button(self._panel_colormap, wx.ID_ANY, _("Save to file"), wx.DefaultPosition, wx.DefaultSize, 0)
245
245
  self._cm_save.SetToolTip(_('Save colormap on .pal file'))
246
+
246
247
  self._cm_load = wx.Button(self._panel_colormap, wx.ID_ANY, _("Load from file"), wx.DefaultPosition, wx.DefaultSize, 0)
247
248
  self._cm_load.SetToolTip(_('Load colormap from .pal file'))
249
+
250
+ self._cm_default_pal = wx.Button(self._panel_colormap, wx.ID_ANY, _("Load precomputed"), wx.DefaultPosition, wx.DefaultSize, 0)
251
+ self._cm_default_pal.SetToolTip(_('Load a default colormap available in the software'))
252
+
248
253
  self._cm_toimage = wx.Button(self._panel_colormap, wx.ID_ANY, _("Create image"), wx.DefaultPosition, wx.DefaultSize, 0)
249
254
  self._cm_toimage.SetToolTip(_('Generate colormap image (horizontal, vertical or both) and save to disk'))
250
255
  self._cm_distribute = wx.Button(self._panel_colormap, wx.ID_ANY, _("Distribute"), wx.DefaultPosition, wx.DefaultSize, 0)
@@ -296,7 +301,14 @@ class Props_Res_2D(wx.Frame):
296
301
 
297
302
  self._panel_colormap.sizer.Add(self._cm_choose_color, 1, wx.EXPAND)
298
303
  self._panel_colormap.sizer.Add(self._cm_apply, 1, wx.EXPAND)
299
- self._panel_colormap.sizer.Add(self._cm_load, 1, wx.EXPAND)
304
+
305
+ sizer_loadpal = wx.BoxSizer(wx.HORIZONTAL)
306
+
307
+ self._panel_colormap.sizer.Add(sizer_loadpal, 1, wx.EXPAND)
308
+
309
+ sizer_loadpal.Add(self._cm_load, 1, wx.EXPAND)
310
+ sizer_loadpal.Add(self._cm_default_pal, 1, wx.EXPAND)
311
+
300
312
  self._panel_colormap.sizer.Add(self._cm_save, 1, wx.EXPAND)
301
313
  self._panel_colormap.sizer.Add(self._cm_toimage, 1, wx.EXPAND)
302
314
  self._panel_colormap.sizer.Add(self._cm_distribute, 1 , wx.EXPAND)
@@ -636,7 +648,10 @@ class Props_Res_2D(wx.Frame):
636
648
  self._Apply_Tools.Bind(wx.EVT_BUTTON, self.OnApplyTools)
637
649
  self._cm_apply.Bind(wx.EVT_BUTTON, self.Onupdatepal)
638
650
  self._cm_save.Bind(wx.EVT_BUTTON, self.Onsavepal)
651
+
639
652
  self._cm_load.Bind(wx.EVT_BUTTON, self.Onloadpal)
653
+ self._cm_default_pal.Bind(wx.EVT_BUTTON, self.Onloaddefaultpal)
654
+
640
655
  self._cm_toimage.Bind(wx.EVT_BUTTON, self.Onpalimage)
641
656
  self._cm_distribute.Bind(wx.EVT_BUTTON, self.Onpaldistribute)
642
657
  self._cm_choose_color.Bind(wx.EVT_BUTTON, self.OnClickColorPal)
@@ -712,7 +727,7 @@ class Props_Res_2D(wx.Frame):
712
727
  # Fill the grid
713
728
  self._parent.mypal.fillgrid(self._cm_grid)
714
729
 
715
- def Onsavepal(self, event):
730
+ def Onsavepal(self, event:wx.MouseEvent):
716
731
  """ Save the colormap to a file """
717
732
 
718
733
  self._parent.mypal.savefile()
@@ -728,6 +743,38 @@ class Props_Res_2D(wx.Frame):
728
743
  self._parent.set_currentview()
729
744
  self.update_palette()
730
745
 
746
+ def Onloaddefaultpal(self, event:wx.MouseEvent):
747
+ """ Load default palette """
748
+
749
+ import glob
750
+ from pathlib import Path
751
+
752
+ # list of all .pal file in model directory
753
+
754
+ dirpal = Path(__file__).parent / 'models'
755
+
756
+ listpal = glob.glob(str(dirpal) + '/*.pal')
757
+
758
+ if len(listpal) == 0:
759
+ logging.info('No default palette found')
760
+ return
761
+
762
+ listpal = [Path(i).name for i in listpal]
763
+
764
+ dlg = wx.SingleChoiceDialog(None, 'Choose the default palette', 'Default palette', listpal)
765
+ ret = dlg.ShowModal()
766
+
767
+ if ret == wx.ID_CANCEL:
768
+ dlg.Destroy()
769
+
770
+ self._parent.mypal.readfile(str(dirpal / dlg.GetStringSelection()))
771
+
772
+ self._parent.mypal.automatic = False
773
+ self._cm_auto.SetValue(0)
774
+ self.update_palette()
775
+
776
+ self._parent.set_currentview()
777
+
731
778
  def Onpalimage(self, event):
732
779
  """ Export the colormap to an image """
733
780
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: wolfhece
3
- Version: 2.1.50
3
+ Version: 2.1.52
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
@@ -13,14 +13,14 @@ Classifier: Topic :: Scientific/Engineering :: Physics
13
13
  Requires-Python: <3.11,>=3.10
14
14
  Description-Content-Type: text/markdown
15
15
  Requires-Dist: wxpython
16
- Requires-Dist: colorlog ==6.7.*
16
+ Requires-Dist: colorlog==6.7.*
17
17
  Requires-Dist: intel-fortran-rt
18
18
  Requires-Dist: scikit-learn
19
19
  Requires-Dist: cryptography
20
- Requires-Dist: jax ==0.4.30
20
+ Requires-Dist: jax==0.4.30
21
21
  Requires-Dist: triangle
22
- Requires-Dist: numpy ==1.23.*
23
- Requires-Dist: pyopengl ==3.1.*
22
+ Requires-Dist: numpy==1.23.*
23
+ Requires-Dist: pyopengl==3.1.*
24
24
  Requires-Dist: pandas
25
25
  Requires-Dist: geopandas
26
26
  Requires-Dist: scipy
@@ -33,7 +33,7 @@ Requires-Dist: graphviz
33
33
  Requires-Dist: beautifulsoup4
34
34
  Requires-Dist: requests
35
35
  Requires-Dist: notebook
36
- Requires-Dist: matplotlib ==3.6.*
36
+ Requires-Dist: matplotlib==3.6.*
37
37
  Requires-Dist: mkl
38
38
  Requires-Dist: python-gettext
39
39
  Requires-Dist: shapely
@@ -49,10 +49,10 @@ Requires-Dist: python-docx
49
49
  Requires-Dist: pygltflib
50
50
  Requires-Dist: ezdxf
51
51
  Requires-Dist: pyvista
52
- Requires-Dist: tqdm ==4.64.*
52
+ Requires-Dist: tqdm==4.64.*
53
53
  Requires-Dist: osmnx
54
54
  Requires-Dist: tifffile
55
- Requires-Dist: numba ==0.58.*
55
+ Requires-Dist: numba==0.58.*
56
56
  Requires-Dist: xmltodict
57
57
  Requires-Dist: opencv-python
58
58
  Requires-Dist: xarray
@@ -11,7 +11,7 @@ wolfhece/PyDraw.py,sha256=_Rfx59LMopR0Cx00d1RRF5Gb-WNxfA2v2RjkOfm84Yo,390847
11
11
  wolfhece/PyGui.py,sha256=aRWv9tBpRl7sKEd2gHWj8Bss0ZOKbGlUYIehWHFm8WY,105008
12
12
  wolfhece/PyGuiHydrology.py,sha256=f60E8K9eGTnRq5RDF6yvt-ahf2AYegwQ9t25zZ2Mk1A,14946
13
13
  wolfhece/PyHydrographs.py,sha256=jwtSNMMACwarxrtN1UeQYth99UNrhwPx1IGgUwcooHA,3774
14
- wolfhece/PyPalette.py,sha256=5TvXF5wWDxP4e70zO9B0UMgVP9c0oAzerM28aoJ1CTg,27982
14
+ wolfhece/PyPalette.py,sha256=3ehK6H2PvqSe0zICR1HyNs6KQokR1DmnAh4LwYnLIcU,28009
15
15
  wolfhece/PyParams.py,sha256=wwgmP-_7wiiPLTcyX8a5jR6FyC1D2c4oBPc1VWQqtSA,97383
16
16
  wolfhece/PyPictures.py,sha256=m1kY0saW6Y9Q0bDCo47lW6XxDkBrbQG-Fd8uVn8G5ic,2514
17
17
  wolfhece/PyTranslate.py,sha256=4appkmNeHHZLFmUtaA_k5_5QL-5ymxnbVN4R2OblmtE,622
@@ -48,13 +48,13 @@ 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=HnrviXNSps9LFDERXyeZmI0L2ovFYY4rBHInPBZLRGw,368994
51
+ wolfhece/wolf_array.py,sha256=4B0rihTY4yu0t8mrt99aV_3VCf0PP_K72SAFFkycclc,370660
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
55
55
  wolfhece/wolf_vrt.py,sha256=89XoDhCJMHiwPQUuOduxtTRKuIa8RDxgNqX65S4xp9M,10569
56
56
  wolfhece/wolf_zi_db.py,sha256=baE0niMCzybWGSvPJc5FNxo9ZxsGfU4p-FmfiavFHAs,12967
57
- wolfhece/wolfresults_2D.py,sha256=f6ezVnKw9LFjh1ynYkga-llDIsDF3BPpR-GYX38-YfE,166127
57
+ wolfhece/wolfresults_2D.py,sha256=J6GBaLlwtRQKRsFnZzvxc-5m9QVSzN0xCiMJA-yXIHs,167541
58
58
  wolfhece/xyz_file.py,sha256=Se4nCPwYAYLSA5i0zsbnZUKoAMAD0mK1FJea5WSZUkk,5755
59
59
  wolfhece/acceptability/Parallels.py,sha256=h4tu3SpC_hR5Hqa68aruxhtAyhs8u666YuZ40_fR5zg,3979
60
60
  wolfhece/acceptability/__init__.py,sha256=hfgoPKLDpX7drN1Vpvux-_5Lfyc_7feT2C2zQr5v-Os,258
@@ -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=3OLK8XkmHW4Hi1ttOxzIDZZILVtXKvYakGuhqG-0N4U,388
75
+ wolfhece/apps/version.py,sha256=9OZ-YcusCh_gbdccX8m4dCLa-9wqi_9uiTxPepfbdRA,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
@@ -191,7 +191,7 @@ wolfhece/libs/vcomp100.dll,sha256=NKvXc8hc4MrFa9k8ErALA6OmldGfR3zidaZPCZhMVJI,57
191
191
  wolfhece/libs/vcruntime140.dll,sha256=gPBsB0DzEBn3b7E5ihESs-AtG4Cu59OnONR1QI17TGA,98720
192
192
  wolfhece/libs/vcruntime140_1.dll,sha256=KZJoe26L6i76Krqne_OribgfhN6LxJQEcs0Xn_01hP8,38304
193
193
  wolfhece/libs/verify_wolf.cp310-win_amd64.pyd,sha256=Cej6r7o8cOF58sXs97kjPN4ddd-ZjDyYZ_WkR0Nmivo,128512
194
- wolfhece/libs/wolfogl.cp310-win_amd64.pyd,sha256=e27Epa44wBSrXiwzeUpl2ud8oCPJpFbfWd_5P5l6sAo,294912
194
+ wolfhece/libs/wolfogl.cp310-win_amd64.pyd,sha256=l2ZpPh_dGLWcvYxM0BdLHhfSYrLhQI5rT59rRwyQjCY,296448
195
195
  wolfhece/libs/wolfpy.cp310-win_amd64.pyd,sha256=6omqEaxmQll-Gg24e90wVomAB9rO_tyyOES2FewXn58,36457472
196
196
  wolfhece/libs/zlib1.dll,sha256=E9a0e62VgmG1A8ohZzhVCmmfGtbyXxXu4aFeADTNJ30,77824
197
197
  wolfhece/libs/GL/gl.h,sha256=IhsS_fOLa8GW9MpiLZebe9QYRy6uIB_qK_uQMWMOoeg,46345
@@ -224,10 +224,12 @@ wolfhece/models/Froude.pal,sha256=FmrvUI01fv4k0ygqDJEYdC1M9Fn72Sr6Sn2IlZAm0KA,13
224
224
  wolfhece/models/HECE_169.pptx,sha256=OWJtsWz504A-REFaaxw8lwStHyQU2l7KEeiE7IZvtbk,3396930
225
225
  wolfhece/models/Risque_TAF.pal,sha256=Tnbx-_gIyCszzwmwo0I9vvFfVVKmATjFXS89AoZwTOs,135
226
226
  wolfhece/models/blue.pal,sha256=s9-wEPzSiKMMHuKofUB2FPjmyO7HfGM2xWaUJwsKAY8,39
227
+ wolfhece/models/blues.pal,sha256=0ZEU1p9EcKwsCvNjU0s9_9aVakqQ71LDNoddVBAluEs,509
227
228
  wolfhece/models/classes.pal,sha256=3gbCVboKhCYJZYOZVHeIco1kJJuSg0VE8BvX5JK6fTU,273
228
229
  wolfhece/models/diff16.pal,sha256=Pkp9kQ1GvmAKz3lgwohsw8eQySjVVKHbjhoWw-gZ6Nc,303
229
230
  wolfhece/models/diff3.pal,sha256=qk-yGgJr_FHdW7p7i93GFsH9ClT0dl5nqa9G1lLh7Z0,50
230
231
  wolfhece/models/haut_coul.pal,sha256=eEwfZ-noqp09YvH3uvElLRgf4xcgaZIfyk4ntqlVTss,496
232
+ wolfhece/models/mako.pal,sha256=F988XGge2o7edAoQwU2CR-40daEz5uA0Bi4_12Ekj8Y,8624
231
233
  wolfhece/models/red.pal,sha256=W6oeIjDCoGCsJDZPH2K4jfyfPmCMlH9rfRi4PTs-n28,33
232
234
  wolfhece/models/reg_20cm.pal,sha256=S_lFMUkc_L9ih0k0XnOG7W9_PCg9J2Lm9ZMS-nloJ1E,366
233
235
  wolfhece/models/shields.pal,sha256=TwPhfaly2j3ZRM5ahlz7xH19NArZlalxYNy1L_UnJoA,166
@@ -247,8 +249,8 @@ wolfhece/pythonfortran/example_numpy_memory.py,sha256=o3hzJDw7YtE4v0FXI3-l2VzupC
247
249
  wolfhece/pythonfortran/tools.py,sha256=oYh9MguRYEGNGKVbHqQW2V9okZJLs3n4Qs-vLWPmBe4,2462
248
250
  wolfhece/radar/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
249
251
  wolfhece/radar/wolfradar.py,sha256=mvsVf6-4KCqVF6kWsKfPuM7KPqRdYHuIZAbb8kzXAZU,10032
250
- wolfhece/rem/REMMaker.py,sha256=xPEnjOJCDzAjf2k1SzQI1oSj4mbrcCD9PTOV3HlXCoM,31088
251
- wolfhece/rem/RasterViz.py,sha256=JaAdbJHjvrNpJ5kuMNY-JPDTSRWm0Pw6k3JNGoWp5HQ,29426
252
+ wolfhece/rem/REMMaker.py,sha256=k1kOb_69kNw00HRPbTc_E2XTypiyV0mADDbW5etkBAs,31079
253
+ wolfhece/rem/RasterViz.py,sha256=fnyMfAJZDoS-rjagsNRGLndS-UYNUzMY4DgenjD3Y_4,29068
252
254
  wolfhece/rem/__init__.py,sha256=S2-J5uEGK_VaMFjRUYFIdSScJjZyuXH4RmMmnG3OG7I,19
253
255
  wolfhece/report/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
254
256
  wolfhece/report/reporting.py,sha256=JUEXovx_S4jpYkJEBU0AC-1Qw2OkkWyV3VAp6iOfSHc,19494
@@ -278,8 +280,8 @@ wolfhece/ui/wolf_multiselection_collapsiblepane.py,sha256=8PlMYrb_8jI8h9F0_EagpM
278
280
  wolfhece/ui/wolf_times_selection_comparison_models.py,sha256=ORy7fz4dcp691qKzaOZHrRLZ0uXNhL-LIHxmpDGL6BI,5007
279
281
  wolfhece/wintab/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
280
282
  wolfhece/wintab/wintab.py,sha256=8A-JNONV6ujgsgG3lM5Uw-pVgglPATwKs86oBzzljoc,7179
281
- wolfhece-2.1.50.dist-info/METADATA,sha256=hDyP3-DlayT9vmBCHDj-deR_EczWlyXfofxjPknApok,2548
282
- wolfhece-2.1.50.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
283
- wolfhece-2.1.50.dist-info/entry_points.txt,sha256=Q5JuIWV4odeIJI3qc6fV9MwRoz0ezqPVlFC1Ppm_vdQ,395
284
- wolfhece-2.1.50.dist-info/top_level.txt,sha256=EfqZXMVCn7eILUzx9xsEu2oBbSo9liWPFWjIHik0iCI,9
285
- wolfhece-2.1.50.dist-info/RECORD,,
283
+ wolfhece-2.1.52.dist-info/METADATA,sha256=dUwuLJdHXEFQCK3QEjlpob02jeFO6Ix1VENGT7JnBSk,2541
284
+ wolfhece-2.1.52.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
285
+ wolfhece-2.1.52.dist-info/entry_points.txt,sha256=Q5JuIWV4odeIJI3qc6fV9MwRoz0ezqPVlFC1Ppm_vdQ,395
286
+ wolfhece-2.1.52.dist-info/top_level.txt,sha256=EfqZXMVCn7eILUzx9xsEu2oBbSo9liWPFWjIHik0iCI,9
287
+ wolfhece-2.1.52.dist-info/RECORD,,