def cake(self,diffractionData,calibrationData,qLower,qUpper,numQ,
            chiLower,chiUpper,numChi,doPolarizationCorrection,P,
            maskedPixelInfo):

        if chiLower >= chiUpper:
            raise Exception("Unable to cake. The lower chi value must be less then the upper chi value.")

        if (chiUpper - chiLower) > 360:
            raise Exception("The chi values must have a range no larger then 360 degrees.")

        if qLower >= qUpper:
            raise Exception("Unable to cake. The lower q value must be less then the upper q value.")

        if qLower < 0: 
            raise Exception("Unable to cake. The lower q value must be larger then 0.")

        if qUpper > Transform.getMaxQ(calibrationData):
            raise Exception("Unable to cake. The upper q value must be less then the largest possible Q value.")


        if maskedPixelInfo.doLessThanMask:
            lessThanMask = maskedPixelInfo.lessThanMask
        else:
            # We can just send the function a bunch of junk since it won't be used
            lessThanMask = -1

        if maskedPixelInfo.doGreaterThanMask:
            greaterThanMask = maskedPixelInfo.greaterThanMask
        else:
            greaterThanMask = -1

        if maskedPixelInfo.doPolygonMask:
            polygonsX = maskedPixelInfo.polygonsX
            polygonsY = maskedPixelInfo.polygonsY
            polygonBeginningsIndex = maskedPixelInfo.polygonBeginningsIndex
            polygonNumberOfItems = maskedPixelInfo.polygonNumberOfItems
        else:
            polygonsX = Numeric.array([])
            polygonsY = Numeric.array([])
            polygonBeginningsIndex = Numeric.array([])
            polygonNumberOfItems = Numeric.array([])


        # use the wraped C code to do the caking
        self.cakeData = DiffractionAnalysisWrap.cake(
                diffractionData,
                calibrationData.getCenterX()['val'],
                calibrationData.getCenterY()['val'],
                calibrationData.getDistance()['val'],
                calibrationData.getEnergy()['val'],
                calibrationData.getAlpha()['val'], 
                calibrationData.getBeta()['val'],
                calibrationData.getRotation()['val'],
                qLower, qUpper,
                numQ,
                chiLower, chiUpper,
                numChi,
                doPolarizationCorrection, P,
                maskedPixelInfo.doGreaterThanMask, greaterThanMask,
                maskedPixelInfo.doLessThanMask, lessThanMask,
                maskedPixelInfo.doPolygonMask,
                polygonsX, polygonsY,
                polygonBeginningsIndex,
                polygonNumberOfItems,
                calibrationData.getPixelLength()['val'],
                calibrationData.getPixelHeight()['val'])

        if type(self.cakeData) == type(None):
            raise Exception("Error occured while caking the data.")

        # store the values for later
        self.qLower=qLower
        self.qUpper=qUpper
        self.numQ=numQ
        self.chiLower=chiLower
        self.chiUpper=chiUpper
        self.numChi=numChi
        self.doPolarizationCorrection=doPolarizationCorrection
        self.P=P

        # We should make a shallow copy so that the widget dose
        # not get copied over. Nevertheless, all the stuff we 
        # care about are single values so they will get really copied over
        self.maskedPixelInfo = copy.copy(maskedPixelInfo)

        self.calibrationData = copy.deepcopy(calibrationData)
        self.diffractionData = diffractionData
Beispiel #2
0
    def cake(self, diffractionData, calibrationData, qLower, qUpper, numQ,
             chiLower, chiUpper, numChi, doPolarizationCorrection, P,
             maskedPixelInfo):

        if chiLower >= chiUpper:
            raise Exception(
                "Unable to cake. The lower chi value must be less then the upper chi value."
            )

        if (chiUpper - chiLower) > 360:
            raise Exception(
                "The chi values must have a range no larger then 360 degrees.")

        if qLower >= qUpper:
            raise Exception(
                "Unable to cake. The lower q value must be less then the upper q value."
            )

        if qLower < 0:
            raise Exception(
                "Unable to cake. The lower q value must be larger then 0.")

        if qUpper > Transform.getMaxQ(calibrationData):
            raise Exception(
                "Unable to cake. The upper q value must be less then the largest possible Q value."
            )

        if maskedPixelInfo.doLessThanMask:
            lessThanMask = maskedPixelInfo.lessThanMask
        else:
            # We can just send the function a bunch of junk since it won't be used
            lessThanMask = -1

        if maskedPixelInfo.doGreaterThanMask:
            greaterThanMask = maskedPixelInfo.greaterThanMask
        else:
            greaterThanMask = -1

        if maskedPixelInfo.doPolygonMask:
            polygonsX = maskedPixelInfo.polygonsX
            polygonsY = maskedPixelInfo.polygonsY
            polygonBeginningsIndex = maskedPixelInfo.polygonBeginningsIndex
            polygonNumberOfItems = maskedPixelInfo.polygonNumberOfItems
        else:
            polygonsX = Numeric.array([])
            polygonsY = Numeric.array([])
            polygonBeginningsIndex = Numeric.array([])
            polygonNumberOfItems = Numeric.array([])

        # use the wraped C code to do the caking
        self.cakeData = DiffractionAnalysisWrap.cake(
            diffractionData,
            calibrationData.getCenterX()['val'],
            calibrationData.getCenterY()['val'],
            calibrationData.getDistance()['val'],
            calibrationData.getEnergy()['val'],
            calibrationData.getAlpha()['val'],
            calibrationData.getBeta()['val'],
            calibrationData.getRotation()['val'], qLower, qUpper, numQ,
            chiLower, chiUpper, numChi, doPolarizationCorrection, P,
            maskedPixelInfo.doGreaterThanMask, greaterThanMask,
            maskedPixelInfo.doLessThanMask, lessThanMask,
            maskedPixelInfo.doPolygonMask, polygonsX, polygonsY,
            polygonBeginningsIndex, polygonNumberOfItems,
            calibrationData.getPixelLength()['val'],
            calibrationData.getPixelHeight()['val'])

        if type(self.cakeData) == type(None):
            raise Exception("Error occured while caking the data.")

        # store the values for later
        self.qLower = qLower
        self.qUpper = qUpper
        self.numQ = numQ
        self.chiLower = chiLower
        self.chiUpper = chiUpper
        self.numChi = numChi
        self.doPolarizationCorrection = doPolarizationCorrection
        self.P = P

        # We should make a shallow copy so that the widget dose
        # not get copied over. Nevertheless, all the stuff we
        # care about are single values so they will get really copied over
        self.maskedPixelInfo = copy.copy(maskedPixelInfo)

        self.calibrationData = copy.deepcopy(calibrationData)
        self.diffractionData = diffractionData
Beispiel #3
0
    def cake(self, diffractionData, calibrationData, qOrTwoThetaLower,
             qOrTwoThetaUpper, numQOrTwoTheta, chiLower, chiUpper, numChi,
             doPolarizationCorrection, P, maskedPixelInfo, type):

        if chiLower >= chiUpper:
            raise Exception("Unable to cake. The lower chi value must be \
less then the upper chi value.")

        if (chiUpper - chiLower) > 360:
            raise Exception("The chi values must have a range no larger \
then 360 degrees.")

        if type == 'Q':
            if qOrTwoThetaLower >= qOrTwoThetaUpper:
                raise Exception("Unable to cake. The lower Q value must be \
less then the upper Q value")

            if qOrTwoThetaLower < 0:
                raise Exception("Unable to cake. The lower Q value must be \
larger then 0.")

            if qOrTwoThetaUpper > Transform.getMaxQ(calibrationData):
                raise Exception("Unable to cake. The upper Q value must be \
less then the largest possible Q value.")

            if numQOrTwoTheta < 1:
                raise Exception("Unable to cake. The number of Q must be at \
least 1.")

        elif type == '2theta':
            if qOrTwoThetaLower >= qOrTwoThetaUpper:
                raise Exception("Unable to cake. The lower 2theta value must \
be less then the upper 2theta value")

            if qOrTwoThetaLower < 0:
                raise Exception("Unable to cake. The lower 2theta value must \
be larger then 0.")

            if qOrTwoThetaUpper > Transform.getMaxTwoTheta():
                raise Exception("Unable to cake. The upper 2theta value must \
be smaller then 90.")

            if numQOrTwoTheta < 1:
                raise Exception("Unable to cake. The number of 2theta must \
be at least 1.")
        else:
            raise Exception("Unable to cake. The function must be passed \
for the parameter type either 'Q', or '2theta'")

        if maskedPixelInfo.doLessThanMask:
            lessThanMask = maskedPixelInfo.lessThanMask
        else:
            # We can just send the function a bunch of junk since
            # it won't be used
            lessThanMask = -1

        if maskedPixelInfo.doGreaterThanMask:
            greaterThanMask = maskedPixelInfo.greaterThanMask
        else:
            greaterThanMask = -1

        if maskedPixelInfo.doPolygonMask:
            polygonsX = maskedPixelInfo.polygonsX
            polygonsY = maskedPixelInfo.polygonsY
            polygonBeginningsIndex = maskedPixelInfo.polygonBeginningsIndex
            polygonNumberOfItems = maskedPixelInfo.polygonNumberOfItems
        else:
            polygonsX = Numeric.array([])
            polygonsY = Numeric.array([])
            polygonBeginningsIndex = Numeric.array([])
            polygonNumberOfItems = Numeric.array([])

        # use the wraped C code to do the caking
        self.cakeData = DiffractionAnalysisWrap.cake(
            diffractionData,
            calibrationData.getCenterX()['val'],
            calibrationData.getCenterY()['val'],
            calibrationData.getDistance()['val'],
            calibrationData.getEnergy()['val'],
            calibrationData.getAlpha()['val'],
            calibrationData.getBeta()['val'],
            calibrationData.getRotation()['val'], qOrTwoThetaLower,
            qOrTwoThetaUpper, numQOrTwoTheta, chiLower, chiUpper, numChi,
            doPolarizationCorrection, P, maskedPixelInfo.doGreaterThanMask,
            greaterThanMask, maskedPixelInfo.doLessThanMask, lessThanMask,
            maskedPixelInfo.doPolygonMask, polygonsX, polygonsY,
            polygonBeginningsIndex, polygonNumberOfItems,
            calibrationData.getPixelLength()['val'],
            calibrationData.getPixelHeight()['val'], type)

        # store the values for later
        self.qOrTwoThetaLower = qOrTwoThetaLower
        self.qOrTwoThetaUpper = qOrTwoThetaUpper
        self.numQOrTwoTheta = numQOrTwoTheta
        self.chiLower = chiLower
        self.chiUpper = chiUpper
        self.numChi = numChi
        self.doPolarizationCorrection = doPolarizationCorrection
        self.P = P
        self.type = type

        # We should make a shallow copy so that the widget dose
        # not get copied over. Nevertheless, all the stuff we
        # care about are single values so they will get really copied over
        self.maskedPixelInfo = copy.copy(maskedPixelInfo)

        self.calibrationData = copy.deepcopy(calibrationData)
        self.diffractionData = diffractionData
    def cake(self,diffractionData,calibrationData,qOrTwoThetaLower,
            qOrTwoThetaUpper,numQOrTwoTheta,chiLower,chiUpper,numChi,
            doPolarizationCorrection,P,maskedPixelInfo,type):

        if chiLower >= chiUpper:
            raise Exception("Unable to cake. The lower chi value must be \
less then the upper chi value.")

        if (chiUpper - chiLower) > 360:
            raise Exception("The chi values must have a range no larger \
then 360 degrees.")

        if type == 'Q':
            if qOrTwoThetaLower >= qOrTwoThetaUpper:
                raise Exception("Unable to cake. The lower Q value must be \
less then the upper Q value")

            if qOrTwoThetaLower < 0: 
                raise Exception("Unable to cake. The lower Q value must be \
larger then 0.")

            if qOrTwoThetaUpper > Transform.getMaxQ(calibrationData):
                raise Exception("Unable to cake. The upper Q value must be \
less then the largest possible Q value.")

            if numQOrTwoTheta < 1:
                raise Exception("Unable to cake. The number of Q must be at \
least 1.")

        elif type == '2theta':
            if qOrTwoThetaLower >= qOrTwoThetaUpper:
                raise Exception("Unable to cake. The lower 2theta value must \
be less then the upper 2theta value")

            if qOrTwoThetaLower < 0: 
                raise Exception("Unable to cake. The lower 2theta value must \
be larger then 0.")

            if qOrTwoThetaUpper > Transform.getMaxTwoTheta():
                raise Exception("Unable to cake. The upper 2theta value must \
be smaller then 90.")

            if numQOrTwoTheta < 1:
                raise Exception("Unable to cake. The number of 2theta must \
be at least 1.")
        else:
            raise Exception("Unable to cake. The function must be passed \
for the parameter type either 'Q', or '2theta'")


        if maskedPixelInfo.doLessThanMask:
            lessThanMask = maskedPixelInfo.lessThanMask
        else:
            # We can just send the function a bunch of junk since 
            # it won't be used
            lessThanMask = -1

        if maskedPixelInfo.doGreaterThanMask:
            greaterThanMask = maskedPixelInfo.greaterThanMask
        else:
            greaterThanMask = -1

        if maskedPixelInfo.doPolygonMask:
            polygonsX = maskedPixelInfo.polygonsX
            polygonsY = maskedPixelInfo.polygonsY
            polygonBeginningsIndex = maskedPixelInfo.polygonBeginningsIndex
            polygonNumberOfItems = maskedPixelInfo.polygonNumberOfItems
        else:
            polygonsX = Numeric.array([])
            polygonsY = Numeric.array([])
            polygonBeginningsIndex = Numeric.array([])
            polygonNumberOfItems = Numeric.array([])

        # use the wraped C code to do the caking
        self.cakeData = DiffractionAnalysisWrap.cake(
                diffractionData,
                calibrationData.getCenterX()['val'],
                calibrationData.getCenterY()['val'],
                calibrationData.getDistance()['val'],
                calibrationData.getEnergy()['val'],
                calibrationData.getAlpha()['val'], 
                calibrationData.getBeta()['val'],
                calibrationData.getRotation()['val'],
                qOrTwoThetaLower, qOrTwoThetaUpper,
                numQOrTwoTheta,
                chiLower, chiUpper,
                numChi,
                doPolarizationCorrection, P,
                maskedPixelInfo.doGreaterThanMask, greaterThanMask,
                maskedPixelInfo.doLessThanMask, lessThanMask,
                maskedPixelInfo.doPolygonMask,
                polygonsX, polygonsY,
                polygonBeginningsIndex,
                polygonNumberOfItems,
                calibrationData.getPixelLength()['val'],
                calibrationData.getPixelHeight()['val'],
                type)

        # store the values for later
        self.qOrTwoThetaLower=qOrTwoThetaLower
        self.qOrTwoThetaUpper=qOrTwoThetaUpper
        self.numQOrTwoTheta=numQOrTwoTheta 
        self.chiLower=chiLower
        self.chiUpper=chiUpper
        self.numChi=numChi
        self.doPolarizationCorrection=doPolarizationCorrection
        self.P=P
        self.type = type

        # We should make a shallow copy so that the widget dose
        # not get copied over. Nevertheless, all the stuff we 
        # care about are single values so they will get really copied over
        self.maskedPixelInfo = copy.copy(maskedPixelInfo)

        self.calibrationData = copy.deepcopy(calibrationData)
        self.diffractionData = diffractionData