Speed up ring extraction

This commit is contained in:
Valentin Valls 2019-03-14 16:33:26 +01:00
parent a613d6bb7d
commit 6a6301ec68
2 changed files with 20 additions and 3 deletions

View File

@ -27,7 +27,7 @@ from __future__ import absolute_import
__authors__ = ["V. Valls"]
__license__ = "MIT"
__date__ = "22/11/2018"
__date__ = "14/03/2019"
import logging
import numpy
@ -137,15 +137,21 @@ class RingExtractor(object):
detector=self.__detector)
return geoRef
def extract(self, peaks=None, geometryModel=None, method="massif", maxRings=None, pointPerDegree=1.0):
def extract(self, peaks=None, geometryModel=None, method="massif", maxRings=None, ringNumbers=None, pointPerDegree=1.0):
"""
Performs an automatic keypoint extraction:
Can be used in recalib or in calib after a first calibration has been performed.
# FIXME pts_per_deg
:param List[int] ringNumbers: If set, extraction will only be done on
rings number contained in this list (the number 0 identify the first
ring)
"""
assert(numpy.logical_xor(peaks is not None, geometryModel is not None))
if ringNumbers is None:
ringNumbers = []
ringNumbers = set(ringNumbers)
if peaks is not None:
# Energy from from experiment settings
wavelength = self.__wavelength
@ -196,6 +202,8 @@ class RingExtractor(object):
ms = marchingsquares.MarchingSquaresMergeImpl(ttha, self.__mask, use_minmax_cache=True)
for i in range(tth.size):
if i not in ringNumbers:
continue
if rings >= maxRings:
break
mask = numpy.logical_and(ttha >= tth_min[i], ttha < tth_max[i])

View File

@ -570,11 +570,13 @@ class _PeakToolItemDelegate(qt.QStyledItemDelegate):
persistantIndex = qt.QPersistentModelIndex(index)
extract = qt.QAction(editor)
extract.setToolTip("Re-extract peaks from this ring")
extract.setIcon(icons.getQIcon("pyfai:gui/icons/extract-ring"))
extract.triggered.connect(functools.partial(self.__extractPeak, persistantIndex))
editor.addAction(extract)
remove = qt.QAction(editor)
remove.setToolTip("Remove this group of peaks")
remove.setIcon(icons.getQIcon("pyfai:gui/icons/remove-peak"))
remove.triggered.connect(functools.partial(self.__removePeak, persistantIndex))
editor.addAction(remove)
@ -1336,10 +1338,17 @@ class PeakPickingTask(AbstractCalibrationTask):
else:
assert(False)
if self.__filterRing is None:
ringNumbers = None
else:
ringNumbers = [self.__filterRing.ringNumber() - 1]
# TODO: maxRings should be removed, not very accurate way to reach for rings
newPeaksRaw = extractor.extract(peaks=peaks,
geometryModel=geometryModel,
method="massif",
maxRings=maxRings,
ringNumbers=ringNumbers,
pointPerDegree=pointPerDegree)
# split peaks per rings