yirgacheffe 1.7.2__py3-none-any.whl → 1.7.4__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.

Potentially problematic release.


This version of yirgacheffe might be problematic. Click here for more details.

@@ -38,6 +38,7 @@ class operators(Enum):
38
38
  FLOOR = 33
39
39
  ROUND = 34
40
40
  CEIL = 35
41
+ ISNAN = 36
41
42
 
42
43
  class dtype(Enum):
43
44
  Float32 = gdal.GDT_Float32
@@ -40,6 +40,7 @@ maximum = mx.maximum
40
40
  minimum = mx.minimum
41
41
  zeros = mx.zeros
42
42
  pad = mx.pad
43
+ isnan = mx.isnan
43
44
  isscalar = np.isscalar
44
45
  full = mx.full
45
46
  allclose = mx.allclose
@@ -218,4 +219,5 @@ operator_map : Dict[op,Callable] = {
218
219
  op.FLOOR: mx.floor,
219
220
  op.ROUND: mx.round,
220
221
  op.CEIL: mx.ceil,
222
+ op.ISNAN: mx.isnan,
221
223
  }
@@ -43,6 +43,7 @@ minimum = np.minimum
43
43
  zeros = np.zeros
44
44
  pad = np.pad
45
45
  sum_op = lambda a: np.sum(a.astype(np.float64))
46
+ isnan = np.isnan
46
47
  isscalar = np.isscalar
47
48
  full = np.full
48
49
  allclose = np.allclose
@@ -156,4 +157,5 @@ operator_map : Dict[op,Callable] = {
156
157
  op.FLOOR: np.floor,
157
158
  op.ROUND: np.round,
158
159
  op.CEIL: np.ceil,
160
+ op.ISNAN: np.isnan,
159
161
  }
@@ -91,7 +91,7 @@ class YirgacheffeLayer(LayerMathMixin):
91
91
  else:
92
92
  return self._underlying_area
93
93
 
94
- def _get_operation_area(self, projection: Optional[MapProjection]) -> Area:
94
+ def _get_operation_area(self, projection: Optional[MapProjection]=None) -> Area:
95
95
  if self._projection is not None and projection is not None and self._projection != projection:
96
96
  raise ValueError("Calculation projection does not match layer projection")
97
97
  return self.area
@@ -119,11 +119,12 @@ class YirgacheffeLayer(LayerMathMixin):
119
119
  if not all(projections[0] == x for x in projections[1:]):
120
120
  raise ValueError("Not all layers are at the same projectin or pixel scale")
121
121
 
122
+ layer_areas = [x._get_operation_area() for x in layers]
122
123
  intersection = Area(
123
- left=max(x._underlying_area.left for x in layers),
124
- top=min(x._underlying_area.top for x in layers),
125
- right=min(x._underlying_area.right for x in layers),
126
- bottom=max(x._underlying_area.bottom for x in layers)
124
+ left=max(x.left for x in layer_areas),
125
+ top=min(x.top for x in layer_areas),
126
+ right=min(x.right for x in layer_areas),
127
+ bottom=max(x.bottom for x in layer_areas)
127
128
  )
128
129
  if (intersection.left >= intersection.right) or (intersection.bottom >= intersection.top):
129
130
  raise ValueError('No intersection possible')
@@ -142,11 +143,12 @@ class YirgacheffeLayer(LayerMathMixin):
142
143
  if not all(projections[0] == x for x in projections[1:]):
143
144
  raise ValueError("Not all layers are at the same projectin or pixel scale")
144
145
 
146
+ layer_areas = [x._get_operation_area() for x in layers]
145
147
  return Area(
146
- left=min(x._underlying_area.left for x in layers),
147
- top=max(x._underlying_area.top for x in layers),
148
- right=max(x._underlying_area.right for x in layers),
149
- bottom=min(x._underlying_area.bottom for x in layers)
148
+ left=min(x.left for x in layer_areas),
149
+ top=max(x.top for x in layer_areas),
150
+ right=max(x.right for x in layer_areas),
151
+ bottom=min(x.bottom for x in layer_areas)
150
152
  )
151
153
 
152
154
  @property
@@ -114,8 +114,9 @@ class GroupLayer(YirgacheffeLayer):
114
114
  if (xsize <= 0) or (ysize <= 0):
115
115
  raise ValueError("Request dimensions must be positive and non-zero")
116
116
 
117
- scale = self.pixel_scale
118
- assert scale is not None
117
+ map_projection = self.map_projection
118
+ assert map_projection is not None
119
+ scale = map_projection.scale
119
120
 
120
121
  target_window = Window(
121
122
  window.xoff + xoffset,
@@ -151,7 +152,7 @@ class GroupLayer(YirgacheffeLayer):
151
152
  intersection.ysize
152
153
  )
153
154
  if layer.nodata is not None:
154
- data[data.isnan()] = 0.0
155
+ data = backend.where(backend.isnan(data), 0.0, data)
155
156
  return data
156
157
 
157
158
  result = np.zeros((ysize, xsize), dtype=float)
yirgacheffe/operators.py CHANGED
@@ -139,6 +139,13 @@ class LayerMathMixin:
139
139
  test_elements=test_elements,
140
140
  )
141
141
 
142
+ def isnan(self):
143
+ return LayerOperation(
144
+ self,
145
+ op.ISNAN,
146
+ window_op=WindowOperation.NONE,
147
+ )
148
+
142
149
  def abs(self):
143
150
  return LayerOperation(
144
151
  self,
@@ -659,7 +666,9 @@ class LayerOperation(LayerMathMixin):
659
666
 
660
667
  if (computation_window.xsize != destination_window.xsize) \
661
668
  or (computation_window.ysize != destination_window.ysize):
662
- raise ValueError("Destination raster window size does not match input raster window size.")
669
+ raise ValueError((f"Destination raster window size does not match input raster window size: "
670
+ f"{(destination_window.xsize, destination_window.ysize)} vs "
671
+ f"{(computation_window.xsize, computation_window.ysize)}"))
663
672
 
664
673
  total = 0.0
665
674
 
@@ -1,10 +1,13 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: yirgacheffe
3
- Version: 1.7.2
3
+ Version: 1.7.4
4
4
  Summary: Abstraction of gdal datasets for doing basic math operations
5
5
  Author-email: Michael Dales <mwd24@cam.ac.uk>
6
6
  License-Expression: ISC
7
7
  Project-URL: Homepage, https://github.com/quantifyearth/yirgacheffe
8
+ Project-URL: Repository, https://github.com/quantifyearth/yirgacheffe.git
9
+ Project-URL: Issues, https://github.com/quantifyearth/yirgacheffe/issues
10
+ Project-URL: Changelog, https://github.com/quantifyearth/yirgacheffe/blob/main/CHANGES.md
8
11
  Keywords: gdal,numpy,math
9
12
  Requires-Python: >=3.10
10
13
  Description-Content-Type: text/markdown
@@ -1,25 +1,25 @@
1
1
  yirgacheffe/__init__.py,sha256=flTXNQQs6k8nboEv9O4eJnlv8kZ11z5zrfWcmUovCLg,537
2
2
  yirgacheffe/_core.py,sha256=2CtRkVOpXBhFnj4fnpwSQBL3lJIvAmQJ4AgsMmKJOSs,4193
3
3
  yirgacheffe/constants.py,sha256=uCWJwec3-ND-zVxYbsk1sdHKANl3ToNCTPg7MZb0j2g,434
4
- yirgacheffe/operators.py,sha256=yFO43w05YNczxpWvRu7y223Lenu1sqLUHly0R4EWUbw,35925
4
+ yirgacheffe/operators.py,sha256=DNZFBHRqwlZq8HHNv72vU5jDBwikDCyuwyo8RmE59bg,36228
5
5
  yirgacheffe/rounding.py,sha256=ggBG4lMyLMtHLW3dBxr3gBCcF2qhRrY5etZiFGlIoqA,2258
6
6
  yirgacheffe/window.py,sha256=0Wy3BT4SZLyviDwzLcX8LYOo2MeZ2zXCWAiJNpMbQpc,9505
7
7
  yirgacheffe/_backends/__init__.py,sha256=jN-2iRrHStnPI6cNL7XhwhsROtI0EaGfIrbF5c-ECV0,334
8
- yirgacheffe/_backends/enumeration.py,sha256=pADawllxpW_hW-IVVvZpHWIKzvEMs9aaqfkZRD1zjnY,1003
9
- yirgacheffe/_backends/mlx.py,sha256=2vOTMqHbQbeqt81Eq_8hxWDXZHaPsDpbXkALRVGEnnw,6130
10
- yirgacheffe/_backends/numpy.py,sha256=cYO628s4-5K_-Bp3CrnHegzYSZfkt2QC8iE9oOOMtvA,4069
8
+ yirgacheffe/_backends/enumeration.py,sha256=Jrce2p2n4Wlk5tHBkiWntDnpLSD_0H-bnwgsKXHjkwQ,1018
9
+ yirgacheffe/_backends/mlx.py,sha256=kEWcJOhhUQSHkRPljv6s0MYlxcuu-LzLL55Fdd8tIqc,6171
10
+ yirgacheffe/_backends/numpy.py,sha256=IdAgK8oFZxjzK1I_-_yXYu_G935920GxpB6oZoJvWvQ,4110
11
11
  yirgacheffe/layers/__init__.py,sha256=mYKjw5YTcMNv_hMy7a6K4yRzIuNUbR8WuBTw4WIAmSk,435
12
12
  yirgacheffe/layers/area.py,sha256=OFOM1_dMblzXLW29TwEqfdgSecl6aNs04bKJwUydLH0,3914
13
- yirgacheffe/layers/base.py,sha256=4BjtEBzAHBWu06k-9Q7J1bm11xNILKDgA2cxuARxVyI,14344
13
+ yirgacheffe/layers/base.py,sha256=MPVGEsFRPuRDYtL1OBu7XP26kBDWfpS3RS3twYKBOQc,14381
14
14
  yirgacheffe/layers/constant.py,sha256=XQ1ibeSckAcUOow-dMUlZiW5S2MKeFquOz_m8Y027GI,1437
15
- yirgacheffe/layers/group.py,sha256=QyrECH5IthmBVV1debqttNvZGVocE-azdayJsvd6qqI,16096
15
+ yirgacheffe/layers/group.py,sha256=YgA0Bl0lAO2KwTT57126rXfyPq6MCssaaFrTQLe377s,16182
16
16
  yirgacheffe/layers/h3layer.py,sha256=Ys6F-e4Jre7lbFBYErF_4oidQx22WkWMKpHpQ7pPDTs,9875
17
17
  yirgacheffe/layers/rasters.py,sha256=-yECyz3Odhy1er0ilJ9bfLUseI2cTHfwqhP-H3ImUKo,13365
18
18
  yirgacheffe/layers/rescaled.py,sha256=hkvsd7paDCyUViABxrAXdXPOZegdwiphibkdrBuRclk,3366
19
19
  yirgacheffe/layers/vectors.py,sha256=OpZaV2MgM0v4-CbrCNy_AHv3T2bvV9PFytolIzPPXFc,19900
20
- yirgacheffe-1.7.2.dist-info/licenses/LICENSE,sha256=dNSHwUCJr6axStTKDEdnJtfmDdFqlE3h1NPCveqPfnY,757
21
- yirgacheffe-1.7.2.dist-info/METADATA,sha256=5_xSRySwK7HSzhOKEPMcUzX1RpmVXH1E-CEmo5dhtsE,22351
22
- yirgacheffe-1.7.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
23
- yirgacheffe-1.7.2.dist-info/entry_points.txt,sha256=j4KgHXbVGbGyfTySc1ypBdERpfihO4WNjppvCdE9HjE,52
24
- yirgacheffe-1.7.2.dist-info/top_level.txt,sha256=9DBFlKO2Ld3hG6TuE3qOTd3Tt8ugTiXil4AN4Wr9_y0,12
25
- yirgacheffe-1.7.2.dist-info/RECORD,,
20
+ yirgacheffe-1.7.4.dist-info/licenses/LICENSE,sha256=dNSHwUCJr6axStTKDEdnJtfmDdFqlE3h1NPCveqPfnY,757
21
+ yirgacheffe-1.7.4.dist-info/METADATA,sha256=-HBVApZog3E94bukfIQJD6SLrg9feJiLm8tLr2Kt7cU,22588
22
+ yirgacheffe-1.7.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
23
+ yirgacheffe-1.7.4.dist-info/entry_points.txt,sha256=j4KgHXbVGbGyfTySc1ypBdERpfihO4WNjppvCdE9HjE,52
24
+ yirgacheffe-1.7.4.dist-info/top_level.txt,sha256=9DBFlKO2Ld3hG6TuE3qOTd3Tt8ugTiXil4AN4Wr9_y0,12
25
+ yirgacheffe-1.7.4.dist-info/RECORD,,