wolfhece 2.1.98__py3-none-any.whl → 2.1.100__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/PyDraw.py +506 -35
- wolfhece/PyParams.py +18 -8
- wolfhece/PyVertex.py +12 -5
- wolfhece/PyVertexvectors.py +27 -16
- wolfhece/Results2DGPU.py +23 -7
- wolfhece/acceptability/Parallels.py +2 -2
- wolfhece/acceptability/_add_path.py +23 -0
- wolfhece/acceptability/acceptability.py +594 -563
- wolfhece/acceptability/acceptability_gui.py +564 -331
- wolfhece/acceptability/cli.py +307 -120
- wolfhece/acceptability/func.py +1743 -1597
- wolfhece/analyze_vect.py +177 -0
- wolfhece/apps/version.py +1 -1
- wolfhece/bernoulli/losses.py +75 -22
- wolfhece/bernoulli/losses_jax.py +143 -0
- wolfhece/bernoulli/pipe.py +7 -2
- wolfhece/math_parser/__init__.py +4 -4
- wolfhece/math_parser/calculator.py +50 -9
- wolfhece/matplotlib_fig.py +1980 -0
- wolfhece/mesh2d/simple_2d.py +2399 -0
- wolfhece/mesh2d/wolf2dprev.py +1 -1
- wolfhece/pidcontroller.py +131 -0
- wolfhece/pywalous.py +7 -7
- wolfhece/scenario/config_manager.py +191 -83
- wolfhece/wolf_array.py +162 -109
- wolfhece/wolf_vrt.py +108 -7
- wolfhece/wolfresults_2D.py +109 -4
- wolfhece/xyz_file.py +91 -51
- {wolfhece-2.1.98.dist-info → wolfhece-2.1.100.dist-info}/METADATA +1 -1
- {wolfhece-2.1.98.dist-info → wolfhece-2.1.100.dist-info}/RECORD +33 -27
- {wolfhece-2.1.98.dist-info → wolfhece-2.1.100.dist-info}/WHEEL +1 -1
- {wolfhece-2.1.98.dist-info → wolfhece-2.1.100.dist-info}/entry_points.txt +0 -0
- {wolfhece-2.1.98.dist-info → wolfhece-2.1.100.dist-info}/top_level.txt +0 -0
wolfhece/wolf_array.py
CHANGED
@@ -49,19 +49,19 @@ from copy import deepcopy
|
|
49
49
|
from enum import Enum
|
50
50
|
|
51
51
|
try:
|
52
|
-
from
|
52
|
+
from .PyTranslate import _
|
53
53
|
except ImportError as e:
|
54
54
|
print(e)
|
55
|
-
raise Exception(_('Error importing
|
55
|
+
raise Exception(_('Error importing modules'))
|
56
56
|
|
57
57
|
try:
|
58
|
-
from
|
58
|
+
from osgeo import gdal
|
59
59
|
except ImportError as e:
|
60
60
|
print(e)
|
61
|
-
raise Exception(_('Error importing
|
61
|
+
raise Exception(_('Error importing GDAL library'))
|
62
62
|
|
63
63
|
try:
|
64
|
-
from .
|
64
|
+
from .Coordinates_operations import reproject_and_resample_raster
|
65
65
|
except ImportError as e:
|
66
66
|
print(e)
|
67
67
|
raise Exception(_('Error importing modules'))
|
@@ -277,7 +277,7 @@ class header_wolf():
|
|
277
277
|
ret += _('Spatial extent : \n')
|
278
278
|
ret += _(' - Origin : ({} ; {}) \n').format(self.origx, self.origy)
|
279
279
|
ret += _(' - End : ({} ; {}) \n').format(self.origx + self.nbx * self.dx, self.origy +self.nby * self.dy)
|
280
|
-
ret += _(' -
|
280
|
+
ret += _(' - Width x Height : {} x {} \n').format(self.nbx * self.dx, self.nby * self.dy)
|
281
281
|
ret += _(' - Translation : ({} ; {})\n').format(self.translx, self.transly)
|
282
282
|
ret += _('Null value : {}\n\n'.format(self.nullvalue))
|
283
283
|
|
@@ -344,8 +344,8 @@ class header_wolf():
|
|
344
344
|
"""
|
345
345
|
Return block header
|
346
346
|
|
347
|
-
:param key:
|
348
|
-
:return
|
347
|
+
:param key: block's index (0-based) or key (str)
|
348
|
+
:return: header_wolf instance if key is found, None otherwise
|
349
349
|
"""
|
350
350
|
if key is None:
|
351
351
|
return self
|
@@ -364,7 +364,7 @@ class header_wolf():
|
|
364
364
|
"""
|
365
365
|
Set block header
|
366
366
|
|
367
|
-
:param value
|
367
|
+
:param value: tuple (key, header_wolf)
|
368
368
|
|
369
369
|
'key' can be an int (0-based) or a str
|
370
370
|
If str, please use getkeyblock function to generate the key
|
@@ -381,9 +381,9 @@ class header_wolf():
|
|
381
381
|
"""
|
382
382
|
Set origin
|
383
383
|
|
384
|
-
:param x
|
385
|
-
:param y
|
386
|
-
:param z
|
384
|
+
:param x: origin along X
|
385
|
+
:param y: origin along Y
|
386
|
+
:param z: origin along Z
|
387
387
|
"""
|
388
388
|
self.origx = x
|
389
389
|
self.origy = y
|
@@ -405,8 +405,8 @@ class header_wolf():
|
|
405
405
|
"""
|
406
406
|
Return bounds in coordinates
|
407
407
|
|
408
|
-
:param abs
|
409
|
-
:return
|
408
|
+
:param abs: if True, add translation to (x, y) (coordinate to global space)
|
409
|
+
:return: tuple of two lists of two floats - ([xmin, xmax],[ymin, ymax])
|
410
410
|
"""
|
411
411
|
if abs:
|
412
412
|
return ([self.origx + self.translx, self.origx + self.translx + float(self.nbx) * self.dx],
|
@@ -421,7 +421,7 @@ class header_wolf():
|
|
421
421
|
|
422
422
|
Firstly, get_bounds is called to get bounds in coordinates and then get_ij_from_xy is called to get bounds in indices.
|
423
423
|
|
424
|
-
:param abs
|
424
|
+
:param abs: if True, add translation to (x, y) (coordinate to global space)
|
425
425
|
"""
|
426
426
|
mybounds = self.get_bounds(abs)
|
427
427
|
|
@@ -433,13 +433,13 @@ class header_wolf():
|
|
433
433
|
"""
|
434
434
|
Get indices from coordinates
|
435
435
|
|
436
|
-
:param x
|
437
|
-
:param y
|
438
|
-
:param z
|
439
|
-
:param scale
|
440
|
-
:param aswolf
|
441
|
-
:param abs
|
442
|
-
:param forcedims2
|
436
|
+
:param x: X coordinate
|
437
|
+
:param y: Y coordinate
|
438
|
+
:param z: Z coordinate (optional)
|
439
|
+
:param scale: scaling of the spatial resolution (dx,dy,[dz])
|
440
|
+
:param aswolf: if True, return if one-based (as Wolf VB6 or Fortran), otherwise 0-based (default Python standard)
|
441
|
+
:param abs: if True, remove translation from (x, y, [z]) (coordinate from global space)
|
442
|
+
:param forcedims2: if True, force to return only 2 indices even if z is supplied
|
443
443
|
"""
|
444
444
|
|
445
445
|
locx = np.float64(x) - self.origx
|
@@ -475,7 +475,7 @@ class header_wolf():
|
|
475
475
|
:param abs = if True, remove translation from (x, y, [z]) (coordinate from global space)
|
476
476
|
:param forcedims2 = if True, force to return only 2 indices even if z is supplied
|
477
477
|
|
478
|
-
:return
|
478
|
+
:return: numpy array containing (i, j, [k]) indices - shape (n, 2) or (n, 3)
|
479
479
|
"""
|
480
480
|
|
481
481
|
if isinstance(xy,tuple):
|
@@ -642,17 +642,17 @@ class header_wolf():
|
|
642
642
|
def ij2xy_np(self, ij:np.ndarray, scale:float=1., aswolf:bool=False, abs:bool=True) -> np.ndarray:
|
643
643
|
""" alias for get_xy_from_ij_array
|
644
644
|
|
645
|
-
:param ij
|
646
|
-
:param scale
|
647
|
-
:param aswolf
|
648
|
-
:param abs
|
645
|
+
:param ij: numpy array containing (i, j, [k]) indices
|
646
|
+
:param scale: scaling of the spatial resolution (dx,dy,[dz])
|
647
|
+
:param aswolf: if True, input is one-based (as Wolf VB6 or Fortran), otherwise 0-based (default Python standard)
|
648
|
+
:param abs: if True, add translation to results (x, y, [z]) (coordinate to global space)
|
649
649
|
|
650
650
|
..warning: 'ij' is not the result of np.where() but if you want to use np.where() you can use the following code:
|
651
651
|
```
|
652
652
|
np.vstack((ij[0], ij[1])).T
|
653
653
|
```
|
654
654
|
|
655
|
-
:return
|
655
|
+
:return: numpy array containing (x, y, [z]) coordinates - shape (n, 2) or (n, 3)
|
656
656
|
"""
|
657
657
|
return self.get_xy_from_ij_array(ij, scale, aswolf, abs)
|
658
658
|
|
@@ -664,11 +664,11 @@ class header_wolf():
|
|
664
664
|
"""
|
665
665
|
alias for get_ij_from_xy_array
|
666
666
|
|
667
|
-
:param xy
|
668
|
-
:param scale
|
669
|
-
:param aswolf
|
670
|
-
:param abs
|
671
|
-
:param forcedims2
|
667
|
+
:param xy: numpy array containing (x, y, [z]) coordinates - shape (n, 2) or (n, 3)
|
668
|
+
:param scale: scaling of the spatial resolution (dx,dy,[dz])
|
669
|
+
:param aswolf: if True, return if one-based (as Wolf VB6 or Fortran), otherwise 0-based (default Python standard)
|
670
|
+
:param abs: if True, remove translation from (x, y, [z]) (coordinate from global space)
|
671
|
+
:param forcedims2: if True, force to return only 2 indices even if z is supplied
|
672
672
|
|
673
673
|
:return : numpy array containing (i, j, [k]) indices - shape (n, 2) or (n, 3)
|
674
674
|
"""
|
@@ -689,8 +689,8 @@ class header_wolf():
|
|
689
689
|
"""
|
690
690
|
Find the intersection of two header
|
691
691
|
|
692
|
-
|
693
|
-
|
692
|
+
:param other: other header
|
693
|
+
:param ij: if True, return indices instead of coordinates
|
694
694
|
|
695
695
|
:return: None or tuple of two lists of two floats - ([xmin, xmax],[ymin, ymax]) or indices in each header (if ij=True) [[imin1, imax1], [jmin1, jmax1]], [[imin2, imax2], [jmin2, jmax2]]
|
696
696
|
"""
|
@@ -759,7 +759,7 @@ class header_wolf():
|
|
759
759
|
"""
|
760
760
|
Read informations from header .txt
|
761
761
|
|
762
|
-
:param filename
|
762
|
+
:param filename: path and filename of the basefile
|
763
763
|
|
764
764
|
If filename is a Path object, it is converted to a string
|
765
765
|
If filename ends with '.tif', nothing is done because infos are in the .tif file
|
@@ -994,9 +994,9 @@ class header_wolf():
|
|
994
994
|
|
995
995
|
Nullvalue is not written
|
996
996
|
|
997
|
-
:param filename
|
998
|
-
:param wolftype
|
999
|
-
:param forceupdate
|
997
|
+
:param filename: path and filename with '.txt' extension, which will NOT be automatically added
|
998
|
+
:param wolftype: type of the WOLF_ARRAY_* array
|
999
|
+
:param forceupdate: if True, the file is rewritten even if it already exists
|
1000
1000
|
"""
|
1001
1001
|
|
1002
1002
|
assert wolftype in [WOLF_ARRAY_CSR_DOUBLE, WOLF_ARRAY_FULL_SINGLE, WOLF_ARRAY_FULL_DOUBLE, WOLF_ARRAY_SYM_DOUBLE, WOLF_ARRAY_FULL_LOGICAL, WOLF_ARRAY_CSR_DOUBLE, WOLF_ARRAY_FULL_INTEGER, WOLF_ARRAY_FULL_SINGLE_3D, WOLF_ARRAY_FULL_INTEGER8, WOLF_ARRAY_MB_SINGLE, WOLF_ARRAY_MB_INTEGER, WOLF_ARRAY_FULL_INTEGER16, WOLF_ARRAY_MNAP_INTEGER, WOLF_ARRAY_FULL_INTEGER16_2], _('The type of array is not correct')
|
@@ -1035,8 +1035,8 @@ class header_wolf():
|
|
1035
1035
|
"""
|
1036
1036
|
Comparison of two headers
|
1037
1037
|
|
1038
|
-
:param other
|
1039
|
-
:param check_mb
|
1038
|
+
:param other: other header to compare
|
1039
|
+
:param check_mb: if True, the comparison is done on the blocks too
|
1040
1040
|
|
1041
1041
|
The nullvalue is not taken into account
|
1042
1042
|
"""
|
@@ -1173,8 +1173,9 @@ class header_wolf():
|
|
1173
1173
|
"""
|
1174
1174
|
Return the coordinates of the cells in the footprint of a vector
|
1175
1175
|
|
1176
|
-
:param myvect
|
1176
|
+
:param myvect: target vector
|
1177
1177
|
:return: tuple of two numpy arrays - (coordinates, indices)
|
1178
|
+
:param eps: epsilon to avoid rounding errors
|
1178
1179
|
|
1179
1180
|
"""
|
1180
1181
|
|
@@ -1190,8 +1191,9 @@ class header_wolf():
|
|
1190
1191
|
"""
|
1191
1192
|
Return the indices of the cells in the footprint of a vector
|
1192
1193
|
|
1193
|
-
:param myvect
|
1194
|
-
:return
|
1194
|
+
:param myvect: target vector
|
1195
|
+
:return: numpy array of indices
|
1196
|
+
:param eps: epsilon to avoid rounding errors
|
1195
1197
|
"""
|
1196
1198
|
|
1197
1199
|
if isinstance(myvect, Polygon):
|
@@ -1219,7 +1221,7 @@ class header_wolf():
|
|
1219
1221
|
"""
|
1220
1222
|
Convert XY coordinates to IJ indices **(0-based)** with Numpy without any check/options
|
1221
1223
|
|
1222
|
-
:param xy = numpy array of shape (n,2) with XY coordinates
|
1224
|
+
:param xy: = numpy array of shape (n,2) with XY coordinates
|
1223
1225
|
|
1224
1226
|
"""
|
1225
1227
|
|
@@ -1230,7 +1232,7 @@ class header_wolf():
|
|
1230
1232
|
"""
|
1231
1233
|
Convert IJ indices **(0-based)** to XY coordinates with Numpy without any check/options
|
1232
1234
|
|
1233
|
-
:param ij = numpy array of shape (n,2) with IJ indices
|
1235
|
+
:param ij: = numpy array of shape (n,2) with IJ indices
|
1234
1236
|
|
1235
1237
|
"""
|
1236
1238
|
|
@@ -7186,7 +7188,7 @@ class WolfArray(Element_To_Draw, header_wolf):
|
|
7186
7188
|
|
7187
7189
|
return newArray
|
7188
7190
|
|
7189
|
-
def mask_outsidepoly(self, myvect: vector, eps:float = 0
|
7191
|
+
def mask_outsidepoly(self, myvect: vector, eps:float = 0., set_nullvalue:bool=True):
|
7190
7192
|
"""
|
7191
7193
|
Mask nodes outside a polygon and set values to nullvalue
|
7192
7194
|
|
@@ -7196,31 +7198,21 @@ class WolfArray(Element_To_Draw, header_wolf):
|
|
7196
7198
|
# (coord will be converted back with translation, origin and dx/dy)
|
7197
7199
|
# (mesh coord, 0-based)
|
7198
7200
|
|
7199
|
-
mask = self.array.mask
|
7200
|
-
mask[:,:] = True # Mask everything
|
7201
|
-
|
7202
7201
|
# trouve les indices dans le polygone
|
7203
|
-
myij = self.get_ij_inside_polygon(myvect, usemask=
|
7204
|
-
|
7205
|
-
# démasquage des mailles contenues
|
7206
|
-
mask[myij[:,0],myij[:,1]] = False
|
7202
|
+
myij = self.get_ij_inside_polygon(myvect, usemask=True, eps=eps)
|
7207
7203
|
|
7208
|
-
#
|
7209
|
-
self.array.data[np.where(mask)] = self.nullvalue
|
7204
|
+
self.array.mask.fill(True) # Mask everything
|
7210
7205
|
|
7211
|
-
#
|
7212
|
-
|
7206
|
+
# démasquage des mailles contenues
|
7207
|
+
self.array.mask[myij[:,0],myij[:,1]] = False
|
7213
7208
|
|
7214
|
-
|
7215
|
-
|
7216
|
-
|
7217
|
-
# FIXME Why simply not use the previous mask value ?
|
7218
|
-
# FIXME This operation seems to contradict mask[:,:] = True
|
7219
|
-
self.mask_data(self.nullvalue)
|
7209
|
+
if set_nullvalue:
|
7210
|
+
# annulation des valeurs en dehors du polygone
|
7211
|
+
self.set_nullvalue_in_mask()
|
7220
7212
|
|
7221
7213
|
self.count()
|
7222
7214
|
|
7223
|
-
def mask_insidepoly(self, myvect: vector, eps:float = 0
|
7215
|
+
def mask_insidepoly(self, myvect: vector, eps:float = 0., set_nullvalue:bool=True):
|
7224
7216
|
"""
|
7225
7217
|
Mask nodes inside a polygon and set values to nullvalue
|
7226
7218
|
|
@@ -7233,8 +7225,9 @@ class WolfArray(Element_To_Draw, header_wolf):
|
|
7233
7225
|
# trouve les indices dans le polygone
|
7234
7226
|
myij = self.get_ij_inside_polygon(myvect, usemask=False, eps=eps)
|
7235
7227
|
|
7236
|
-
|
7237
|
-
|
7228
|
+
if set_nullvalue:
|
7229
|
+
# annulation des valeurs en dehors du polygone
|
7230
|
+
self.array.data[myij[:,0],myij[:,1]] = self.nullvalue
|
7238
7231
|
|
7239
7232
|
# masquage des mailles contenues
|
7240
7233
|
self.array.mask[myij[:,0],myij[:,1]] = True
|
@@ -7250,8 +7243,8 @@ class WolfArray(Element_To_Draw, header_wolf):
|
|
7250
7243
|
"""
|
7251
7244
|
Return the coordinates inside a polygon
|
7252
7245
|
|
7253
|
-
:param myvect
|
7254
|
-
:param usemask
|
7246
|
+
:param myvect: target vector
|
7247
|
+
:param usemask: limit potential nodes to unmaksed nodes
|
7255
7248
|
"""
|
7256
7249
|
|
7257
7250
|
if isinstance(myvect, vector):
|
@@ -7279,8 +7272,8 @@ class WolfArray(Element_To_Draw, header_wolf):
|
|
7279
7272
|
"""
|
7280
7273
|
Return the coordinates inside a polygon
|
7281
7274
|
|
7282
|
-
:param myvect
|
7283
|
-
:param usemask
|
7275
|
+
:param myvect: target vector
|
7276
|
+
:param usemask: limit potential nodes to unmaksed nodes
|
7284
7277
|
"""
|
7285
7278
|
|
7286
7279
|
if isinstance(myvect, vector):
|
@@ -7307,8 +7300,8 @@ class WolfArray(Element_To_Draw, header_wolf):
|
|
7307
7300
|
"""
|
7308
7301
|
Return the coordinates along a polyline
|
7309
7302
|
|
7310
|
-
:param myvect
|
7311
|
-
:param usemask
|
7303
|
+
:param myvect: target vector
|
7304
|
+
:param usemask: limit potential nodes to unmaksed nodes
|
7312
7305
|
"""
|
7313
7306
|
|
7314
7307
|
allij = self.get_ij_under_polyline(myvect, usemask)
|
@@ -7320,8 +7313,9 @@ class WolfArray(Element_To_Draw, header_wolf):
|
|
7320
7313
|
"""
|
7321
7314
|
Return the indices inside a polygon
|
7322
7315
|
|
7323
|
-
:param myvect
|
7324
|
-
:param usemask
|
7316
|
+
:param myvect: target vector
|
7317
|
+
:param usemask: limit potential nodes to unmaksed nodes
|
7318
|
+
:param eps: epsilon for the intersection
|
7325
7319
|
"""
|
7326
7320
|
|
7327
7321
|
# force la mise à jour des min/max
|
@@ -7346,8 +7340,8 @@ class WolfArray(Element_To_Draw, header_wolf):
|
|
7346
7340
|
def intersects_polygon(self, myvect: vector | Polygon, usemask:bool=True):
|
7347
7341
|
""" Return True if the array intersects the polygon
|
7348
7342
|
|
7349
|
-
:param myvect
|
7350
|
-
:param usemask
|
7343
|
+
:param myvect: target vector
|
7344
|
+
:param usemask: limit potential nodes to unmaksed nodes
|
7351
7345
|
"""
|
7352
7346
|
|
7353
7347
|
return self.get_xy_inside_polygon(myvect, usemask).shape[0] > 0
|
@@ -7355,8 +7349,8 @@ class WolfArray(Element_To_Draw, header_wolf):
|
|
7355
7349
|
def intersects_polygon_shapely(self, myvect: vector | Polygon, eps:float = 0., usemask:bool=True):
|
7356
7350
|
""" Return True if the array intersects the polygon
|
7357
7351
|
|
7358
|
-
:param myvect
|
7359
|
-
:param usemask
|
7352
|
+
:param myvect: target vector
|
7353
|
+
:param usemask: limit potential nodes to unmaksed nodes
|
7360
7354
|
"""
|
7361
7355
|
return self.get_xy_inside_polygon_shapely(myvect, usemask).shape[0] > 0
|
7362
7356
|
|
@@ -7364,8 +7358,8 @@ class WolfArray(Element_To_Draw, header_wolf):
|
|
7364
7358
|
"""
|
7365
7359
|
Return the indices along a polyline
|
7366
7360
|
|
7367
|
-
:param myvect
|
7368
|
-
:param usedmask
|
7361
|
+
:param myvect: target vector
|
7362
|
+
:param usedmask: limit potential nodes to unmaksed nodes
|
7369
7363
|
"""
|
7370
7364
|
|
7371
7365
|
ds = min(self.dx, self.dy)
|
@@ -7388,8 +7382,8 @@ class WolfArray(Element_To_Draw, header_wolf):
|
|
7388
7382
|
"""
|
7389
7383
|
Récupération des valeurs contenues dans un polygone
|
7390
7384
|
|
7391
|
-
:param usemask
|
7392
|
-
:param getxy
|
7385
|
+
:param usemask: (optional) restreint les éléments aux éléments non masqués de la matrice
|
7386
|
+
:param getxy: (optional) retourne en plus les coordonnées des points
|
7393
7387
|
"""
|
7394
7388
|
mypoints = self.get_xy_inside_polygon(myvect, usemask)
|
7395
7389
|
myvalues = np.asarray([self.get_value(cur[0], cur[1]) for cur in mypoints])
|
@@ -7403,8 +7397,8 @@ class WolfArray(Element_To_Draw, header_wolf):
|
|
7403
7397
|
"""
|
7404
7398
|
Récupération des valeurs contenues sous une polyligne
|
7405
7399
|
|
7406
|
-
:param usemask
|
7407
|
-
:param getxy
|
7400
|
+
:param usemask: (optional) restreint les éléments aux éléments non masqués de la matrice
|
7401
|
+
:param getxy: (optional) retourne en plus les coordonnées des points
|
7408
7402
|
"""
|
7409
7403
|
mypoints = self.get_xy_under_polyline(myvect, usemask)
|
7410
7404
|
|
@@ -7419,8 +7413,8 @@ class WolfArray(Element_To_Draw, header_wolf):
|
|
7419
7413
|
"""
|
7420
7414
|
Récupération de toutes les valeurs contenues dans un polygone
|
7421
7415
|
|
7422
|
-
:param usemask
|
7423
|
-
:param getxy
|
7416
|
+
:param usemask: (optional) restreint les éléments aux éléments non masqués de la matrice
|
7417
|
+
:param getxy: (optional) retourne en plus les coordonnées des points
|
7424
7418
|
|
7425
7419
|
ICI on retourne le résultat de get_values_insidepoly, car une seule matrice, mais une autre classe pourrait vouloir faure autre chose
|
7426
7420
|
C'est le cas notamment de Wolfresults_2D
|
@@ -7432,8 +7426,8 @@ class WolfArray(Element_To_Draw, header_wolf):
|
|
7432
7426
|
"""
|
7433
7427
|
Récupération de toutes les valeurs sous la polyligne
|
7434
7428
|
|
7435
|
-
:param usemask
|
7436
|
-
:param getxy
|
7429
|
+
:param usemask: (optional) restreint les éléments aux éléments non masqués de la matrice
|
7430
|
+
:param getxy: (optional) retourne en plus les coordonnées des points
|
7437
7431
|
|
7438
7432
|
ICI on retourne le résultat de get_values_underpoly, car une seule matrice, mais une autre classe pourrait vouloir faure autre chose
|
7439
7433
|
C'est le cas notamment de Wolfresults_2D
|
@@ -7525,7 +7519,7 @@ class WolfArray(Element_To_Draw, header_wolf):
|
|
7525
7519
|
if update_min_max:
|
7526
7520
|
self.mypal.distribute_values(self.array.min(), self.array.max())
|
7527
7521
|
|
7528
|
-
def write_all(self, newpath:str = None, EPSG:int = 31370):
|
7522
|
+
def write_all(self, newpath:str | Path = None, EPSG:int = 31370):
|
7529
7523
|
"""
|
7530
7524
|
Ecriture de tous les fichiers d'un Wolf array
|
7531
7525
|
|
@@ -7586,7 +7580,7 @@ class WolfArray(Element_To_Draw, header_wolf):
|
|
7586
7580
|
:param factor: factor of resolution change -- > 1.0 : decrease resolution, < 1.0 : increase resolution
|
7587
7581
|
:type factor: float
|
7588
7582
|
:return: new shape
|
7589
|
-
:rtype: Tuple[int, int]
|
7583
|
+
:rtype: Tuple[int, int], Tuple[float, float]
|
7590
7584
|
"""
|
7591
7585
|
|
7592
7586
|
newdx = self.dx * float(factor)
|
@@ -7903,7 +7897,8 @@ class WolfArray(Element_To_Draw, header_wolf):
|
|
7903
7897
|
|
7904
7898
|
return xyz[filter]
|
7905
7899
|
|
7906
|
-
|
7900
|
+
@classmethod
|
7901
|
+
def set_general_frame_from_xyz(cls, fname:str, dx:float, dy:float, border_size:int=5, delimiter:str=',', fillin:bool=False):
|
7907
7902
|
"""
|
7908
7903
|
Lecture d'un fichier texte xyz et initialisation des données de base
|
7909
7904
|
|
@@ -7913,19 +7908,72 @@ class WolfArray(Element_To_Draw, header_wolf):
|
|
7913
7908
|
:param border_size: nombre de mailles de bordure en plus de l'extension spatiale du fichier
|
7914
7909
|
"""
|
7915
7910
|
|
7916
|
-
my_file = XYZFile(fname)
|
7911
|
+
my_file = XYZFile(fname, delimiter=delimiter)
|
7917
7912
|
my_file.read_from_file()
|
7918
7913
|
(xlim, ylim) = my_file.get_extent()
|
7919
7914
|
|
7920
|
-
|
7921
|
-
|
7922
|
-
|
7923
|
-
|
7924
|
-
|
7925
|
-
|
7915
|
+
Array = WolfArray()
|
7916
|
+
Array.dx = dx
|
7917
|
+
Array.dy = dy
|
7918
|
+
Array.origx = m.floor(xlim[0]) - dx/2. - float(border_size) * Array.dx
|
7919
|
+
Array.origy = m.floor(ylim[0]) - dy/2. - float(border_size) * Array.dy
|
7920
|
+
Array.nbx = int((m.floor(xlim[1]) - m.ceil(xlim[0])) / Array.dx) + 1 + 2*border_size
|
7921
|
+
Array.nby = int((m.floor(ylim[1]) - m.ceil(ylim[0])) / Array.dy) + 1 + 2*border_size
|
7922
|
+
|
7923
|
+
Array.array = np.ma.zeros((Array.nbx, Array.nby), dtype=np.float32)
|
7926
7924
|
|
7927
|
-
|
7928
|
-
|
7925
|
+
if fillin:
|
7926
|
+
Array.fillin_from_xyz(my_file.xyz)
|
7927
|
+
|
7928
|
+
return Array
|
7929
|
+
|
7930
|
+
@classmethod
|
7931
|
+
def set_general_frame_from_xyz_dir(cls, path:str, bounds:list, delimiter:str=',', dxdy:tuple[float, float]= None, border_size:int=5, fillin:bool=True):
|
7932
|
+
"""
|
7933
|
+
Lecture d'un dossier contenant des fichiers texte xyz, initialisation des données de base et chargement de la matrice
|
7934
|
+
Renvoie un WolfArray or False si le fichier n'est pas dans les limites
|
7935
|
+
|
7936
|
+
:param path: chemin du dossier avec les fichier xyz
|
7937
|
+
:dtype path: str
|
7938
|
+
:param bounds: limites de l'extension spatiale
|
7939
|
+
:dtype bounds: list
|
7940
|
+
:param delimiter: délimiteur des fichiers xyz
|
7941
|
+
:dtype delimiter: str
|
7942
|
+
:param border_size: nombre de mailles de bordure en plus de l'extension spatiale du fichier
|
7943
|
+
:dtype border_size: int
|
7944
|
+
"""
|
7945
|
+
|
7946
|
+
Data_xyz = XYZFile('nothing.xyz', folder=path, bounds=bounds, delimiter=delimiter)
|
7947
|
+
|
7948
|
+
if Data_xyz.nblines == 0:
|
7949
|
+
logging.info(f"File not in the boundaries for {path.split(os.sep)[-1]}")
|
7950
|
+
return False
|
7951
|
+
|
7952
|
+
xlim, ylim = Data_xyz.get_extent()
|
7953
|
+
|
7954
|
+
if dxdy is None:
|
7955
|
+
# We assume dx and dy are equals within xyz file
|
7956
|
+
dx = np.diff(Data_xyz.xyz[0:2,0])[0]
|
7957
|
+
logging.info(f"dx = {dx} ; dy = {dx}")
|
7958
|
+
dy = dx
|
7959
|
+
else:
|
7960
|
+
dx,dy = dxdy
|
7961
|
+
assert dx is not None and dy is not None, _('dx and dy must be defined')
|
7962
|
+
|
7963
|
+
Array = WolfArray()
|
7964
|
+
Array.dx = dx
|
7965
|
+
Array.dy = dy
|
7966
|
+
Array.origx = m.floor(xlim[0]) -dx/2. - float(border_size) * Array.dx
|
7967
|
+
Array.origy = m.floor(ylim[0]) -dy/2. - float(border_size) * Array.dy
|
7968
|
+
Array.nbx = int((m.floor(xlim[1]) - m.ceil(xlim[0])) / Array.dx) +1 + 2*border_size
|
7969
|
+
Array.nby = int((m.floor(ylim[1]) - m.ceil(ylim[0])) / Array.dy) +1 + 2*border_size
|
7970
|
+
|
7971
|
+
Array.array = np.ma.zeros((Array.nbx, Array.nby))
|
7972
|
+
|
7973
|
+
if fillin:
|
7974
|
+
Array.fillin_from_xyz(Data_xyz.xyz)
|
7975
|
+
|
7976
|
+
return Array
|
7929
7977
|
|
7930
7978
|
def fillin_from_xyz(self, xyz:np.ndarray):
|
7931
7979
|
""" Remplissage du tableau à partir d'un tableau xyz """
|
@@ -8190,7 +8238,7 @@ class WolfArray(Element_To_Draw, header_wolf):
|
|
8190
8238
|
assert type(k_start) == int, "k_start must be an integer"
|
8191
8239
|
assert type(nbz) == int, "nbz must be an integer"
|
8192
8240
|
|
8193
|
-
newWolfArray = WolfArray()
|
8241
|
+
newWolfArray = WolfArray(nullvalue=self.nullvalue)
|
8194
8242
|
newWolfArray.nbx = nbx
|
8195
8243
|
newWolfArray.nby = nby
|
8196
8244
|
newWolfArray.dx = self.dx
|
@@ -8561,7 +8609,7 @@ class WolfArray(Element_To_Draw, header_wolf):
|
|
8561
8609
|
self.mygrid = {}
|
8562
8610
|
self.gridmaxscales = -1
|
8563
8611
|
|
8564
|
-
def plot_matplotlib(self):
|
8612
|
+
def plot_matplotlib(self, figax:tuple=None, getdata_im:bool=False):
|
8565
8613
|
"""
|
8566
8614
|
Plot the array - Matplotlib version
|
8567
8615
|
|
@@ -8570,14 +8618,19 @@ class WolfArray(Element_To_Draw, header_wolf):
|
|
8570
8618
|
|
8571
8619
|
self.mask_data(self.nullvalue)
|
8572
8620
|
self.updatepalette(0)
|
8621
|
+
if figax is None:
|
8622
|
+
fig, ax = plt.subplots()
|
8623
|
+
else:
|
8624
|
+
fig, ax = figax
|
8573
8625
|
|
8574
|
-
|
8575
|
-
|
8576
|
-
ax.imshow(self.array.transpose(), origin='lower', cmap=self.mypal,
|
8626
|
+
im = ax.imshow(self.array.transpose(), origin='lower', cmap=self.mypal,
|
8577
8627
|
extent=(self.origx, self.origx + self.dx * self.nbx, self.origy, self.origy + self.dy * self.nby))
|
8578
8628
|
ax.set_aspect('equal')
|
8579
8629
|
|
8580
|
-
|
8630
|
+
if getdata_im:
|
8631
|
+
return fig, ax, im
|
8632
|
+
else:
|
8633
|
+
return fig, ax
|
8581
8634
|
|
8582
8635
|
def fillonecellgrid(self, curscale, loci, locj, force=False):
|
8583
8636
|
""" Fill one cell of the plotted grid """
|
@@ -8764,8 +8817,8 @@ class WolfArray(Element_To_Draw, header_wolf):
|
|
8764
8817
|
"""
|
8765
8818
|
The borders are computed on basis of the current *mask*
|
8766
8819
|
|
8767
|
-
:param filename
|
8768
|
-
:param abs
|
8820
|
+
:param filename: if provided, write 'sux', 'sux' and 'xy' files
|
8821
|
+
:param abs: add translation coordinates (Global World Coordinates)
|
8769
8822
|
|
8770
8823
|
:return indicesX, indicesY, contourgen, interior
|
8771
8824
|
|