Skip to content

Commit

Permalink
adding minimum element operation
Browse files Browse the repository at this point in the history
  • Loading branch information
Will Bierbower authored and Will Bierbower committed Apr 17, 2015
1 parent f2367b9 commit c78243e
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions fauxgeo/raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,23 @@ def __eq__(self, raster):
else:
return False

def minimum(self, raster):
if type(raster) in [float, int]:
# Implement broadcast operation
def min_closure(nodata):
def mini(x):
f = np.where((np.less(x, raster)), x, raster)
return np.where((np.not_equal(x, nodata)), f(x), nodata)
return mini
return self.local_op(raster, min_closure, broadcast=True)
else:
def min_closure(nodata):
def mini(x, y):
f = np.where((np.less(x, y)), x, y)
return np.where((np.not_equal(x, nodata)) & (np.not_equal(y, nodata)), f(x, y), nodata)
return mini
return self.local_op(raster, min_closure)

def __getitem__(self):
pass # return numpy slice? Raster object with sliced numpy array?

Expand Down

0 comments on commit c78243e

Please sign in to comment.