예제 #1
0
def initPeaksFromControlPoints(peakSelectionModel, controlPoints, context=None):
    """Initialize peak selection model using control points object

    :rtype: pyFAI.control_points.ControlPoints
    """
    if not isinstance(peakSelectionModel, PeakSelectionModel):
        raise TypeError("Unexpected model type")
    if not isinstance(controlPoints, ControlPoints):
        raise TypeError("Unexpected model type")

    if context is None:
        context = CalibrationContext.instance()

    peakSelectionModel.clear()
    for label in controlPoints.get_labels():
        group = controlPoints.get(lbl=label)
        peakModel = createRing(group.points, peakSelectionModel=peakSelectionModel, context=context)
        peakModel.setRingNumber(group.ring + 1)
        peakModel.setName(label)
        peakSelectionModel.append(peakModel)
예제 #2
0
def createRing(points, peakSelectionModel, ringNumber=None, context=None):
    """Create a new ring from a group of points

    :rtype: PeakModel
    """
    if context is None:
        context = CalibrationContext.instance()

    name = _findUnusedName(peakSelectionModel)
    if ringNumber is None:
        ringNumber = 1
    color = context.getMarkerColor(ringNumber - 1)

    peakModel = PeakModel(peakSelectionModel)
    peakModel.setName(name)
    peakModel.setColor(color)
    peakModel.setCoords(points)
    peakModel.setRingNumber(ringNumber)

    return peakModel
예제 #3
0
def createRing(points, peakSelectionModel, context=None):
    """Create a new ring from a group of points"""

    if context is None:
        context = CalibrationContext.instance()

    # reach the bigger name
    names = ["% 8s" % p.name() for p in peakSelectionModel]
    if len(names) > 0:
        names = list(sorted(names))
        bigger = names[-1].strip()
        number = 0
        for c in bigger:
            number = number * 26 + (ord(c) - ord('a'))
    else:
        number = -1
    number = number + 1

    # compute the next one
    name = ""
    if number == 0:
        name = "a"
    else:
        n = number
        while n > 0:
            c = n % 26
            n = n // 26
            name = chr(c + ord('a')) + name

    color = context.getMarkerColor(number)

    # TODO: color and name should be removed from the model
    # TODO: As result this function should be removed
    peakModel = PeakModel(peakSelectionModel)
    peakModel.setName(name)
    peakModel.setColor(color)
    peakModel.setCoords(points)
    peakModel.setRingNumber(1)

    return peakModel
예제 #4
0
def createRing(points, peakSelectionModel, context=None):
    """Create a new ring from a group of points"""

    if context is None:
        context = CalibrationContext.instance()

    # reach the bigger name
    names = ["% 8s" % p.name() for p in peakSelectionModel]
    if len(names) > 0:
        names = list(sorted(names))
        bigger = names[-1].strip()
        number = 0
        for c in bigger:
            number = number * 26 + (ord(c) - ord('a'))
    else:
        number = -1
    number = number + 1

    # compute the next one
    name = ""
    if number == 0:
        name = "a"
    else:
        n = number
        while n > 0:
            c = n % 26
            n = n // 26
            name = chr(c + ord('a')) + name

    color = context.getMarkerColor(number)

    # TODO: color and name should be removed from the model
    # TODO: As result this function should be removed
    peakModel = PeakModel(peakSelectionModel)
    peakModel.setName(name)
    peakModel.setColor(color)
    peakModel.setCoords(points)
    peakModel.setRingNumber(1)

    return peakModel
예제 #5
0
def initPeaksFromControlPoints(peakSelectionModel, controlPoints, context=None):
    """Initialize peak selection model using control points object

    :rtype: pyFAI.control_points.ControlPoints
    """
    if not isinstance(peakSelectionModel, PeakSelectionModel):
        raise TypeError("Unexpected model type")
    if not isinstance(controlPoints, ControlPoints):
        raise TypeError("Unexpected model type")

    if context is None:
        context = CalibrationContext.instance()

    peakSelectionModel.clear()
    for label in controlPoints.get_labels():
        group = controlPoints.get(lbl=label)
        color = context.getMarkerColor(group.ring)
        points = numpy.array(group.points)
        peakModel = createRing(points, peakSelectionModel=peakSelectionModel, context=context)
        peakModel.setRingNumber(group.ring + 1)
        peakModel.setColor(color)
        peakModel.setName(label)
        peakSelectionModel.append(peakModel)