Commit af568c14 authored by Andrea Bizzego's avatar Andrea Bizzego
Browse files

check monotonicity

parent 61e2a782
......@@ -88,8 +88,13 @@ def binImage(binwidth, parameterMatrix, parameterMatrixCoordinates=None, bincoun
if mode == 'uniform':
binEdges = numpy.histogram(parameterMatrix[:], bincount)[1]
elif mode == 'equal':
# print('equal')
binEdges = numpy.percentile(parameterMatrix[:], numpy.arange(0, 1, 1/bincount))
binEdges = numpy.r_[binEdges, numpy.max(parameterMatrix[:])]
#check monotonicity
diff = numpy.diff(binEdges)
idx_non_monotonical = numpy.where(diff<0)[0]
binEdges = numpy.delete(binEdges, idx_non_monotonical)
else:
binEdges = getBinEdges(binwidth, parameterMatrix[:])
parameterMatrix = numpy.digitize(parameterMatrix, binEdges)
......@@ -98,8 +103,13 @@ def binImage(binwidth, parameterMatrix, parameterMatrixCoordinates=None, bincoun
if mode == 'uniform':
binEdges = numpy.histogram(parameterMatrix[parameterMatrixCoordinates], bincount)[1]
elif mode == 'equal':
# print('equal')
binEdges = numpy.percentile(parameterMatrix[parameterMatrixCoordinates], numpy.arange(0, 1, 1/bincount))
binEdges = numpy.r_[binEdges, numpy.max(parameterMatrix[:])]
#check monotonicity
diff = numpy.diff(binEdges)
idx_non_monotonical = numpy.where(diff<0)[0]
binEdges = numpy.delete(binEdges, idx_non_monotonical)
else:
binEdges = getBinEdges(binwidth, parameterMatrix[parameterMatrixCoordinates])
parameterMatrix[parameterMatrixCoordinates] = numpy.digitize(parameterMatrix[parameterMatrixCoordinates], binEdges)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment