This commit is contained in:
Valentin Valls 2019-03-22 09:28:13 +01:00
parent 61e803518f
commit e653c42210
1 changed files with 12 additions and 10 deletions

View File

@ -31,7 +31,7 @@ __author__ = "Jérôme Kieffer"
__contact__ = "Jerome.Kieffer@ESRF.eu"
__license__ = "MIT"
__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France"
__date__ = "21/03/2019"
__date__ = "22/03/2019"
__status__ = "production"
import sys
@ -123,34 +123,35 @@ class Massif(object):
"""
All in one function that finds a maximum from the given seed (x)
then calculates the region extension and extract position of the neighboring peaks.
:param x: coordinates of the peak, seed for the calculation
:type x: tuple of integer
:param nmax: maximum number of peak per region
:param annotate: call back method taking number of points + coordinate as input.
:param Tuple[int] x: coordinates of the peak, seed for the calculation
:param int nmax: maximum number of peak per region
:param annotate: callback method taking number of points + coordinate as input.
:param massif_contour: callback to show the contour of a massif with the given index.
:param stdout: this is the file where output is written by default.
:return: list of peaks
"""
listpeaks = []
region = self.calculate_massif(x)
if region is None:
logger.error("You picked a background point at %s", x)
return listpeaks
return []
xinit = self.nearest_peak(x)
if xinit is None:
logger.error("Unable to find peak in the vinicy of %s", x)
return listpeaks
return []
else:
if not region[int(xinit[0] + 0.5), int(xinit[1] + 0.5)]:
logger.error("Nearest peak %s is not in the same region %s", xinit, x)
return listpeaks
return []
if annotate is not None:
try:
annotate(xinit, x)
except Exception as error:
logger.error("Error in annotate %i: %i %i. %s", len(listpeaks), xinit[0], xinit[1], error)
logger.debug("Backtrace", exc_info=True)
logger.error("Error in annotate %i: %i %i. %s", 0, xinit[0], xinit[1], error)
listpeaks = []
listpeaks.append(xinit)
cleaned_data = self.cleaned_data
mean = cleaned_data[region].mean(dtype=numpy.float64)
@ -162,6 +163,7 @@ class Massif(object):
try:
massif_contour(region)
except (WindowsError, MemoryError) as error:
logger.debug("Backtrace", exc_info=True)
logger.error("Error in plotting region: %s", error)
nbFailure = 0
for j in idx: