def computeSumWithThreshold( dataNumpyArray, threshold):
# convert to a mesh grid
grid = numpy.meshgrid(dataNumpyArray)
# Logical comparison
# 1) compute a boolean array of values less than the threshold
compareThreshold = numpy.less (grid , threshold)
# 2) compare and extract # TODO Not elegant, but works. found this at http://stackoverflow.com/a/26511354
boolThreshold = numpy.logical_and(compareThreshold , grid)
# Create new array
lowPlank = numpy.extract(boolThreshold, grid)
return numpy.sum(lowPlank)
评论列表
文章目录