def generateDataMOSFLMInputGeneratePrediction(self):
        """
        """
        from XSDataMOSFLMv10 import XSDataMOSFLMBeamPosition
        xsDataMOSFLMBeamPosition = XSDataMOSFLMBeamPosition()
        xsDataMOSFLMBeamPosition.setX(XSDataLength(102.5))
        xsDataMOSFLMBeamPosition.setY(XSDataLength(104.7))

        from XSDataMOSFLMv10 import XSDataMOSFLMDetector
        xsDataMOSFLMDetector = XSDataMOSFLMDetector()
        xsDataMOSFLMDetector.setType(XSDataString("ADSC"))

        from XSDataMOSFLMv10 import XSDataMOSFLMImage
        xsDataMOSFLMImage1 = XSDataMOSFLMImage()
        xsDataMOSFLMImage1.setNumber(XSDataInteger(1))
        xsDataMOSFLMImage1.setRotationAxisStart(XSDataAngle(0.0))
        xsDataMOSFLMImage1.setRotationAxisEnd(XSDataAngle(1.0))

        from XSDataMOSFLMv10 import XSDataMOSFLMInputGeneratePrediction
        xsDataMOSFLMInputGeneratePrediction = XSDataMOSFLMInputGeneratePrediction(
        )
        xsDataMOSFLMInputGeneratePrediction.setDistance(XSDataLength(198.4))
        xsDataMOSFLMInputGeneratePrediction.setWavelength(
            XSDataWavelength(0.9340))
        xsDataMOSFLMInputGeneratePrediction.setBeam(xsDataMOSFLMBeamPosition)
        xsDataMOSFLMInputGeneratePrediction.setDetector(xsDataMOSFLMDetector)
        xsDataMOSFLMInputGeneratePrediction.setDirectory(
            XSDataString(self.strDataImagePath))
        xsDataMOSFLMInputGeneratePrediction.setTemplate(
            XSDataString("ref-testscale_1_###.img"))
        xsDataMOSFLMInputGeneratePrediction.setImage(xsDataMOSFLMImage1)

        return xsDataMOSFLMInputGeneratePrediction
예제 #2
0
 def buildChildren(self, child_, nodeName_):
     if child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'symmetry':
         obj_ = XSDataString()
         obj_.build(child_)
         self.setSymmetry(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'orientation':
         obj_ = XSDataXOalignOrientation()
         obj_.build(child_)
         self.setOrientation(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'cell':
         obj_ = XSDataXOalignCell()
         obj_.build(child_)
         self.setCell(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'omega':
         obj_ = XSDataAngle()
         obj_.build(child_)
         self.setOmega(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'kappa':
         obj_ = XSDataAngle()
         obj_.build(child_)
         self.setKappa(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'phi':
         obj_ = XSDataAngle()
         obj_.build(child_)
         self.setPhi(obj_)
     XSDataInput.buildChildren(self, child_, nodeName_)
    def testDefaultChemicalComposition(self):
        edPluginStrategy = self.createPlugin()

        from XSDataCommon import XSDataAngle
        from XSDataCommon import XSDataLength
        from XSDataMXv1 import XSDataSampleCrystalMM
        from XSDataMXv1 import XSDataCrystal
        from XSDataMXv1 import XSDataCell


        xsDataSampleCrystalMM = XSDataSampleCrystalMM()
        xsDataCrystal = XSDataCrystal()
        xsDataCell = XSDataCell(XSDataAngle(90.0),
                                 XSDataAngle(90.0),
                                 XSDataAngle(90.0),
                                 XSDataLength(78.9),
                                 XSDataLength(95.162),
                                 XSDataLength(104.087))
        xsDataCrystal.setCell(xsDataCell)
        xsDataSampleCrystalMM.setCrystal(xsDataCrystal)
        inumOperators = 4

        xsDataSample2 = edPluginStrategy.getDefaultChemicalComposition(xsDataSampleCrystalMM, inumOperators)
        strChainType = xsDataSample2.getStructure().getChain()[0].getType()
        EDAssert.equal("protein", strChainType.getValue())
예제 #4
0
    def collectionRunItemListToCollectionRun(self, _xsCollectionRunItemList):
        xsDataCollectionRun = XSDataBestCollectionRun()

        xsItemExposureTime = EDUtilsTable.getItemFromList(
            _xsCollectionRunItemList, "exposure_time")
        fExposureTime = float(xsItemExposureTime.getValueOf_())
        xsDataCollectionRun.setExposureTime(XSDataTime(fExposureTime))

        xsItemDistance = EDUtilsTable.getItemFromList(_xsCollectionRunItemList,
                                                      "distance")
        fDistance = float(xsItemDistance.getValueOf_())
        xsDataCollectionRun.setDistance(XSDataLength(fDistance))

        xsItemRotationAxisStart = EDUtilsTable.getItemFromList(
            _xsCollectionRunItemList, "phi_start")
        fRotationAxisStart = float(xsItemRotationAxisStart.getValueOf_())
        xsDataCollectionRun.setPhiStart(XSDataAngle(fRotationAxisStart))

        xsNumberOfImages = EDUtilsTable.getItemFromList(
            _xsCollectionRunItemList, "number_of_images")
        iNumberOfImages = int(xsNumberOfImages.getValueOf_())
        xsDataCollectionRun.setNumberOfImages(XSDataInteger(iNumberOfImages))

        xsItemPhiWidth = EDUtilsTable.getItemFromList(_xsCollectionRunItemList,
                                                      "phi_width")
        fPhiWidth = float(xsItemPhiWidth.getValueOf_())
        xsDataCollectionRun.setPhiWidth(XSDataAngle(fPhiWidth))

        xsItemOverlaps = EDUtilsTable.getItemFromList(_xsCollectionRunItemList,
                                                      "overlaps")
        strOverlaps = xsItemOverlaps.getValueOf_()
        xsDataCollectionRun.setOverlaps(XSDataString(strOverlaps))

        return xsDataCollectionRun
예제 #5
0
def populateXSDataInputSPDCake(dictID11):
    xsDataInputSPDCake = XSDataInputSPDCake()
    # Angle of tilt
    xsDataInputSPDCake.setAngleOfTilt(
        XSDataAngle(float(dictID11["ANGLE OF TILT"])))

    # Dark current
    if dictID11["DARK CURRENT"] == "YES":
        xsDataInputSPDCake.setDarkCurrentImageFile(
            XSDataFile(XSDataString(dictID11["DC FILE"])))
        #xsDataFile = XSDataFile()
        #xsDataFile.setPath(XSDataString(dictID11["DC FILE "]))
        #xsDataInputSPDCake.setDarkCurrentImageFile(xsDataFile)

    if dictID11["FLAT-FIELD"] == "YES":
        xsDataInputSPDCake.setFlatFieldImageFile(
            XSDataFile(XSDataString(dictID11["FF FILE"])))

    if dictID11["FF SCALE"] == "NO":
        xsDataInputSPDCake.setFlatFieldImageFile(
            XSDataFile(XSDataString(dictID11["FF MULTIPLIER"])))

    if dictID11["SPATIAL DIS."] == "YES":
        xsDataInputSPDCake.setSpatialDistortionFile(
            XSDataFile(XSDataString(dictID11["SD FILE"])))

    xsDataInputSPDCake.setStartAzimuth(
        XSDataAngle(float(dictID11["START AZIMUTH"])))
    xsDataInputSPDCake.setStopAzimuth(
        XSDataAngle(float(dictID11["END AZIMUTH"])))
    xsDataInputSPDCake.setInnerRadius(
        XSDataDouble(float(dictID11["INNER RADIUS"])))
    xsDataInputSPDCake.setOuterRadius(
        XSDataDouble(float(dictID11["OUTER RADIUS"])))

    xsDataInputSPDCake.setBufferSizeX(
        XSDataInteger(int(dictID11["X-PIXEL SIZE"])))
    xsDataInputSPDCake.setBufferSizeY(
        XSDataInteger(int(dictID11["Y-PIXEL SIZE"])))
    xsDataInputSPDCake.setSampleToDetectorDistance(
        XSDataLength(float(dictID11["DISTANCE"])))
    xsDataInputSPDCake.setWavelength(
        XSDataLength(float(dictID11["WAVELENGTH"])))

    xsDataInputSPDCake.setBeamCentreInPixelsX(
        XSDataDouble(float(dictID11["X-BEAM CENTRE"])))
    xsDataInputSPDCake.setBeamCentreInPixelsY(
        XSDataDouble(float(dictID11["Y-BEAM CENTRE"])))
    xsDataInputSPDCake.setTiltRotation(
        XSDataAngle(float(dictID11["TILT ROTATION"])))
    xsDataInputSPDCake.setOutputFileType(
        XSDataFile(XSDataString(dictID11["saving_format"])))
    xsDataInputSPDCake.setOutputFileType(
        XSDataFile(XSDataString(dictID11["output_dir"])))

    # TODO : some parameters remain not inserted in this file because not in the datamodel

    print xsDataInputSPDCake.marshal()
예제 #6
0
    def preProcess(self, _edObject=None):
        """
        The pre-process of ED Plugin Control DiffractionCT Powder Integration consists in preparing the input data for SPD Cake. 
        and declares the execution plugin as EDPluginFit2DCacke
        """
        EDPluginControl.preProcess(self)
        EDVerbose.DEBUG("EDPluginControlDCTPowderIntegrationv1_1.preProcess")
        # Load the execution plugin
        self.m_edPluginPowderIntegration = self.loadPlugin(self.m_edStringControlledPluginName)
        #Retrive its'datamodel

        xsDataInputSPDCake = XSDataInputSPDCake()

        instrumentParameters = self.getDataInput().getInstrumentParameters()
        imageParameters = self.getDataInput().getImageParameters()

        xsDataInputSPDCake.setInputFile(self.getDataInput().getImageFile())

        xsDataInputSPDCake.setWavelength(instrumentParameters.get_diffrn_radiation_wavelength())

        xsDataInputSPDCake.setSampleToDetectorDistance(instrumentParameters.get_pd_instr_dist_spec_detc())


        xsDataInputSPDCake.setAngleOfTilt(imageParameters.get_pd_instr_special_details_tilt_angle())
        xsDataInputSPDCake.setTiltRotation(imageParameters.get_pd_instr_special_details_tilt_rotation())

        xsDataInputSPDCake.setDarkCurrentImageFile(imageParameters.get_file_correction_image_dark_current())
        xsDataInputSPDCake.setFlatFieldImageFile(imageParameters.get_file_correction_image_flat_field())
        xsDataInputSPDCake.setSpatialDistortionFile(imageParameters.get_file_correction_spline_spatial_distortion())

#        EDVerbose.screen("imageParameters.get_array_element_size_1: %s" % imageParameters.get_array_element_size_1().marshal())
        xsDataInputSPDCake.setBeamCentreInPixelsX(XSDataDouble(\
                            EDUtilsUnit.getSIValue(imageParameters.get_diffrn_detector_element_center_1()) / \
                            EDUtilsUnit.getSIValue(imageParameters.get_array_element_size_1())))
        xsDataInputSPDCake.setBeamCentreInPixelsY(XSDataDouble(\
                            EDUtilsUnit.getSIValue(imageParameters.get_diffrn_detector_element_center_2()) / \
                            EDUtilsUnit.getSIValue(imageParameters.get_array_element_size_2())))
        xsDataInputSPDCake.setPixelSizeX(imageParameters.get_array_element_size_1())
                            #imageParameters.get_diffrn_detector_element_center_1())
        xsDataInputSPDCake.setPixelSizeY(imageParameters.get_array_element_size_2())
                            #imageParameters.get_diffrn_detector_element_center_1())

        xsDataInputSPDCake.setBufferSizeX(XSDataInteger(2048))
        xsDataInputSPDCake.setBufferSizeY(XSDataInteger(2048))
        xsDataInputSPDCake.setStartAzimuth(XSDataAngle(0))
        xsDataInputSPDCake.setStopAzimuth(XSDataAngle(360))
        xsDataInputSPDCake.setStepAzimuth(XSDataAngle(360))
        xsDataInputSPDCake.setOutputDirCake(self.getDataInput().getDestinationDir())
        xsDataInputSPDCake.setDeleteCorImg(XSDataBoolean(True))

        try:
            self.m_edPluginPowderIntegration.setDataInput(xsDataInputSPDCake)
        except Exception, error:
           # This exception handling needs to be rethought, see bug #43.
            errorMessage = EDMessage.ERROR_DATA_HANDLER_02 % ("EDPluginControlDCTPowderIntegrationv1_1.preProcess: Unexpected error in SPD handler: ", error)
            EDVerbose.error(errorMessage)
            self.addErrorMessage(errorMessage)
            raise RuntimeError, errorMessage
예제 #7
0
    def collectionRunItemListToCollectionRun(self, _xsCollectionRunItemList,
                                             _iCollectionRunNumber):
        xsDataCollectionRun = XSDataBestCollectionRun()

        xsItemWedge = EDUtilsTable.getItemFromList(_xsCollectionRunItemList,
                                                   "Wedge")
        if xsItemWedge is not None:
            iWedge = int(xsItemWedge.getValueOf_())
        else:
            iWedge = _iCollectionRunNumber
        xsDataCollectionRun.setCollectionRunNumber(XSDataInteger(iWedge))

        xsItemCrystal = EDUtilsTable.getItemFromList(_xsCollectionRunItemList,
                                                     "Crystal")
        if xsItemCrystal is not None:
            iCrystal = int(xsItemCrystal.getValueOf_())
            xsDataCollectionRun.setCrystalPosition(XSDataInteger(iCrystal))

        xsItemExposureTime = EDUtilsTable.getItemFromList(
            _xsCollectionRunItemList, "exposure_time")
        fExposureTime = float(xsItemExposureTime.getValueOf_())
        xsDataCollectionRun.setExposureTime(XSDataTime(fExposureTime))

        xsItemAction = EDUtilsTable.getItemFromList(_xsCollectionRunItemList,
                                                    "action")
        if (xsItemAction is not None):
            strAction = xsItemAction.getValueOf_()
            xsDataCollectionRun.setAction(XSDataString(strAction))

        xsItemRotationAxisStart = EDUtilsTable.getItemFromList(
            _xsCollectionRunItemList, "phi_start")
        fRotationAxisStart = float(xsItemRotationAxisStart.getValueOf_())
        xsDataCollectionRun.setPhiStart(XSDataAngle(fRotationAxisStart))

        xsNumberOfImages = EDUtilsTable.getItemFromList(
            _xsCollectionRunItemList, "number_of_images")
        iNumberOfImages = int(xsNumberOfImages.getValueOf_())
        xsDataCollectionRun.setNumberOfImages(XSDataInteger(iNumberOfImages))

        xsItemPhiWidth = EDUtilsTable.getItemFromList(_xsCollectionRunItemList,
                                                      "phi_width")
        fPhiWidth = float(xsItemPhiWidth.getValueOf_())
        xsDataCollectionRun.setPhiWidth(XSDataAngle(fPhiWidth))

        xsItemOverlaps = EDUtilsTable.getItemFromList(_xsCollectionRunItemList,
                                                      "overlaps")
        if (xsItemOverlaps is not None):
            strOverlaps = xsItemOverlaps.getValueOf_()
            xsDataCollectionRun.setOverlaps(XSDataString(strOverlaps))

        xsItemTransmission = EDUtilsTable.getItemFromList(
            _xsCollectionRunItemList, "transmission")
        if (xsItemTransmission is not None):
            fTransmission = float(xsItemTransmission.getValueOf_())
            xsDataCollectionRun.setTransmission(XSDataDouble(fTransmission))

        return xsDataCollectionRun
예제 #8
0
 def readIdxrefLp(self, _pathToIdxrefLp, _xsDataResultXDSIndexing=None):
     self.DEBUG("EDPluginXDSIndexingv1_0.readIdxrefLp")
     if _xsDataResultXDSIndexing is None:
         xsDataResultXDSIndexing = XSDataResultXDSIndexing()
     else:
         xsDataResultXDSIndexing = _xsDataResultXDSIndexing
     if os.path.exists(_pathToIdxrefLp):
         xsDataResultXDSIndexing.pathToLogFile = XSDataFile(XSDataString(_pathToIdxrefLp))
         with open(_pathToIdxrefLp) as f:
             listLines = f.readlines()
         indexLine = 0
         doParseParameters = False
         doParseLattice = False
         while (indexLine < len(listLines)):
             if "DIFFRACTION PARAMETERS USED AT START OF INTEGRATION" in listLines[indexLine]:
                 doParseParameters = True
                 doParseLattice = False
             elif "DETERMINATION OF LATTICE CHARACTER AND BRAVAIS LATTICE" in listLines[indexLine]:
                 doParseParameters = False
                 doParseLattice = True
             if doParseParameters:
                 if "MOSAICITY" in listLines[indexLine]:
                     mosaicity = float(listLines[indexLine].split()[-1])
                     xsDataResultXDSIndexing.mosaicity = XSDataAngle(mosaicity)
                 elif "DETECTOR COORDINATES (PIXELS) OF DIRECT BEAM" in listLines[indexLine]:
                     xBeam = float(listLines[indexLine].split()[-2])
                     yBeam = float(listLines[indexLine].split()[-1])
                     xsDataResultXDSIndexing.beamCentreX = XSDataFloat(xBeam)
                     xsDataResultXDSIndexing.beamCentreY = XSDataFloat(yBeam)
                 elif "CRYSTAL TO DETECTOR DISTANCE" in listLines[indexLine]:
                     distance = float(listLines[indexLine].split()[-1])
                     xsDataResultXDSIndexing.distance = XSDataLength(distance)
             elif doParseLattice:
                 if listLines[indexLine].startswith(" * ") and not listLines[indexLine + 1].startswith(" * "):
                     listLine = listLines[indexLine].split()
                     xsDataResultXDSIndexing.latticeCharacter = XSDataInteger(int(listLine[1]))
                     bravaisLattice = listLine[2]
                     xsDataResultXDSIndexing.bravaisLattice = XSDataString(bravaisLattice)
                     spaceGroup = EDUtilsSymmetry.getMinimumSymmetrySpaceGroupFromBravaisLattice(bravaisLattice)
                     xsDataResultXDSIndexing.spaceGroup = XSDataString(spaceGroup)
                     spaceGroupNumber = EDUtilsSymmetry.getITNumberFromSpaceGroupName(spaceGroup)
                     xsDataResultXDSIndexing.spaceGroupNumber = XSDataInteger(spaceGroupNumber)
                     xsDataResultXDSIndexing.qualityOfFit = XSDataFloat(float(listLine[3]))
                     xsDataXDSCell = XSDataXDSCell()
                     xsDataXDSCell.length_a = XSDataLength(float(listLine[4]))
                     xsDataXDSCell.length_b = XSDataLength(float(listLine[5]))
                     xsDataXDSCell.length_c = XSDataLength(float(listLine[6]))
                     xsDataXDSCell.angle_alpha = XSDataAngle(float(listLine[7]))
                     xsDataXDSCell.angle_beta = XSDataAngle(float(listLine[8]))
                     xsDataXDSCell.angle_gamma = XSDataAngle(float(listLine[9]))
                     xsDataResultXDSIndexing.unitCell = xsDataXDSCell
             indexLine += 1
     return xsDataResultXDSIndexing
    def parsePointlessOutput(self, _outputFile):

        sgre = re.compile(
            """ \* Space group = '(?P<sgstr>.*)' \(number\s+(?P<sgnumber>\d+)\)"""
        )

        sgnumber = sgstr = None

        res = XSDataPointlessOut()
        status = XSDataStatus()
        status.isSuccess = XSDataBoolean(False)
        if os.path.exists(_outputFile):
            res.status = status

            strLog = EDUtilsFile.readFile(_outputFile)
            if strLog is not None:
                # we'll apply the regexp to the whole file contents which
                # hopefully won't be that long.
                m = sgre.search(strLog)
                if m is not None:
                    d = m.groupdict()
                    sgnumber = d['sgnumber']
                    sgstr = d['sgstr']

                    res.sgnumber = XSDataInteger(sgnumber)
                    res.sgstr = XSDataString(sgstr)
                    status.isSuccess = XSDataBoolean(True)
                    # Search first for unit cell after the Laue group...
                    unitCellRe = re.compile(
                        """  Laue group confidence.+\\n\\n\s+Unit cell:(.+)""")
                    m2 = unitCellRe.search(strLog)
                    if m2 is None:
                        # Then search it from the end...
                        unitCellRe = re.compile(
                            """ \* Cell Dimensions : \(obsolete \- refer to dataset cell dimensions above\)\\n\\n(.+)"""
                        )
                        m2 = unitCellRe.search(strLog)
                    if m2 is not None:
                        listCell = m2.groups()[0].split()
                        xsDataCCP4Cell = XSDataCCP4Cell()
                        xsDataCCP4Cell.length_a = XSDataLength(listCell[0])
                        xsDataCCP4Cell.length_b = XSDataLength(listCell[1])
                        xsDataCCP4Cell.length_c = XSDataLength(listCell[2])
                        xsDataCCP4Cell.angle_alpha = XSDataAngle(listCell[3])
                        xsDataCCP4Cell.angle_beta = XSDataAngle(listCell[4])
                        xsDataCCP4Cell.angle_gamma = XSDataAngle(listCell[5])
                        res.cell = xsDataCCP4Cell
        return res
예제 #10
0
	def buildChildren(self, child_, nodeName_):
		if child_.nodeType == Node.ELEMENT_NODE and \
			nodeName_ == 'beamCentreX':
			obj_ = XSDataLength()
			obj_.build(child_)
			self.setBeamCentreX(obj_)
		elif child_.nodeType == Node.ELEMENT_NODE and \
			nodeName_ == 'beamCentreY':
			obj_ = XSDataLength()
			obj_.build(child_)
			self.setBeamCentreY(obj_)
		elif child_.nodeType == Node.ELEMENT_NODE and \
			nodeName_ == 'distance':
			obj_ = XSDataLength()
			obj_.build(child_)
			self.setDistance(obj_)
		elif child_.nodeType == Node.ELEMENT_NODE and \
			nodeName_ == 'mosaicity':
			obj_ = XSDataAngle()
			obj_.build(child_)
			self.setMosaicity(obj_)
		elif child_.nodeType == Node.ELEMENT_NODE and \
			nodeName_ == 'selectedSolutionNumber':
			obj_ = XSDataInteger()
			obj_.build(child_)
			self.setSelectedSolutionNumber(obj_)
		elif child_.nodeType == Node.ELEMENT_NODE and \
			nodeName_ == 'labelitScreenSolution':
			obj_ = XSDataLabelitScreenSolution()
			obj_.build(child_)
			self.labelitScreenSolution.append(obj_)
		XSData.buildChildren(self, child_, nodeName_)
예제 #11
0
 def mergeTwoSubWedgesAdjascentInRotationAxis(self, _subWedge1, _subWedge2):
     """
     This method takes as input two sub wedges and merges them to an unique subwedge, if possible,
     and returns the resulting merged sub wedge. If the merge is not possible a None is returned.
     """
     EDVerbose.DEBUG(
         "EDPluginSubWedgeMergev1_1.mergeTwoSubWedgesAdjascentInRotationAxis"
     )
     xsDataSubWedgeMerged = None
     # First check that the two sub wedges have identical experimental conditions
     if (self.isSameExperimentalConditionInSubWedge(_subWedge1,
                                                    _subWedge2)):
         # Check if sub wedges are adjascent:
         dRoationAxisEnd1 = _subWedge1.getExperimentalCondition(
         ).getGoniostat().getRotationAxisEnd().getValue()
         dRoationAxisStart2 = _subWedge2.getExperimentalCondition(
         ).getGoniostat().getRotationAxisStart().getValue()
         #print dRoationAxisEnd1, dRoationAxisStart2
         if (self.compareTwoValues(dRoationAxisEnd1, dRoationAxisStart2,
                                   0.001)):
             # Same sub wedge! Let's merge them
             xsDataSubWedgeMerged = XSDataSubWedge.parseString(
                 _subWedge1.marshal())
             xsDataSubWedge2 = XSDataSubWedge.parseString(
                 _subWedge2.marshal())
             dRoationAxisEnd2 = xsDataSubWedge2.getExperimentalCondition(
             ).getGoniostat().getRotationAxisEnd().getValue()
             xsDataSubWedgeMerged.getExperimentalCondition().getGoniostat(
             ).setRotationAxisEnd(XSDataAngle(dRoationAxisEnd2))
             for xsDataImage in xsDataSubWedge2.getImage():
                 xsDataSubWedgeMerged.addImage(xsDataImage)
     return xsDataSubWedgeMerged
예제 #12
0
    def testDefaultChemicalComposition(self):
        edPluginStrategy = self.createPlugin()

        xsDataSampleCrystalMM = XSDataSampleCrystalMM()
        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)
        xsDataSampleCrystalMM.setCrystal(xsDataCrystal)
        inumOperators = 4

        xsDataSample2 = edPluginStrategy.getDefaultChemicalComposition(xsDataSampleCrystalMM, inumOperators)
        pyStrChainType = xsDataSample2.getStructure().getChain()[0].getType()
        EDAssert.equal("protein", pyStrChainType.getValue())
예제 #13
0
 def buildChildren(self, child_, nodeName_):
     if child_.nodeType == Node.ELEMENT_NODE and \
      nodeName_ == 'mxv1InputCharacterisation':
         obj_ = XSDataInputCharacterisation()
         obj_.build(child_)
         self.setMxv1InputCharacterisation(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
      nodeName_ == 'mxv1ResultCharacterisation_Reference':
         obj_ = XSDataResultCharacterisation()
         obj_.build(child_)
         self.setMxv1ResultCharacterisation_Reference(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
      nodeName_ == 'mxv2DataCollection':
         obj_ = XSDataCollection()
         obj_.build(child_)
         self.setMxv2DataCollection(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
      nodeName_ == 'mxv2DataCollection_Reference':
         obj_ = XSDataCollection()
         obj_.build(child_)
         self.setMxv2DataCollection_Reference(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
      nodeName_ == 'possibleOrientations':
         obj_ = kappa_alignment_response()
         obj_.build(child_)
         self.setPossibleOrientations(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
      nodeName_ == 'omega':
         obj_ = XSDataAngle()
         obj_.build(child_)
         self.setOmega(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
      nodeName_ == 'kappa':
         obj_ = XSDataAngle()
         obj_.build(child_)
         self.setKappa(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
      nodeName_ == 'phi':
         obj_ = XSDataAngle()
         obj_.build(child_)
         self.setPhi(obj_)
     XSDataInputInterface.buildChildren(self, child_, nodeName_)
예제 #14
0
 def unitTestGetSIValue(self):
     """
     test the execution of unitTestGetSIValue static method
     """
     EDVerbose.DEBUG("EDTestCaseEDUtilsUnit.unitTestGetSIValue")
     xsd = XSDataLength(1.5)
     xsd.setUnit(XSDataString("mm"))
     EDAssert.equal(0.0015, EDUtilsUnit.getSIValue(xsd),
                    "Conversion mm to meter")
     xsd = XSDataAngle(90)
     xsd.setUnit(XSDataString("deg"))
     EDAssert.equal(math.pi / 2, EDUtilsUnit.getSIValue(xsd),
                    "Conversion deg to rad")
예제 #15
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
예제 #16
0
    def getReferenceDataMOSFLMNewmat(self):

        xsDataMOSFLMNewmat = XSDataMOSFLMNewmat()

        XSDataMatrixDoubleA = XSDataMatrixDouble()
        XSDataMatrixDoubleA.setM11(-0.00826416)
        XSDataMatrixDoubleA.setM12(0.00885073)
        XSDataMatrixDoubleA.setM13(0.00937013)
        XSDataMatrixDoubleA.setM21(0.00126554)
        XSDataMatrixDoubleA.setM22(0.01251971)
        XSDataMatrixDoubleA.setM23(-0.00845341)
        XSDataMatrixDoubleA.setM31(-0.01484956)
        XSDataMatrixDoubleA.setM32(-0.00385867)
        XSDataMatrixDoubleA.setM33(-0.00593515)
        xsDataMOSFLMNewmat.setAMatrix(XSDataMatrixDoubleA)

        xsDataMOSFLMMissettingsAngles = XSDataMOSFLMMissettingsAngles()
        xsDataMOSFLMMissettingsAngles.setPhix(XSDataAngle(1.000))
        xsDataMOSFLMMissettingsAngles.setPhiy(XSDataAngle(2.000))
        xsDataMOSFLMMissettingsAngles.setPhiz(XSDataAngle(3.000))
        xsDataMOSFLMNewmat.setMissettingAngles(xsDataMOSFLMMissettingsAngles)

        XSDataMatrixDoubleU = XSDataMatrixDouble()
        XSDataMatrixDoubleU.setM11(-0.4849475)
        XSDataMatrixDoubleU.setM12(0.5598049)
        XSDataMatrixDoubleU.setM13(0.6718960)
        XSDataMatrixDoubleU.setM21(0.0742629)
        XSDataMatrixDoubleU.setM22(0.7918670)
        XSDataMatrixDoubleU.setM23(-0.6061614)
        XSDataMatrixDoubleU.setM31(-0.8713845)
        XSDataMatrixDoubleU.setM32(-0.2440595)
        XSDataMatrixDoubleU.setM33(-0.4255866)
        xsDataMOSFLMNewmat.setUMatrix(XSDataMatrixDoubleU)

        xsDataCellRefined = XSDataCell()
        xsDataCellRefined.setLength_a(XSDataLength(54.8079))
        xsDataCellRefined.setLength_b(XSDataLength(59.0751))
        xsDataCellRefined.setLength_c(XSDataLength(66.9736))
        xsDataCellRefined.setAngle_alpha(XSDataAngle(91.0000))
        xsDataCellRefined.setAngle_beta(XSDataAngle(92.0000))
        xsDataCellRefined.setAngle_gamma(XSDataAngle(93.0000))
        xsDataMOSFLMNewmat.setRefinedCell(xsDataCellRefined)

        return xsDataMOSFLMNewmat
예제 #17
0
    def setup(self, _listInput=[], _mode="offline"):
        """Configure the various options"""

        bOK = False
        if _listInput == []:
            _listInput = [os.getcwd()]
        while not bOK:
            strtmp = raw_input(
                "What are the input directories (mandatory, space separated) %s: "
                % _listInput).strip()
            if len(strtmp) > 0:
                bAllExists = True
                lstTemp = shlex.split(strtmp)
                for oneDir in shlex.split(strtmp):
                    if not os.path.exists(oneDir):
                        EDVerbose.screen("No such file or directory: %s" %
                                         oneDir)
                        bAllExists = False
                if bAllExists is True:
                    self.listInput = lstTemp
                    bOK = True
            else:
                self.listInput = _listInput
                bOK = True
        bOK = False
        while not bOK:
            strtmp = raw_input(
                "What is operation mode [offline|online|all] (mandatory: %s): "
                % _mode).strip().lower()
            if len(strtmp) > 0:
                bOK = True
                if strtmp == "offline":
                    self.bNewerOnly = False
                    self.strMode = "OffLine"
                elif strtmp == "online":
                    self.bNewerOnly = True
                    self.strMode = "dirwatch"
                elif strtmp == "all":
                    self.bNewerOnly = False
                    self.strMode = "dirwatch"
                else:
                    bOK = False

        bOK = False
        while not bOK:
            strtmp = raw_input(
                "What is the destination directory (mandatory): ").strip()
            if os.path.isdir(strtmp):
                self.destinationDirectory = XSDataFile()
                self.destinationDirectory.setPath(
                    XSDataString(os.path.abspath(strtmp)))
                bOK = True

        bOK = False
        while not bOK:
            strtmp = raw_input(
                "What is the sinogram filename prefix  (mandatory): ").strip()
            if strtmp != "":
                self.sinogramFileNamePrefix = XSDataString(strtmp)
                bOK = True

        bOK = False
        while not bOK:
            strtmp = raw_input(
                "What is the powder diffraction subdirectory  (mandatory): "
            ).strip()
            if strtmp != "":
                self.powderDiffractionSubdirectory = XSDataString(strtmp)
                bOK = True

        strtmp = raw_input(
            "What is the powder diffraction output format (CHI or CIF, if any ): "
        ).strip().lower()
        if strtmp.find("cif") >= 0:
            self.powderDiffractionFormat = XSDataString("cif")
        elif strtmp.find("chi") >= 0:
            self.powderDiffractionFormat = XSDataString("chi")

        strtmp = raw_input("Process all files ending with: ").strip()
        if len(strtmp) > 0:
            for oneExt in shlex.split(strtmp):
                self.listExtensions.append(oneExt)

        strtmp = raw_input("Exclude all files starting with: ").strip()
        if len(strtmp) > 0:
            for oneExt in shlex.split(strtmp):
                self.listExcludedPrefix.append(oneExt)

        strtmp = raw_input(
            "Do you want to over-ride metadata from the headers [y|N]: "
        ).strip().lower()
        if len(strtmp) > 0 and strtmp[0] == "y":

            strtmp = raw_input("What is the flat field image: ").strip()
            if os.path.isfile(strtmp):
                if self.forceImage is None:
                    self.forceImage = XSDataDiffractionCTImage()
                flatFieldImage = XSDataFile()
                flatFieldImage.setPath(XSDataString(os.path.abspath(strtmp)))
                self.forceImage.set_file_correction_image_flat_field(
                    flatFieldImage)

            strtmp = raw_input("What is the dark current image: ").strip()
            if os.path.isfile(strtmp):
                if self.forceImage is None:
                    self.forceImage = XSDataDiffractionCTImage()
                darkCurrentImage = XSDataFile()
                darkCurrentImage.setPath(XSDataString(os.path.abspath(strtmp)))
                self.forceImage.set_file_correction_image_dark_current(
                    darkCurrentImage)

            strtmp = raw_input("What is the mask file: ").strip()
            if os.path.isfile(strtmp):
                if self.forceImage is None:
                    self.forceImage = XSDataDiffractionCTImage()
                maskFile = XSDataFile()
                maskFile.setPath(XSDataString(strtmp))
                self.forceImage.set_file_correction_image_mask(maskFile)

            strtmp = raw_input("What is the spline file: ").strip()
            if os.path.isfile(strtmp):
                if self.forceImage is None:
                    self.forceImage = XSDataDiffractionCTImage()
                splineFile = XSDataFile()
                splineFile.setPath(XSDataString(os.path.abspath(strtmp)))
                self.forceImage.set_file_correction_spline_spatial_distortion(
                    splineFile)

            strtmp = raw_input(
                "What is the wavelength (like 0.7 A): ").replace(
                    "(", "").replace(")", "").strip()
            w = strtmp.split()
            if len(w) > 0:
                try:
                    f = float(w[0])
                except ValueError:
                    print("unable to understand what you said, skipping")
                else:
                    wavelength = XSDataWavelength()
                    wavelength.setValue(f)
                    if len(w) == 2:
                        wavelength.setUnit(XSDataString(w[1]))
                    if self.forceInstrument is None:
                        self.forceInstrument = XSDataDiffractionCTInstrument()
                    self.forceInstrument.set_diffrn_radiation_wavelength(
                        wavelength)

            strtmp = raw_input(
                "What is the distance between the sample and the detector along the beam: "
            ).replace("(", "").replace(")", "").strip()
            w = strtmp.split()
            if len(w) > 0:
                try:
                    f = float(w[0])
                except ValueError:
                    print("unable to understand what you said, skipping")
                else:
                    distance = XSDataLength()
                    distance.setValue(f)
                    if len(w) == 2:
                        distance.setUnit(XSDataString(w[1]))
                    if self.forceInstrument is None:
                        self.forceInstrument = XSDataDiffractionCTInstrument()
                    self.forceInstrument.set_pd_instr_dist_spec_detc(distance)

            strtmp = raw_input(
                "What is the pixel size (like 52.8 um 53.2 um): ").replace(
                    "(", "").replace(")", "").strip()
            w = strtmp.split()
            if len(w) > 0:
                xsdata1 = None
                xsdata2 = None
                if len(w) == 4:
                    try:
                        f1 = float(w[0])
                        f2 = float(w[2])
                    except ValueError:
                        print "Unable to convert to float !!! skipping"
                    else:
                        xsdata1 = XSDataLength()
                        xsdata1.setValue(f1)
                        xsdata1.setUnit(XSDataString(w[1]))
                        xsdata2 = XSDataLength()
                        xsdata2.setValue(f2)
                        xsdata2.setUnit(XSDataString(w[3]))
                elif len(w) == 2:
                    try:
                        f1 = float(w[0])
                        f2 = float(w[1])
                    except ValueError:
                        print "Unable to convert to float !!! skipping"
                    else:
                        xsdata1 = XSDataLength()
                        xsdata1.setValue(f1)
                        xsdata2 = XSDataLength()
                        xsdata2.setValue(f2)
                else:
                    print("unable to understand what you said, skipping")
                if (xsdata1 is not None) and (xsdata2 is not None):
                    if self.forceImage is None:
                        self.forceImage = XSDataDiffractionCTImage()
                    self.forceImage.set_array_element_size_1(xsdata1)
                    self.forceImage.set_array_element_size_2(xsdata2)

            strtmp = raw_input(
                "What is the beam center in distance, not pixels (like 53.5 mm 48.2 mm): "
            ).strip().replace("(", "").replace(")", "").strip()
            w = strtmp.split()
            if len(w) > 0:
                xsdata1 = None
                xsdata2 = None
                if len(w) == 4:
                    try:
                        f1 = float(w[0])
                        f2 = float(w[2])
                    except ValueError:
                        print "Unable to convert to float !!! skipping"
                    else:
                        xsdata1 = XSDataLength()
                        xsdata1.setValue(f1)
                        xsdata1.setUnit(XSDataString(w[1]))
                        xsdata2 = XSDataLength()
                        xsdata2.setValue(f2)
                        xsdata2.setUnit(XSDataString(w[3]))
                elif len(w) == 2:
                    try:
                        f1 = float(w[0])
                        f2 = float(w[1])
                    except ValueError, IndexError:
                        print "Unable to convert to float !!! skipping"
                    else:
                        xsdata1 = XSDataLength()
                        xsdata1.setValue(f1)
                        xsdata2 = XSDataLength()
                        xsdata2.setValue(f2)
                else:
                    print("unable to understand what you said, skipping")
                if (xsdata1 is not None) and (xsdata2 is not None):
                    if self.forceImage is None:
                        self.forceImage = XSDataDiffractionCTImage()
                    self.forceImage.set_diffrn_detector_element_center_1(
                        xsdata1)
                    self.forceImage.set_diffrn_detector_element_center_2(
                        xsdata2)

            strtmp = raw_input("What is the detector tilt angle: ").strip()
            tiltAngle = None
            try:
                tiltAngle = XSDataAngle(float(strtmp))
            except ValueError:
                print("unable to understand what you said, skipping")
            else:
                if self.forceImage is None:
                    self.forceImage = XSDataDiffractionCTImage()
                self.forceImage.set_pd_instr_special_details_tilt_angle(
                    tiltAngle)

            strtmp = raw_input("What is the tilt plan rotation: ").strip()
            tiltRotation = None
            try:
                tiltRotation = XSDataAngle(float(strtmp))
            except ValueError:
                print("unable to understand what you said, skipping")
            else:
                if self.forceImage is None:
                    self.forceImage = XSDataDiffractionCTImage()
                self.forceImage.set_pd_instr_special_details_tilt_rotation(
                    tiltRotation)

            strtmp = raw_input(
                "What is the number of fast motor steps (you will have n+1 points): "
            ).strip()
            try:
                self.fastMotorSteps = int(strtmp)
            except ValueError:
                fastMotorSteps = None
            else:
                if self.forceInstrument is None:
                    self.forceInstrument = XSDataDiffractionCTInstrument()
                self.forceInstrument.set_tomo_spec_displ_x_max(
                    XSDataLength(self.fastMotorSteps))
                self.forceInstrument.set_tomo_spec_displ_x_min(XSDataLength(0))
                self.forceInstrument.set_tomo_spec_displ_x_inc(XSDataLength(1))
                self.forceInstrument.set_tomo_scan_type(XSDataString("flat"))

            strtmp = raw_input(
                "What is the number of slow motor steps (you will have n+1 points): "
            ).strip()
            try:
                self.slowMotorSteps = int(strtmp)
            except ValueError:
                self.slowMotorSteps = None
            else:
                if self.forceInstrument is None:
                    self.forceInstrument = XSDataDiffractionCTInstrument()
                self.forceInstrument.set_tomo_scan_ampl(
                    XSDataLength(self.slowMotorSteps))
                self.forceInstrument.set_tomo_spec_displ_rotation_inc(
                    XSDataLength(1))
                self.forceInstrument.set_tomo_scan_type(XSDataString("flat"))

            strtmp = raw_input(
                "What is the index offset of your images: ").strip()
            try:
                self.indexOffset = int(strtmp)
            except ValueError:
                print("unable to understand what you said, skipping")
예제 #18
0
 def createInputCharacterisationFromSubWedges(self):
     self.DEBUG(
         "EDPluginControlInterfacev1_3.createInputCharacterisationFromSubWedges"
     )
     xsDataResultSubWedgeAssemble = self.edPluginControlSubWedgeAssemble.getDataOutput(
     )
     self.xsDataInputCharacterisation = XSDataInputCharacterisation()
     xsDataCollection = XSDataCollection()
     # Default exposure time (for the moment, this value should be
     # possible to read from the command line)
     if self.xsDataDiffractionPlan is None:
         self.xsDataDiffractionPlan = XSDataDiffractionPlan()
     if (not xsDataResultSubWedgeAssemble is None):
         pyListSubWedge = xsDataResultSubWedgeAssemble.getSubWedge()
         xsDataCollection.setSubWedge(pyListSubWedge)
         for xsDataSubWedge in pyListSubWedge:
             if (self.strComplexity is not None):
                 self.xsDataDiffractionPlan.setComplexity(
                     XSDataString(self.strComplexity))
             if (self.fFlux is not None):
                 xsDataSubWedge.getExperimentalCondition().getBeam(
                 ).setFlux(XSDataFlux(self.fFlux))
             if (self.fBeamSizeX is not None) and (self.fBeamSizeY
                                                   is not None):
                 xsDataSize = XSDataSize()
                 xsDataSize.setX(XSDataLength(self.fBeamSizeX))
                 xsDataSize.setY(XSDataLength(self.fBeamSizeY))
                 xsDataSubWedge.getExperimentalCondition().getBeam(
                 ).setSize(xsDataSize)
             if (self.fApertureSize is not None):
                 xsDataSubWedge.getExperimentalCondition().getBeam(
                 ).setApertureSize(XSDataLength(self.fApertureSize))
             if (self.fBeamPosX is not None):
                 xsDataSubWedge.getExperimentalCondition().getDetector(
                 ).setBeamPositionX(XSDataLength(self.fBeamPosX))
             if (self.fBeamPosY is not None):
                 xsDataSubWedge.getExperimentalCondition().getDetector(
                 ).setBeamPositionY(XSDataLength(self.fBeamPosY))
             if (self.fMinExposureTimePerImage is not None):
                 xsDataSubWedge.getExperimentalCondition().getBeam(
                 ).setMinExposureTimePerImage(
                     XSDataTime(self.fMinExposureTimePerImage))
             if (self.fTransmission is not None):
                 xsDataSubWedge.getExperimentalCondition().getBeam(
                 ).setTransmission(XSDataDouble(self.fTransmission))
             if (self.fWavelength is not None):
                 xsDataSubWedge.getExperimentalCondition().getBeam(
                 ).setWavelength(XSDataWavelength(self.fWavelength))
             if self.fMinOscillationWidth != None:
                 xsDataSubWedge.getExperimentalCondition().getGoniostat(
                 ).setMinOscillationWidth(
                     XSDataAngle(self.fMinOscillationWidth))
             if self.fMaxOscillationSpeed != None:
                 xsDataSubWedge.getExperimentalCondition().getGoniostat(
                 ).setMaxOscillationSpeed(
                     XSDataAngularSpeed(self.fMaxOscillationSpeed))
     if (self.strForcedSpaceGroup is not None):
         self.xsDataDiffractionPlan.setForcedSpaceGroup(
             XSDataString(self.strForcedSpaceGroup))
     self.xsDataDiffractionPlan.setAnomalousData(
         XSDataBoolean(self.bAnomalousData))
     self.xsDataDiffractionPlan.setMaxExposureTimePerDataCollection(
         XSDataTime(self.fMaxExposureTimePerDataCollection))
     if (self.strStrategyOption is not None):
         self.xsDataDiffractionPlan.setStrategyOption(
             XSDataString(self.strStrategyOption))
     xsDataCollection.setDiffractionPlan(self.xsDataDiffractionPlan)
     if self.xsDataSample is not None:
         xsDataCollection.setSample(
             XSDataSampleCrystalMM.parseString(self.xsDataSample.marshal()))
     self.xsDataInputCharacterisation.setDataCollection(xsDataCollection)
    def generateXSDataMOSFLMInputIndexing(_xsDataIndexingInput):
        """
        Translation from XSDataIndexingInput to XSDataMOSFLMInputIndexing.
        """
        EDFactoryPluginStatic.loadModule("XSDataMOSFLMv10")
        from XSDataMOSFLMv10 import XSDataMOSFLMInputIndexing
        from XSDataMOSFLMv10 import XSDataMOSFLMBeamPosition
        from XSDataMOSFLMv10 import XSDataMOSFLMImage

        EDVerbose.DEBUG(
            "EDHandlerXSDataMOSFLMv10.generateXSDataMOSFLMInputIndexing")

        xsDataCollection = _xsDataIndexingInput.getDataCollection()
        xsDataExperimentalCondition = _xsDataIndexingInput.getExperimentalCondition(
        )
        xsDataCrystal = _xsDataIndexingInput.getCrystal()
        xsDataSubWedgeList = xsDataCollection.getSubWedge()
        xsDataMOSFLMInputIndexing = XSDataMOSFLMInputIndexing()

        if (xsDataExperimentalCondition is None):
            xsDataExperimentalCondition = xsDataSubWedgeList[
                0].getExperimentalCondition()

        xsDataBeam = xsDataExperimentalCondition.getBeam()
        xsDataDetector = xsDataExperimentalCondition.getDetector()
        xsDataGoniostat = xsDataExperimentalCondition.getGoniostat()

        dWavelength = xsDataBeam.getWavelength().getValue()
        dDistance = xsDataDetector.getDistance().getValue()
        dBeamPositionX = xsDataDetector.getBeamPositionX().getValue()
        dBeamPositionY = xsDataDetector.getBeamPositionY().getValue()

        xsDataMOSFLMBeamPosition = XSDataMOSFLMBeamPosition()
        xsDataMOSFLMBeamPosition.setX(XSDataLength(dBeamPositionX))
        xsDataMOSFLMBeamPosition.setY(XSDataLength(dBeamPositionY))
        xsDataMOSFLMInputIndexing.setBeam(xsDataMOSFLMBeamPosition)

        xsDataMOSFLMDetector = EDHandlerXSDataMOSFLMv10.getXSDataMOSFLMDetector(
            xsDataDetector)
        xsDataMOSFLMInputIndexing.setDetector(xsDataMOSFLMDetector)

        xsDataMOSFLMInputIndexing.setWavelength(XSDataWavelength(dWavelength))
        xsDataMOSFLMInputIndexing.setDistance(XSDataLength(dDistance))

        xsDataSubWedgeFirst = xsDataSubWedgeList[0]
        xsDataImageFirst = xsDataSubWedgeFirst.getImage()[0]
        strPath = xsDataImageFirst.getPath().getValue()
        strFileName = os.path.basename(strPath)
        strDirectory = os.path.dirname(strPath)

        if xsDataDetector.type.value == "eiger2_16m":
            strMOSFLMTemplate = EDUtilsImage.getH5MasterTemplate(
                strFileName, 1)
        else:
            strMOSFLMTemplate = EDUtilsImage.getTemplate(strFileName, "#")
        xsDataMOSFLMInputIndexing.setTemplate(XSDataString(strMOSFLMTemplate))
        xsDataMOSFLMInputIndexing.setDirectory(XSDataString(strDirectory))

        if (xsDataCrystal is not None):
            xsDataSpaceGroup = xsDataCrystal.getSpaceGroup()
            if (xsDataSpaceGroup is not None):
                xsDataStringName = xsDataSpaceGroup.getName()
                if (xsDataStringName is not None):
                    xsDataMOSFLMInputIndexing.setSymmetry(
                        XSDataString(xsDataStringName.getValue()))

        # Loop through the list of sub wedges

        for xsDataSubWedge in xsDataSubWedgeList:

            xsDataImageList = xsDataSubWedge.getImage()
            xsDataGoniostat = xsDataSubWedge.getExperimentalCondition(
            ).getGoniostat()
            fGonioStatOscillationStart = xsDataGoniostat.getRotationAxisStart(
            ).getValue()
            fGonioStatOscillationRange = xsDataGoniostat.getOscillationWidth(
            ).getValue()

            # 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

            # Loop through the list of images

            for xsDataImage in xsDataImageList:
                # Create the MOSFLM image object

                xsDataMOSFLMImage = XSDataMOSFLMImage()

                iImageNumber = xsDataImage.getNumber().getValue()
                xsDataMOSFLMImage.setNumber(XSDataInteger(iImageNumber))

                fImageOscillationStart = fGonioStatOscillationStart + (
                    iImageNumber -
                    iLowestImageNumber) * fGonioStatOscillationRange
                xsDataMOSFLMImage.setRotationAxisStart(
                    XSDataAngle(fImageOscillationStart))
                xsDataMOSFLMImage.setRotationAxisEnd(
                    XSDataAngle(fImageOscillationStart +
                                fGonioStatOscillationRange))

                xsDataMOSFLMInputIndexing.addImage(xsDataMOSFLMImage)

        return xsDataMOSFLMInputIndexing
    def generateXSDataMOSFLMInputGeneratePrediction(
            xsDataGeneratePredictionInput):
        """
        Translation from XSDataGeneratePredictionInput to XSDataMOSFLMInputGeneratePrediction.
        """
        EDVerbose.DEBUG(
            "EDHandlerXSDataMOSFLMv10.generateXSDataMOSFLMInputGeneratePrediction"
        )
        EDFactoryPluginStatic.loadModule("XSDataMOSFLMv10")
        from XSDataMOSFLMv10 import XSDataMOSFLMBeamPosition
        from XSDataMOSFLMv10 import XSDataMOSFLMImage
        from XSDataMOSFLMv10 import XSDataMOSFLMNewmat
        from XSDataMOSFLMv10 import XSDataMOSFLMMissettingsAngles
        from XSDataMOSFLMv10 import XSDataMOSFLMInputGeneratePrediction

        xsDataIndexingSolutionSelected = xsDataGeneratePredictionInput.getSelectedIndexingSolution(
        )

        xsDataCollection = xsDataGeneratePredictionInput.getDataCollection()
        xsDataSubWedge = xsDataCollection.getSubWedge()[0]
        xsDataImageList = xsDataSubWedge.getImage()
        xsDataImageFirst = xsDataImageList[0]

        xsDataCrystal = xsDataIndexingSolutionSelected.getCrystal()
        xsDataOrientation = xsDataIndexingSolutionSelected.getOrientation()
        xsDataExperimentalCondition = xsDataIndexingSolutionSelected.getExperimentalConditionRefined(
        )
        xsDataDetector = xsDataExperimentalCondition.getDetector()
        xsDataBeam = xsDataExperimentalCondition.getBeam()
        xsDataMatrixA = xsDataOrientation.getMatrixA()
        xsDataMatrixU = xsDataOrientation.getMatrixU()
        xsDataCell = xsDataCrystal.getCell()

        xsDataMOSFLMInputGeneratePrediction = XSDataMOSFLMInputGeneratePrediction(
        )
        xsDataMOSFLMNewmat = XSDataMOSFLMNewmat()
        xsDataMOSFLMNewmat.setRefinedCell(xsDataCell)
        xsDataMOSFLMNewmat.setAMatrix(xsDataMatrixA)
        xsDataMOSFLMNewmat.setUMatrix(xsDataMatrixU)
        xsDataMOSFLMInputGeneratePrediction.setMatrix(xsDataMOSFLMNewmat)

        xsDataMOSFLMMissettingsAngles = XSDataMOSFLMMissettingsAngles()
        xsDataMOSFLMMissettingsAngles.setPhix(XSDataAngle(0.0))
        xsDataMOSFLMMissettingsAngles.setPhiy(XSDataAngle(0.0))
        xsDataMOSFLMMissettingsAngles.setPhiz(XSDataAngle(0.0))
        xsDataMOSFLMNewmat.setMissettingAngles(xsDataMOSFLMMissettingsAngles)

        xsDataMOSFLMBeamPosition = XSDataMOSFLMBeamPosition()
        xsDataMOSFLMBeamPosition.setX(xsDataDetector.getBeamPositionX())
        xsDataMOSFLMBeamPosition.setY(xsDataDetector.getBeamPositionY())
        xsDataMOSFLMInputGeneratePrediction.setBeam(xsDataMOSFLMBeamPosition)

        xsDataMOSFLMInputGeneratePrediction.setMosaicity(
            xsDataCrystal.getMosaicity())
        xsDataMOSFLMInputGeneratePrediction.setSymmetry(
            xsDataCrystal.getSpaceGroup().getName())

        strPathFirst = xsDataImageFirst.getPath().getValue()
        strDirectoryFirst = os.path.dirname(strPathFirst)
        strFilenameFirst = os.path.basename(strPathFirst)

        xsDataMOSFLMInputGeneratePrediction.setWavelength(
            xsDataBeam.getWavelength())
        xsDataMOSFLMInputGeneratePrediction.setDistance(
            xsDataDetector.getDistance())
        xsDataMOSFLMInputGeneratePrediction.setDirectory(
            XSDataString(strDirectoryFirst))
        xsDataMOSFLMDetector = EDHandlerXSDataMOSFLMv10.getXSDataMOSFLMDetector(
            xsDataDetector)
        xsDataMOSFLMInputGeneratePrediction.setDetector(xsDataMOSFLMDetector)

        # The MOSFLM plugin can only handle one image

        xsDataImage = xsDataSubWedge.getImage()[0]
        xsDataGoniostat = xsDataSubWedge.getExperimentalCondition(
        ).getGoniostat()

        iImageNumber = xsDataImage.getNumber().getValue()

        if xsDataDetector.type.value == "eiger2_16m":
            strMOSFLMTemplate = EDUtilsImage.getH5MasterTemplate(
                strFilenameFirst, iImageNumber)
        else:
            strMOSFLMTemplate = EDUtilsImage.getTemplate(strFilenameFirst, "#")
        xsDataMOSFLMInputGeneratePrediction.setTemplate(
            XSDataString(strMOSFLMTemplate))

        xsDataMOSFLMImage = XSDataMOSFLMImage()
        xsDataMOSFLMImage.setNumber(XSDataInteger(iImageNumber))

        fOscillationStart = xsDataGoniostat.getRotationAxisStart().getValue()
        fOscillationRange = xsDataGoniostat.getOscillationWidth().getValue()
        xsDataMOSFLMImage.setRotationAxisStart(XSDataAngle(fOscillationStart))
        xsDataMOSFLMImage.setRotationAxisEnd(
            XSDataAngle(fOscillationStart + fOscillationRange))

        xsDataMOSFLMInputGeneratePrediction.setImage(xsDataMOSFLMImage)

        return xsDataMOSFLMInputGeneratePrediction
    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
예제 #22
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 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())
예제 #24
0
    def populateXSDataInputSPDCake(self, _inputDict=None):
        self.DEBUG("EDPluginControlID11v1_0.populateXSDataInputSPDCake")
        xsDataInputSPDCake = XSDataInputSPDCake()
        if isinstance(_inputDict, dict):
            self.__dictID11 = _inputDict

    # Angle of tilt
        if "ANGLE OF TILT" in self.__dictID11:
            xsDataTilt = XSDataAngle()
            xsDataTilt.setValue(float(self.__dictID11["ANGLE OF TILT"]))
            xsDataTilt.setUnit(XSDataString("deg"))
            xsDataInputSPDCake.setAngleOfTilt(xsDataTilt)

        if "TILT ROTATION" in self.__dictID11:
            xsDataTiltRot = XSDataAngle()
            xsDataTiltRot.setValue(float(self.__dictID11["TILT ROTATION"]))
            xsDataTiltRot.setUnit(XSDataString("deg"))
            xsDataInputSPDCake.setTiltRotation(xsDataTiltRot)

        if "X-PIXEL SIZE" in self.__dictID11:
            xsDataXPixel = XSDataLength()
            xsDataXPixel.setValue(float(self.__dictID11["Y-PIXEL SIZE"]))
            xsDataXPixel.setUnit(XSDataString("micron"))
            xsDataInputSPDCake.setPixelSizeX(xsDataXPixel)

        if "Y-PIXEL SIZE" in self.__dictID11:
            xsDataYPixel = XSDataLength()
            xsDataYPixel.setValue(float(self.__dictID11["Y-PIXEL SIZE"]))
            xsDataYPixel.setUnit(XSDataString("micron"))
            xsDataInputSPDCake.setPixelSizeY(xsDataYPixel)

        if "DISTANCE" in self.__dictID11:
            xsDataDistance = XSDataLength()
            xsDataDistance.setValue(float(self.__dictID11["DISTANCE"]))
            xsDataDistance.setUnit(XSDataString("mm"))
            xsDataInputSPDCake.setSampleToDetectorDistance(xsDataDistance)

        if "WAVELENGTH" in self.__dictID11:
            xsDataWaweLength = XSDataWavelength()
            xsDataWaweLength.setValue(float(self.__dictID11["WAVELENGTH"]))
            xsDataWaweLength.setUnit(XSDataString("A"))
            xsDataInputSPDCake.setWavelength(xsDataWaweLength)

        if "DIM1_DATA" in self.__dictID11:
            xsDataBufferSizeX = XSDataInteger(int(self.__dictID11["DIM1_DATA"]))
            xsDataInputSPDCake.setBufferSizeX(xsDataBufferSizeX)

        if "DIM2_DATA" in self.__dictID11:
            xsDataBufferSizeY = XSDataInteger(int(self.__dictID11["DIM2_DATA"]))
            xsDataInputSPDCake.setBufferSizeY(xsDataBufferSizeY)

    # Dark current
        if ("DARK CURRENT" in self.__dictID11) and (self.__dictID11["DARK CURRENT"] == "YES") :
            if  ("DC FILE" in self.__dictID11) and os.path.isfile(self.__dictID11["DC FILE"]):
                xsDataFile = XSDataFile()
                xsDataFile.setPath(XSDataString(self.__dictID11["DC FILE"]))
                xsDataInputSPDCake.setDarkCurrentImageFile(xsDataFile)
            else:
                self.warning("Asked for DC Current correction but no DC current file")

        if ("FLAT-FIELD" in self.__dictID11) and (self.__dictID11["FLAT-FIELD"] == "YES"):
            if  ("FF FILE" in self.__dictID11) and os.path.isfile(self.__dictID11["FF FILE"]):
                xsDataFile = XSDataFile()
                xsDataFile.setPath(XSDataString(self.__dictID11["FF FILE"]))
                xsDataInputSPDCake.setFlatFieldImageFile(xsDataFile)
            else:
                self.warning("Asked for FLAT-FIELD correction but no FLAT-FIELD file")

        if ("MASK FILE" in self.__dictID11) and (self.__dictID11["USE MASK"] == "YES") :
            if  ("MASK FILE" in self.__dictID11) and os.path.isfile(self.__dictID11["MASK FILE"]):
                xsDataFile = XSDataFile()
                xsDataFile.setPath(XSDataString(self.__dictID11["MASK FILE"]))
                xsDataInputSPDCake.setMaskFile(xsDataFile)
            else:
                self.warning("Asked for DC Current correction but no DC current file")


        if ("FF SCALE" in self.__dictID11) and (self.__dictID11["FF SCALE"] == "YES"):
            if ("FF MULTIPLIER" in self.__dictID11):
                try:
                    value = float(self.__dictID11["FF MULTIPLIER"])
                except Exception:
                    self.warning("Asked for FF SCALE correction but FF MULTIPLIER provided (%s) in not float !" % (self.__dictID11["FF MULTIPLIER"]))
                else:
                     xsDataInputSPDCake.setIntensityScaleFactor(XSDataDouble(1 / value))
            else:
                self.warning("Asked for FF SCALE correction but no FF MULTIPLIER provided")


        if ("SPATIAL DIS." in self.__dictID11) and (self.__dictID11["SPATIAL DIS."] == "YES"):
            if  ("SD FILE" in self.__dictID11) and  os.path.isfile(self.__dictID11["SD FILE"]):
                xsDataFile = XSDataFile()
                xsDataFile.setPath(XSDataString(self.__dictID11["SD FILE"]))
                xsDataInputSPDCake.setSpatialDistortionFile(xsDataFile)
            else :
                self.warning("Asked for SPATIAL DISTORSION correction but no SPATIAL DISTORSION file")

        if "START AZIMUTH" in self.__dictID11:
            xsDataAzimuthStart = XSDataAngle()
            xsDataAzimuthStart.setValue(float(self.__dictID11["START AZIMUTH"]))
            xsDataAzimuthStart.setUnit(XSDataString("deg"))
            xsDataInputSPDCake.setStartAzimuth(xsDataAzimuthStart)

        if "END AZIMUTH" in self.__dictID11:
            xsDataAzimuthStop = XSDataAngle()
            xsDataAzimuthStop.setValue(float(self.__dictID11["END AZIMUTH"]))
            xsDataAzimuthStop.setUnit(XSDataString("deg"))
            xsDataInputSPDCake.setStopAzimuth(xsDataAzimuthStop)

        if "AZIMUTH BINS" in self.__dictID11:
            xsDataAzimuthStep = XSDataAngle()
            xsDataAzimuthStep.setValue((float(self.__dictID11["END AZIMUTH"]) - float(self.__dictID11["START AZIMUTH"])) /
                                       float(self.__dictID11["AZIMUTH BINS"]))
            xsDataAzimuthStep.setUnit(XSDataString("deg"))
            xsDataInputSPDCake.setStepAzimuth(xsDataAzimuthStep)

        if "INNER RADIUS" in self.__dictID11:
            xsDataInnerRadius = XSDataDouble()
            xsDataInnerRadius.setValue(float(self.__dictID11["INNER RADIUS"]))
            xsDataInputSPDCake.setInnerRadius(xsDataInnerRadius)

        if "OUTER RADIUS" in self.__dictID11:
            xsDataOuterRadius = XSDataDouble()
            xsDataOuterRadius.setValue(float(self.__dictID11["OUTER RADIUS"]))
            xsDataInputSPDCake.setOuterRadius(xsDataOuterRadius)

        if "X-BEAM CENTRE" in self.__dictID11:
            xsDataXBeamCentre = XSDataDouble()
            xsDataXBeamCentre.setValue(float(self.__dictID11["X-BEAM CENTRE"]))
            xsDataInputSPDCake.setBeamCentreInPixelsX(xsDataXBeamCentre)

        if "Y-BEAM CENTRE" in self.__dictID11:
            xsDataYBeamCentre = XSDataDouble()
            xsDataYBeamCentre.setValue(float(self.__dictID11["Y-BEAM CENTRE"]))
            xsDataInputSPDCake.setBeamCentreInPixelsY(xsDataYBeamCentre)

#        if "saving_format" in self.__dictID11:
#            xsSaveFormat = XSDataString()
#            if self.__dictID11["saving_format"] == "SPREAD SHEET":
#                xsSaveFormat.setValue("spr")
#            elif self.__dictID11["saving_format"] == "CIF":
#                xsSaveFormat.setValue("cif")
#            elif self.__dictID11["saving_format"] == "CHIPLOT":
#                xsSaveFormat.setValue("chi")
#            else:
#                xsSaveFormat.setValue("edf")
#            xsDataInputSPDCake.setOutputFileType(xsSaveFormat)

        if "output_dir" in self.__dictID11:
            xsOutputDir = XSDataFile()
            xsOutputDir.setPath(XSDataString(self.__dictID11["output_dir"]))
            xsDataInputSPDCake.setOutputDir(xsOutputDir)

        #Default options to SPD
        xsDataInputSPDCake.setOutputFileType(XSDataString("azim"))
        xsDataInputSPDCake.setDeleteCorImg(XSDataBoolean(not self.isVerboseDebug()))
        xsDataInputSPDCake.setCorrectTiltMask(XSDataBoolean(self.bCorrectMask))
        return xsDataInputSPDCake
예제 #25
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 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 doSuccessReadHeader(self, _edPlugin=None):
        EDVerbose.DEBUG("EDPluginControlDiffractionCTv1_1.doSuccessReadHeader")
        self.retrieveSuccessMessages(_edPlugin, "EDPluginControlDiffractionCTv1_1.doSuccessReadHeader")
        # Translate dictionary to image and instrument objects
        xsDataInputPowderIntegration = XSDataInputPowderIntegration()
        self.xsDataDiffractionCTInstrument = XSDataDiffractionCTInstrument()
        self.xsDataDiffractionCTImage = XSDataDiffractionCTImage()
        xsDataDictionaryHeader = self.edPluginReadHeader.getDataOutput().getDictionary()
        for xsDataKeyValuePair in xsDataDictionaryHeader.getKeyValuePair():
            strKey = str(xsDataKeyValuePair.getKey().getValue())
            lstValue = xsDataKeyValuePair.getValue().getValue().split()
            if len(lstValue) == 2:
                strValue = lstValue[0]
                strUnit = lstValue[1]
            else:
                strValue = xsDataKeyValuePair.getValue().getValue()
                strUnit = None

            if (strKey == "_diffrn_radiation_wavelength"):
                xsd = EDUtilsUnit.toXSD(XSDataWavelength, strValue)
#                if strUnit is None: strUnit = "A"
#                xsd.setUnit(XSDataString(strUnit))
                self.xsDataDiffractionCTInstrument.set_diffrn_radiation_wavelength(xsd)
            elif (strKey == "_pd_instr_dist_spec/detc"):
                xsd = EDUtilsUnit.toXSD(XSDataLength, strValue)
#                if strUnit is None: strUnit = "mm"
#                xsd.setUnit(XSDataString(strUnit))
                self.xsDataDiffractionCTInstrument.set_pd_instr_dist_spec_detc(xsd)
            elif (strKey == "_pd_meas_2theta_range_max"):
                xsd = XSDataAngle(float(strValue))
                if strUnit is None: strUnit = "deg"
                xsd.setUnit(XSDataString(strUnit))
                self.xsDataDiffractionCTInstrument.set_pd_meas_2theta_range_max(xsd)
            elif (strKey == "_pd_meas_2theta_range_min"):
                xsd = XSDataAngle(float(strValue))
                if strUnit is None: strUnit = "deg"
                xsd.setUnit(XSDataString(strUnit))
                self.xsDataDiffractionCTInstrument.set_pd_meas_2theta_range_min(xsd)
            elif (strKey == "_pd_meas_2theta_range_inc"):
                xsd = XSDataAngle(float(strValue))
                if strUnit is None: strUnit = "deg"
                xsd.setUnit(XSDataString(strUnit))
                self.xsDataDiffractionCTInstrument.set_pd_meas_2theta_range_inc(xsd)
            elif (strKey == "_synchrotron_photon-flux"):
                self.xsDataDiffractionCTInstrument.set_synchrotron_photon_flux(XSDataFlux(float(strValue)))
            elif (strKey == "_synchrotron_ring-intensity"):
                self.xsDataDiffractionCTInstrument.set_synchrotron_ring_intensity(XSDataDouble(float(strValue)))
            elif (strKey == "_tomo_scan_ampl"):
                xsd = XSDataAngle(float(strValue))
                if strUnit is None: strUnit = "deg"
                xsd.setUnit(XSDataString(strUnit))
                self.xsDataDiffractionCTInstrument.set_tomo_scan_ampl(xsd)
            elif (strKey == "_tomo_scan_type"):
                self.xsDataDiffractionCTInstrument.set_tomo_scan_type(XSDataString(strValue))
            elif (strKey == "_tomo_spec_displ_rotation"):
                xsd = XSDataAngle(float(strValue))
                if strUnit is None: strUnit = "deg"
                xsd.setUnit(XSDataString(strUnit))
                self.xsDataDiffractionCTInstrument.set_tomo_spec_displ_rotation(xsd)
            elif (strKey == "_tomo_spec_displ_rotation_inc"):
                xsd = XSDataAngle(float(strValue))
                if strUnit is None: strUnit = "deg"
                xsd.setUnit(XSDataString(strUnit))
                self.xsDataDiffractionCTInstrument.set_tomo_spec_displ_rotation_inc(xsd)
            elif (strKey == "_tomo_spec_displ_x"):
                xsd = EDUtilsUnit.toXSD(XSDataLength, strValue)
#                if strUnit is None: strUnit = "mm"
#                xsd.setUnit(XSDataString(strUnit))
                self.xsDataDiffractionCTInstrument.set_tomo_spec_displ_x(xsd)
            elif (strKey == "_tomo_spec_displ_x_inc"):
                xsd = EDUtilsUnit.toXSD(XSDataLength, strValue)
#                if strUnit is None: strUnit = "mm"
#                xsd.setUnit(XSDataString(strUnit))
                self.xsDataDiffractionCTInstrument.set_tomo_spec_displ_x_inc(xsd)
            elif (strKey == "_tomo_spec_displ_x_max"):
                xsd = XSDataLength(float(strValue))
                if strUnit is None: strUnit = "mm"
                xsd.setUnit(XSDataString(strUnit))
                self.xsDataDiffractionCTInstrument.set_tomo_spec_displ_x_max(xsd)
            elif (strKey == "_tomo_spec_displ_x_min"):
                xsd = XSDataLength(float(strValue))
                if strUnit is None: strUnit = "mm"
                xsd.setUnit(XSDataString(strUnit))
                self.xsDataDiffractionCTInstrument.set_tomo_spec_displ_x_min(xsd)
            elif (strKey == "_tomo_spec_displ_z"):
                xsd = XSDataLength(float(strValue))
                if strUnit is None: strUnit = "mm"
                xsd.setUnit(XSDataString(strUnit))
                self.xsDataDiffractionCTInstrument.set_tomo_spec_displ_z(xsd)
            elif (strKey == "_tomo_spec_displ_z_inc"):
                xsd = XSDataLength(float(strValue))
                if strUnit is None: strUnit = "mm"
                xsd.setUnit(XSDataString(strUnit))
                self.xsDataDiffractionCTInstrument.set_tomo_spec_displ_z_inc(xsd)
            elif (strKey == "_tomo_spec_displ_z_max"):
                xsd = XSDataLength(float(strValue))
                if strUnit is None: strUnit = "mm"
                xsd.setUnit(XSDataString(strUnit))
                self.xsDataDiffractionCTInstrument.set_tomo_spec_displ_z_max(xsd)
            elif (strKey == "_tomo_spec_displ_z_min"):
                xsd = XSDataLength(float(strValue))
                if strUnit is None: strUnit = "mm"
                xsd.setUnit(XSDataString(strUnit))
                self.xsDataDiffractionCTInstrument.set_tomo_spec_displ_z_min(xsd)
            elif (strKey == "_pd_instr_special_details_tilt_angle"):
                xsd = XSDataAngle(float(strValue))
                if strUnit is None: strUnit = "deg"
                xsd.setUnit(XSDataString(strUnit))
                self.xsDataDiffractionCTImage.set_pd_instr_special_details_tilt_angle(xsd)
            elif (strKey == "_pd_instr_special_details_tilt_rotation"):
                xsd = XSDataAngle(float(strValue))
                if strUnit is None: strUnit = "deg"
                xsd.setUnit(XSDataString(strUnit))
                self.xsDataDiffractionCTImage.set_pd_instr_special_details_tilt_rotation(xsd)
            elif (strKey == "_array_element_size[1]"):
                xsd = XSDataLength(float(strValue))
                if strUnit is None: strUnit = "m"
                xsd.setUnit(XSDataString(strUnit))
                self.xsDataDiffractionCTImage.set_array_element_size_1(xsd)
            elif (strKey == "_array_element_size[2]"):
                xsd = XSDataLength(float(strValue))
                if strUnit is None: strUnit = "m"
                xsd.setUnit(XSDataString(strUnit))
                self.xsDataDiffractionCTImage.set_array_element_size_2(xsd)
            elif (strKey == "_diffrn_detector_element.center[1]"):
                xsd = XSDataLength(float(strValue))
                if strUnit is None: strUnit = "mm"
                xsd.setUnit(XSDataString(strUnit))
                self.xsDataDiffractionCTImage.set_diffrn_detector_element_center_1(xsd)
            elif (strKey == "_diffrn_detector_element.center[2]"):
                xsd = XSDataLength(float(strValue))
                if strUnit is None: strUnit = "mm"
                xsd.setUnit(XSDataString(strUnit))
                self.xsDataDiffractionCTImage.set_diffrn_detector_element_center_2(xsd)
#            elif strKey.startswith("_pd_sum_2theta_range_max"):
#                if strKey.find("[") > 0:
#                    pyintIndex = int(strKey.split("[")[1].split("]")[0]) - 1 #gets the int that is between []
#                else:
#                    pyintIndex = 0
#                while len(self.xsDataDiffractionCTInstrument.get_pd_sum_2theta_range_max()) < pyintIndex + 1:
#                    self.xsDataDiffractionCTInstrument.get_pd_sum_2theta_range_max().append(None)
#                xsd = XSDataAngle(float(strValue))
#                if strUnit is None: strUnit = "deg"
#                xsd.setUnit(XSDataString(strUnit))
#                self.xsDataDiffractionCTInstrument.get_pd_sum_2theta_range_max()[pyintIndex] = xsd
#            elif strKey.startswith("_pd_sum_2theta_range_min"):
#                if strKey.find("[") > 0:
#                    pyintIndex = int(strKey.split("[")[1].split("]")[0]) - 1 #gets the int that is between []
#                else:
#                    pyintIndex = 0
#                while len(self.xsDataDiffractionCTInstrument.get_pd_sum_2theta_range_min()) < pyintIndex + 1:
#                    self.xsDataDiffractionCTInstrument.get_pd_sum_2theta_range_min().append(None)
#                xsd = XSDataAngle(float(strValue))
#                if strUnit is None: strUnit = "deg"
#                xsd.setUnit(XSDataString(strUnit))
#                self.xsDataDiffractionCTInstrument.get_pd_sum_2theta_range_min()[pyintIndex] = xsd
            elif (strKey == "_file_correction_image_dark-current"):
                    xsDataFileDark = XSDataFile()
                    xsDataFileDark.setPath(XSDataString(strValue))
                    self.xsDataDiffractionCTImage.set_file_correction_image_dark_current(xsDataFileDark)
            elif (strKey == "_file_correction_image_flat-field"):
                xsDataFileFlat = XSDataFile()
                xsDataFileFlat.setPath(XSDataString(strValue))
                self.xsDataDiffractionCTImage.set_file_correction_image_flat_field(xsDataFileFlat)
            elif (strKey == "_file_correction_image-mask"):
                xsDataFileMask = XSDataFile()
                xsDataFileMask.setPath(XSDataString(strValue))
                self.xsDataDiffractionCTImage.set_file_correction_image_mask(xsDataFileMask)
            elif (strKey == "_file_correction_spline_spatial-distortion"):
                xsDataFileSpatialDist = XSDataFile()
                xsDataFileSpatialDist.setPath(XSDataString(strValue))
                self.xsDataDiffractionCTImage.set_file_correction_spline_spatial_distortion(xsDataFileSpatialDist)

        if self.xsdForceImageParam is not None:
            self.forceImageParam(self.xsdForceImageParam)

        if self.xsdForceScanParam is not None:
            self.forceScanParam(self.xsdForceScanParam)


        xsDataInputPowderIntegration.setImageParameters(self.xsDataDiffractionCTImage)
        xsDataInputPowderIntegration.setInstrumentParameters(self.xsDataDiffractionCTInstrument)
        xsDataInputPowderIntegration.setImageFile(self.xsDataFileInputImage)


# Set the destination directory for output  XRPD file

        strDestinationDirectory = os.path.join(self.getDataInput().getDestinationDirectory().getPath().getValue(), \
                                               self.getDataInput().getPowderDiffractionSubdirectory().getValue())

        if self.xsDataDiffractionCTInstrument.get_tomo_scan_type().getValue().lower() in  ["flat", "spiral"]:
            pyintLineNumber = int(abs(self.xsDataDiffractionCTInstrument.get_tomo_spec_displ_rotation().getValue()) / self.xsDataDiffractionCTInstrument.get_tomo_spec_displ_rotation_inc().getValue())
        elif self.xsDataDiffractionCTInstrument.get_tomo_scan_type().getValue().lower() == "mapping": #I agree mappings are not sinograms but the really looks like, no ? 
            pyintLineNumber = int(abs(self.xsDataDiffractionCTInstrument.get_tomo_spec_displ_z().getValue() - self.xsDataDiffractionCTInstrument.get_tomo_spec_displ_z_min().getValue()) / self.xsDataDiffractionCTInstrument.get_tomo_spec_displ_z_inc().getValue())
        else:
            pyintLineNumber = None
        try:
            strDestinationDirectory = "%s%04i" % (strDestinationDirectory, pyintLineNumber)
        except TypeError:
            pass #if pyintLineNumber is none: do not add suffix


        xsDataInputPowderIntegration.setDestinationDir(XSDataFile(XSDataString(strDestinationDirectory)))



        self.edPluginPowderIntegration.setDataInput(xsDataInputPowderIntegration)
        self.edPluginPowderIntegration.executeSynchronous()
예제 #28
0
    def testSetDataModelInput(self):
        """
        """
        edPluginBest = self.createPlugin()
        xsPluginItemGood01 = self.getPluginConfiguration(
            os.path.join(self.strDataPath, "XSConfiguration.xml"))
        edPluginBest.setConfiguration(xsPluginItemGood01)
        edPluginBest.setScriptExecutable("cat")
        edPluginBest.configure()

        from XSDataBestv10 import XSDataBestInput
        xsDataBestInput = XSDataBestInput()

        from XSDataCommon import XSDataAbsorbedDoseRate
        from XSDataCommon import XSDataFloat
        from XSDataCommon import XSDataString
        from XSDataCommon import XSDataTime
        from XSDataCommon import XSDataFile
        from XSDataCommon import XSDataSpeed
        from XSDataCommon import XSDataString
        from XSDataCommon import XSDataAngle

        xsDataBestInput.setCrystalAbsorbedDoseRate(
            XSDataAbsorbedDoseRate(0.22E+06))
        xsDataBestInput.setCrystalShape(XSDataFloat(1))
        xsDataBestInput.setCrystalSusceptibility(XSDataFloat(1.5))
        xsDataBestInput.setDetectorType(XSDataString("q210-2x"))
        xsDataBestInput.setBeamExposureTime(XSDataTime(1))
        xsDataBestInput.setBeamMaxExposureTime(XSDataTime(10000))
        xsDataBestInput.setBeamMinExposureTime(XSDataTime(0.1))
        xsDataBestInput.setGoniostatMinRotationWidth(XSDataAngle(0.1))
        xsDataBestInput.setGoniostatMaxRotationSpeed(XSDataSpeed(10))
        xsDataBestInput.setAimedResolution(XSDataFloat(2))
        xsDataBestInput.setAimedRedundancy(XSDataFloat(6.5))
        xsDataBestInput.setAimedCompleteness(XSDataFloat(0.9))
        xsDataBestInput.setAimedIOverSigma(XSDataFloat(3))
        xsDataBestInput.setComplexity(XSDataString("min"))
        fileDirectory = edPluginBest.getWorkingDirectory()

        bestFileContentDat = EDUtilsFile.readFile(
            os.path.join(self.strDataPath, "bestfile.dat"))
        xsDataBestInput.setBestFileContentDat(XSDataString(bestFileContentDat))

        bestFileContentPar = EDUtilsFile.readFile(
            os.path.join(self.strDataPath, "bestfile.par"))
        xsDataBestInput.setBestFileContentPar(XSDataString(bestFileContentPar))

        bestFileContentHKL = EDUtilsFile.readFile(
            os.path.join(self.strDataPath, "bestfile1.hkl"))
        listBestFileContentHKL = []
        listBestFileContentHKL.append(XSDataString(bestFileContentHKL))
        xsDataBestInput.setBestFileContentHKL(listBestFileContentHKL)

        xsDataBestInput.outputFile(self.strObtainedInputFile)

        strExpectedInput = self.readAndParseFile(self.strReferenceInputFile)
        strObtainedInput = self.readAndParseFile(self.strObtainedInputFile)

        xsDataInputExpected = XSDataBestInput.parseString(strExpectedInput)
        xsDataInputObtained = XSDataBestInput.parseString(strObtainedInput)

        EDAssert.equal(xsDataInputExpected.marshal(),
                       xsDataInputObtained.marshal())

        self.cleanUp(edPluginBest)
예제 #29
0
    def populateXSDataInputSPDCake(self, _inputDict=None):
        self.DEBUG("EDPluginControlID11v1_0.populateXSDataInputSPDCake")
        xsDataInputSPDCake = XSDataInputSPDCake()
        if isinstance(_inputDict, dict):
            self.__dictID11 = _inputDict

    # Angle of tilt
        if "ANGLE OF TILT" in self.__dictID11:
            xsDataTilt = XSDataAngle()
            xsDataTilt.setValue(float(self.__dictID11["ANGLE OF TILT"]))
            xsDataTilt.setUnit(XSDataString("deg"))
            xsDataInputSPDCake.setAngleOfTilt(xsDataTilt)

        if "TILT ROTATION" in self.__dictID11:
            xsDataTiltRot = XSDataAngle()
            xsDataTiltRot.setValue(float(self.__dictID11["TILT ROTATION"]))
            xsDataTiltRot.setUnit(XSDataString("deg"))
            xsDataInputSPDCake.setTiltRotation(xsDataTiltRot)

        if "X-PIXEL SIZE" in self.__dictID11:
            xsDataXPixel = XSDataLength()
            xsDataXPixel.setValue(float(self.__dictID11["Y-PIXEL SIZE"]))
            xsDataXPixel.setUnit(XSDataString("micron"))
            xsDataInputSPDCake.setPixelSizeX(xsDataXPixel)

        if "Y-PIXEL SIZE" in self.__dictID11:
            xsDataYPixel = XSDataLength()
            xsDataYPixel.setValue(float(self.__dictID11["Y-PIXEL SIZE"]))
            xsDataYPixel.setUnit(XSDataString("micron"))
            xsDataInputSPDCake.setPixelSizeY(xsDataYPixel)

        if "DISTANCE" in self.__dictID11:
            xsDataDistance = XSDataLength()
            xsDataDistance.setValue(float(self.__dictID11["DISTANCE"]))
            xsDataDistance.setUnit(XSDataString("mm"))
            xsDataInputSPDCake.setSampleToDetectorDistance(xsDataDistance)

        if "WAVELENGTH" in self.__dictID11:
            xsDataWaweLength = XSDataWavelength()
            xsDataWaweLength.setValue(float(self.__dictID11["WAVELENGTH"]))
            xsDataWaweLength.setUnit(XSDataString("A"))
            xsDataInputSPDCake.setWavelength(xsDataWaweLength)

        if "DIM1_DATA" in self.__dictID11:
            xsDataBufferSizeX = XSDataInteger(int(
                self.__dictID11["DIM1_DATA"]))
            xsDataInputSPDCake.setBufferSizeX(xsDataBufferSizeX)

        if "DIM2_DATA" in self.__dictID11:
            xsDataBufferSizeY = XSDataInteger(int(
                self.__dictID11["DIM2_DATA"]))
            xsDataInputSPDCake.setBufferSizeY(xsDataBufferSizeY)

    # Dark current
        if ("DARK CURRENT"
                in self.__dictID11) and (self.__dictID11["DARK CURRENT"]
                                         == "YES"):
            if ("DC FILE" in self.__dictID11) and os.path.isfile(
                    self.__dictID11["DC FILE"]):
                xsDataFile = XSDataFile()
                xsDataFile.setPath(XSDataString(self.__dictID11["DC FILE"]))
                xsDataInputSPDCake.setDarkCurrentImageFile(xsDataFile)
            else:
                self.warning(
                    "Asked for DC Current correction but no DC current file")

        if ("FLAT-FIELD" in self.__dictID11) and (self.__dictID11["FLAT-FIELD"]
                                                  == "YES"):
            if ("FF FILE" in self.__dictID11) and os.path.isfile(
                    self.__dictID11["FF FILE"]):
                xsDataFile = XSDataFile()
                xsDataFile.setPath(XSDataString(self.__dictID11["FF FILE"]))
                xsDataInputSPDCake.setFlatFieldImageFile(xsDataFile)
            else:
                self.warning(
                    "Asked for FLAT-FIELD correction but no FLAT-FIELD file")

        if ("MASK FILE" in self.__dictID11) and (self.__dictID11["USE MASK"]
                                                 == "YES"):
            if ("MASK FILE" in self.__dictID11) and os.path.isfile(
                    self.__dictID11["MASK FILE"]):
                xsDataFile = XSDataFile()
                xsDataFile.setPath(XSDataString(self.__dictID11["MASK FILE"]))
                xsDataInputSPDCake.setMaskFile(xsDataFile)
            else:
                self.warning(
                    "Asked for DC Current correction but no DC current file")

        if ("FF SCALE" in self.__dictID11) and (self.__dictID11["FF SCALE"]
                                                == "YES"):
            if ("FF MULTIPLIER" in self.__dictID11):
                try:
                    value = float(self.__dictID11["FF MULTIPLIER"])
                except Exception:
                    self.warning(
                        "Asked for FF SCALE correction but FF MULTIPLIER provided (%s) in not float !"
                        % (self.__dictID11["FF MULTIPLIER"]))
                else:
                    xsDataInputSPDCake.setIntensityScaleFactor(
                        XSDataDouble(1 / value))
            else:
                self.warning(
                    "Asked for FF SCALE correction but no FF MULTIPLIER provided"
                )

        if ("SPATIAL DIS."
                in self.__dictID11) and (self.__dictID11["SPATIAL DIS."]
                                         == "YES"):
            if ("SD FILE" in self.__dictID11) and os.path.isfile(
                    self.__dictID11["SD FILE"]):
                xsDataFile = XSDataFile()
                xsDataFile.setPath(XSDataString(self.__dictID11["SD FILE"]))
                xsDataInputSPDCake.setSpatialDistortionFile(xsDataFile)
            else:
                self.warning(
                    "Asked for SPATIAL DISTORSION correction but no SPATIAL DISTORSION file"
                )

        if "START AZIMUTH" in self.__dictID11:
            xsDataAzimuthStart = XSDataAngle()
            xsDataAzimuthStart.setValue(float(
                self.__dictID11["START AZIMUTH"]))
            xsDataAzimuthStart.setUnit(XSDataString("deg"))
            xsDataInputSPDCake.setStartAzimuth(xsDataAzimuthStart)

        if "END AZIMUTH" in self.__dictID11:
            xsDataAzimuthStop = XSDataAngle()
            xsDataAzimuthStop.setValue(float(self.__dictID11["END AZIMUTH"]))
            xsDataAzimuthStop.setUnit(XSDataString("deg"))
            xsDataInputSPDCake.setStopAzimuth(xsDataAzimuthStop)

        if "AZIMUTH BINS" in self.__dictID11:
            xsDataAzimuthStep = XSDataAngle()
            xsDataAzimuthStep.setValue(
                (float(self.__dictID11["END AZIMUTH"]) -
                 float(self.__dictID11["START AZIMUTH"])) /
                float(self.__dictID11["AZIMUTH BINS"]))
            xsDataAzimuthStep.setUnit(XSDataString("deg"))
            xsDataInputSPDCake.setStepAzimuth(xsDataAzimuthStep)

        if "INNER RADIUS" in self.__dictID11:
            xsDataInnerRadius = XSDataDouble()
            xsDataInnerRadius.setValue(float(self.__dictID11["INNER RADIUS"]))
            xsDataInputSPDCake.setInnerRadius(xsDataInnerRadius)

        if "OUTER RADIUS" in self.__dictID11:
            xsDataOuterRadius = XSDataDouble()
            xsDataOuterRadius.setValue(float(self.__dictID11["OUTER RADIUS"]))
            xsDataInputSPDCake.setOuterRadius(xsDataOuterRadius)

        if "X-BEAM CENTRE" in self.__dictID11:
            xsDataXBeamCentre = XSDataDouble()
            xsDataXBeamCentre.setValue(float(self.__dictID11["X-BEAM CENTRE"]))
            xsDataInputSPDCake.setBeamCentreInPixelsX(xsDataXBeamCentre)

        if "Y-BEAM CENTRE" in self.__dictID11:
            xsDataYBeamCentre = XSDataDouble()
            xsDataYBeamCentre.setValue(float(self.__dictID11["Y-BEAM CENTRE"]))
            xsDataInputSPDCake.setBeamCentreInPixelsY(xsDataYBeamCentre)

#        if "saving_format" in self.__dictID11:
#            xsSaveFormat = XSDataString()
#            if self.__dictID11["saving_format"] == "SPREAD SHEET":
#                xsSaveFormat.setValue("spr")
#            elif self.__dictID11["saving_format"] == "CIF":
#                xsSaveFormat.setValue("cif")
#            elif self.__dictID11["saving_format"] == "CHIPLOT":
#                xsSaveFormat.setValue("chi")
#            else:
#                xsSaveFormat.setValue("edf")
#            xsDataInputSPDCake.setOutputFileType(xsSaveFormat)

        if "output_dir" in self.__dictID11:
            xsOutputDir = XSDataFile()
            xsOutputDir.setPath(XSDataString(self.__dictID11["output_dir"]))
            xsDataInputSPDCake.setOutputDir(xsOutputDir)

        #Default options to SPD
        xsDataInputSPDCake.setOutputFileType(XSDataString("azim"))
        xsDataInputSPDCake.setDeleteCorImg(
            XSDataBoolean(not self.isVerboseDebug()))
        xsDataInputSPDCake.setCorrectTiltMask(XSDataBoolean(self.bCorrectMask))
        return xsDataInputSPDCake
    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)
예제 #31
0
 def buildChildren(self, child_, nodeName_):
     if child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'angle_alpha':
         obj_ = XSDataAngle()
         obj_.build(child_)
         self.setAngle_alpha(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'angle_beta':
         obj_ = XSDataAngle()
         obj_.build(child_)
         self.setAngle_beta(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'angle_gamma':
         obj_ = XSDataAngle()
         obj_.build(child_)
         self.setAngle_gamma(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'length_a':
         obj_ = XSDataLength()
         obj_.build(child_)
         self.setLength_a(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'length_b':
         obj_ = XSDataLength()
         obj_.build(child_)
         self.setLength_b(obj_)
     elif child_.nodeType == Node.ELEMENT_NODE and \
         nodeName_ == 'length_c':
         obj_ = XSDataLength()
         obj_.build(child_)
         self.setLength_c(obj_)
     XSData.buildChildren(self, child_, nodeName_)
예제 #32
0
    def from_params(self, data_collection, char_params):
        edna_input = XSDataInputMXCuBE.parseString(self.edna_default_input)

        if data_collection.id:
            edna_input.setDataCollectionId(XSDataInteger(data_collection.id))

        #Beam object
        beam = edna_input.getExperimentalCondition().getBeam()

        try:
            transmission = self.collect_obj.get_transmission()
            beam.setTransmission(XSDataDouble(transmission))
        except AttributeError:
            pass

        try:
            wavelength = self.collect_obj.get_wavelength()
            beam.setWavelength(XSDataWavelength(wavelength))
        except AttributeError:
            pass

        try:
            beam.setFlux(XSDataFlux(self.collect_obj.get_measured_intensity()))
        except AttributeError:
            pass

        try:
            beamsize = self.get_beam_size()
            if not None in beamsize:
                beam.setSize(
                    XSDataSize(x=XSDataLength(float(beamsize[0])),
                               y=XSDataLength(float(beamsize[1]))))
        except AttributeError:
            pass

        #Optimization parameters
        diff_plan = edna_input.getDiffractionPlan()

        aimed_i_sigma = XSDataDouble(char_params.aimed_i_sigma)
        aimed_completness = XSDataDouble(char_params.aimed_completness)
        aimed_multiplicity = XSDataDouble(char_params.aimed_multiplicity)
        aimed_resolution = XSDataDouble(char_params.aimed_resolution)

        complexity = char_params.strategy_complexity
        complexity = XSDataString(qme.STRATEGY_COMPLEXITY[complexity])

        permitted_phi_start = XSDataAngle(char_params.permitted_phi_start)
        _range = char_params.permitted_phi_end - char_params.permitted_phi_start
        rotation_range = XSDataAngle(_range)

        diff_plan.setAimedIOverSigmaAtHighestResolution(aimed_i_sigma)
        diff_plan.setAimedCompleteness(aimed_completness)

        if char_params.use_aimed_multiplicity:
            diff_plan.setAimedMultiplicity(aimed_multiplicity)

        if char_params.use_aimed_resolution:
            diff_plan.setAimedResolution(aimed_resolution)

        diff_plan.setComplexity(complexity)

        if char_params.use_permitted_rotation:
            diff_plan.setUserDefinedRotationStart(permitted_phi_start)
            diff_plan.setUserDefinedRotationRange(rotation_range)

        #Vertical crystal dimension
        sample = edna_input.getSample()
        sample.getSize().setY(XSDataLength(char_params.max_crystal_vdim))
        sample.getSize().setZ(XSDataLength(char_params.min_crystal_vdim))

        #Radiation damage model
        sample.setSusceptibility(XSDataDouble(char_params.rad_suscept))
        sample.setChemicalComposition(None)
        sample.setRadiationDamageModelBeta(XSDataDouble(char_params.beta /
                                                        1e6))
        sample.setRadiationDamageModelGamma(
            XSDataDouble(char_params.gamma / 1e6))

        diff_plan.setForcedSpaceGroup(XSDataString(char_params.space_group))

        # Characterisation type - Routine DC
        if char_params.use_min_dose:
            pass

        if char_params.use_min_time:
            time = XSDataTime(char_params.min_time)
            diff_plan.setMaxExposureTimePerDataCollection(time)

        # Account for radiation damage
        if char_params.induce_burn:
            diff_plan.setStrategyOption(XSDataString("-DamPar"))
        else:
            diff_plan.setStrategyOption(None)

        # Characterisation type - SAD
        if char_params.opt_sad:
            diff_plan.setAnomalousData(XSDataBoolean(True))
        else:
            diff_plan.setAnomalousData(XSDataBoolean(False))

        #Data set
        data_set = XSDataMXCuBEDataSet()
        acquisition_parameters = data_collection.acquisitions[
            0].acquisition_parameters
        path_template = data_collection.acquisitions[0].path_template
        path_str = os.path.join(path_template.directory,
                                path_template.get_image_file_name())

        for img_num in range(int(acquisition_parameters.num_images)):
            image_file = XSDataFile()
            path = XSDataString()
            path.setValue(path_str % (img_num + 1))
            image_file.setPath(path)
            data_set.addImageFile(image_file)

        edna_input.addDataSet(data_set)
        edna_input.process_directory = path_template.process_directory

        return edna_input
 def testIsSameExperimentalCondition(self):
     edPluginSubWedgeMergev10 = self.createPlugin()
     xsDataExperimentalConditionReference = self.getTestExperimentalCondition(
     )
     xsDataExperimentalConditionSameAsReference = self.getTestExperimentalCondition(
     )
     EDAssert.equal(
         edPluginSubWedgeMergev10.isSameExperimentalCondition(
             xsDataExperimentalConditionReference,
             xsDataExperimentalConditionSameAsReference), True)
     xsDataExperimentalConditionDifferentExposureTime = self.getTestExperimentalCondition(
     )
     xsDataExperimentalConditionDifferentExposureTime.getBeam(
     ).setExposureTime(XSDataTime(10.0))
     EDAssert.equal(
         edPluginSubWedgeMergev10.isSameExperimentalCondition(
             xsDataExperimentalConditionReference,
             xsDataExperimentalConditionDifferentExposureTime), False)
     xsDataExperimentalConditionDifferentWavelength = self.getTestExperimentalCondition(
     )
     xsDataExperimentalConditionDifferentWavelength.getBeam().setWavelength(
         XSDataWavelength(1.5))
     EDAssert.equal(
         edPluginSubWedgeMergev10.isSameExperimentalCondition(
             xsDataExperimentalConditionReference,
             xsDataExperimentalConditionDifferentWavelength), False)
     xsDataExperimentalConditionDifferentBeamPositionX = self.getTestExperimentalCondition(
     )
     xsDataExperimentalConditionDifferentBeamPositionX.getDetector(
     ).setBeamPositionX(XSDataLength(20.0))
     EDAssert.equal(
         edPluginSubWedgeMergev10.isSameExperimentalCondition(
             xsDataExperimentalConditionReference,
             xsDataExperimentalConditionDifferentBeamPositionX), False)
     xsDataExperimentalConditionDifferentBeamPositionY = self.getTestExperimentalCondition(
     )
     xsDataExperimentalConditionDifferentBeamPositionY.getDetector(
     ).setBeamPositionY(XSDataLength(20.0))
     EDAssert.equal(
         edPluginSubWedgeMergev10.isSameExperimentalCondition(
             xsDataExperimentalConditionReference,
             xsDataExperimentalConditionDifferentBeamPositionY), False)
     xsDataExperimentalConditionDifferentDistance = self.getTestExperimentalCondition(
     )
     xsDataExperimentalConditionDifferentDistance.getDetector().setDistance(
         XSDataLength(220.0))
     EDAssert.equal(
         edPluginSubWedgeMergev10.isSameExperimentalCondition(
             xsDataExperimentalConditionReference,
             xsDataExperimentalConditionDifferentDistance), False)
     xsDataExperimentalConditionDifferentName = self.getTestExperimentalCondition(
     )
     xsDataExperimentalConditionDifferentName.getDetector().setName(
         XSDataString(u"EDNA"))
     EDAssert.equal(
         edPluginSubWedgeMergev10.isSameExperimentalCondition(
             xsDataExperimentalConditionReference,
             xsDataExperimentalConditionDifferentName), False)
     xsDataExperimentalConditionDifferentNumberPixelX = self.getTestExperimentalCondition(
     )
     xsDataExperimentalConditionDifferentNumberPixelX.getDetector(
     ).setNumberPixelX(XSDataInteger(2))
     EDAssert.equal(
         edPluginSubWedgeMergev10.isSameExperimentalCondition(
             xsDataExperimentalConditionReference,
             xsDataExperimentalConditionDifferentNumberPixelX), False)
     xsDataExperimentalConditionDifferentNumberPixelY = self.getTestExperimentalCondition(
     )
     xsDataExperimentalConditionDifferentNumberPixelY.getDetector(
     ).setNumberPixelY(XSDataInteger(2))
     EDAssert.equal(
         edPluginSubWedgeMergev10.isSameExperimentalCondition(
             xsDataExperimentalConditionReference,
             xsDataExperimentalConditionDifferentNumberPixelY), False)
     xsDataExperimentalConditionDifferentSerialNumber = self.getTestExperimentalCondition(
     )
     xsDataExperimentalConditionDifferentSerialNumber.getDetector(
     ).setSerialNumber(XSDataString(u"EDNA"))
     EDAssert.equal(
         edPluginSubWedgeMergev10.isSameExperimentalCondition(
             xsDataExperimentalConditionReference,
             xsDataExperimentalConditionDifferentSerialNumber), False)
     xsDataExperimentalConditionDifferentTwoTheta = self.getTestExperimentalCondition(
     )
     xsDataExperimentalConditionDifferentTwoTheta.getDetector().setTwoTheta(
         XSDataAngle(90.0))
     EDAssert.equal(
         edPluginSubWedgeMergev10.isSameExperimentalCondition(
             xsDataExperimentalConditionReference,
             xsDataExperimentalConditionDifferentTwoTheta), False)
     xsDataExperimentalConditionDifferentOscillationWidth = self.getTestExperimentalCondition(
     )
     xsDataExperimentalConditionDifferentOscillationWidth.getGoniostat(
     ).setOscillationWidth(XSDataAngle(2.0))
     EDAssert.equal(
         edPluginSubWedgeMergev10.isSameExperimentalCondition(
             xsDataExperimentalConditionReference,
             xsDataExperimentalConditionDifferentOscillationWidth), False)
     xsDataExperimentalConditionDifferentRotationAxis = self.getTestExperimentalCondition(
     )
     xsDataExperimentalConditionDifferentRotationAxis.getGoniostat(
     ).setRotationAxis(XSDataString(u"EDNA"))
     EDAssert.equal(
         edPluginSubWedgeMergev10.isSameExperimentalCondition(
             xsDataExperimentalConditionReference,
             xsDataExperimentalConditionDifferentRotationAxis), False)