Пример #1
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 process(self, _edObject=None):
        EDPluginExec.process(self)
        EDVerbose.DEBUG("EDPluginExecReadImageHeaderPilatus2Mv10.process")
        xsDataInputReadImageHeader = self.getDataInput()
        xsDataFile = xsDataInputReadImageHeader.getImage()
        strPath = xsDataFile.getPath().getValue()
        dictPilatus2MHeader = self.readHeaderPilatus2M(strPath)
        if (dictPilatus2MHeader is None):
            strErrorMessage = "EDPluginExecReadImageHeaderPilatus2Mv10.process : Cannot read header : %s" % strPath
            EDVerbose.error(strErrorMessage)
            self.addErrorMessage(strErrorMessage)
            self.setFailure()
        else:
            xsDataExperimentalCondition = XSDataExperimentalCondition()
            xsDataDetector = XSDataDetector()

            iNoPixelsX = 1475
            iNoPixelsY = 1679
            xsDataDetector.setNumberPixelX(XSDataInteger(iNoPixelsX))
            xsDataDetector.setNumberPixelY(XSDataInteger(iNoPixelsY))
            # Pixel size
            listPixelSizeXY = dictPilatus2MHeader[ "Pixel_size"   ].split(" ")
            fPixelSizeX = float(listPixelSizeXY[0]) * 1000
            xsDataDetector.setPixelSizeX(XSDataLength(fPixelSizeX))
            fPixelSizeY = float(listPixelSizeXY[3]) * 1000
            xsDataDetector.setPixelSizeY(XSDataLength(fPixelSizeY))
            # Beam position
            listBeamPosition = dictPilatus2MHeader["Beam_xy"].replace("(", " ").replace(")", " ").replace(",", " ").split()
            fBeamPositionX = float(listBeamPosition[1]) * fPixelSizeX
            fBeamPositionY = float(listBeamPosition[0]) * fPixelSizeY
            xsDataDetector.setBeamPositionX(XSDataLength(fBeamPositionX))
            xsDataDetector.setBeamPositionY(XSDataLength(fBeamPositionY))
            fDistance = float(dictPilatus2MHeader[ "Detector_distance" ].split(" ")[0]) * 1000
            xsDataDetector.setDistance(XSDataLength(fDistance))
#            xsDataDetector.setNumberBytesInHeader(XSDataInteger(float(dictPilatus2MHeader[ "header_size"   ])))
            xsDataDetector.setSerialNumber(XSDataString(dictPilatus2MHeader[ "Detector:"   ]))
#            #xsDataDetector.setBin(                 XSDataString(   dictPilatus2MHeader[ "BIN" ] ) ) )
#            #xsDataDetector.setDataType(            XSDataString(   dictPilatus2MHeader[ "TYPE" ] ) ) )
#            #xsDataDetector.setByteOrder(           XSDataString(   dictPilatus2MHeader[ "BYTE_ORDER" ] ) ) )
#            xsDataDetector.setImageSaturation(XSDataInteger(int(dictPilatus2MHeader[ "saturation_level" ])))
            xsDataDetector.setName(XSDataString("PILATUS2 3M"))
            xsDataDetector.setType(XSDataString("pilatus2m"))
            xsDataExperimentalCondition.setDetector(xsDataDetector)

            # Beam object

            xsDataBeam = XSDataBeam()
            xsDataBeam.setWavelength(XSDataWavelength(float(dictPilatus2MHeader[ "Wavelength" ].split(" ")[0])))
            xsDataBeam.setExposureTime(XSDataTime(float(dictPilatus2MHeader[ "Exposure_time" ].split(" ")[0])))
            xsDataExperimentalCondition.setBeam(xsDataBeam)

            # Goniostat object
            xsDataGoniostat = XSDataGoniostat()
            fRotationAxisStart = float(dictPilatus2MHeader[ "Start_angle" ].split(" ")[0])
            fOscillationWidth = float(dictPilatus2MHeader[ "Angle_increment" ].split(" ")[0])
            xsDataGoniostat.setRotationAxisStart(XSDataAngle(fRotationAxisStart))
            xsDataGoniostat.setRotationAxisEnd(XSDataAngle(fRotationAxisStart + fOscillationWidth))
            xsDataGoniostat.setOscillationWidth(XSDataAngle(fOscillationWidth))
            xsDataExperimentalCondition.setGoniostat(xsDataGoniostat)
#
            # Create the image object
            xsDataImage = XSDataImage()
            xsDataImage.setPath(XSDataString(strPath))
            if "DateTime" in dictPilatus2MHeader:
                strTimeStamp = dictPilatus2MHeader[ "DateTime" ]
                xsDataImage.setDate(XSDataString(strTimeStamp))
            iImageNumber = EDUtilsImage.getImageNumber(strPath)
            xsDataImage.setNumber(XSDataInteger(iImageNumber))

            xsDataSubWedge = XSDataSubWedge()
            xsDataSubWedge.setExperimentalCondition(xsDataExperimentalCondition)
            xsDataSubWedge.addImage(xsDataImage)

            self.__xsDataResultReadImageHeader = XSDataResultReadImageHeader()
            self.__xsDataResultReadImageHeader.setSubWedge(xsDataSubWedge)
    def process(self, _edObject=None):
        EDPluginExec.process(self)
        self.DEBUG("EDPluginExecReadImageHeaderEiger4Mv10.process")
        xsDataInputReadImageHeader = self.getDataInput()
        xsDataFile = xsDataInputReadImageHeader.getImage()
        strPath = xsDataFile.getPath().getValue()
        dictEiger4MHeader = self.readHeaderEiger4M(strPath)
        if (dictEiger4MHeader is None):
            strErrorMessage = "EDPluginExecReadImageHeaderEiger4Mv10.process : Cannot read header : %s" % strPath
            self.error(strErrorMessage)
            self.addErrorMessage(strErrorMessage)
            self.setFailure()
        else:
            xsDataExperimentalCondition = XSDataExperimentalCondition()
            xsDataDetector = XSDataDetector()

            iNoPixelsX = 2070
            iNoPixelsY = 2167
            xsDataDetector.setNumberPixelX(XSDataInteger(iNoPixelsX))
            xsDataDetector.setNumberPixelY(XSDataInteger(iNoPixelsY))
            # Pixel size
            listPixelSizeXY = dictEiger4MHeader[ "Pixel_size"   ].split(" ")
            fPixelSizeX = float(listPixelSizeXY[0]) * 1000
            xsDataDetector.setPixelSizeX(XSDataLength(fPixelSizeX))
            fPixelSizeY = float(listPixelSizeXY[3]) * 1000
            xsDataDetector.setPixelSizeY(XSDataLength(fPixelSizeY))
            # Beam position
            listBeamPosition = dictEiger4MHeader["Beam_xy"].replace("(", " ").replace(")", " ").replace(",", " ").split()
            fBeamPositionX = float(listBeamPosition[1]) * fPixelSizeX
            fBeamPositionY = float(listBeamPosition[0]) * fPixelSizeY
            xsDataDetector.setBeamPositionX(XSDataLength(fBeamPositionX))
            xsDataDetector.setBeamPositionY(XSDataLength(fBeamPositionY))
            fDistance = float(dictEiger4MHeader[ "Detector_distance" ].split(" ")[0]) * 1000
            xsDataDetector.setDistance(XSDataLength(fDistance))
#            xsDataDetector.setNumberBytesInHeader(XSDataInteger(float(dictEiger4MHeader[ "header_size"   ])))
            xsDataDetector.setSerialNumber(XSDataString(dictEiger4MHeader[ "Detector:"   ]))
#            #xsDataDetector.setBin(                 XSDataString(   dictEiger4MHeader[ "BIN" ] ) ) )
#            #xsDataDetector.setDataType(            XSDataString(   dictEiger4MHeader[ "TYPE" ] ) ) )
#            #xsDataDetector.setByteOrder(           XSDataString(   dictEiger4MHeader[ "BYTE_ORDER" ] ) ) )
#            xsDataDetector.setImageSaturation(XSDataInteger(int(dictEiger4MHeader[ "saturation_level" ])))
            xsDataDetector.setName(XSDataString("EIGER 4M"))
            xsDataDetector.setType(XSDataString("eiger4m"))
            xsDataExperimentalCondition.setDetector(xsDataDetector)

            # Beam object

            xsDataBeam = XSDataBeam()
            xsDataBeam.setWavelength(XSDataWavelength(float(dictEiger4MHeader[ "Wavelength" ].split(" ")[0])))
            xsDataBeam.setExposureTime(XSDataTime(float(dictEiger4MHeader[ "Exposure_time" ].split(" ")[0])))
            xsDataExperimentalCondition.setBeam(xsDataBeam)

            # Goniostat object
            xsDataGoniostat = XSDataGoniostat()
            fRotationAxisStart = float(dictEiger4MHeader[ "Start_angle" ].split(" ")[0])
            fOscillationWidth = float(dictEiger4MHeader[ "Angle_increment" ].split(" ")[0])
            xsDataGoniostat.setRotationAxisStart(XSDataAngle(fRotationAxisStart))
            xsDataGoniostat.setRotationAxisEnd(XSDataAngle(fRotationAxisStart + fOscillationWidth))
            xsDataGoniostat.setOscillationWidth(XSDataAngle(fOscillationWidth))
            xsDataExperimentalCondition.setGoniostat(xsDataGoniostat)
#
            # Create the image object
            xsDataImage = XSDataImage()
            xsDataImage.setPath(XSDataString(strPath))
            if "DateTime" in dictEiger4MHeader:
                strTimeStamp = dictEiger4MHeader[ "DateTime" ]
                xsDataImage.setDate(XSDataString(strTimeStamp))
            iImageNumber = EDUtilsImage.getImageNumber(strPath)
            xsDataImage.setNumber(XSDataInteger(iImageNumber))

            xsDataSubWedge = XSDataSubWedge()
            xsDataSubWedge.setExperimentalCondition(xsDataExperimentalCondition)
            xsDataSubWedge.addImage(xsDataImage)

            self.__xsDataResultReadImageHeader = XSDataResultReadImageHeader()
            self.__xsDataResultReadImageHeader.setSubWedge(xsDataSubWedge)
    def process(self, _edObject=None):
        EDPluginExec.process(self)
        EDVerbose.DEBUG("*** EDPluginExecReadImageHeaderADSCv10.process")
        xsDataInputReadImageHeader = self.getDataInput()
        xsDataFile = xsDataInputReadImageHeader.getImage()
        strPath = xsDataFile.getPath().getValue()
        strAbsolutePath = os.path.abspath(strPath)
        dictHeader = self.readHeaderADSC(strPath)
        if (dictHeader is None):
            strErrorMessage = "EDPluginExecReadImageHeaderADSCv10.process : error when reading header from %s" % strAbsolutePath
            EDVerbose.error(strErrorMessage)
            self.addErrorMessage(strErrorMessage)
            self.setFailure()
        else:
            xsDataExperimentalCondition = XSDataExperimentalCondition()
            xsDataDetector = XSDataDetector()

            xsDataDetector.setBeamPositionX(XSDataLength(float(dictHeader[ "BEAM_CENTER_X" ])))
            xsDataDetector.setBeamPositionY(XSDataLength(float(dictHeader[ "BEAM_CENTER_Y" ])))
            xsDataDetector.setDistance(XSDataLength(float(dictHeader[ "DISTANCE"   ])))
            fPixelSize = float(dictHeader[ "PIXEL_SIZE"   ])
            xsDataDetector.setPixelSizeX(XSDataLength(fPixelSize))
            xsDataDetector.setPixelSizeY(XSDataLength(fPixelSize))
            if "TWOTHETA" in dictHeader.keys():
                xsDataDetector.setTwoTheta(XSDataAngle(float(dictHeader[ "TWOTHETA"   ])))
            xsDataDetector.setNumberBytesInHeader(XSDataInteger(float(dictHeader[ "HEADER_BYTES"   ])))
            xsDataDetector.setSerialNumber(XSDataString(dictHeader[ "DETECTOR_SN"   ]))
            xsDataDetector.setNumberPixelX(XSDataInteger(int(dictHeader[ "SIZE1"   ])))
            xsDataDetector.setNumberPixelY(XSDataInteger(int(dictHeader[ "SIZE2"   ])))
            xsDataDetector.setBin(XSDataString(dictHeader[ "BIN" ]))
            xsDataDetector.setDataType(XSDataString(dictHeader[ "TYPE" ]))
            xsDataDetector.setByteOrder(XSDataString(dictHeader[ "BYTE_ORDER" ]))
            if "CCD_IMAGE_SATURATION" in dictHeader.keys():
                xsDataDetector.setImageSaturation(XSDataInteger(int(dictHeader[ "CCD_IMAGE_SATURATION" ])))

            # Determine type of detector...
            iNoPixelsX = xsDataDetector.getNumberPixelX().getValue()
            iNoPixelsY = xsDataDetector.getNumberPixelY().getValue()
            if (iNoPixelsX == 2304 and iNoPixelsY == 2304):
                xsDataDetector.setName(XSDataString("ADSC Q4"))
                xsDataDetector.setType(XSDataString("q4"))
            elif (iNoPixelsX == 1152 and iNoPixelsY == 1152):
                xsDataDetector.setName(XSDataString("ADSC Q4 bin 2x2"))
                xsDataDetector.setType(XSDataString("q4-2x"))
            elif (iNoPixelsX == 4096 and iNoPixelsY == 4096):
                xsDataDetector.setName(XSDataString("ADSC Q210"))
                xsDataDetector.setType(XSDataString("q210"))
            elif (iNoPixelsX == 2048 and iNoPixelsY == 2048):
                xsDataDetector.setName(XSDataString("ADSC Q210 bin 2x2"))
                xsDataDetector.setType(XSDataString("q210-2x"))
            elif (iNoPixelsX == 6144 and iNoPixelsY == 6144):
                xsDataDetector.setName(XSDataString("ADSC Q315"))
                xsDataDetector.setType(XSDataString("q315"))
            elif (iNoPixelsX == 3072 and iNoPixelsY == 3072):
                xsDataDetector.setName(XSDataString("ADSC Q315 bin 2x2"))
                xsDataDetector.setType(XSDataString("q315-2x"))
            else:
                strErrorMessage = EDMessage.ERROR_DATA_HANDLER_02 % ("EDPluginExecReadImageHeaderADSCv10.process", "Unknown detector type")
                EDVerbose.error(strErrorMessage)
                self.addErrorMessage(strErrorMessage)
                raise RuntimeError, strErrorMessage

            xsDataExperimentalCondition.setDetector(xsDataDetector)

            # Beam object

            xsDataBeam = XSDataBeam()
            xsDataBeam.setWavelength(XSDataWavelength(float(dictHeader[ "WAVELENGTH" ])))
            xsDataBeam.setExposureTime(XSDataTime(float(dictHeader[ "TIME" ])))
            xsDataExperimentalCondition.setBeam(xsDataBeam)

            # Goniostat object
            xsDataGoniostat = XSDataGoniostat()
            fRotationAxisStart = float(dictHeader[ "OSC_START" ])
            fOscillationWidth = float(dictHeader[ "OSC_RANGE" ])
            xsDataGoniostat.setRotationAxisStart(XSDataAngle(fRotationAxisStart))
            xsDataGoniostat.setRotationAxisEnd(XSDataAngle(fRotationAxisStart + fOscillationWidth))
            xsDataGoniostat.setOscillationWidth(XSDataAngle(fOscillationWidth))
            strRotationAxis = None
            if ("AXIS" in dictHeader.keys()):
                strRotationAxis = dictHeader[ "AXIS" ]
            elif ("OSC_AXIS" in dictHeader.keys()):
                strRotationAxis = dictHeader[ "OSC_AXIS" ]
            else:
                strErrorMessage = "EDPluginExecReadImageHeaderADSCv10.process : Neither AXIS nor OSC_AXIS header item found."
                EDVerbose.error(strErrorMessage)
                self.addErrorMessage(strErrorMessage)
                self.setFailure()
            xsDataGoniostat.setRotationAxis(XSDataString(strRotationAxis))
            xsDataExperimentalCondition.setGoniostat(xsDataGoniostat)

            # Create the image object
            xsDataImage = XSDataImage()
            xsDataImage.setPath(XSDataString(strAbsolutePath))
            xsDataImage.setDate(XSDataString(dictHeader[ "DATE" ]))
            strFileName = os.path.basename(strPath)
            iImageNumber = EDUtilsImage.getImageNumber(strFileName)
            xsDataImage.setNumber(XSDataInteger(iImageNumber))

            xsDataSubWedge = XSDataSubWedge()
            xsDataSubWedge.setExperimentalCondition(xsDataExperimentalCondition)
            xsDataSubWedge.addImage(xsDataImage)

            self.__xsDataResultReadImageHeader = XSDataResultReadImageHeader()
            self.__xsDataResultReadImageHeader.setSubWedge(xsDataSubWedge)
    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
    def testSetDataModelInput(self):
        edPluginStrategy = self.createPlugin()
        strPathToTestConfigFile = os.path.join(self.getPluginTestsDataHome(),
                                               "XSConfiguration_ESRF.xml")
        edConfiguration = EDConfiguration(strPathToTestConfigFile)
        dictItem = edConfiguration.get(edPluginStrategy.getPluginName())
        edPluginStrategy.setConfig(dictItem)
        edPluginStrategy.configure()

        xsDataStrategy = XSDataInputStrategy()

        # Beam

        xsExperimentalCondition = XSDataExperimentalCondition()

        xsBeam = XSDataBeam()
        xsBeam.setFlux(XSDataFlux(1e+12))
        xsBeam.setWavelength(XSDataWavelength(2.41))
        xsBeam.setSize(XSDataSize(x=XSDataLength(0.1), y=XSDataLength(0.1)))
        xsBeam.setExposureTime(XSDataTime(1))

        xsExperimentalCondition.setBeam(xsBeam)

        # Detector and Exposure Time

        xsDataDetector = XSDataDetector()
        xsDataDetector.setType(XSDataString("q210-2x"))
        xsExperimentalCondition.setDetector(xsDataDetector)

        xsDataGoniostat = XSDataGoniostat()
        xsDataGoniostat.setRotationAxis(XSDataString("phi"))
        xsExperimentalCondition.setGoniostat(xsDataGoniostat)

        xsDataStrategy.setExperimentalCondition(xsExperimentalCondition)

        # Best Files
        bestFileContentDat = EDUtilsFile.readFile(
            os.path.join(self.strDataPath, "bestfile.dat"))
        xsDataStrategy.setBestFileContentDat(XSDataString(bestFileContentDat))
        bestFileContentPar = EDUtilsFile.readFile(
            os.path.join(self.strDataPath, "bestfile.par"))
        xsDataStrategy.setBestFileContentPar(XSDataString(bestFileContentPar))
        bestFileContentHKL = EDUtilsFile.readFile(
            os.path.join(self.strDataPath, "bestfile1.hkl"))
        xsDataStrategy.addBestFileContentHKL(XSDataString(bestFileContentHKL))

        # Crystal

        xsDataSampleCrystalMM = XSDataSampleCrystalMM()
        xsDataStructure = XSDataStructure()
        xsDataComposition = XSDataChemicalCompositionMM()

        xsDataChain = XSDataChain()
        xsDataChain.setType(XSDataString("protein"))
        xsDataChain.setNumberOfCopies(XSDataDouble(2))
        xsDataAtomicComposition = XSDataAtomicComposition()
        xsDataAtom1 = XSDataAtom()
        xsDataAtom1.setSymbol(XSDataString("Se"))
        xsDataAtom1.setNumberOf(XSDataDouble(4))
        xsDataAtomicComposition.addAtom(xsDataAtom1)

        xsDataChain.setHeavyAtoms(xsDataAtomicComposition)
        xsDataChain.setNumberOfMonomers(XSDataDouble(100))
        xsDataStructure.addChain(xsDataChain)

        xsDataChain2 = XSDataChain()
        xsDataChain2.setType(XSDataString("rna"))
        xsDataChain2.setNumberOfCopies(XSDataDouble(1))
        xsDataChain2.setNumberOfMonomers(XSDataDouble(60))
        xsDataStructure.addChain(xsDataChain2)

        xsDataLigand = XSDataLigand()
        xsDataLigand.setNumberOfCopies(XSDataDouble(2))
        xsDataLigand.setNumberOfLightAtoms(XSDataDouble(42))
        xsDataAtomicComposition = XSDataAtomicComposition()
        xsDataAtom2 = XSDataAtom()
        xsDataAtom2.setSymbol(XSDataString("Fe"))
        xsDataAtom2.setNumberOf(XSDataDouble(1))
        xsDataAtomicComposition.addAtom(xsDataAtom2)
        xsDataLigand.setHeavyAtoms(xsDataAtomicComposition)
        xsDataStructure.addLigand(xsDataLigand)
        xsDataStructure.setNumberOfCopiesInAsymmetricUnit(XSDataDouble(0.25))

        xsDataSolvent = XSDataSolvent()
        xsDataAtomicComposition = XSDataAtomicComposition()

        xsDataAtom3 = XSDataAtom()
        xsDataAtom3.setSymbol(XSDataString("Na"))
        xsDataAtom3.setConcentration(XSDataDouble(1000))
        xsDataAtom4 = XSDataAtom()
        xsDataAtom4.setSymbol(XSDataString("Cl"))
        xsDataAtom4.setConcentration(XSDataDouble(1000))

        xsDataAtomicComposition.addAtom(xsDataAtom3)
        xsDataAtomicComposition.addAtom(xsDataAtom4)
        xsDataSolvent.setAtoms(xsDataAtomicComposition)

        xsDataComposition.setStructure(xsDataStructure)
        xsDataComposition.setSolvent(xsDataSolvent)
        xsDataSampleCrystalMM.setChemicalComposition(xsDataComposition)

        xsDataSampleCrystalMM.setSize(
            XSDataSize(XSDataLength(0.1), XSDataLength(0.1),
                       XSDataLength(0.1)))

        xsDataCrystal = XSDataCrystal()
        xsDataCell = XSDataCell(angle_alpha=XSDataAngle(90.0),
                                angle_beta=XSDataAngle(90.0),
                                angle_gamma=XSDataAngle(90.0),
                                length_a=XSDataLength(78.9),
                                length_b=XSDataLength(95.162),
                                length_c=XSDataLength(104.087))
        xsDataCrystal.setCell(xsDataCell)

        xsDataSpaceGroup = XSDataSpaceGroup()
        xsDataSpaceGroup.setITNumber(XSDataInteger(16))
        xsDataCrystal.setSpaceGroup(xsDataSpaceGroup)

        xsDataSampleCrystalMM.setSusceptibility(XSDataDouble(1.5))

        xsDataStrategy.setCrystalRefined(xsDataCrystal)

        xsDataStrategy.setSample(xsDataSampleCrystalMM)

        xsDataStrategy.exportToFile(self.strObtainedInputFile)

        pyStrExpectedInput = self.readAndParseFile(self.strReferenceInputFile)
        pyStrObtainedInput = self.readAndParseFile(self.strObtainedInputFile)

        xsDataInputExpected = XSDataInputStrategy.parseString(
            pyStrExpectedInput)
        xsDataInputObtained = XSDataInputStrategy.parseString(
            pyStrObtainedInput)

        EDAssert.equal(xsDataInputExpected.marshal(),
                       xsDataInputObtained.marshal())
Пример #8
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 testSetDataModelInput(self):
        edPluginStrategy = self.createPlugin()
        strPathToTestConfigFile = os.path.join(self.getPluginTestsDataHome(), "XSConfiguration_ESRF.xml")
        edConfiguration = EDConfiguration(strPathToTestConfigFile)
        dictItem = edConfiguration.get(edPluginStrategy.getPluginName())
        edPluginStrategy.setConfig(dictItem)
        edPluginStrategy.configure()

        xsDataStrategy = XSDataInputStrategy()

        # Beam

        xsExperimentalCondition = XSDataExperimentalCondition()

        xsBeam = XSDataBeam()
        xsBeam.setFlux(XSDataFlux(1e+12))
        xsBeam.setWavelength(XSDataWavelength(2.41))
        xsBeam.setSize(XSDataSize(x=XSDataLength(0.1), y=XSDataLength(0.1)))
        xsBeam.setExposureTime(XSDataTime(1))

        xsExperimentalCondition.setBeam(xsBeam)

        # Detector and Exposure Time

        xsDataDetector = XSDataDetector()
        xsDataDetector.setType(XSDataString("q210-2x"))
        xsExperimentalCondition.setDetector(xsDataDetector)

        xsDataGoniostat = XSDataGoniostat()
        xsDataGoniostat.setRotationAxis(XSDataString("phi"))
        xsExperimentalCondition.setGoniostat(xsDataGoniostat)

        xsDataStrategy.setExperimentalCondition(xsExperimentalCondition)


        # Best Files
        bestFileContentDat = EDUtilsFile.readFile(os.path.join(self.strDataPath, "bestfile.dat"))
        xsDataStrategy.setBestFileContentDat(XSDataString(bestFileContentDat))
        bestFileContentPar = EDUtilsFile.readFile(os.path.join(self.strDataPath, "bestfile.par"))
        xsDataStrategy.setBestFileContentPar(XSDataString(bestFileContentPar))
        bestFileContentHKL = EDUtilsFile.readFile(os.path.join(self.strDataPath, "bestfile1.hkl"))
        xsDataStrategy.addBestFileContentHKL(XSDataString(bestFileContentHKL))

        # Crystal

        xsDataSampleCrystalMM = XSDataSampleCrystalMM()
        xsDataStructure = XSDataStructure()
        xsDataComposition = XSDataChemicalCompositionMM()

        xsDataChain = XSDataChain()
        xsDataChain.setType(XSDataString("protein"))
        xsDataChain.setNumberOfCopies(XSDataDouble(2))
        xsDataAtomicComposition = XSDataAtomicComposition()
        xsDataAtom1 = XSDataAtom()
        xsDataAtom1.setSymbol(XSDataString("Se"))
        xsDataAtom1.setNumberOf(XSDataDouble(4))
        xsDataAtomicComposition.addAtom(xsDataAtom1)

        xsDataChain.setHeavyAtoms(xsDataAtomicComposition)
        xsDataChain.setNumberOfMonomers(XSDataDouble(100))
        xsDataStructure.addChain(xsDataChain)

        xsDataChain2 = XSDataChain()
        xsDataChain2.setType(XSDataString("rna"))
        xsDataChain2.setNumberOfCopies(XSDataDouble(1))
        xsDataChain2.setNumberOfMonomers(XSDataDouble(60))
        xsDataStructure.addChain(xsDataChain2)

        xsDataLigand = XSDataLigand()
        xsDataLigand.setNumberOfCopies(XSDataDouble(2))
        xsDataLigand.setNumberOfLightAtoms(XSDataDouble(42))
        xsDataAtomicComposition = XSDataAtomicComposition()
        xsDataAtom2 = XSDataAtom()
        xsDataAtom2.setSymbol(XSDataString("Fe"))
        xsDataAtom2.setNumberOf(XSDataDouble(1))
        xsDataAtomicComposition.addAtom(xsDataAtom2)
        xsDataLigand.setHeavyAtoms(xsDataAtomicComposition)
        xsDataStructure.addLigand(xsDataLigand)
        xsDataStructure.setNumberOfCopiesInAsymmetricUnit(XSDataDouble(0.25))

        xsDataSolvent = XSDataSolvent()
        xsDataAtomicComposition = XSDataAtomicComposition()

        xsDataAtom3 = XSDataAtom()
        xsDataAtom3.setSymbol(XSDataString("Na"))
        xsDataAtom3.setConcentration(XSDataDouble(1000))
        xsDataAtom4 = XSDataAtom()
        xsDataAtom4.setSymbol(XSDataString("Cl"))
        xsDataAtom4.setConcentration(XSDataDouble(1000))

        xsDataAtomicComposition.addAtom(xsDataAtom3)
        xsDataAtomicComposition.addAtom(xsDataAtom4)
        xsDataSolvent.setAtoms(xsDataAtomicComposition)

        xsDataComposition.setStructure(xsDataStructure)
        xsDataComposition.setSolvent(xsDataSolvent)
        xsDataSampleCrystalMM.setChemicalComposition(xsDataComposition)

        xsDataSampleCrystalMM.setSize(XSDataSize(XSDataLength(0.1), XSDataLength(0.1), XSDataLength(0.1)))

        xsDataCrystal = XSDataCrystal()
        xsDataCell = XSDataCell(angle_alpha=XSDataAngle(90.0),
                                angle_beta=XSDataAngle(90.0),
                                angle_gamma=XSDataAngle(90.0),
                                length_a=XSDataLength(78.9),
                                length_b=XSDataLength(95.162),
                                length_c=XSDataLength(104.087))
        xsDataCrystal.setCell(xsDataCell)

        xsDataSpaceGroup = XSDataSpaceGroup()
        xsDataSpaceGroup.setITNumber(XSDataInteger(16))
        xsDataCrystal.setSpaceGroup(xsDataSpaceGroup)

        xsDataSampleCrystalMM.setSusceptibility(XSDataDouble(1.5))

        xsDataStrategy.setCrystalRefined(xsDataCrystal)

        xsDataStrategy.setSample(xsDataSampleCrystalMM)

        xsDataStrategy.exportToFile(self.strObtainedInputFile)

        pyStrExpectedInput = self.readAndParseFile (self.strReferenceInputFile)
        pyStrObtainedInput = self.readAndParseFile (self.strObtainedInputFile)

        xsDataInputExpected = XSDataInputStrategy.parseString(pyStrExpectedInput)
        xsDataInputObtained = XSDataInputStrategy.parseString(pyStrObtainedInput)

        EDAssert.equal(xsDataInputExpected.marshal(), xsDataInputObtained.marshal())
    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
    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
    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
    def process(self, _edObject=None):
        EDPluginExec.process(self)
        EDVerbose.DEBUG("EDPluginExecReadImageHeaderMARCCDv10.process")
        xsDataInputReadImageHeader = self.getDataInput()
        xsDataFile = xsDataInputReadImageHeader.getImage()
        strPath = xsDataFile.getPath().getValue()
        dictMARCCDHeader = self.readHeaderMarccd(strPath)
        if (dictMARCCDHeader is None):
            strErrorMessage = "EDPluginExecReadImageHeaderMARCCDv10.process : Cannot read header : %s" % strPath
            EDVerbose.error(strErrorMessage)
            self.addErrorMessage(strErrorMessage)
            self.setFailure()
        else:
            xsDataExperimentalCondition = XSDataExperimentalCondition()
            xsDataDetector = XSDataDetector()

            iNoPixelsX = int(dictMARCCDHeader[ "nslow"   ])
            iNoPixelsY = int(dictMARCCDHeader[ "nfast"   ])
            xsDataDetector.setNumberPixelX(XSDataInteger(iNoPixelsX))
            xsDataDetector.setNumberPixelY(XSDataInteger(iNoPixelsY))
            fPixelSizeX = float(dictMARCCDHeader[ "pixelsize_x"   ]) / 1000.0
            xsDataDetector.setPixelSizeX(XSDataLength(fPixelSizeX))
            fPixelSizeY = float(dictMARCCDHeader[ "pixelsize_y"   ]) / 1000.0
            xsDataDetector.setPixelSizeY(XSDataLength(fPixelSizeY))
            fBeamPositionX = float(dictMARCCDHeader[ "beam_x" ]) / 1000.0
            fBeamPositionY = float(dictMARCCDHeader[ "beam_y" ]) / 1000.0
            # Fix for bug 397 - check if the beam position is close to the centre of the image
            fTwoTheta = float(dictMARCCDHeader[ "end_twotheta"   ]) / 1000.0
            xsDataDetector.setTwoTheta(XSDataAngle(fTwoTheta))
            if (abs(fTwoTheta) < 0.1):
                if (abs(fBeamPositionX / (fPixelSizeX / 1000.0) - iNoPixelsX / 2.0) > (2 * iNoPixelsX)):
                    fBeamPositionX = fBeamPositionX * fPixelSizeX / 1000.0
                    fBeamPositionY = fBeamPositionY * fPixelSizeY / 1000.0
            xsDataDetector.setBeamPositionX(XSDataLength(fBeamPositionX))
            xsDataDetector.setBeamPositionY(XSDataLength(fBeamPositionY))
            fDistance = float(dictMARCCDHeader[ "xtal_to_detector"   ]) / 1000.0
            if (abs(fDistance) < 0.1):
                fDistanceStart = float(dictMARCCDHeader[ "start_xtal_to_detector"   ]) / 1000.0
                fDistanceEnd = float(dictMARCCDHeader[ "end_xtal_to_detector"   ]) / 1000.0
                if (abs(fDistanceStart - fDistanceEnd) < 0.1):
                    fDistance = fDistanceStart
                else:
                    # Somethings very wrong with the distances...
                    strErrorMessage = "EDPluginExecReadImageHeaderMARCCDv10.process : Inconsistency in MAR CCD image header: start_xtal_to_detector = %d, end_xtal_to_detector = %d" % \
                                                                           (fDistanceStart, fDistanceEnd)
                    EDVerbose.error(strErrorMessage)
                    self.addErrorMessage(strErrorMessage)
                    self.setFailure()
            xsDataDetector.setDistance(XSDataLength(fDistance))
            xsDataDetector.setNumberBytesInHeader(XSDataInteger(float(dictMARCCDHeader[ "header_size"   ])))
            # xsDataDetector.setSerialNumber(        XSDataInteger(  dictMARCCDHeader[ "DETECTOR_SN"   ] ) ) )
            # xsDataDetector.setBin(                 XSDataString(   dictMARCCDHeader[ "BIN" ] ) ) )
            # xsDataDetector.setDataType(            XSDataString(   dictMARCCDHeader[ "TYPE" ] ) ) )
            # xsDataDetector.setByteOrder(           XSDataString(   dictMARCCDHeader[ "BYTE_ORDER" ] ) ) )
            xsDataDetector.setImageSaturation(XSDataInteger(int(dictMARCCDHeader[ "saturation_level" ])))
            # Determine type of detector...
            if (iNoPixelsX == 2048 and iNoPixelsY == 2048):
                xsDataDetector.setName(XSDataString("MAR CCD 165"))
                xsDataDetector.setType(XSDataString("mar165"))
            elif (iNoPixelsX == 3072 and iNoPixelsY == 3072):
                xsDataDetector.setName(XSDataString("MAR CCD 225"))
                xsDataDetector.setType(XSDataString("mar225"))
            elif (iNoPixelsX == 4096 and iNoPixelsY == 4096):
                xsDataDetector.setName(XSDataString("MAR CCD 325"))
                xsDataDetector.setType(XSDataString("mar325"))
            else:
                strErrorMessage = EDMessage.ERROR_DATA_HANDLER_02 % ("EDPluginExecReadImageHeaderMARCCDv10.process", "Unknown detector type")
                EDVerbose.error(strErrorMessage)
                self.addErrorMessage(strErrorMessage)
                raise RuntimeError, strErrorMessage

            xsDataExperimentalCondition.setDetector(xsDataDetector)

            # Beam object

            xsDataBeam = XSDataBeam()
            xsDataBeam.setWavelength(XSDataWavelength(float(dictMARCCDHeader[ "source_wavelength" ]) / 100000.0))
            xsDataBeam.setExposureTime(XSDataTime(float(dictMARCCDHeader[ "exposure_time" ]) / 1000.0))
            xsDataExperimentalCondition.setBeam(xsDataBeam)

            # Goniostat object
            xsDataGoniostat = XSDataGoniostat()
            fRotationAxisStart = float(dictMARCCDHeader[ "start_phi" ]) / 1000.0
            fOscillationWidth = float(dictMARCCDHeader[ "rotation_range" ]) / 1000.0
            xsDataGoniostat.setRotationAxisStart(XSDataAngle(fRotationAxisStart))
            xsDataGoniostat.setRotationAxisEnd(XSDataAngle(fRotationAxisStart + fOscillationWidth))
            xsDataGoniostat.setOscillationWidth(XSDataAngle(fOscillationWidth))
            xsDataExperimentalCondition.setGoniostat(xsDataGoniostat)

            # Create the image object
            xsDataImage = XSDataImage()
            xsDataImage.setPath(XSDataString(strPath))
            strTimeStamp = dictMARCCDHeader[ "acquire_timestamp" ]
            xsDataImage.setDate(XSDataString(strTimeStamp))
            iImageNumber = EDUtilsImage.getImageNumber(strPath)
            xsDataImage.setNumber(XSDataInteger(iImageNumber))

            xsDataSubWedge = XSDataSubWedge()
            xsDataSubWedge.setExperimentalCondition(xsDataExperimentalCondition)
            xsDataSubWedge.addImage(xsDataImage)

            self.__xsDataResultReadImageHeader = XSDataResultReadImageHeader()
            self.__xsDataResultReadImageHeader.setSubWedge(xsDataSubWedge)
Пример #14
0
    def process(self, _edObject=None):
        EDPluginExec.process(self)
        EDVerbose.DEBUG("EDPluginExecReadImageHeaderMARCCDv10.process")
        xsDataInputReadImageHeader = self.getDataInput()
        xsDataFile = xsDataInputReadImageHeader.getImage()
        strPath = xsDataFile.getPath().getValue()
        dictMARCCDHeader = self.readHeaderMarccd(strPath)
        if (dictMARCCDHeader is None):
            strErrorMessage = "EDPluginExecReadImageHeaderMARCCDv10.process : Cannot read header : %s" % strPath
            EDVerbose.error(strErrorMessage)
            self.addErrorMessage(strErrorMessage)
            self.setFailure()
        else:
            xsDataExperimentalCondition = XSDataExperimentalCondition()
            xsDataDetector = XSDataDetector()

            iNoPixelsX = int(dictMARCCDHeader["nslow"])
            iNoPixelsY = int(dictMARCCDHeader["nfast"])
            xsDataDetector.setNumberPixelX(XSDataInteger(iNoPixelsX))
            xsDataDetector.setNumberPixelY(XSDataInteger(iNoPixelsY))
            fPixelSizeX = float(dictMARCCDHeader["pixelsize_x"]) / 1000.0
            xsDataDetector.setPixelSizeX(XSDataLength(fPixelSizeX))
            fPixelSizeY = float(dictMARCCDHeader["pixelsize_y"]) / 1000.0
            xsDataDetector.setPixelSizeY(XSDataLength(fPixelSizeY))
            fBeamPositionX = float(dictMARCCDHeader["beam_x"]) / 1000.0
            fBeamPositionY = float(dictMARCCDHeader["beam_y"]) / 1000.0
            # Fix for bug 397 - check if the beam position is close to the centre of the image
            fTwoTheta = float(dictMARCCDHeader["end_twotheta"]) / 1000.0
            xsDataDetector.setTwoTheta(XSDataAngle(fTwoTheta))
            if (abs(fTwoTheta) < 0.1):
                if (abs(fBeamPositionX /
                        (fPixelSizeX / 1000.0) - iNoPixelsX / 2.0) >
                    (2 * iNoPixelsX)):
                    fBeamPositionX = fBeamPositionX * fPixelSizeX / 1000.0
                    fBeamPositionY = fBeamPositionY * fPixelSizeY / 1000.0
            xsDataDetector.setBeamPositionX(XSDataLength(fBeamPositionX))
            xsDataDetector.setBeamPositionY(XSDataLength(fBeamPositionY))
            fDistance = float(dictMARCCDHeader["xtal_to_detector"]) / 1000.0
            if (abs(fDistance) < 0.1):
                fDistanceStart = float(
                    dictMARCCDHeader["start_xtal_to_detector"]) / 1000.0
                fDistanceEnd = float(
                    dictMARCCDHeader["end_xtal_to_detector"]) / 1000.0
                if (abs(fDistanceStart - fDistanceEnd) < 0.1):
                    fDistance = fDistanceStart
                else:
                    # Somethings very wrong with the distances...
                    strErrorMessage = "EDPluginExecReadImageHeaderMARCCDv10.process : Inconsistency in MAR CCD image header: start_xtal_to_detector = %d, end_xtal_to_detector = %d" % \
                                                                           (fDistanceStart, fDistanceEnd)
                    EDVerbose.error(strErrorMessage)
                    self.addErrorMessage(strErrorMessage)
                    self.setFailure()
            xsDataDetector.setDistance(XSDataLength(fDistance))
            xsDataDetector.setNumberBytesInHeader(
                XSDataInteger(float(dictMARCCDHeader["header_size"])))
            #xsDataDetector.setSerialNumber(        XSDataInteger(  dictMARCCDHeader[ "DETECTOR_SN"   ] ) ) )
            #xsDataDetector.setBin(                 XSDataString(   dictMARCCDHeader[ "BIN" ] ) ) )
            #xsDataDetector.setDataType(            XSDataString(   dictMARCCDHeader[ "TYPE" ] ) ) )
            #xsDataDetector.setByteOrder(           XSDataString(   dictMARCCDHeader[ "BYTE_ORDER" ] ) ) )
            xsDataDetector.setImageSaturation(
                XSDataInteger(int(dictMARCCDHeader["saturation_level"])))
            # Determine type of detector...
            if (iNoPixelsX == 2048 and iNoPixelsY == 2048):
                xsDataDetector.setName(XSDataString("MAR CCD 165"))
                xsDataDetector.setType(XSDataString("mar165"))
            elif (iNoPixelsX == 3072 and iNoPixelsY == 3072):
                xsDataDetector.setName(XSDataString("MAR CCD 225"))
                xsDataDetector.setType(XSDataString("mar225"))
            elif (iNoPixelsX == 4096 and iNoPixelsY == 4096):
                xsDataDetector.setName(XSDataString("MAR CCD 325"))
                xsDataDetector.setType(XSDataString("mar325"))
            else:
                strErrorMessage = EDMessage.ERROR_DATA_HANDLER_02 % (
                    "EDPluginExecReadImageHeaderMARCCDv10.process",
                    "Unknown detector type")
                EDVerbose.error(strErrorMessage)
                self.addErrorMessage(strErrorMessage)
                raise RuntimeError, strErrorMessage

            xsDataExperimentalCondition.setDetector(xsDataDetector)

            # Beam object

            xsDataBeam = XSDataBeam()
            xsDataBeam.setWavelength(
                XSDataWavelength(
                    float(dictMARCCDHeader["source_wavelength"]) / 100000.0))
            xsDataBeam.setExposureTime(
                XSDataTime(float(dictMARCCDHeader["exposure_time"]) / 1000.0))
            xsDataExperimentalCondition.setBeam(xsDataBeam)

            # Goniostat object
            xsDataGoniostat = XSDataGoniostat()
            fRotationAxisStart = float(dictMARCCDHeader["start_phi"]) / 1000.0
            fOscillationWidth = float(
                dictMARCCDHeader["rotation_range"]) / 1000.0
            xsDataGoniostat.setRotationAxisStart(
                XSDataAngle(fRotationAxisStart))
            xsDataGoniostat.setRotationAxisEnd(
                XSDataAngle(fRotationAxisStart + fOscillationWidth))
            xsDataGoniostat.setOscillationWidth(XSDataAngle(fOscillationWidth))
            xsDataExperimentalCondition.setGoniostat(xsDataGoniostat)

            # Create the image object
            xsDataImage = XSDataImage()
            xsDataImage.setPath(XSDataString(strPath))
            strTimeStamp = dictMARCCDHeader["acquire_timestamp"]
            xsDataImage.setDate(XSDataString(strTimeStamp))
            iImageNumber = EDUtilsImage.getImageNumber(strPath)
            xsDataImage.setNumber(XSDataInteger(iImageNumber))

            xsDataSubWedge = XSDataSubWedge()
            xsDataSubWedge.setExperimentalCondition(
                xsDataExperimentalCondition)
            xsDataSubWedge.addImage(xsDataImage)

            self.__xsDataResultReadImageHeader = XSDataResultReadImageHeader()
            self.__xsDataResultReadImageHeader.setSubWedge(xsDataSubWedge)