def getTestExperimentalCondition(self):
     strPathToTestExperimentalCondition = os.path.join(
         self.getPluginTestsDataHome(),
         "XSDataExperimentalCondition_test.xml")
     strXMLInput = self.readAndParseFile(strPathToTestExperimentalCondition)
     xsDataExperimentalCondition = XSDataExperimentalCondition.parseString(
         strXMLInput)
     return xsDataExperimentalCondition
Exemplo n.º 2
0
    def generateXSDataIndexingResult(_xsDataResultXDSIndexing, _xsDataExperimentalCondition=None):

        xsDataIndexingResult = XSDataIndexingResult()
        xsDataIndexingSolutionSelected = XSDataIndexingSolutionSelected()
        xsDataCrystalSelected = XSDataCrystal()
#        xsDataIndexingSolutionSelected.setNumber(XSDataInteger(iIndex))
#        xsDataCellSelected = xsDataLabelitSolution.getUnitCell()
        spaceGroupName = EDUtilsSymmetry.getMinimumSymmetrySpaceGroupFromBravaisLattice(_xsDataResultXDSIndexing.bravaisLattice.value)
        xsDataCrystalSelected = XSDataCrystal()
        xsDataSpaceGroupSelected = XSDataSpaceGroup()
        xsDataSpaceGroupSelected.setName(XSDataString(spaceGroupName))
        xsDataCrystalSelected.setSpaceGroup(xsDataSpaceGroupSelected)
#        xsDataCrystalSelected.setCell(xsDataCellSelected)
        xsDataCrystalSelected.setMosaicity(XSDataDouble(_xsDataResultXDSIndexing.mosaicity.value))
        xsDataCrystalSelected.setCell(XSDataCell.parseString(_xsDataResultXDSIndexing.unitCell.marshal()))

        xsDataIndexingSolutionSelected.setCrystal(xsDataCrystalSelected)

        xsDataOrientation = XSDataOrientation()
        xsDataOrientation.setMatrixA(_xsDataResultXDSIndexing.getAMatrix())
        xsDataOrientation.setMatrixU(_xsDataResultXDSIndexing.getUMatrix())
        xsDataIndexingSolutionSelected.setOrientation(xsDataOrientation)


        xsDataStatisticsIndexing = XSDataStatisticsIndexing()

        if (_xsDataExperimentalCondition is not None):
            fBeamPositionXOrig = _xsDataExperimentalCondition.getDetector().getBeamPositionX().getValue()
            fBeamPositionYOrig = _xsDataExperimentalCondition.getDetector().getBeamPositionY().getValue()
            fBeamPositionXNew = _xsDataResultXDSIndexing.getBeamCentreX().getValue()
            fBeamPositionYNew = _xsDataResultXDSIndexing.getBeamCentreY().getValue()
            xsDataStatisticsIndexing.setBeamPositionShiftX(XSDataLength(fBeamPositionXOrig - fBeamPositionXNew))
            xsDataStatisticsIndexing.setBeamPositionShiftY(XSDataLength(fBeamPositionYOrig - fBeamPositionYNew))

        xsDataExperimentalConditionRefined = None
        if (_xsDataExperimentalCondition is None):
            xsDataExperimentalConditionRefined = XSDataExperimentalCondition()
        else:
            # Copy the incoming experimental condition
            xmlExperimentalCondition = _xsDataExperimentalCondition.marshal()
            xsDataExperimentalConditionRefined = XSDataExperimentalCondition.parseString(xmlExperimentalCondition)

        xsDataDetector = xsDataExperimentalConditionRefined.getDetector()
        if (xsDataDetector is None):
            xsDataDetector = XSDataDetector()

        xsDataDetector.setBeamPositionX(XSDataLength(_xsDataResultXDSIndexing.getBeamCentreX().value))
        xsDataDetector.setBeamPositionY(XSDataLength(_xsDataResultXDSIndexing.getBeamCentreY().value))
        xsDataDetector.setDistance(_xsDataResultXDSIndexing.getDistance())

        xsDataExperimentalConditionRefined.setDetector(xsDataDetector)
        xsDataIndexingSolutionSelected.setExperimentalConditionRefined(xsDataExperimentalConditionRefined)

        xsDataIndexingResult.setSelectedSolution(xsDataIndexingSolutionSelected)

        return xsDataIndexingResult
    def preProcess(self, _edObject=None):
        """
        Gets the Configuration Parameters, if found, overrides default parameters
        """
        EDPluginControl.preProcess(self, _edObject)
        self.DEBUG("EDPluginControlGeneratePredictionv10.preProcess...")

        xsDataGeneratePredictionInput = self.getDataInput()

        xsDataSelectedIndexingSolution = xsDataGeneratePredictionInput.getSelectedIndexingSolution()
        xsDataExperimentalConditionRefined = xsDataSelectedIndexingSolution.getExperimentalConditionRefined()
        xsDataCollection = xsDataGeneratePredictionInput.getDataCollection()
        xsDataSubWedgeList = xsDataCollection.getSubWedge()

        # List containing instances of all the generate prediction plugins
        self.__listPluginGeneratePrediction = []

        # Loop through all subwedges
        iIndex = 0
        for xsDataSubWedge in xsDataSubWedgeList:

            xsDataImageList = xsDataSubWedge.getImage()
            # First find the lowest image number
            iLowestImageNumber = None
            for xsDataImage in xsDataImageList:
                iImageNumber = xsDataImage.getNumber().getValue()
                if (iLowestImageNumber is None):
                    iLowestImageNumber = iImageNumber
                elif (iImageNumber < iLowestImageNumber):
                    iLowestImageNumber = iImageNumber
            # Then loop through all images in a sub wedge
            for xsDataImage in xsDataImageList:
                iIndex += 1
                edPluginGeneratePrediction = self.loadPlugin(self.__strPluginGeneratePredictionName,
                                                              "%s-%02d" % (self.__strPluginGeneratePredictionName, iIndex))
                xsDataGeneratePredictionInput = XSDataGeneratePredictionInput()
                xsDataGeneratePredictionInput.setSelectedIndexingSolution(XSDataIndexingSolutionSelected.parseString(xsDataSelectedIndexingSolution.marshal()))
                xsDataCollectionNew = XSDataCollection()
                xsDataSubWedgeNew = XSDataSubWedge()
                xsDataSubWedgeNew.addImage(XSDataImage.parseString(xsDataImage.marshal()))
                xsDataSubWedgeNew.setExperimentalCondition(XSDataExperimentalCondition.parseString(xsDataSubWedge.getExperimentalCondition().marshal()))
                # We must modify the rotationOscillationStart for the new subwedge
                xsDataGoniostatNew = xsDataSubWedgeNew.getExperimentalCondition().getGoniostat()
                fGoniostatRotationAxisStart = xsDataGoniostatNew.getRotationAxisStart().getValue()
                fGonioStatOscillationRange = xsDataGoniostatNew.getOscillationWidth().getValue()
                iImageNumber = xsDataImage.getNumber().getValue()
                fGoniostatRotationAxisStartNew = fGoniostatRotationAxisStart + (iImageNumber - iLowestImageNumber) * fGonioStatOscillationRange
                xsDataGoniostatNew.setRotationAxisStart(XSDataAngle(fGoniostatRotationAxisStartNew))
                # 
                xsDataCollectionNew.addSubWedge(xsDataSubWedgeNew)
                xsDataGeneratePredictionInput.setDataCollection(xsDataCollectionNew)
                from EDHandlerXSDataMOSFLMv10 import EDHandlerXSDataMOSFLMv10
                xsDataMOSFLMInputGeneratePrediction = EDHandlerXSDataMOSFLMv10.generateXSDataMOSFLMInputGeneratePrediction(xsDataGeneratePredictionInput)
                edPluginGeneratePrediction.setDataInput(xsDataMOSFLMInputGeneratePrediction)
                self.__listPluginGeneratePrediction.append(edPluginGeneratePrediction)
    def preProcess(self, _edObject=None):
        """
        Gets the Configuration Parameters, if found, overrides default parameters
        """
        EDPluginControl.preProcess(self, _edObject)
        self.DEBUG("EDPluginControlIntegrationv10.preProcess...")

        xsDataIntegrationInput = self.getDataInput()
        xsDataSelectedIndexingSolution = xsDataIntegrationInput.getSelectedIndexingSolution()
        self.__xsDataExperimentalConditionRefined = xsDataIntegrationInput.getExperimentalConditionRefined()
        # To be changed (see bug #40)
        if (self.__xsDataExperimentalConditionRefined is None):
            self.__xsDataExperimentalConditionRefined = xsDataSelectedIndexingSolution.getExperimentalConditionRefined()
        xsDataCollection = xsDataIntegrationInput.getDataCollection()
        xsDataSubWedgeList = xsDataCollection.getSubWedge()

        self.__edPluginIntegrationList = []

        iIndex = 0
        for xsDataSubWedge in xsDataSubWedgeList:
            iSubWedgeNumber = iIndex
            if (xsDataSubWedge.getSubWedgeNumber() is not None):
                # Use the incoming subwedge number if it exists
                iSubWedgeNumber = xsDataSubWedge.getSubWedgeNumber().getValue()

            edPluginIntegration = self.loadPlugin(self.__strPluginIntegrationName)

            if (not edPluginIntegration is None):
                iIndex += 1
                xsDataIntegrationInputSubWedge = XSDataIntegrationInput()
                xsDataIntegrationInputSubWedge.setSelectedIndexingSolution(XSDataIndexingSolutionSelected.parseString(xsDataSelectedIndexingSolution.marshal()))
                xsDataIntegrationInputSubWedge.setExperimentalConditionRefined(XSDataExperimentalCondition.parseString(self.__xsDataExperimentalConditionRefined.marshal()))
                xsDataCollection = XSDataCollection()
                xsDataCollection.addSubWedge(xsDataSubWedge)
                xsDataIntegrationInputSubWedge.setDataCollection(xsDataCollection)
                try:
                    from EDHandlerXSDataMOSFLMv10 import EDHandlerXSDataMOSFLMv10
                    xsDataMOSFLMInputIntegration = EDHandlerXSDataMOSFLMv10.generateXSDataMOSFLMInputIntegration(xsDataIntegrationInputSubWedge)
                    edPluginIntegration.setDataInput(xsDataMOSFLMInputIntegration)
                    edPluginIntegration.setBaseName("%s-%02d" % (self.__strPluginIntegrationName, iIndex))
                    edPluginIntegration.connectSUCCESS(self.doSuccessActionIntegration)
                    edPluginIntegration.connectFAILURE(self.doFailureActionIntegration)
                    # Here we store the sub wedge number for use in the results
                    self.__edPluginIntegrationList.append([iSubWedgeNumber, edPluginIntegration])
                except Exception as strErrorMessage:
                    self.addErrorMessage(strErrorMessage)
                    self.ERROR(strErrorMessage)
                    self.setFailure()
            else:
                strErrorMessage = "EDPluginControlIntegrationv10.preProcess: could not load plugin %s" % self.__strPluginIntegrationName
                self.error(strErrorMessage)
                self.addErrorMessage(strErrorMessage)
                self.setFailure()
Exemplo n.º 5
0
    def getXSDataResultStrategy(self, _xsDataResultBest, _xsDataExperimentalCondition, _xsDataSample):
        xsDataResultStrategy = XSDataResultStrategy()


        #xsDataCollectionRunsBest = _xsDataResultBest.getCollectionRun()
        xsDataCollectionPlansBest = _xsDataResultBest.getCollectionPlan()

        for xsDataCollectionPlanBest in xsDataCollectionPlansBest:

            xsDataCollectionPlan = XSDataCollectionPlan()
            xsDataCollectionStrategy = XSDataCollection()

            xsDataDoubleTransmission = xsDataCollectionPlanBest.getStrategySummary().getAttenuation()

            for xsDataCollectionRunBest in xsDataCollectionPlanBest.getCollectionRun():
                xsDataSubWedge = XSDataSubWedge()
                strXmlStringDataExperimentalCondition = _xsDataExperimentalCondition.marshal()
                xsDataExperimentalCondition = XSDataExperimentalCondition.parseString(strXmlStringDataExperimentalCondition)
                xsDataExperimentalCondition.getBeam().setExposureTime(xsDataCollectionRunBest.getExposureTime())
                xsDataExperimentalCondition.getBeam().setTransmission(xsDataDoubleTransmission)
                xsDataExperimentalCondition.getDetector().setDistance(xsDataCollectionRunBest.getDistance())
                xsDataExperimentalCondition.getGoniostat().setRotationAxisStart(xsDataCollectionRunBest.getPhiStart())
                xsDataExperimentalCondition.getGoniostat().setOscillationWidth(xsDataCollectionRunBest.getPhiWidth())
                fRotationAxisEnd = xsDataCollectionRunBest.getPhiStart().getValue() + xsDataCollectionRunBest.getNumberOfImages().getValue() * xsDataCollectionRunBest.getPhiWidth().getValue()
                xsDataExperimentalCondition.getGoniostat().setRotationAxisEnd(XSDataAngle(fRotationAxisEnd))
                xsDataSubWedge.setExperimentalCondition(xsDataExperimentalCondition)
                xsDataSubWedge.setSubWedgeNumber(xsDataCollectionRunBest.getCollectionRunNumber())
                xsDataCollectionStrategy.addSubWedge(xsDataSubWedge)

            xsDataCollectionStrategy.setSample(_xsDataSample)

            xsDataCollectionPlan.setCollectionStrategy(xsDataCollectionStrategy)
            xsDataStrategySummary = xsDataCollectionPlanBest.getStrategySummary()
            xsDataCollectionPlan.setStrategySummary(xsDataStrategySummary)

            xsDataStatistics = xsDataCollectionPlanBest.getStatisticalPrediction()
            xsDataCollectionPlan.setStatistics(xsDataStatistics)

            xsDataCollectionPlan.setCollectionPlanNumber(xsDataCollectionPlanBest.getCollectionPlanNumber())

            xsDataResultStrategy.addCollectionPlan(xsDataCollectionPlan)

        return xsDataResultStrategy
Exemplo n.º 6
0
    def getXSDataStrategyResult(self, _xsDataBestOutput, _xsDataExperimentalCondition, _xsDataSample):
        xsDataStrategyResult = XSDataStrategyResult()


        #xsDataCollectionRunsBest = _xsDataBestOutput.getCollectionRun()
        xsDataCollectionPlansBest = _xsDataBestOutput.getCollectionPlan()

        for xsDataCollectionPlanBest in xsDataCollectionPlansBest:

            xsDataCollectionPlan = XSDataCollectionPlan()
            xsDataCollectionStrategy = XSDataCollection()

            for xsDataCollectionRunBest in xsDataCollectionPlanBest.getCollectionRun():
                xsDataSubWedge = XSDataSubWedge()
                strXmlStringDataExperimentalCondition = _xsDataExperimentalCondition.marshal()
                xsDataExperimentalCondition = XSDataExperimentalCondition.parseString(strXmlStringDataExperimentalCondition)
                xsDataExperimentalCondition.getBeam().setExposureTime(xsDataCollectionRunBest.getExposureTime())
                xsDataExperimentalCondition.getDetector().setDistance(xsDataCollectionRunBest.getDistance())
                xsDataExperimentalCondition.getGoniostat().setRotationAxisStart(xsDataCollectionRunBest.getPhiStart())
                xsDataExperimentalCondition.getGoniostat().setOscillationWidth(xsDataCollectionRunBest.getPhiWidth())
                fRotationAxisEnd = xsDataCollectionRunBest.getPhiStart().getValue() + xsDataCollectionRunBest.getNumberOfImages().getValue() * xsDataCollectionRunBest.getPhiWidth().getValue()
                xsDataExperimentalCondition.getGoniostat().setRotationAxisEnd(XSDataAngle(fRotationAxisEnd))
                xsDataSubWedge.setExperimentalCondition(xsDataExperimentalCondition)
                xsDataCollectionStrategy.addSubWedge(xsDataSubWedge)

            xsDataCollectionStrategy.setSample(_xsDataSample)

            xsDataCollectionPlan.setCollectionStrategy(xsDataCollectionStrategy)
            xsDataStrategySummary = xsDataCollectionPlanBest.getStrategySummary()
            xsDataCollectionPlan.setStrategySummary(xsDataStrategySummary)

            xsDataStatistics = xsDataCollectionPlanBest.getStatisticalPrediction()
            xsDataCollectionPlan.setStatistics(xsDataStatistics)

            xsDataStrategyResult.addCollectionPlan(xsDataCollectionPlan)

        return xsDataStrategyResult
    def generateXSDataIntegrationSubWedgeResult(
            _xsDataMOSFLMOutputIntegration, _xsDataExperimentalCondition=None):
        """
        Translation from XSDataMOSFLMOutputIntegration to XSDataIntegrationSubWedgeResult.
        """
        EDVerbose.DEBUG(
            "EDHandlerXSDataMOSFLMv10.generateXSDataIntegrationInput")
        EDFactoryPluginStatic.loadModule("XSDataMOSFLMv10")
        xsDataIntegrationSubWedgeResult = XSDataIntegrationSubWedgeResult()
        xsDataExperimentalConditionRefined = None
        if (_xsDataExperimentalCondition is None):
            xsDataExperimentalConditionRefined = XSDataExperimentalCondition()
        else:
            # Copy the incoming experimental condition
            xmlExperimentalCondition = _xsDataExperimentalCondition.marshal()
            xsDataExperimentalConditionRefined = XSDataExperimentalCondition.parseString(
                xmlExperimentalCondition)

        xsDataDetector = xsDataExperimentalConditionRefined.getDetector()
        if (xsDataDetector is None):
            xsDataDetector = XSDataDetector()

        if _xsDataMOSFLMOutputIntegration.getBestfilePar() is not None:
            xsDataIntegrationSubWedgeResult.setBestfilePar(
                XSDataString(_xsDataMOSFLMOutputIntegration.getBestfilePar().
                             getValue()))
            xsDataIntegrationSubWedgeResult.setBestfileDat(
                XSDataString(_xsDataMOSFLMOutputIntegration.getBestfileDat().
                             getValue()))
            xsDataIntegrationSubWedgeResult.setBestfileHKL(
                XSDataString(_xsDataMOSFLMOutputIntegration.getBestfileHKL().
                             getValue()))

        xsDataLengthRefinedDistance = _xsDataMOSFLMOutputIntegration.getRefinedDistance(
        )
        if (xsDataLengthRefinedDistance is not None):
            xsDataDetector.setDistance(xsDataLengthRefinedDistance)

        xsDataMOSFLMBeamPositionRefined = _xsDataMOSFLMOutputIntegration.getRefinedBeam(
        )
        if (xsDataMOSFLMBeamPositionRefined is not None):
            xsDataDetector.setBeamPositionX(
                XSDataLength(
                    xsDataMOSFLMBeamPositionRefined.getX().getValue()))
            xsDataDetector.setBeamPositionY(
                XSDataLength(
                    xsDataMOSFLMBeamPositionRefined.getY().getValue()))

        xsDataExperimentalConditionRefined.setDetector(xsDataDetector)
        xsDataIntegrationSubWedgeResult.setExperimentalConditionRefined(
            xsDataExperimentalConditionRefined)

        if (_xsDataMOSFLMOutputIntegration.getGeneratedMTZFile() is not None):
            xsDataIntegrationSubWedgeResult.setGeneratedMTZFile(
                _xsDataMOSFLMOutputIntegration.getGeneratedMTZFile())

        xsDataStatisticsIntegration = XSDataStatisticsIntegration()
        if (_xsDataMOSFLMOutputIntegration.getOverallIOverSigma() is not None):
            xsDataStatisticsIntegration.setIOverSigmaOverall(
                XSDataDouble(_xsDataMOSFLMOutputIntegration.
                             getOverallIOverSigma().getValue()))
        if (_xsDataMOSFLMOutputIntegration.getHighestResolutionIOverSigma()
                is not None):
            xsDataStatisticsIntegration.setIOverSigmaAtHighestResolution(
                XSDataDouble(_xsDataMOSFLMOutputIntegration.
                             getHighestResolutionIOverSigma().getValue()))
        if (_xsDataMOSFLMOutputIntegration.getRMSSpotDeviation() is not None):
            xsDataStatisticsIntegration.setRMSSpotDeviation(
                XSDataLength(_xsDataMOSFLMOutputIntegration.
                             getRMSSpotDeviation().getValue()))
        if (_xsDataMOSFLMOutputIntegration.getNumberOfBadReflections()
                is not None):
            xsDataStatisticsIntegration.setNumberOfBadReflections(
                XSDataInteger(_xsDataMOSFLMOutputIntegration.
                              getNumberOfBadReflections().getValue()))
        if (_xsDataMOSFLMOutputIntegration.getNumberOfFullyRecordedReflections(
        ) is not None):
            xsDataStatisticsIntegration.setNumberOfFullyRecordedReflections(
                XSDataInteger(
                    _xsDataMOSFLMOutputIntegration.
                    getNumberOfFullyRecordedReflections().getValue()))
        if (_xsDataMOSFLMOutputIntegration.getNumberOfNegativeReflections()
                is not None):
            xsDataStatisticsIntegration.setNumberOfNegativeReflections(
                XSDataInteger(_xsDataMOSFLMOutputIntegration.
                              getNumberOfNegativeReflections().getValue()))
        if (_xsDataMOSFLMOutputIntegration.getNumberOfOverlappedReflections()
                is not None):
            xsDataStatisticsIntegration.setNumberOfOverlappedReflections(
                XSDataInteger(_xsDataMOSFLMOutputIntegration.
                              getNumberOfOverlappedReflections().getValue()))
        if (_xsDataMOSFLMOutputIntegration.getNumberOfPartialReflections()
                is not None):
            xsDataStatisticsIntegration.setNumberOfPartialReflections(
                XSDataInteger(_xsDataMOSFLMOutputIntegration.
                              getNumberOfPartialReflections().getValue()))
        if (_xsDataMOSFLMOutputIntegration.getNumberOfReflectionsGenerated()
                is not None):
            xsDataStatisticsIntegration.setNumberOfReflectionsGenerated(
                XSDataInteger(_xsDataMOSFLMOutputIntegration.
                              getNumberOfReflectionsGenerated().getValue()))

        xsDataIntegrationSubWedgeResult.setStatistics(
            xsDataStatisticsIntegration)
        xsDataIntegrationSubWedgeResult.setExperimentalConditionRefined(
            xsDataExperimentalConditionRefined)

        for xsDataMOSFLMIntegrationStatisticsPerResolutionBin in _xsDataMOSFLMOutputIntegration.getStatisticsPerResolutionBin(
        ):
            xsDataStatisticsIntegrationPerResolutionBin = XSDataStatisticsIntegrationPerResolutionBin(
            )
            if (xsDataMOSFLMIntegrationStatisticsPerResolutionBin.
                    getMaxResolution() is not None):
                xsDataStatisticsIntegrationPerResolutionBin.setMaxResolution(
                    XSDataDouble(
                        xsDataMOSFLMIntegrationStatisticsPerResolutionBin.
                        getMaxResolution().getValue()))
            if (xsDataMOSFLMIntegrationStatisticsPerResolutionBin.
                    getMinResolution() is not None):
                xsDataStatisticsIntegrationPerResolutionBin.setMinResolution(
                    XSDataDouble(
                        xsDataMOSFLMIntegrationStatisticsPerResolutionBin.
                        getMinResolution().getValue()))

            xsDataStatisticsIntegrationPerResolutionBin.setProfileFitted(
                EDHandlerXSDataMOSFLMv10.
                generateXSDataIntegrationStatisticsPerReflectionType(
                    xsDataMOSFLMIntegrationStatisticsPerResolutionBin.
                    getProfileFitted()))
            xsDataStatisticsIntegrationPerResolutionBin.setSummation(
                EDHandlerXSDataMOSFLMv10.
                generateXSDataIntegrationStatisticsPerReflectionType(
                    xsDataMOSFLMIntegrationStatisticsPerResolutionBin.
                    getSummation()))

            xsDataIntegrationSubWedgeResult.addStatisticsPerResolutionBin(
                xsDataStatisticsIntegrationPerResolutionBin)

        xsDataIntegrationSubWedgeResult.setIntegrationLogFile(
            _xsDataMOSFLMOutputIntegration.getPathToLogFile())

        return xsDataIntegrationSubWedgeResult
    def generateXSDataIndexingResult(_xsDataMOSFLMIndexingOutput,
                                     _xsDataExperimentalCondition=None):
        """
        Translation from XSDataMOSFLMIndexingOutput to XSDataIndexingResult.
        """
        EDVerbose.DEBUG(
            "EDHandlerXSDataMOSFLMv10.generateXSDataIndexingOutput")
        xsDataMOSFLMBeamPositionRefined = _xsDataMOSFLMIndexingOutput.getRefinedBeam(
        )
        xsDataMOSFLMBeamPositionShift = _xsDataMOSFLMIndexingOutput.getBeamShift(
        )
        dDeviationAngular = _xsDataMOSFLMIndexingOutput.getDeviationAngular(
        ).getValue()
        dDeviationPositional = _xsDataMOSFLMIndexingOutput.getDeviationPositional(
        ).getValue()
        dMosaicityEstimation = _xsDataMOSFLMIndexingOutput.getMosaicityEstimation(
        ).getValue()
        dDistanceRefined = _xsDataMOSFLMIndexingOutput.getRefinedDistance(
        ).getValue()
        iSelectedSolution = _xsDataMOSFLMIndexingOutput.getSelectedSolutionNumber(
        ).getValue()
        iSpotsTotal = _xsDataMOSFLMIndexingOutput.getSpotsTotal().getValue()
        iSpotsUsed = _xsDataMOSFLMIndexingOutput.getSpotsUsed().getValue()
        xsDataCellRefined = _xsDataMOSFLMIndexingOutput.getRefinedNewmat(
        ).getRefinedCell()
        xsDataMatrixA = _xsDataMOSFLMIndexingOutput.getRefinedNewmat(
        ).getAMatrix()
        xsDataMatrixU = _xsDataMOSFLMIndexingOutput.getRefinedNewmat(
        ).getUMatrix()
        strSelectedSpaceGroupName = _xsDataMOSFLMIndexingOutput.getSelectedSolutionSpaceGroup(
        ).getValue()
        iSelectedSpaceGroupNumber = _xsDataMOSFLMIndexingOutput.getSelectedSolutionSpaceGroupNumber(
        ).getValue()

        xsDataIndexingResult = XSDataIndexingResult()
        xsDataIndexingSolutionSelected = None

        for possibleSolutions in _xsDataMOSFLMIndexingOutput.getPossibleSolutions(
        ):
            xsDataCrystal = XSDataCrystal()
            xsDataSpaceGroup = XSDataSpaceGroup()
            xsDataSpaceGroup.setName(
                XSDataString(possibleSolutions.getLattice().getValue()))
            xsDataCrystal.setSpaceGroup(xsDataSpaceGroup)
            xsDataCrystal.setCell(possibleSolutions.getCell())
            xsDataIndexingSolution = XSDataIndexingSolution()
            xsDataIndexingSolution.setCrystal(xsDataCrystal)
            iIndex = possibleSolutions.getIndex().getValue()
            xsDataIndexingSolution.setNumber(XSDataInteger(iIndex))
            xsDataIndexingSolution.setPenalty(
                XSDataFloat(possibleSolutions.getPenalty().getValue()))
            xsDataIndexingResult.addSolution(xsDataIndexingSolution)
            if (iIndex == iSelectedSolution):
                xsDataIndexingSolutionSelected = XSDataIndexingSolutionSelected(
                )
                xsDataIndexingSolutionSelected.setNumber(XSDataInteger(iIndex))
                xsDataIndexingSolutionSelected.setPenalty(
                    XSDataFloat(possibleSolutions.getPenalty().getValue()))

        xsDataCrystalSelected = XSDataCrystal()
        xsDataSpaceGroupSelected = XSDataSpaceGroup()
        xsDataSpaceGroupSelected.setName(
            XSDataString(strSelectedSpaceGroupName))
        xsDataSpaceGroupSelected.setITNumber(
            XSDataInteger(iSelectedSpaceGroupNumber))
        xsDataCrystalSelected.setSpaceGroup(xsDataSpaceGroupSelected)
        xsDataCrystalSelected.setCell(xsDataCellRefined)
        xsDataCrystalSelected.setMosaicity(XSDataDouble(dMosaicityEstimation))
        xsDataIndexingSolutionSelected.setCrystal(xsDataCrystalSelected)

        xsDataOrientation = XSDataOrientation()
        xsDataOrientation.setMatrixA(xsDataMatrixA)
        xsDataOrientation.setMatrixU(xsDataMatrixU)
        xsDataIndexingSolutionSelected.setOrientation(xsDataOrientation)

        xsDataStatisticsIndexing = XSDataStatisticsIndexing()

        xsDataStatisticsIndexing.setBeamPositionShiftX(
            XSDataLength(xsDataMOSFLMBeamPositionShift.getX().getValue()))
        xsDataStatisticsIndexing.setBeamPositionShiftY(
            XSDataLength(xsDataMOSFLMBeamPositionShift.getY().getValue()))
        xsDataStatisticsIndexing.setSpotDeviationAngular(
            XSDataAngle(dDeviationAngular))
        xsDataStatisticsIndexing.setSpotDeviationPositional(
            XSDataLength(dDeviationPositional))
        xsDataStatisticsIndexing.setSpotsUsed(XSDataInteger(iSpotsUsed))
        xsDataStatisticsIndexing.setSpotsTotal(XSDataInteger(iSpotsTotal))
        xsDataIndexingSolutionSelected.setStatistics(xsDataStatisticsIndexing)

        xsDataExperimentalConditionRefined = None
        if (_xsDataExperimentalCondition is None):
            xsDataExperimentalConditionRefined = XSDataExperimentalCondition()
        else:
            # Copy the incoming experimental condition
            xmlExperimentalCondition = _xsDataExperimentalCondition.marshal()
            xsDataExperimentalConditionRefined = XSDataExperimentalCondition.parseString(
                xmlExperimentalCondition)

        xsDataDetector = xsDataExperimentalConditionRefined.getDetector()
        if (xsDataDetector is None):
            xsDataDetector = XSDataDetector()

        xsDataDetector.setBeamPositionX(
            XSDataLength(xsDataMOSFLMBeamPositionRefined.getX().getValue()))
        xsDataDetector.setBeamPositionY(
            XSDataLength(xsDataMOSFLMBeamPositionRefined.getY().getValue()))
        xsDataDetector.setDistance(XSDataLength(dDistanceRefined))

        xsDataExperimentalConditionRefined.setDetector(xsDataDetector)
        xsDataIndexingSolutionSelected.setExperimentalConditionRefined(
            xsDataExperimentalConditionRefined)

        xsDataIndexingResult.setSelectedSolution(
            xsDataIndexingSolutionSelected)

        xsDataIndexingResult.setIndexingLogFile(
            _xsDataMOSFLMIndexingOutput.getPathToLogFile())

        return xsDataIndexingResult
Exemplo n.º 9
0
    def getXSDataResultStrategy(self, _xsDataResultBest,
                                _xsDataExperimentalCondition, _xsDataSample):
        xsDataResultStrategy = XSDataResultStrategy()

        listXSDataBestCollectionPlan = _xsDataResultBest.getCollectionPlan()

        for xsDataBestCollectionPlan in listXSDataBestCollectionPlan:

            xsDataCollectionPlan = XSDataCollectionPlan()
            xsDataCollectionStrategy = XSDataCollection()

            xsDataBestStrategySummary = xsDataBestCollectionPlan.getStrategySummary(
            )

            xsDataDoubleTransmission = xsDataBestStrategySummary.getTransmission(
            )

            for xsDataBestCollectionRun in xsDataBestCollectionPlan.getCollectionRun(
            ):
                xsDataSubWedge = XSDataSubWedge()
                strXmlStringDataExperimentalCondition = _xsDataExperimentalCondition.marshal(
                )
                xsDataExperimentalCondition = XSDataExperimentalCondition.parseString(
                    strXmlStringDataExperimentalCondition)
                xsDataExperimentalCondition.getBeam().setExposureTime(
                    xsDataBestCollectionRun.getExposureTime())
                if (xsDataBestCollectionRun.getTransmission() is None):
                    xsDataExperimentalCondition.getBeam().setTransmission(
                        xsDataDoubleTransmission)
                else:
                    xsDataExperimentalCondition.getBeam().setTransmission(
                        xsDataBestCollectionRun.getTransmission())
                xsDataExperimentalCondition.getDetector().setDistance(
                    xsDataBestStrategySummary.getDistance())
                xsDataExperimentalCondition.getGoniostat(
                ).setRotationAxisStart(xsDataBestCollectionRun.getPhiStart())
                xsDataExperimentalCondition.getGoniostat().setOscillationWidth(
                    xsDataBestCollectionRun.getPhiWidth())
                fRotationAxisEnd = xsDataBestCollectionRun.getPhiStart(
                ).getValue(
                ) + xsDataBestCollectionRun.getNumberOfImages().getValue(
                ) * xsDataBestCollectionRun.getPhiWidth().getValue()
                xsDataExperimentalCondition.getGoniostat().setRotationAxisEnd(
                    XSDataAngle(fRotationAxisEnd))
                xsDataSubWedge.setExperimentalCondition(
                    xsDataExperimentalCondition)
                xsDataSubWedge.setSubWedgeNumber(
                    xsDataBestCollectionRun.getCollectionRunNumber())
                if xsDataBestCollectionRun.getCrystalPosition():
                    xsDataSubWedge.setAction(
                        XSDataString("Crystal position: %d" %
                                     xsDataBestCollectionRun.
                                     getCrystalPosition().getValue()))
                else:
                    xsDataSubWedge.setAction(
                        xsDataBestCollectionRun.getAction())
                xsDataCollectionStrategy.addSubWedge(xsDataSubWedge)

            xsDataCollectionStrategy.setSample(_xsDataSample)

            xsDataCollectionPlan.setCollectionStrategy(
                xsDataCollectionStrategy)

            xsDataStrategySummary = XSDataStrategySummary()
            xsDataStrategySummary.setCompleteness(
                xsDataBestStrategySummary.getCompleteness())
            xsDataStrategySummary.setISigma(
                xsDataBestStrategySummary.getISigma())
            xsDataStrategySummary.setRankingResolution(
                xsDataBestStrategySummary.getRankingResolution())
            xsDataStrategySummary.setRedundancy(
                xsDataBestStrategySummary.getRedundancy())
            xsDataStrategySummary.setResolution(
                xsDataBestStrategySummary.getResolution())
            xsDataStrategySummary.setResolutionReasoning(
                xsDataBestStrategySummary.getResolutionReasoning())
            xsDataStrategySummary.setTotalDataCollectionTime(
                xsDataBestStrategySummary.getTotalDataCollectionTime())
            xsDataStrategySummary.setTotalExposureTime(
                xsDataBestStrategySummary.getTotalExposureTime())
            xsDataCollectionPlan.setStrategySummary(xsDataStrategySummary)

            if xsDataBestCollectionPlan.getStatisticalPrediction() is not None:
                xsDataStatisticsStrategy = XSDataStatisticsStrategy.parseString(
                    xsDataBestCollectionPlan.getStatisticalPrediction(
                    ).marshal())
                xsDataCollectionPlan.setStatistics(xsDataStatisticsStrategy)

            xsDataCollectionPlan.setCollectionPlanNumber(
                xsDataBestCollectionPlan.getCollectionPlanNumber())

            xsDataResultStrategy.addCollectionPlan(xsDataCollectionPlan)

        if _xsDataResultBest.getPathToLogFile() != None:
            xsDataResultStrategy.setBestLogFile(
                _xsDataResultBest.getPathToLogFile())

        return xsDataResultStrategy
Exemplo n.º 10
0
    def generateXSDataIndexingResult(_xsDataLabelitScreenOutput, _xsDataLabelitMosflmScriptsOutput, \
                                     _xsDataExperimentalCondition=None):
        EDVerbose.DEBUG(
            "EDHandlerXSDataLabelitv1_1.generateXSDataIndexingOutput")

        iSelectedSolutionNumber = _xsDataLabelitScreenOutput.getSelectedSolutionNumber(
        ).getValue()

        xsDataIndexingResult = XSDataIndexingResult()
        xsDataIndexingSolutionSelected = None

        for xsDataLabelitSolution in _xsDataLabelitScreenOutput.getLabelitScreenSolution(
        ):
            xsDataCrystal = XSDataCrystal()
            xsDataSpaceGroup = XSDataSpaceGroup()
            edStringSpaceGroupName = EDUtilsSymmetry.getMinimumSymmetrySpaceGroupFromBravaisLattice(
                xsDataLabelitSolution.getBravaisLattice().getValue())
            xsDataSpaceGroup.setName(XSDataString(edStringSpaceGroupName))
            xsDataCrystal.setSpaceGroup(xsDataSpaceGroup)
            xsDataCrystal.setCell(xsDataLabelitSolution.getUnitCell())
            xsDataIndexingSolution = XSDataIndexingSolution()
            xsDataIndexingSolution.setCrystal(xsDataCrystal)
            iIndex = xsDataLabelitSolution.getSolutionNumber().getValue()
            xsDataIndexingSolution.setNumber(XSDataInteger(iIndex))
            xsDataIndexingResult.addSolution(xsDataIndexingSolution)
            if (iIndex == iSelectedSolutionNumber):
                xsDataIndexingSolutionSelected = XSDataIndexingSolutionSelected(
                )
                xsDataIndexingSolutionSelected.setNumber(XSDataInteger(iIndex))
                edStringSelectedSpaceGroupName = edStringSpaceGroupName
                xsDataCellSelected = xsDataLabelitSolution.getUnitCell()
                fRmsdSelected = xsDataLabelitSolution.getRmsd().getValue()
                iNumberOfSpotsSelected = xsDataLabelitSolution.getNumberOfSpots(
                ).getValue()

        xsDataCrystalSelected = XSDataCrystal()
        xsDataSpaceGroupSelected = XSDataSpaceGroup()
        xsDataSpaceGroupSelected.setName(
            XSDataString(edStringSelectedSpaceGroupName))
        #xsDataSpaceGroupSelected.setITNumber( XSDataInteger( iSelectedSpaceGroupNumber ) )
        xsDataCrystalSelected.setSpaceGroup(xsDataSpaceGroupSelected)
        xsDataCrystalSelected.setCell(xsDataCellSelected)
        xsDataCrystalSelected.setMosaicity(
            XSDataDouble(_xsDataLabelitScreenOutput.getMosaicity().getValue()))
        xsDataIndexingSolutionSelected.setCrystal(xsDataCrystalSelected)

        xsDataOrientation = XSDataOrientation()
        xsDataOrientation.setMatrixA(
            _xsDataLabelitMosflmScriptsOutput.getAMatrix())
        xsDataOrientation.setMatrixU(
            _xsDataLabelitMosflmScriptsOutput.getUMatrix())
        xsDataIndexingSolutionSelected.setOrientation(xsDataOrientation)

        xsDataStatisticsIndexing = XSDataStatisticsIndexing()

        if (_xsDataExperimentalCondition is not None):
            fBeamPositionXOrig = _xsDataExperimentalCondition.getDetector(
            ).getBeamPositionX().getValue()
            fBeamPositionYOrig = _xsDataExperimentalCondition.getDetector(
            ).getBeamPositionY().getValue()
            fBeamPositionXNew = _xsDataLabelitScreenOutput.getBeamCentreX(
            ).getValue()
            fBeamPositionYNew = _xsDataLabelitScreenOutput.getBeamCentreY(
            ).getValue()
            xsDataStatisticsIndexing.setBeamPositionShiftX(
                XSDataLength(fBeamPositionXOrig - fBeamPositionXNew))
            xsDataStatisticsIndexing.setBeamPositionShiftY(
                XSDataLength(fBeamPositionYOrig - fBeamPositionYNew))

        #xsDataStatisticsIndexing.setSpotDeviXSDataLength( dDistanceRefinedationAngular( XSDataAngle( dDeviationAngular ) )
        xsDataStatisticsIndexing.setSpotDeviationPositional(
            XSDataLength(fRmsdSelected))
        xsDataStatisticsIndexing.setSpotsUsed(
            XSDataInteger(iNumberOfSpotsSelected))
        xsDataStatisticsIndexing.setSpotsTotal(
            XSDataInteger(iNumberOfSpotsSelected))
        xsDataIndexingSolutionSelected.setStatistics(xsDataStatisticsIndexing)

        xsDataExperimentalConditionRefined = None
        if (_xsDataExperimentalCondition is None):
            xsDataExperimentalConditionRefined = XSDataExperimentalCondition()
        else:
            # Copy the incoming experimental condition
            xmlExperimentalCondition = _xsDataExperimentalCondition.marshal()
            xsDataExperimentalConditionRefined = XSDataExperimentalCondition.parseString(
                xmlExperimentalCondition)

        xsDataDetector = xsDataExperimentalConditionRefined.getDetector()
        if (xsDataDetector is None):
            xsDataDetector = XSDataDetector()

        xsDataDetector.setBeamPositionX(
            _xsDataLabelitScreenOutput.getBeamCentreX())
        xsDataDetector.setBeamPositionY(
            _xsDataLabelitScreenOutput.getBeamCentreY())
        xsDataDetector.setDistance(_xsDataLabelitScreenOutput.getDistance())

        xsDataExperimentalConditionRefined.setDetector(xsDataDetector)
        xsDataIndexingSolutionSelected.setExperimentalConditionRefined(
            xsDataExperimentalConditionRefined)

        xsDataIndexingResult.setSelectedSolution(
            xsDataIndexingSolutionSelected)

        xsDataIndexingResult.setIndexingLogFile(
            _xsDataLabelitScreenOutput.getPathToLogFile())

        return xsDataIndexingResult
    def generateXSDataIndexingResult(_xsDataResultLabelitIndexing, _xsDataExperimentalCondition=None):
        EDVerbose.DEBUG("EDHandlerXSDataLabelitv1_1.generateXSDataIndexingOutput")

        xsDataLabelitScreenOutput = _xsDataResultLabelitIndexing.screenOutput
        xsDataLabelitMosflmScriptsOutput = _xsDataResultLabelitIndexing.mosflmScriptsOutput

        iSelectedSolutionNumber = xsDataLabelitScreenOutput.getSelectedSolutionNumber().getValue()

        xsDataIndexingResult = XSDataIndexingResult()
        xsDataIndexingSolutionSelected = None

        for xsDataLabelitSolution in xsDataLabelitScreenOutput.getLabelitScreenSolution():
            xsDataCrystal = XSDataCrystal()
            xsDataSpaceGroup = XSDataSpaceGroup()
            edStringSpaceGroupName = EDUtilsSymmetry.getMinimumSymmetrySpaceGroupFromBravaisLattice(xsDataLabelitSolution.getBravaisLattice().getValue())
            xsDataSpaceGroup.setName(XSDataString(edStringSpaceGroupName))
            xsDataCrystal.setSpaceGroup(xsDataSpaceGroup)
            xsDataCrystal.setCell(xsDataLabelitSolution.getUnitCell())
            xsDataIndexingSolution = XSDataIndexingSolution()
            xsDataIndexingSolution.setCrystal(xsDataCrystal)
            iIndex = xsDataLabelitSolution.getSolutionNumber().getValue()
            xsDataIndexingSolution.setNumber(XSDataInteger(iIndex))
            xsDataIndexingResult.addSolution(xsDataIndexingSolution)
            if (iIndex == iSelectedSolutionNumber):
                xsDataIndexingSolutionSelected = XSDataIndexingSolutionSelected()
                xsDataIndexingSolutionSelected.setNumber(XSDataInteger(iIndex))
                edStringSelectedSpaceGroupName = edStringSpaceGroupName
                xsDataCellSelected = xsDataLabelitSolution.getUnitCell()
                fRmsdSelected = xsDataLabelitSolution.getRmsd().getValue()
                iNumberOfSpotsSelected = xsDataLabelitSolution.getNumberOfSpots().getValue()

        xsDataCrystalSelected = XSDataCrystal()
        xsDataSpaceGroupSelected = XSDataSpaceGroup()
        xsDataSpaceGroupSelected.setName(XSDataString(edStringSelectedSpaceGroupName))
        xsDataSpaceGroupSelected.setITNumber(XSDataInteger(EDUtilsSymmetry.getITNumberFromSpaceGroupName(edStringSelectedSpaceGroupName)))
        xsDataCrystalSelected.setSpaceGroup(xsDataSpaceGroupSelected)
        xsDataCrystalSelected.setCell(xsDataCellSelected)
        xsDataCrystalSelected.setMosaicity(XSDataDouble(xsDataLabelitScreenOutput.getMosaicity().getValue()))
        xsDataIndexingSolutionSelected.setCrystal(xsDataCrystalSelected)

        xsDataOrientation = XSDataOrientation()
        xsDataOrientation.setMatrixA(xsDataLabelitMosflmScriptsOutput.getAMatrix())
        xsDataOrientation.setMatrixU(xsDataLabelitMosflmScriptsOutput.getUMatrix())
        xsDataIndexingSolutionSelected.setOrientation(xsDataOrientation)

        xsDataStatisticsIndexing = XSDataStatisticsIndexing()

        if (_xsDataExperimentalCondition is not None):
            fBeamPositionXOrig = _xsDataExperimentalCondition.getDetector().getBeamPositionX().getValue()
            fBeamPositionYOrig = _xsDataExperimentalCondition.getDetector().getBeamPositionY().getValue()
            fBeamPositionXNew = xsDataLabelitScreenOutput.getBeamCentreX().getValue()
            fBeamPositionYNew = xsDataLabelitScreenOutput.getBeamCentreY().getValue()
            xsDataStatisticsIndexing.setBeamPositionShiftX(XSDataLength(fBeamPositionXOrig - fBeamPositionXNew))
            xsDataStatisticsIndexing.setBeamPositionShiftY(XSDataLength(fBeamPositionYOrig - fBeamPositionYNew))

        # xsDataStatisticsIndexing.setSpotDeviXSDataLength( dDistanceRefinedationAngular( XSDataAngle( dDeviationAngular ) )
        xsDataStatisticsIndexing.setSpotDeviationPositional(XSDataLength(fRmsdSelected))
        xsDataStatisticsIndexing.setSpotsUsed(XSDataInteger(iNumberOfSpotsSelected))
        xsDataStatisticsIndexing.setSpotsTotal(XSDataInteger(iNumberOfSpotsSelected))
        xsDataIndexingSolutionSelected.setStatistics(xsDataStatisticsIndexing)

        xsDataExperimentalConditionRefined = None
        if (_xsDataExperimentalCondition is None):
            xsDataExperimentalConditionRefined = XSDataExperimentalCondition()
        else:
            # Copy the incoming experimental condition
            xmlExperimentalCondition = _xsDataExperimentalCondition.marshal()
            xsDataExperimentalConditionRefined = XSDataExperimentalCondition.parseString(xmlExperimentalCondition)

        xsDataDetector = xsDataExperimentalConditionRefined.getDetector()
        if (xsDataDetector is None):
            xsDataDetector = XSDataDetector()

        xsDataDetector.setBeamPositionX(xsDataLabelitScreenOutput.getBeamCentreX())
        xsDataDetector.setBeamPositionY(xsDataLabelitScreenOutput.getBeamCentreY())
        xsDataDetector.setDistance(xsDataLabelitScreenOutput.getDistance())

        xsDataExperimentalConditionRefined.setDetector(xsDataDetector)
        xsDataIndexingSolutionSelected.setExperimentalConditionRefined(xsDataExperimentalConditionRefined)

        xsDataIndexingResult.setSelectedSolution(xsDataIndexingSolutionSelected)

        xsDataIndexingResult.setIndexingLogFile(xsDataLabelitScreenOutput.getPathToLogFile())

        return xsDataIndexingResult
Exemplo n.º 12
0
    def preProcess(self, _edObject=None):
        """
        Gets the Configuration Parameters, if found, overrides default parameters
        """
        EDPluginControl.preProcess(self, _edObject)
        self.DEBUG("EDPluginControlIntegrationv10.preProcess...")

        xsDataIntegrationInput = self.getDataInput()
        xsDataSelectedIndexingSolution = xsDataIntegrationInput.getSelectedIndexingSolution(
        )
        self.__xsDataExperimentalConditionRefined = xsDataIntegrationInput.getExperimentalConditionRefined(
        )
        # To be changed (see bug #40)
        if (self.__xsDataExperimentalConditionRefined is None):
            self.__xsDataExperimentalConditionRefined = xsDataSelectedIndexingSolution.getExperimentalConditionRefined(
            )
        xsDataCollection = xsDataIntegrationInput.getDataCollection()
        xsDataSubWedgeList = xsDataCollection.getSubWedge()

        self.__edPluginIntegrationList = []

        iIndex = 0
        for xsDataSubWedge in xsDataSubWedgeList:
            iSubWedgeNumber = iIndex
            if (xsDataSubWedge.getSubWedgeNumber() is not None):
                # Use the incoming subwedge number if it exists
                iSubWedgeNumber = xsDataSubWedge.getSubWedgeNumber().getValue()

            edPluginIntegration = self.loadPlugin(
                self.__strPluginIntegrationName)

            if (not edPluginIntegration is None):
                iIndex += 1
                xsDataIntegrationInputSubWedge = XSDataIntegrationInput()
                xsDataIntegrationInputSubWedge.setSelectedIndexingSolution(
                    XSDataIndexingSolutionSelected.parseString(
                        xsDataSelectedIndexingSolution.marshal()))
                xsDataIntegrationInputSubWedge.setExperimentalConditionRefined(
                    XSDataExperimentalCondition.parseString(
                        self.__xsDataExperimentalConditionRefined.marshal()))
                xsDataCollection = XSDataCollection()
                xsDataCollection.addSubWedge(xsDataSubWedge)
                xsDataIntegrationInputSubWedge.setDataCollection(
                    xsDataCollection)
                try:
                    from EDHandlerXSDataMOSFLMv10 import EDHandlerXSDataMOSFLMv10
                    xsDataMOSFLMInputIntegration = EDHandlerXSDataMOSFLMv10.generateXSDataMOSFLMInputIntegration(
                        xsDataIntegrationInputSubWedge)
                    edPluginIntegration.setDataInput(
                        xsDataMOSFLMInputIntegration)
                    edPluginIntegration.setBaseName(
                        "%s-%02d" % (self.__strPluginIntegrationName, iIndex))
                    edPluginIntegration.connectSUCCESS(
                        self.doSuccessActionIntegration)
                    edPluginIntegration.connectFAILURE(
                        self.doFailureActionIntegration)
                    # Here we store the sub wedge number for use in the results
                    self.__edPluginIntegrationList.append(
                        [iSubWedgeNumber, edPluginIntegration])
                except Exception as strErrorMessage:
                    self.addErrorMessage(strErrorMessage)
                    self.ERROR(strErrorMessage)
                    self.setFailure()
            else:
                strErrorMessage = "EDPluginControlIntegrationv10.preProcess: could not load plugin %s" % self.__strPluginIntegrationName
                self.error(strErrorMessage)
                self.addErrorMessage(strErrorMessage)
                self.setFailure()
    def generateXSDataIndexingResult(_xsDataMOSFLMIndexingOutput, _xsDataExperimentalCondition=None):
        """
        Translation from XSDataMOSFLMIndexingOutput to XSDataIndexingResult.
        """
        EDVerbose.DEBUG("EDHandlerXSDataMOSFLMv10.generateXSDataIndexingOutput")
        xsDataMOSFLMBeamPositionRefined = _xsDataMOSFLMIndexingOutput.getRefinedBeam()
        xsDataMOSFLMBeamPositionShift = _xsDataMOSFLMIndexingOutput.getBeamShift()
        dDeviationAngular = _xsDataMOSFLMIndexingOutput.getDeviationAngular().getValue()
        dDeviationPositional = _xsDataMOSFLMIndexingOutput.getDeviationPositional().getValue()
        dMosaicityEstimation = _xsDataMOSFLMIndexingOutput.getMosaicityEstimation().getValue()
        dDistanceRefined = _xsDataMOSFLMIndexingOutput.getRefinedDistance().getValue()
        iSelectedSolution = _xsDataMOSFLMIndexingOutput.getSelectedSolutionNumber().getValue()
        iSpotsTotal = _xsDataMOSFLMIndexingOutput.getSpotsTotal().getValue()
        iSpotsUsed = _xsDataMOSFLMIndexingOutput.getSpotsUsed().getValue()
        xsDataCellRefined = _xsDataMOSFLMIndexingOutput.getRefinedNewmat().getRefinedCell()
        xsDataMatrixA = _xsDataMOSFLMIndexingOutput.getRefinedNewmat().getAMatrix()
        xsDataMatrixU = _xsDataMOSFLMIndexingOutput.getRefinedNewmat().getUMatrix()
        strSelectedSpaceGroupName = _xsDataMOSFLMIndexingOutput.getSelectedSolutionSpaceGroup().getValue()
        iSelectedSpaceGroupNumber = _xsDataMOSFLMIndexingOutput.getSelectedSolutionSpaceGroupNumber().getValue()

        xsDataIndexingResult = XSDataIndexingResult()
        xsDataIndexingSolutionSelected = None

        for possibleSolutions in _xsDataMOSFLMIndexingOutput.getPossibleSolutions():
            xsDataCrystal = XSDataCrystal()
            xsDataSpaceGroup = XSDataSpaceGroup()
            xsDataSpaceGroup.setName(XSDataString(possibleSolutions.getLattice().getValue()))
            xsDataCrystal.setSpaceGroup(xsDataSpaceGroup)
            xsDataCrystal.setCell(possibleSolutions.getCell())
            xsDataIndexingSolution = XSDataIndexingSolution()
            xsDataIndexingSolution.setCrystal(xsDataCrystal)
            iIndex = possibleSolutions.getIndex().getValue()
            xsDataIndexingSolution.setNumber(XSDataInteger(iIndex))
            xsDataIndexingSolution.setPenalty(XSDataFloat(possibleSolutions.getPenalty().getValue()))
            xsDataIndexingResult.addSolution(xsDataIndexingSolution)
            if (iIndex == iSelectedSolution):
                xsDataIndexingSolutionSelected = XSDataIndexingSolutionSelected()
                xsDataIndexingSolutionSelected.setNumber(XSDataInteger(iIndex))
                xsDataIndexingSolutionSelected.setPenalty(XSDataFloat(possibleSolutions.getPenalty().getValue()))

        xsDataCrystalSelected = XSDataCrystal()
        xsDataSpaceGroupSelected = XSDataSpaceGroup()
        xsDataSpaceGroupSelected.setName(XSDataString(strSelectedSpaceGroupName))
        xsDataSpaceGroupSelected.setITNumber(XSDataInteger(iSelectedSpaceGroupNumber))
        xsDataCrystalSelected.setSpaceGroup(xsDataSpaceGroupSelected)
        xsDataCrystalSelected.setCell(xsDataCellRefined)
        xsDataCrystalSelected.setMosaicity(XSDataDouble(dMosaicityEstimation))
        xsDataIndexingSolutionSelected.setCrystal(xsDataCrystalSelected)

        xsDataOrientation = XSDataOrientation()
        xsDataOrientation.setMatrixA(xsDataMatrixA)
        xsDataOrientation.setMatrixU(xsDataMatrixU)
        xsDataIndexingSolutionSelected.setOrientation(xsDataOrientation)

        xsDataStatisticsIndexing = XSDataStatisticsIndexing()

        xsDataStatisticsIndexing.setBeamPositionShiftX(XSDataLength(xsDataMOSFLMBeamPositionShift.getX().getValue()))
        xsDataStatisticsIndexing.setBeamPositionShiftY(XSDataLength(xsDataMOSFLMBeamPositionShift.getY().getValue()))
        xsDataStatisticsIndexing.setSpotDeviationAngular(XSDataAngle(dDeviationAngular))
        xsDataStatisticsIndexing.setSpotDeviationPositional(XSDataLength(dDeviationPositional))
        xsDataStatisticsIndexing.setSpotsUsed(XSDataInteger(iSpotsUsed))
        xsDataStatisticsIndexing.setSpotsTotal(XSDataInteger(iSpotsTotal))
        xsDataIndexingSolutionSelected.setStatistics(xsDataStatisticsIndexing)

        xsDataExperimentalConditionRefined = None
        if (_xsDataExperimentalCondition is None):
            xsDataExperimentalConditionRefined = XSDataExperimentalCondition()
        else:
            # Copy the incoming experimental condition
            xmlExperimentalCondition = _xsDataExperimentalCondition.marshal()
            xsDataExperimentalConditionRefined = XSDataExperimentalCondition.parseString(xmlExperimentalCondition)

        xsDataDetector = xsDataExperimentalConditionRefined.getDetector()
        if (xsDataDetector is None):
            xsDataDetector = XSDataDetector()

        xsDataDetector.setBeamPositionX(XSDataLength(xsDataMOSFLMBeamPositionRefined.getX().getValue()))
        xsDataDetector.setBeamPositionY(XSDataLength(xsDataMOSFLMBeamPositionRefined.getY().getValue()))
        xsDataDetector.setDistance(XSDataLength(dDistanceRefined))

        xsDataExperimentalConditionRefined.setDetector(xsDataDetector)
        xsDataIndexingSolutionSelected.setExperimentalConditionRefined(xsDataExperimentalConditionRefined)

        xsDataIndexingResult.setSelectedSolution(xsDataIndexingSolutionSelected)

        return xsDataIndexingResult
Exemplo n.º 14
0
    def getXSDataResultStrategy(self, _xsDataResultBest, _xsDataExperimentalCondition, _xsDataSample):
        xsDataResultStrategy = XSDataResultStrategy()

        listXSDataBestCollectionPlan = _xsDataResultBest.getCollectionPlan()

        for xsDataBestCollectionPlan in listXSDataBestCollectionPlan:

            xsDataCollectionPlan = XSDataCollectionPlan()
            xsDataCollectionStrategy = XSDataCollection()

            xsDataBestStrategySummary = xsDataBestCollectionPlan.getStrategySummary()

            xsDataDoubleTransmission = xsDataBestStrategySummary.getTransmission()

            for xsDataBestCollectionRun in xsDataBestCollectionPlan.getCollectionRun():
                xsDataSubWedge = XSDataSubWedge()
                strXmlStringDataExperimentalCondition = _xsDataExperimentalCondition.marshal()
                xsDataExperimentalCondition = XSDataExperimentalCondition.parseString(
                    strXmlStringDataExperimentalCondition
                )
                xsDataExperimentalCondition.getBeam().setExposureTime(xsDataBestCollectionRun.getExposureTime())
                if xsDataBestCollectionRun.getTransmission() is None:
                    xsDataExperimentalCondition.getBeam().setTransmission(xsDataDoubleTransmission)
                else:
                    xsDataExperimentalCondition.getBeam().setTransmission(xsDataBestCollectionRun.getTransmission())
                xsDataExperimentalCondition.getDetector().setDistance(xsDataBestStrategySummary.getDistance())
                xsDataExperimentalCondition.getGoniostat().setRotationAxisStart(xsDataBestCollectionRun.getPhiStart())
                xsDataExperimentalCondition.getGoniostat().setOscillationWidth(xsDataBestCollectionRun.getPhiWidth())
                fRotationAxisEnd = (
                    xsDataBestCollectionRun.getPhiStart().getValue()
                    + xsDataBestCollectionRun.getNumberOfImages().getValue()
                    * xsDataBestCollectionRun.getPhiWidth().getValue()
                )
                xsDataExperimentalCondition.getGoniostat().setRotationAxisEnd(XSDataAngle(fRotationAxisEnd))
                xsDataSubWedge.setExperimentalCondition(xsDataExperimentalCondition)
                xsDataSubWedge.setSubWedgeNumber(xsDataBestCollectionRun.getCollectionRunNumber())
                if xsDataBestCollectionRun.getCrystalPosition():
                    xsDataSubWedge.setAction(
                        XSDataString("Crystal position: %d" % xsDataBestCollectionRun.getCrystalPosition().getValue())
                    )
                else:
                    xsDataSubWedge.setAction(xsDataBestCollectionRun.getAction())
                xsDataCollectionStrategy.addSubWedge(xsDataSubWedge)

            xsDataCollectionStrategy.setSample(_xsDataSample)

            xsDataCollectionPlan.setCollectionStrategy(xsDataCollectionStrategy)

            xsDataStrategySummary = XSDataStrategySummary()
            xsDataStrategySummary.setCompleteness(xsDataBestStrategySummary.getCompleteness())
            xsDataStrategySummary.setISigma(xsDataBestStrategySummary.getISigma())
            xsDataStrategySummary.setRankingResolution(xsDataBestStrategySummary.getRankingResolution())
            xsDataStrategySummary.setRedundancy(xsDataBestStrategySummary.getRedundancy())
            xsDataStrategySummary.setResolution(xsDataBestStrategySummary.getResolution())
            xsDataStrategySummary.setResolutionReasoning(xsDataBestStrategySummary.getResolutionReasoning())
            xsDataStrategySummary.setTotalDataCollectionTime(xsDataBestStrategySummary.getTotalDataCollectionTime())
            xsDataStrategySummary.setTotalExposureTime(xsDataBestStrategySummary.getTotalExposureTime())
            xsDataCollectionPlan.setStrategySummary(xsDataStrategySummary)

            if xsDataBestCollectionPlan.getStatisticalPrediction() is not None:
                xsDataStatisticsStrategy = XSDataStatisticsStrategy.parseString(
                    xsDataBestCollectionPlan.getStatisticalPrediction().marshal()
                )
                xsDataCollectionPlan.setStatistics(xsDataStatisticsStrategy)

            xsDataCollectionPlan.setCollectionPlanNumber(xsDataBestCollectionPlan.getCollectionPlanNumber())

            xsDataResultStrategy.addCollectionPlan(xsDataCollectionPlan)

        if _xsDataResultBest.getPathToLogFile() != None:
            xsDataResultStrategy.setBestLogFile(_xsDataResultBest.getPathToLogFile())

        return xsDataResultStrategy
 def getTestExperimentalCondition(self):
     strPathToTestExperimentalCondition = os.path.join(self.getPluginTestsDataHome(), "XSDataExperimentalCondition_test.xml")
     strXMLInput = self.readAndParseFile(strPathToTestExperimentalCondition)
     xsDataExperimentalCondition = XSDataExperimentalCondition.parseString(strXMLInput)
     return xsDataExperimentalCondition
Exemplo n.º 16
0
    def preProcess(self, _edObject=None):
        """
        Gets the Configuration Parameters, if found, overrides default parameters
        """
        EDPluginControl.preProcess(self, _edObject)
        EDVerbose.DEBUG("EDPluginControlGeneratePredictionv10.preProcess...")

        xsDataGeneratePredictionInput = self.getDataInput()

        xsDataSelectedIndexingSolution = xsDataGeneratePredictionInput.getSelectedIndexingSolution(
        )
        xsDataExperimentalConditionRefined = xsDataSelectedIndexingSolution.getExperimentalConditionRefined(
        )
        xsDataCollection = xsDataGeneratePredictionInput.getDataCollection()
        xsDataSubWedgeList = xsDataCollection.getSubWedge()

        # List containing instances of all the generate prediction plugins
        self.__listPluginGeneratePrediction = []

        # Loop through all subwedges
        iIndex = 0
        for xsDataSubWedge in xsDataSubWedgeList:

            xsDataImageList = xsDataSubWedge.getImage()
            # First find the lowest image number
            iLowestImageNumber = None
            for xsDataImage in xsDataImageList:
                iImageNumber = xsDataImage.getNumber().getValue()
                if (iLowestImageNumber is None):
                    iLowestImageNumber = iImageNumber
                elif (iImageNumber < iLowestImageNumber):
                    iLowestImageNumber = iImageNumber
            # Then loop through all images in a sub wedge
            for xsDataImage in xsDataImageList:
                iIndex += 1
                edPluginGeneratePrediction = self.loadPlugin(
                    self.__strPluginGeneratePredictionName, "%s-%02d" %
                    (self.__strPluginGeneratePredictionName, iIndex))
                xsDataGeneratePredictionInput = XSDataGeneratePredictionInput()
                xsDataGeneratePredictionInput.setSelectedIndexingSolution(
                    XSDataIndexingSolutionSelected.parseString(
                        xsDataSelectedIndexingSolution.marshal()))
                xsDataCollectionNew = XSDataCollection()
                xsDataSubWedgeNew = XSDataSubWedge()
                xsDataSubWedgeNew.addImage(
                    XSDataImage.parseString(xsDataImage.marshal()))
                xsDataSubWedgeNew.setExperimentalCondition(
                    XSDataExperimentalCondition.parseString(
                        xsDataSubWedge.getExperimentalCondition().marshal()))
                # We must modify the rotationOscillationStart for the new subwedge
                xsDataGoniostatNew = xsDataSubWedgeNew.getExperimentalCondition(
                ).getGoniostat()
                fGoniostatRotationAxisStart = xsDataGoniostatNew.getRotationAxisStart(
                ).getValue()
                fGonioStatOscillationRange = xsDataGoniostatNew.getOscillationWidth(
                ).getValue()
                iImageNumber = xsDataImage.getNumber().getValue()
                fGoniostatRotationAxisStartNew = fGoniostatRotationAxisStart + (
                    iImageNumber -
                    iLowestImageNumber) * fGonioStatOscillationRange
                xsDataGoniostatNew.setRotationAxisStart(
                    XSDataAngle(fGoniostatRotationAxisStartNew))
                #
                xsDataCollectionNew.addSubWedge(xsDataSubWedgeNew)
                xsDataGeneratePredictionInput.setDataCollection(
                    xsDataCollectionNew)
                from EDHandlerXSDataMOSFLMv10 import EDHandlerXSDataMOSFLMv10
                xsDataMOSFLMInputGeneratePrediction = EDHandlerXSDataMOSFLMv10.generateXSDataMOSFLMInputGeneratePrediction(
                    xsDataGeneratePredictionInput)
                edPluginGeneratePrediction.setDataInput(
                    xsDataMOSFLMInputGeneratePrediction)
                self.__listPluginGeneratePrediction.append(
                    edPluginGeneratePrediction)
    def generateXSDataIntegrationSubWedgeResult(_xsDataMOSFLMOutputIntegration, _xsDataExperimentalCondition=None):
        """
        Translation from XSDataMOSFLMOutputIntegration to XSDataIntegrationSubWedgeResult.
        """
        EDVerbose.DEBUG("EDHandlerXSDataMOSFLMv10.generateXSDataIntegrationInput")
        EDFactoryPluginStatic.loadModule("XSDataMOSFLMv10")
        xsDataIntegrationSubWedgeResult = XSDataIntegrationSubWedgeResult()
        xsDataExperimentalConditionRefined = None
        if (_xsDataExperimentalCondition is None):
            xsDataExperimentalConditionRefined = XSDataExperimentalCondition()
        else:
            # Copy the incoming experimental condition
            xmlExperimentalCondition = _xsDataExperimentalCondition.marshal()
            xsDataExperimentalConditionRefined = XSDataExperimentalCondition.parseString(xmlExperimentalCondition)

        xsDataDetector = xsDataExperimentalConditionRefined.getDetector()
        if (xsDataDetector is None):
            xsDataDetector = XSDataDetector()

        xsDataIntegrationSubWedgeResult.setBestfilePar(XSDataString(_xsDataMOSFLMOutputIntegration.getBestfilePar().getValue()))
        xsDataIntegrationSubWedgeResult.setBestfileDat(XSDataString(_xsDataMOSFLMOutputIntegration.getBestfileDat().getValue()))
        xsDataIntegrationSubWedgeResult.setBestfileHKL(XSDataString(_xsDataMOSFLMOutputIntegration.getBestfileHKL().getValue()))

        xsDataLengthRefinedDistance = _xsDataMOSFLMOutputIntegration.getRefinedDistance()
        if (xsDataLengthRefinedDistance is not None):
            xsDataDetector.setDistance(xsDataLengthRefinedDistance)

        xsDataMOSFLMBeamPositionRefined = _xsDataMOSFLMOutputIntegration.getRefinedBeam()
        if (xsDataMOSFLMBeamPositionRefined is not None):
            xsDataDetector.setBeamPositionX(XSDataLength(xsDataMOSFLMBeamPositionRefined.getX().getValue()))
            xsDataDetector.setBeamPositionY(XSDataLength(xsDataMOSFLMBeamPositionRefined.getY().getValue()))

        xsDataExperimentalConditionRefined.setDetector(xsDataDetector)
        xsDataIntegrationSubWedgeResult.setExperimentalConditionRefined(xsDataExperimentalConditionRefined)

        if (_xsDataMOSFLMOutputIntegration.getGeneratedMTZFile() is not None):
            xsDataIntegrationSubWedgeResult.setGeneratedMTZFile(_xsDataMOSFLMOutputIntegration.getGeneratedMTZFile())

        xsDataStatisticsIntegration = XSDataStatisticsIntegration()
        if (_xsDataMOSFLMOutputIntegration.getOverallIOverSigma() is not None):
            xsDataStatisticsIntegration.setIOverSigmaOverall(XSDataDouble(_xsDataMOSFLMOutputIntegration.getOverallIOverSigma().getValue()))
        if (_xsDataMOSFLMOutputIntegration.getHighestResolutionIOverSigma() is not None):
            xsDataStatisticsIntegration.setIOverSigmaAtHighestResolution(XSDataDouble(_xsDataMOSFLMOutputIntegration.getHighestResolutionIOverSigma().getValue()))
        if (_xsDataMOSFLMOutputIntegration.getRMSSpotDeviation() is not None):
            xsDataStatisticsIntegration.setRMSSpotDeviation(XSDataLength(_xsDataMOSFLMOutputIntegration.getRMSSpotDeviation().getValue()))
        if (_xsDataMOSFLMOutputIntegration.getNumberOfBadReflections() is not None):
            xsDataStatisticsIntegration.setNumberOfBadReflections(XSDataInteger(_xsDataMOSFLMOutputIntegration.getNumberOfBadReflections().getValue()))
        if (_xsDataMOSFLMOutputIntegration.getNumberOfFullyRecordedReflections() is not None):
            xsDataStatisticsIntegration.setNumberOfFullyRecordedReflections(XSDataInteger(_xsDataMOSFLMOutputIntegration.getNumberOfFullyRecordedReflections().getValue()))
        if (_xsDataMOSFLMOutputIntegration.getNumberOfNegativeReflections() is not None):
            xsDataStatisticsIntegration.setNumberOfNegativeReflections(XSDataInteger(_xsDataMOSFLMOutputIntegration.getNumberOfNegativeReflections().getValue()))
        if (_xsDataMOSFLMOutputIntegration.getNumberOfOverlappedReflections() is not None):
            xsDataStatisticsIntegration.setNumberOfOverlappedReflections(XSDataInteger(_xsDataMOSFLMOutputIntegration.getNumberOfOverlappedReflections().getValue()))
        if (_xsDataMOSFLMOutputIntegration.getNumberOfPartialReflections() is not None):
            xsDataStatisticsIntegration.setNumberOfPartialReflections(XSDataInteger(_xsDataMOSFLMOutputIntegration.getNumberOfPartialReflections().getValue()))
        if (_xsDataMOSFLMOutputIntegration.getNumberOfReflectionsGenerated() is not None):
            xsDataStatisticsIntegration.setNumberOfReflectionsGenerated(XSDataInteger(_xsDataMOSFLMOutputIntegration.getNumberOfReflectionsGenerated().getValue()))

        xsDataIntegrationSubWedgeResult.setStatistics(xsDataStatisticsIntegration)
        xsDataIntegrationSubWedgeResult.setExperimentalConditionRefined(xsDataExperimentalConditionRefined)

        for xsDataMOSFLMIntegrationStatisticsPerResolutionBin in _xsDataMOSFLMOutputIntegration.getStatisticsPerResolutionBin():
            xsDataStatisticsIntegrationPerResolutionBin = XSDataStatisticsIntegrationPerResolutionBin()
            if (xsDataMOSFLMIntegrationStatisticsPerResolutionBin.getMaxResolution() is not None):
                xsDataStatisticsIntegrationPerResolutionBin.setMaxResolution(XSDataDouble(xsDataMOSFLMIntegrationStatisticsPerResolutionBin.getMaxResolution().getValue()))
            if (xsDataMOSFLMIntegrationStatisticsPerResolutionBin.getMinResolution() is not None):
                xsDataStatisticsIntegrationPerResolutionBin.setMinResolution(XSDataDouble(xsDataMOSFLMIntegrationStatisticsPerResolutionBin.getMinResolution().getValue()))

            xsDataStatisticsIntegrationPerResolutionBin.setProfileFitted(EDHandlerXSDataMOSFLMv10.generateXSDataIntegrationStatisticsPerReflectionType(xsDataMOSFLMIntegrationStatisticsPerResolutionBin.getProfileFitted()))
            xsDataStatisticsIntegrationPerResolutionBin.setSummation(EDHandlerXSDataMOSFLMv10.generateXSDataIntegrationStatisticsPerReflectionType(xsDataMOSFLMIntegrationStatisticsPerResolutionBin.getSummation()))

            xsDataIntegrationSubWedgeResult.addStatisticsPerResolutionBin(xsDataStatisticsIntegrationPerResolutionBin)

        return xsDataIntegrationSubWedgeResult