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
Ejemplo n.º 2
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_)
    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())
Ejemplo n.º 4
0
 def testGenerateMOSFLMCommands(self):
     xsDataMOSFLMInput = XSDataMOSFLMInput()
     xsDataMOSFLMBeam = XSDataMOSFLMBeamPosition()
     xsDataMOSFLMBeam.setX(XSDataLength(1.0))
     xsDataMOSFLMBeam.setY(XSDataLength(2.0))
     xsDataMOSFLMInput.setBeam(xsDataMOSFLMBeam)
     xsDataMOSFLMDetector = XSDataMOSFLMDetector()
     xsDataMOSFLMDetector.setType(XSDataString("ADSC"))
     xsDataMOSFLMInput.setDetector(xsDataMOSFLMDetector)
     xsDataMOSFLMInput.setDirectory(XSDataString("/tmp"))
     xsDataMOSFLMInput.setTemplate(XSDataString("testdata_1_###.img"))
     xsDataMOSFLMInput.setWavelength(XSDataWavelength(1.1111))
     xsDataMOSFLMInput.setDistance(XSDataLength(222.22))
     edPluginMOSFLMv10 = self.createPlugin()
     edPluginMOSFLMv10.setScriptExecutable("cat")
     edPluginMOSFLMv10.configure()
     edPluginMOSFLMv10.setXSDataInputClass(XSDataMOSFLMInput)
     edPluginMOSFLMv10.setDataInput(xsDataMOSFLMInput)
     edPluginMOSFLMv10.generateMOSFLMCommands()
     edListCommands = edPluginMOSFLMv10.getListCommandExecution()
     edListCommandsReference = [
         'WAVELENGTH 1.1111', 'DISTANCE 222.22', 'BEAM 1.0 2.0',
         'DETECTOR ADSC', 'DIRECTORY /tmp', 'TEMPLATE testdata_1_###.img'
     ]
     EDAssert.equal(edListCommandsReference, edListCommands,
                    "MOSFLM commands")
     self.cleanUp(edPluginMOSFLMv10)
Ejemplo n.º 5
0
 def testRasterConfiguration(self):
     strPathToTestConfigFile = os.path.join(self.strUnitTestDataHome,
                                            "XSConfiguration_raster.xml")
     edConfiguration = EDConfiguration(strPathToTestConfigFile)
     dictItem = edConfiguration.get(self.getPluginName())
     xsDataMOSFLMInput = XSDataMOSFLMInput()
     xsDataMOSFLMBeam = XSDataMOSFLMBeamPosition()
     xsDataMOSFLMBeam.setX(XSDataLength(1.0))
     xsDataMOSFLMBeam.setY(XSDataLength(2.0))
     xsDataMOSFLMInput.setBeam(xsDataMOSFLMBeam)
     xsDataMOSFLMDetector = XSDataMOSFLMDetector()
     xsDataMOSFLMDetector.setType(XSDataString("ADSC"))
     xsDataMOSFLMInput.setDetector(xsDataMOSFLMDetector)
     xsDataMOSFLMInput.setDirectory(XSDataString("/tmp"))
     xsDataMOSFLMInput.setTemplate(XSDataString("testdata_1_###.img"))
     xsDataMOSFLMInput.setWavelength(XSDataWavelength(1.1111))
     xsDataMOSFLMInput.setDistance(XSDataLength(222.22))
     edPluginMOSFLMv10 = self.createPlugin()
     edPluginMOSFLMv10.setScriptExecutable("cat")
     edPluginMOSFLMv10.setConfig(dictItem, _bLocal=True)
     edPluginMOSFLMv10.configure()
     edPluginMOSFLMv10.setXSDataInputClass(XSDataMOSFLMInput)
     edPluginMOSFLMv10.setDataInput(xsDataMOSFLMInput)
     edPluginMOSFLMv10.generateMOSFLMCommands()
     edListCommands = edPluginMOSFLMv10.getListCommandExecution()
     edListCommandsReference = [
         'WAVELENGTH 1.1111', 'DISTANCE 222.22', 'BEAM 1.0 2.0',
         'DETECTOR ADSC', 'DIRECTORY /tmp', 'TEMPLATE testdata_1_###.img',
         'RASTER 15 15 3 3 3'
     ]
     EDAssert.equal(edListCommandsReference, edListCommands,
                    "MOSFLM commands with ratser configured")
Ejemplo n.º 6
0
 def unitTestToXSD(self):
     """
     """
     EDVerbose.DEBUG("EDTestCaseEDUtilsUnit.unitTestToXSD")
     xsdObt = EDUtilsUnit.toXSD(XSDataLength, "1.5 mm")
     xsdExp = XSDataLength(1.5)
     xsdExp.setUnit(XSDataString("mm"))
     EDAssert.equal(xsdExp.marshal(), xsdObt.marshal(), "XML representation are the same")
Ejemplo n.º 7
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()
Ejemplo n.º 8
0
 def unitTestToXSD(self):
     """
     """
     EDVerbose.DEBUG("EDTestCaseEDUtilsUnit.unitTestToXSD")
     xsdObt = EDUtilsUnit.toXSD(XSDataLength, "1.5 mm")
     xsdExp = XSDataLength(1.5)
     xsdExp.setUnit(XSDataString("mm"))
     EDAssert.equal(xsdExp.marshal(), xsdObt.marshal(),
                    "XML representation are the same")
Ejemplo n.º 9
0
    def generateXSDataIndexingResult(_xsDataResultXDSIndexing, _xsDataExperimentalCondition=None):

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

        xsDataIndexingSolutionSelected.setCrystal(xsDataCrystalSelected)

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


        xsDataStatisticsIndexing = XSDataStatisticsIndexing()

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

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

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

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

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

        xsDataIndexingResult.setSelectedSolution(xsDataIndexingSolutionSelected)

        return xsDataIndexingResult
 def getFluxAndBeamSizeFromISPyB(self, _xsDataFirstImage,
                                 _xsDataExperimentalCondition):
     """
     This method retrieves the flux and beamsize from ISPyB
     """
     xsDataExperimentalCondition = None
     if (_xsDataExperimentalCondition is not None):
         bFoundValidFlux = False
         xsDataExperimentalCondition = _xsDataExperimentalCondition.copy()
         xsDataInputRetrieveDataCollection = XSDataInputRetrieveDataCollection(
         )
         xsDataInputRetrieveDataCollection.setImage(
             XSDataImage(_xsDataFirstImage.getPath()))
         self.edPluginISPyBRetrieveDataCollection.setDataInput(
             xsDataInputRetrieveDataCollection)
         self.edPluginISPyBRetrieveDataCollection.executeSynchronous()
         xsDataResultRetrieveDataCollection = self.edPluginISPyBRetrieveDataCollection.getDataOutput(
         )
         if xsDataResultRetrieveDataCollection is not None:
             xsDataISPyBDataCollection = xsDataResultRetrieveDataCollection.getDataCollection(
             )
             if xsDataISPyBDataCollection is not None:
                 fFlux = xsDataISPyBDataCollection.getFlux()
                 if fFlux is not None:
                     self.screen(
                         "ISPyB reports flux to be: %g photons/sec" % fFlux)
                     if fFlux > self.fFluxThreshold:
                         xsDataExperimentalCondition.getBeam().setFlux(
                             XSDataFlux(fFlux))
                         bFoundValidFlux = True
                 fBeamSizeAtSampleX = xsDataISPyBDataCollection.beamSizeAtSampleX
                 fBeamSizeAtSampleY = xsDataISPyBDataCollection.beamSizeAtSampleY
                 if fBeamSizeAtSampleX is not None and fBeamSizeAtSampleY is not None:
                     self.screen("ISPyB reports beamsize X to be: %.3f mm" %
                                 fBeamSizeAtSampleX)
                     self.screen("ISPyB reports beamsize Y to be: %.3f mm" %
                                 fBeamSizeAtSampleY)
                     xsDataSize = XSDataSize()
                     xsDataSize.x = XSDataLength(fBeamSizeAtSampleX)
                     xsDataSize.y = XSDataLength(fBeamSizeAtSampleY)
                     xsDataExperimentalCondition.getBeam().setSize(
                         xsDataSize)
         if not bFoundValidFlux:
             self.screen(
                 "No valid flux could be retrieved from ISPyB! Trying to obtain flux from input data."
             )
             xsDataBeam = xsDataExperimentalCondition.getBeam()
             xsDataBeamFlux = xsDataBeam.getFlux()
             if xsDataBeamFlux is not None:
                 fFluxMXCuBE = xsDataBeamFlux.getValue()
                 self.screen("MXCuBE reports flux to be: %g photons/sec" %
                             fFluxMXCuBE)
                 if fFluxMXCuBE < self.fFluxThreshold:
                     self.screen("MXCuBE flux invalid!")
     return xsDataExperimentalCondition
Ejemplo n.º 11
0
    def getXSDataInputFIT2DCake(self, _xsDataInputPowderIntegration):
        """
        """

        xsDataInputFIT2DCake = XSDataInputFIT2DCake()

        imageFile = _xsDataInputPowderIntegration.getImageFile()
        instrumentParameters = _xsDataInputPowderIntegration.getInstrumentParameters(
        )
        imageParameters = _xsDataInputPowderIntegration.getImageParameters()

        xsDataInputFIT2DCake.setInputFile(imageFile)

        xsDataInputFIT2DCake.setWavelength(
            instrumentParameters.get_diffrn_radiation_wavelength())
        xsDataInputFIT2DCake.setSampleToDetectorDistance(
            instrumentParameters.get_pd_instr_dist_spec_detc())

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

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

        fBeamCentreInMillimetersX = imageParameters.get_diffrn_detector_element_center_1(
        ).getValue()
        fBeamCentreInMillimetersY = imageParameters.get_diffrn_detector_element_center_2(
        ).getValue()
        fPixelSizeInMetersX = imageParameters.get_array_element_size_1(
        ).getValue()
        fPixelSizeInMetersY = imageParameters.get_array_element_size_2(
        ).getValue()
        xsDataInputFIT2DCake.setBeamCentreInPixelsX(
            XSDataLength(fBeamCentreInMillimetersX / fPixelSizeInMetersX /
                         1000))
        xsDataInputFIT2DCake.setBeamCentreInPixelsY(
            XSDataLength(fBeamCentreInMillimetersY / fPixelSizeInMetersX /
                         1000))
        xsDataInputFIT2DCake.setPixelSizeX(
            XSDataLength(fPixelSizeInMetersX * 1000))
        xsDataInputFIT2DCake.setPixelSizeY(
            XSDataLength(fPixelSizeInMetersY * 1000))

        xsDataInputFIT2DCake.setBufferSizeX(XSDataInteger(2048))
        xsDataInputFIT2DCake.setBufferSizeY(XSDataInteger(2048))
        xsDataInputFIT2DCake.setOutputFileType(XSDataString("CHIPLOT"))

        return xsDataInputFIT2DCake
Ejemplo n.º 12
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
Ejemplo n.º 13
0
 def createInputCharacterisationFromSubWedges(self):
     EDVerbose.DEBUG(
         "EDPluginControlInterfacev2_0.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)
     xsDataDiffractionPlan = XSDataDiffractionPlan()
     if (not xsDataResultSubWedgeAssemble is None):
         pyListSubWedge = xsDataResultSubWedgeAssemble.getSubWedge()
         xsDataCollection.setSubWedge(pyListSubWedge)
         for xsDataSubWedge in pyListSubWedge:
             if (self.strComplexity is not None):
                 xsDataDiffractionPlan.setComplexity(
                     XSDataString(self.strComplexity))
             if (self.fFlux is not None):
                 xsDataSubWedge.getExperimentalCondition().getBeam(
                 ).setFlux(XSDataFloat(self.fFlux))
             if (self.fBeamSize is not None):
                 xsDataSize = XSDataSize()
                 xsDataSize.setX(XSDataLength(self.fBeamSize))
                 xsDataSize.setY(XSDataLength(self.fBeamSize))
                 xsDataSubWedge.getExperimentalCondition().getBeam(
                 ).setSize(xsDataSize)
             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(
                     XSDataFloat(self.fMinExposureTimePerImage))
             if (self.fTransmission is not None):
                 xsDataSubWedge.getExperimentalCondition().getBeam(
                 ).setTransmission(XSDataDouble(self.fTransmission))
     if (self.strForcedSpaceGroup is not None):
         xsDataDiffractionPlan.setForcedSpaceGroup(
             XSDataString(self.strForcedSpaceGroup))
     xsDataDiffractionPlan.setAnomalousData(
         XSDataBoolean(self.bAnomalousData))
     xsDataDiffractionPlan.setMaxExposureTimePerDataCollection(
         XSDataTime(self.fMaxExposureTimePerDataCollection))
     if (self.strStrategyOption is not None):
         xsDataDiffractionPlan.setStrategyOption(
             XSDataString(self.strStrategyOption))
     xsDataCollection.setDiffractionPlan(xsDataDiffractionPlan)
     self.xsDataInputCharacterisation.setDataCollection(xsDataCollection)
Ejemplo n.º 14
0
    def makeXML(self, filename):
        """Here we create the XML string to be passed to the EDNA plugin from the input filename
        This can / should be modified by the final user
        
        @param filename: full path of the input file
        @type filename: python string representing the path
        @rtype: XML string
        @return: python string  
        """
        bProcessFile = False
        basename = os.path.basename(filename)
        for oneExt in self.listExtensions:
            if basename.endswith(oneExt):
                bProcessFile = True
                break
        if bProcessFile:
            for onePref in self.listExcludedPrefix:
                if basename.startswith(onePref):
                    bProcessFile = False
        if not bProcessFile:
            EDVerbose.screen("Not processing file: %s" % filename)
            return
        xsdimage = XSDataImage()
        xsdimage.setPath(XSDataString(filename))
        xsd = XSDataInputDiffractionCT()
        xsd.setImage(xsdimage)
        xsd.setDestinationDirectory(self.destinationDirectory)
        xsd.setSinogramFileNamePrefix(self.sinogramFileNamePrefix)
        xsd.setPowderDiffractionSubdirectory(
            self.powderDiffractionSubdirectory)
        xsd.setPowderDiffractionFormat(self.powderDiffractionFormat)
        if self.indexOffset is not None and self.fastMotorSteps is not None:
            idx = 0
            basename = list(os.path.splitext(os.path.basename(filename))[0])
            basename.reverse()
            number = ""
            for i in basename:
                if i.isdigit():
                    number = i + number
                else:
                    break
            idx = int(number) - self.indexOffset
            if idx < 0: return

            self.forceInstrument.set_tomo_spec_displ_x(
                XSDataLength(idx % (self.fastMotorSteps + 1)))
            self.forceInstrument.set_tomo_spec_displ_rotation(
                XSDataLength(idx // (self.fastMotorSteps + 1)))
        xsd.setOverrideScanParam(self.forceInstrument)
        xsd.setOverrideImageParam(self.forceImage)

        return xsd.marshal()
Ejemplo n.º 15
0
    def getFluxAndBeamSizeFromISPyB(self, _xsDataFirstImage, _xsDataExperimentalCondition):
        """
        This method retrieves the flux and beamsize from ISPyB
        """
        xsDataExperimentalCondition = None
        if (_xsDataExperimentalCondition is not None):
            bFoundValidFlux = False
            xsDataExperimentalCondition = _xsDataExperimentalCondition.copy()
            xsDataInputRetrieveDataCollection = XSDataInputRetrieveDataCollection()
            xsDataInputRetrieveDataCollection.setImage(XSDataImage(_xsDataFirstImage.getPath()))
            self.edPluginISPyBRetrieveDataCollection.setDataInput(xsDataInputRetrieveDataCollection)
            self.edPluginISPyBRetrieveDataCollection.executeSynchronous()
            xsDataResultRetrieveDataCollection = self.edPluginISPyBRetrieveDataCollection.getDataOutput()
            if xsDataResultRetrieveDataCollection is not None:
                xsDataISPyBDataCollection = xsDataResultRetrieveDataCollection.getDataCollection()
                if xsDataISPyBDataCollection is not None:
                    fFlux = xsDataISPyBDataCollection.getFlux_end()
                    if fFlux is not None:
                        self.screen("ISPyB reports flux to be: %g photons/sec" % fFlux)
                        if fFlux > self.fFluxThreshold:
                            xsDataExperimentalCondition.getBeam().setFlux(XSDataFlux(fFlux))
                            bFoundValidFlux = True
                    fBeamSizeAtSampleX = xsDataISPyBDataCollection.beamSizeAtSampleX
                    fBeamSizeAtSampleY = xsDataISPyBDataCollection.beamSizeAtSampleY
                    if fBeamSizeAtSampleX is not None and fBeamSizeAtSampleY is not None:
                        self.screen("ISPyB reports beamsize X to be: %.3f mm" % fBeamSizeAtSampleX)
                        self.screen("ISPyB reports beamsize Y to be: %.3f mm" % fBeamSizeAtSampleY)
                        xsDataSize = XSDataSize()
                        xsDataSize.x = XSDataLength(fBeamSizeAtSampleX)
                        xsDataSize.y = XSDataLength(fBeamSizeAtSampleY)
                        xsDataExperimentalCondition.getBeam().setSize(xsDataSize)
                    # Get transmission if it's not already there
                    if xsDataExperimentalCondition.beam.transmission is None:
                        fTransmission = xsDataISPyBDataCollection.transmission
                        xsDataExperimentalCondition.beam.transmission = XSDataDouble(fTransmission)
            if not bFoundValidFlux:
                self.screen("No valid flux could be retrieved from ISPyB! Trying to obtain flux from input data.")
                xsDataBeam = xsDataExperimentalCondition.getBeam()
                xsDataBeamFlux = xsDataBeam.getFlux()
                if xsDataBeamFlux is not None:
                    fFluxMXCuBE = xsDataBeamFlux.getValue()
                    self.screen("MXCuBE reports flux to be: %g photons/sec" % fFluxMXCuBE)
                    if fFluxMXCuBE < self.fFluxThreshold:
                        self.screen("MXCuBE flux lower than threshold flux %g photons/s!" % self.fFluxThreshold)
                        self.screen("Forcing flux to 0.0 photons/s")
                        xsDataExperimentalCondition.getBeam().setFlux(XSDataFlux(0.0))
                else:
                    # Force missing flux to 0.0
                    self.screen("No flux neither in ISPyB nor in mxCuBE, forcing flux to 0.0 photon/s")
                    xsDataExperimentalCondition.getBeam().setFlux(XSDataFlux(0.0))

        return xsDataExperimentalCondition
Ejemplo n.º 16
0
 def postProcess(self, _edObject=None):
     EDPluginControl.postProcess(self)
     EDVerbose.DEBUG("EDPluginBioSaxsMetadatav1_0.postProcess")
     # Create some output data
     xsDataResult = XSDataResultBioSaxsMetadatav1_0()
     if self.strOutputImage is not None:
         xsdImage = XSDataImage()
         xsdImage.setPath(XSDataString(self.strOutputImage))
         xsDataResult.setOutputImage(xsdImage)
     if self.detector is not None:
         #            EDVerbose.DEBUG("Detector=%s" % self.detector)
         xsDataResult.setDetector(XSDataString(self.detector))
     if self.detectorDistance is not None:
         #            EDVerbose.DEBUG("DetectorDistance %s(%s)" % (self.detectorDistance, self.detectorDistance.__class__))
         xsDataResult.setDetectorDistance(
             XSDataLength(self.detectorDistance))
     if self.pixelSize_1 is not None:
         #            EDVerbose.DEBUG("pixelSize_1  %s(%s)" % (self.pixelSize_1, self.pixelSize_1.__class__))
         xsDataResult.setPixelSize_1(XSDataLength(self.pixelSize_1))
     if self.pixelSize_2 is not None:
         #            EDVerbose.DEBUG("pixelSize_2  %s(%s)" % (self.pixelSize_2, self.pixelSize_2.__class__))
         xsDataResult.setPixelSize_2(XSDataLength(self.pixelSize_2))
     if self.beamCenter_1 is not None:
         #            EDVerbose.DEBUG("beamCenter_1  %s(%s)" % (self.beamCenter_1, self.beamCenter_1.__class__))
         xsDataResult.setBeamCenter_1(XSDataDouble(self.beamCenter_1))
     if self.beamCenter_2 is not None:
         #            EDVerbose.DEBUG("beamCenter_2  %s(%s)" % (self.beamCenter_2, self.beamCenter_2.__class__))
         xsDataResult.setBeamCenter_2(XSDataDouble(self.beamCenter_2))
     if self.beamStopDiode is not None:
         #            EDVerbose.DEBUG("beamStopDiode  %s(%s)" % (self.beamStopDiode, self.beamStopDiode.__class__))
         xsDataResult.setBeamStopDiode(XSDataDouble(self.beamStopDiode))
     if self.wavelength is not None:
         xsDataResult.setWavelength(XSDataWavelength(self.wavelength))
     if self.maskFile is not None:
         xsdFile = XSDataImage()
         xsdFile.setPath(XSDataString(self.maskFile))
         xsDataResult.setMaskFile(xsdFile)
     if self.normalizationFactor is not None:
         xsDataResult.setNormalizationFactor(
             XSDataDouble(self.normalizationFactor))
     if self.machineCurrent is not None:
         xsDataResult.setMachineCurrent(XSDataDouble(self.machineCurrent))
     if self.code is not None:
         xsDataResult.setCode(XSDataString(self.code))
     if self.comments is not None:
         xsDataResult.setComments(XSDataString(self.comments))
     if self.concentration is not None:
         xsDataResult.setConcentration(XSDataDouble(self.concentration))
     EDVerbose.DEBUG("xsDataResult=%s" % xsDataResult.marshal())
     self.setDataOutput(xsDataResult)
Ejemplo n.º 17
0
    def __init__(self, code=None, comment=None, \
                 maskFile=None, normalization=None, imageSize=None, detector="pilatus", detectorDistance=None, pixelSize_1=None, pixelSize_2=None, beamCenter_1=None, beamCenter_2=None, wavelength=None,):
        EDLogging.__init__(self)
        self.comment = comment
        self.code = code
        self.maskFile = maskFile
        self.normalization = normalization

        self.detector = detector
        self.detectorDistance = detectorDistance
        if (detector == "pilatus") and (pixelSize_1 is None) and (pixelSize_2
                                                                  is None):
            self.pixelSize_1 = 1.72e-4
            self.pixelSize_2 = 1.72e-4
        else:
            self.pixelSize_1 = pixelSize_1
            self.pixelSize_2 = pixelSize_2
        if (detector == "pilatus") and (beamCenter_1 is None):
            self.imageSize = 4000000
        else:
            self.imageSize = imageSize
        self.beamCenter_1 = beamCenter_1
        self.beamCenter_2 = beamCenter_2
        self.wavelength = wavelength

        self.timeStamp = time.strftime("-%Y%m%d%H%M%S", time.localtime())
        self.dest1D = "1d" + self.timeStamp
        self.dest2D = "2d" + self.timeStamp
        self.destMisc = "misc" + self.timeStamp
        self.sample = XSDataBioSaxsSample()
        if code is not None:
            self.sample.code = XSDataString(code)
        if comment is not None:
            self.sample.comment = XSDataString(comment)
        self.experimentSetup = XSDataBioSaxsExperimentSetup()
        if self.detector:
            self.experimentSetup.detector = XSDataString(self.detector)
        if self.detectorDistance:
            self.experimentSetup.detectorDistance = XSDataLength(
                self.detectorDistance)
        if self.pixelSize_1:
            self.experimentSetup.pixelSize_1 = XSDataLength(self.pixelSize_1)
        if self.pixelSize_2:
            self.experimentSetup.pixelSize_2 = XSDataLength(self.pixelSize_2)
        if self.beamCenter_1:
            self.experimentSetup.beamCenter_1 = XSDataDouble(self.beamCenter_1)
        if self.beamCenter_2:
            self.experimentSetup.beamCenter_2 = XSDataDouble(self.beamCenter_2)
        if self.wavelength:
            self.experimentSetup.wavelength = XSDataWavelength(self.wavelength)
    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
Ejemplo n.º 19
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
Ejemplo n.º 20
0
 def createInputCharacterisationFromSubWedges(self):
     self.DEBUG("EDPluginControlInterfacev1_2.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.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)
     self.xsDataInputCharacterisation.setToken(self.xsDataToken)
Ejemplo n.º 21
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())
Ejemplo n.º 22
0
    def strategySummaryItemListToStrategySummary(self,
                                                 _xsStrategySummaryItemList):
        xsDataStrategySummary = XSDataBestStrategySummary()

        xsItemDistance = EDUtilsTable.getItemFromList(
            _xsStrategySummaryItemList, "distance")
        fDistance = float(xsItemDistance.getValueOf_())
        xsDataStrategySummary.setDistance(XSDataLength(fDistance))

        strItemTransmission = EDUtilsTable.getItemFromList(
            _xsStrategySummaryItemList, "transmission")
        fTransmission = float(strItemTransmission.getValueOf_())
        xsDataStrategySummary.setTransmission(XSDataDouble(fTransmission))

        strItemCompleteness = EDUtilsTable.getItemFromList(
            _xsStrategySummaryItemList, "completeness")
        # For homegeneity concerns, EDNA data model should store all the completeness value in fraction
        # ( DNA table xml file stores the summary strategy completeness in percentage whereas
        # the resolution bin completeness are in fraction )
        fCompleteness = float(strItemCompleteness.getValueOf_()) / 100
        xsDataStrategySummary.setCompleteness(XSDataDouble(fCompleteness))

        strItemISigma = EDUtilsTable.getItemFromList(
            _xsStrategySummaryItemList, "i_sigma")
        fISigma = float(strItemISigma.getValueOf_())
        xsDataStrategySummary.setISigma(XSDataDouble(fISigma))

        strItemRedundancy = EDUtilsTable.getItemFromList(
            _xsStrategySummaryItemList, "redundancy")
        fRedundancy = float(strItemRedundancy.getValueOf_())
        xsDataStrategySummary.setRedundancy(XSDataDouble(fRedundancy))

        strItemResolution = EDUtilsTable.getItemFromList(
            _xsStrategySummaryItemList, "resolution")
        fResolution = float(strItemResolution.getValueOf_())
        xsDataStrategySummary.setResolution(XSDataDouble(fResolution))

        strItemResolutionReasoning = EDUtilsTable.getItemFromList(
            _xsStrategySummaryItemList, "resolution_reasoning")
        strResolutionReasoning = strItemResolutionReasoning.getValueOf_()
        xsDataStrategySummary.setResolutionReasoning(
            XSDataString(strResolutionReasoning))

        strItemTotalDataCollectionTime = EDUtilsTable.getItemFromList(
            _xsStrategySummaryItemList, "total_data_collection_time")
        fTotalDataCollectionTime = float(
            strItemTotalDataCollectionTime.getValueOf_())
        xsDataStrategySummary.setTotalDataCollectionTime(
            XSDataTime(fTotalDataCollectionTime))

        strItemTotalExposureTime = EDUtilsTable.getItemFromList(
            _xsStrategySummaryItemList, "total_exposure_time")
        fTotalExposureTime = float(strItemTotalExposureTime.getValueOf_())
        xsDataStrategySummary.setTotalExposureTime(
            XSDataTime(fTotalExposureTime))

        return xsDataStrategySummary
Ejemplo n.º 23
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
Ejemplo n.º 24
0
	def buildChildren(self, child_, nodeName_):
		if child_.nodeType == Node.ELEMENT_NODE and \
			nodeName_ == 'bravaisLattice':
			obj_ = XSDataString()
			obj_.build(child_)
			self.setBravaisLattice(obj_)
		elif child_.nodeType == Node.ELEMENT_NODE and \
			nodeName_ == 'crystalSystem':
			obj_ = XSDataString()
			obj_.build(child_)
			self.setCrystalSystem(obj_)
		elif child_.nodeType == Node.ELEMENT_NODE and \
			nodeName_ == 'happy':
			obj_ = XSDataBoolean()
			obj_.build(child_)
			self.setHappy(obj_)
		elif child_.nodeType == Node.ELEMENT_NODE and \
			nodeName_ == 'metricFitCode':
			obj_ = XSDataString()
			obj_.build(child_)
			self.setMetricFitCode(obj_)
		elif child_.nodeType == Node.ELEMENT_NODE and \
			nodeName_ == 'metricFitValue':
			obj_ = XSDataDouble()
			obj_.build(child_)
			self.setMetricFitValue(obj_)
		elif child_.nodeType == Node.ELEMENT_NODE and \
			nodeName_ == 'numberOfSpots':
			obj_ = XSDataInteger()
			obj_.build(child_)
			self.setNumberOfSpots(obj_)
		elif child_.nodeType == Node.ELEMENT_NODE and \
			nodeName_ == 'rmsd':
			obj_ = XSDataLength()
			obj_.build(child_)
			self.setRmsd(obj_)
		elif child_.nodeType == Node.ELEMENT_NODE and \
			nodeName_ == 'solutionNumber':
			obj_ = XSDataInteger()
			obj_.build(child_)
			self.setSolutionNumber(obj_)
		elif child_.nodeType == Node.ELEMENT_NODE and \
			nodeName_ == 'unitCell':
			obj_ = XSDataCell()
			obj_.build(child_)
			self.setUnitCell(obj_)
		elif child_.nodeType == Node.ELEMENT_NODE and \
			nodeName_ == 'volume':
			obj_ = XSDataInteger()
			obj_.build(child_)
			self.setVolume(obj_)
		XSData.buildChildren(self, child_, nodeName_)
Ejemplo n.º 25
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")
Ejemplo n.º 26
0
 def doFailureExecAutoRg(self, _edPlugin=None):
     self.DEBUG("EDPluginAutoSubv1_0.doFailureExecAutoRg")
     self.retrieveFailureMessages(
         _edPlugin, "EDPluginAutoSubv1_0.doFailureExecAutoRg")
     self.lstProcessLog.append("Failure in AutoRg")
     if len(_edPlugin.dataInput.inputCurve) == 2:
         # we were comparing 2 buffers but were analyzed by AutoRg
         for fn in self.buffers:
             self.dictRg[fn] = (0, numpy.loadtxt(fn, unpack=True)[1].sum())
     elif os.path.exists(self.subtractedCurve):
         # we don't want to fail the subtraction plugin because the result has no Rg - default to 0
         res = XSDataAutoRg()
         res.rg = XSDataLength(0.0)
         res.rgStdev = XSDataLength(0.0)
         res.i0 = XSDataDouble(0.0)
         res.i0Stdev = XSDataDouble(0.0)
         res.firstPointUsed = XSDataInteger(0)
         res.lastPointUsed = XSDataInteger(0)
         res.quality = XSDataDouble(0.0)
         res.isagregated = XSDataBoolean(bool(0))
         res.filename = XSDataFile(XSDataString(self.subtractedCurve))
         self.xsDataResult.autoRg = res
     else:
         self.setFailure()
Ejemplo n.º 27
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")
 def testSortSubWedgesOnExperimentalCondition(self):
     # First check two sub wedges with identical experimental conditions
     edPluginSubWedgeMergev10 = self.createPlugin()
     edPluginSubWedgeMergev10.configure()
     xsDataInputSubWedgeMerge = XSDataInputSubWedgeMerge.parseFile(
         self.__strPathToReferenceInput)
     edListSubWedgeSorted = edPluginSubWedgeMergev10.sortSubWedgesOnExperimentalCondition(
         xsDataInputSubWedgeMerge)
     # Check that we got a list with one element
     EDAssert.equal(len(edListSubWedgeSorted), 1)
     # Then modify one sub wedge
     xsDataSubWedge1 = xsDataInputSubWedgeMerge.getSubWedge()[0]
     xsDataSubWedge1.getExperimentalCondition().getDetector().setDistance(
         XSDataLength(300.0))
     edListSubWedgeSorted = edPluginSubWedgeMergev10.sortSubWedgesOnExperimentalCondition(
         xsDataInputSubWedgeMerge)
     # Check that we got a list with two elements
     EDAssert.equal(len(edListSubWedgeSorted), 2)
Ejemplo n.º 29
0
    def getDamParOutputFromDNATables(self, _xsDataDnaTables):
        xsDataResultBest = XSDataResultBest()
        xsTablesCollectionStrategy = EDUtilsTable.getTableListFromTables(
            _xsDataDnaTables, "dam_par_plan")

        iCollectionPlanNumber = 1
        for xsTableCollectionStrategy in xsTablesCollectionStrategy:

            xsDataBestCollectionPlan = XSDataBestCollectionPlan()
            xsDataStrategySummary = XSDataBestStrategySummary()
            xsGeneralList = EDUtilsTable.getListsFromTable(
                xsTableCollectionStrategy, "general")[0]
            xsCollectionRunList = EDUtilsTable.getListsFromTable(
                xsTableCollectionStrategy, "collection_run")

            iCollectionRunNumber = 1
            for xsCollectionRunItemList in xsCollectionRunList:
                xsDataCollectionRun = self.collectionRunItemListToCollectionRun(
                    xsCollectionRunItemList, iCollectionRunNumber)
                xsDataBestCollectionPlan.addCollectionRun(xsDataCollectionRun)
                iCollectionRunNumber = iCollectionRunNumber + 1

            xsDataBestCollectionPlan.setCollectionPlanNumber(
                XSDataInteger(iCollectionPlanNumber))
            xsDataResultBest.addCollectionPlan(xsDataBestCollectionPlan)
            iCollectionPlanNumber = iCollectionPlanNumber + 1

            xsItemDistance = EDUtilsTable.getItemFromList(
                xsGeneralList, "distance")
            fDistance = float(xsItemDistance.getValueOf_())
            xsDataStrategySummary.setDistance(XSDataLength(fDistance))

            xsItemResolution = EDUtilsTable.getItemFromList(
                xsGeneralList, "resolution")
            fResolution = float(xsItemResolution.getValueOf_())
            xsDataStrategySummary.setResolution(XSDataDouble(fResolution))

            xsDataBestCollectionPlan.setStrategySummary(xsDataStrategySummary)

        return xsDataResultBest
Ejemplo n.º 30
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")
Ejemplo n.º 31
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_)
    def process(self, _edObject=None):
        EDPluginExec.process(self)
        self.DEBUG("EDPluginExecReadImageHeaderEiger4Mv10.process")
        xsDataInputReadImageHeader = self.getDataInput()
        xsDataFile = xsDataInputReadImageHeader.getImage()
        strPath = xsDataFile.getPath().getValue()
        dictEiger4MHeader = self.readHeaderEiger4M(strPath)
        if (dictEiger4MHeader is None):
            strErrorMessage = "EDPluginExecReadImageHeaderEiger4Mv10.process : Cannot read header : %s" % strPath
            self.error(strErrorMessage)
            self.addErrorMessage(strErrorMessage)
            self.setFailure()
        else:
            xsDataExperimentalCondition = XSDataExperimentalCondition()
            xsDataDetector = XSDataDetector()

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

            # Beam object

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

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

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

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

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

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

            xsDataExperimentalCondition.setDetector(xsDataDetector)

            # Beam object

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

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

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

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

            self.__xsDataResultReadImageHeader = XSDataResultReadImageHeader()
            self.__xsDataResultReadImageHeader.setSubWedge(xsDataSubWedge)
Ejemplo n.º 34
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
Ejemplo n.º 35
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