コード例 #1
0
    def testSetDataModelInput(self):
        edPluginBest = self.createPlugin()
        edConfigurationGood01 = EDConfiguration(os.path.join(self.m_pyStrDataPath, "XSConfiguration.xml"))
        dictItemGood01 = edConfigurationGood01.get(self.getPluginName())
        edPluginBest.setConfig(dictItemGood01, _bLocal = True)
        edPluginBest.setScriptExecutable("cat")
        edPluginBest.configure()

        from XSDataBestv1_2 import XSDataInputBest
        xsDataInputBest = XSDataInputBest()

        from XSDataCommon import XSDataAbsorbedDoseRate
        from XSDataCommon import XSDataDouble
        from XSDataCommon import XSDataString
        from XSDataCommon import XSDataTime
        from XSDataCommon import XSDataFile
        from XSDataCommon import XSDataAngularSpeed
        from XSDataCommon import XSDataString
        from XSDataCommon import XSDataAngle
        from XSDataCommon import XSDataBoolean

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

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

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

        bestFileContentHKL = EDUtilsFile.readFile(os.path.join(self.m_pyStrDataPath, "bestfile1.hkl"))
        xsDataInputBest.addBestFileContentHKL(XSDataString(bestFileContentHKL))

        xsDataInputBest.exportToFile(self.m_edObtainedInputFile)

        pyStrExpectedInput = self.readAndParseFile (self.m_edReferenceInputFile)
        pyStrObtainedInput = self.readAndParseFile (self.m_edObtainedInputFile)

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

        EDAssert.equal(xsDataInputExpected.marshal(), xsDataInputObtained.marshal())
        EDUtilsFile.deleteFile(self.m_edObtainedInputFile)

        self.cleanUp(edPluginBest)
コード例 #2
0
    def getXSDataInputBest(self, _xsDataInputStrategy):
        xsDataBeam = _xsDataInputStrategy.getExperimentalCondition().getBeam()
        xsDataSample = _xsDataInputStrategy.getSample()
        xsDataDetector = _xsDataInputStrategy.getExperimentalCondition().getDetector()
        xsDataGoniostat = _xsDataInputStrategy.getExperimentalCondition().getGoniostat()
        xsDataDiffractionPlan = _xsDataInputStrategy.getDiffractionPlan()
        xsDataStringBestFileContentDat = _xsDataInputStrategy.getBestFileContentDat()
        xsDataStringBestFileContentPar = _xsDataInputStrategy.getBestFileContentPar()
        xsDataFileXdsBackgroundImage = _xsDataInputStrategy.getXdsBackgroundImage()
        listXSDataStringBestFileContentHKL = _xsDataInputStrategy.getBestFileContentHKL()
        xsDataInputBest = XSDataInputBest()

        # Sample      
        xdDataAbsorbedDose = None
        xsDataSusceptibility = None

        # Could be None if sample has not been set
        # It could be not None in case Raddose has calculated an absorbed dose with default sample values
        if(xsDataSample is not None):
            xdDataAbsorbedDose = xsDataSample.getAbsorbedDoseRate()
            xsDataSusceptibility = xsDataSample.getSusceptibility()
            # crystalShape
            # Default value is 1 (We assume that Xtal is smaller than beam)
            xsDataDoubleCrystalShape = xsDataSample.getShape()
            if(xsDataDoubleCrystalShape is None):
                if (xsDataSample.getSize() is None) or (xsDataBeam.getSize() is None):
                    xsDataDoubleCrystalShape = XSDataDouble(1)
                else:
                    fCrystalSizeY = xsDataSample.getSize().getY().getValue()
                    fCrystalSizeZ = xsDataSample.getSize().getZ().getValue()
                    fDiagonal = math.sqrt(fCrystalSizeY ** 2 + fCrystalSizeZ ** 2)
                    fBeamSizeX = xsDataBeam.getSize().getX().getValue()
                    fCrystalShape = None
                    if fBeamSizeX > fDiagonal:
                        fCrystalShape = 1.0
                    else:
                        fCrystalShape = int(10 * fDiagonal / fBeamSizeX) / 10.0
                    xsDataDoubleCrystalShape = XSDataDouble(fCrystalShape)
            xsDataInputBest.setCrystalShape(xsDataDoubleCrystalShape)

        # Could be None if Raddose failed to calculate the absorbed dose
        if(xdDataAbsorbedDose is not None):
            xsDataInputBest.setCrystalAbsorbedDoseRate(xsDataSample.getAbsorbedDoseRate())

        xsDataInputBest.setCrystalSusceptibility(xsDataSusceptibility)


        # Detector
        xsDataInputBest.setDetectorType(xsDataDetector.getType())

        # Minimum exposure time per image
        xsDataTimeMinExposureTimePerImage = None
        if xsDataBeam:
            xsDataTimeMinExposureTimePerImage = xsDataBeam.getMinExposureTimePerImage()
        if xsDataTimeMinExposureTimePerImage == None:
            xsDataTimeMinExposureTimePerImage = xsDataDiffractionPlan.getMinExposureTimePerImage()
        xsDataInputBest.setBeamMinExposureTime(xsDataTimeMinExposureTimePerImage)

        # Max rotation speed
        xsDataAngularSpeedMax = None
        if xsDataGoniostat:
            xsDataAngularSpeedMax = xsDataGoniostat.getMaxOscillationSpeed()
        if xsDataDiffractionPlan and xsDataAngularSpeedMax == None:
            xsDataAngularSpeedMax = xsDataDiffractionPlan.getGoniostatMaxOscillationSpeed()
        xsDataInputBest.setGoniostatMaxRotationSpeed(xsDataAngularSpeedMax)

        # Min rotation width
        xsDataAngleMin = None
        if xsDataGoniostat:
            xsDataAngleMin = xsDataGoniostat.getMinOscillationWidth()
        if xsDataDiffractionPlan and xsDataAngleMin == None:
            xsDataAngleMin = xsDataDiffractionPlan.getGoniostatMinOscillationWidth()
        xsDataInputBest.setGoniostatMinRotationWidth(xsDataAngleMin)

        # Other beam parameters
        if xsDataBeam:
            xsDataInputBest.setBeamExposureTime(xsDataBeam.getExposureTime())
            if xsDataBeam.getTransmission():
                # Fix for bug 741: if the transmission is zero don't set it and warn the user
                fTransmission = xsDataBeam.getTransmission().getValue()
                if (abs(fTransmission) < 0.1):
                    EDVerbose.warning("Input transmission to BEST ignored because it is zero or close to zero: %f" % fTransmission)
                else:
                    xsDataInputBest.setTransmission(xsDataBeam.getTransmission())

        # Other diffraction plan parameters
        if xsDataDiffractionPlan:
            xsDataInputBest.setAimedResolution(xsDataDiffractionPlan.getAimedResolution())
            xsDataInputBest.setAimedRedundancy(xsDataDiffractionPlan.getAimedMultiplicity())
            xsDataInputBest.setAimedCompleteness(xsDataDiffractionPlan.getAimedCompleteness())
            xsDataInputBest.setAimedIOverSigma(xsDataDiffractionPlan.getAimedIOverSigmaAtHighestResolution())
            xsDataInputBest.setBeamMaxExposureTime(xsDataDiffractionPlan.getMaxExposureTimePerDataCollection())
            xsDataInputBest.setComplexity(xsDataDiffractionPlan.getComplexity())
            xsDataInputBest.setAnomalousData(xsDataDiffractionPlan.getAnomalousData())
            xsDataInputBest.setStrategyOption(xsDataDiffractionPlan.getStrategyOption())
            xsDataInputBest.setMinTransmission(xsDataDiffractionPlan.getMinTransmission())
            xsDataInputBest.setNumberOfCrystalPositions(xsDataDiffractionPlan.getNumberOfPositions())
            xsDataInputBest.setDetectorDistanceMin(xsDataDiffractionPlan.getDetectorDistanceMin())
            xsDataInputBest.setDetectorDistanceMax(xsDataDiffractionPlan.getDetectorDistanceMax())

        # Best Files
        xsDataInputBest.setBestFileContentDat(xsDataStringBestFileContentDat)
        xsDataInputBest.setBestFileContentPar(xsDataStringBestFileContentPar)
        xsDataInputBest.setBestFileContentHKL(listXSDataStringBestFileContentHKL)
        xsDataInputBest.setXdsBackgroundImage(xsDataFileXdsBackgroundImage)

        return xsDataInputBest
コード例 #3
0
    def testSetDataModelInput(self):
        edPluginBest = self.createPlugin()
        xsPluginItemGood01 = self.getPluginConfiguration(
            os.path.join(self.m_pyStrDataPath, "XSConfiguration.xml"))
        edPluginBest.setConfiguration(xsPluginItemGood01)
        edPluginBest.setScriptExecutable("cat")
        edPluginBest.configure()

        from XSDataBestv1_2 import XSDataInputBest
        xsDataInputBest = XSDataInputBest()

        from XSDataCommon import XSDataAbsorbedDoseRate
        from XSDataCommon import XSDataDouble
        from XSDataCommon import XSDataString
        from XSDataCommon import XSDataTime
        from XSDataCommon import XSDataFile
        from XSDataCommon import XSDataSpeed
        from XSDataCommon import XSDataString
        from XSDataCommon import XSDataAngle
        from XSDataCommon import XSDataBoolean

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

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

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

        bestFileContentHKL = EDUtilsFile.readFile(
            os.path.join(self.m_pyStrDataPath, "bestfile1.hkl"))
        xsDataInputBest.addBestFileContentHKL(XSDataString(bestFileContentHKL))

        xsDataInputBest.exportToFile(self.m_edObtainedInputFile)

        pyStrExpectedInput = self.readAndParseFile(self.m_edReferenceInputFile)
        pyStrObtainedInput = self.readAndParseFile(self.m_edObtainedInputFile)

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

        EDAssert.equal(xsDataInputExpected.marshal(),
                       xsDataInputObtained.marshal())
        EDUtilsFile.deleteFile(self.m_edObtainedInputFile)

        self.cleanUp(edPluginBest)
コード例 #4
0
    def getXSDataInputBest(self, _xsDataInputStrategy):
        xsDataBeam = _xsDataInputStrategy.getExperimentalCondition().getBeam()
        xsDataSample = _xsDataInputStrategy.getSample()
        xsDataDetector = _xsDataInputStrategy.getExperimentalCondition().getDetector()
        xsDataGoniostat = _xsDataInputStrategy.getExperimentalCondition().getGoniostat()
        xsDataDiffractionPlan = _xsDataInputStrategy.getDiffractionPlan()
        xsDataStringBestFileContentDat = _xsDataInputStrategy.getBestFileContentDat()
        xsDataStringBestFileContentPar = _xsDataInputStrategy.getBestFileContentPar()
        xsDataFileXdsBackgroundImage = _xsDataInputStrategy.getXdsBackgroundImage()
        listXSDataStringBestFileContentHKL = _xsDataInputStrategy.getBestFileContentHKL()
        xsDataInputBest = XSDataInputBest()

        # Sample
        xsDataAbsorbedDose = None
        xsDataSusceptibility = None

        # Could be None if sample has not been set
        # It could be not None in case Raddose has calculated an absorbed dose with default sample values
        if xsDataSample is not None:
            xsDataAbsorbedDose = xsDataSample.getAbsorbedDoseRate()
            xsDataSusceptibility = xsDataSample.getSusceptibility()
            # crystalShape
            # Default value is 1 (We assume that Xtal is smaller than beam)
            xsDataDoubleCrystalShape = xsDataSample.getShape()
            if xsDataDoubleCrystalShape is None:
                if (xsDataSample.getSize() is None) or (xsDataBeam.getSize() is None):
                    xsDataDoubleCrystalShape = XSDataDouble(1)
                else:
                    fCrystalSizeY = xsDataSample.getSize().getY().getValue()
                    fCrystalSizeZ = xsDataSample.getSize().getZ().getValue()
                    fDiagonal = math.sqrt(fCrystalSizeY ** 2 + fCrystalSizeZ ** 2)
                    fBeamSizeX = xsDataBeam.getSize().getX().getValue()
                    fCrystalShape = None
                    if fBeamSizeX > fDiagonal:
                        fCrystalShape = 1.0
                    else:
                        fCrystalShape = int(10 * fDiagonal / fBeamSizeX) / 10.0
                    xsDataDoubleCrystalShape = XSDataDouble(fCrystalShape)
            xsDataInputBest.setCrystalShape(xsDataDoubleCrystalShape)
            # Radiation damage model parameters
            xsDataInputBest.setRadiationDamageModelBeta(xsDataSample.getRadiationDamageModelBeta())
            xsDataInputBest.setRadiationDamageModelGamma(xsDataSample.getRadiationDamageModelGamma())

        # Could be None if Raddose failed to calculate the absorbed dose
        if xsDataAbsorbedDose is not None:
            xsDataInputBest.setCrystalAbsorbedDoseRate(xsDataSample.getAbsorbedDoseRate())

        xsDataInputBest.setCrystalSusceptibility(xsDataSusceptibility)

        # Detector
        xsDataInputBest.setDetectorType(xsDataDetector.getType())

        # Minimum exposure time per image
        xsDataTimeMinExposureTimePerImage = None
        if xsDataBeam:
            xsDataTimeMinExposureTimePerImage = xsDataBeam.getMinExposureTimePerImage()
        if xsDataTimeMinExposureTimePerImage == None:
            xsDataTimeMinExposureTimePerImage = xsDataDiffractionPlan.getMinExposureTimePerImage()
        xsDataInputBest.setBeamMinExposureTime(xsDataTimeMinExposureTimePerImage)

        # Max rotation speed
        xsDataAngularSpeedMax = None
        if xsDataGoniostat:
            xsDataAngularSpeedMax = xsDataGoniostat.getMaxOscillationSpeed()
        if xsDataDiffractionPlan and xsDataAngularSpeedMax == None:
            xsDataAngularSpeedMax = xsDataDiffractionPlan.getGoniostatMaxOscillationSpeed()
        xsDataInputBest.setGoniostatMaxRotationSpeed(xsDataAngularSpeedMax)

        # Min rotation width
        xsDataAngleMin = None
        if xsDataGoniostat:
            xsDataAngleMin = xsDataGoniostat.getMinOscillationWidth()
        if xsDataDiffractionPlan and xsDataAngleMin == None:
            xsDataAngleMin = xsDataDiffractionPlan.getGoniostatMinOscillationWidth()
        xsDataInputBest.setGoniostatMinRotationWidth(xsDataAngleMin)

        # Other beam parameters
        if xsDataBeam:
            xsDataInputBest.setBeamExposureTime(xsDataBeam.getExposureTime())
            if xsDataBeam.getTransmission():
                # Fix for bug 741: if the transmission is zero don't set it and warn the user
                fTransmission = xsDataBeam.getTransmission().getValue()
                if abs(fTransmission) < 0.1:
                    EDVerbose.warning(
                        "Input transmission to BEST ignored because it is zero or close to zero: %f" % fTransmission
                    )
                else:
                    xsDataInputBest.setTransmission(xsDataBeam.getTransmission())

        # Other diffraction plan parameters
        if xsDataDiffractionPlan:
            xsDataInputBest.setAimedResolution(xsDataDiffractionPlan.getAimedResolution())
            xsDataInputBest.setAimedRedundancy(xsDataDiffractionPlan.getAimedMultiplicity())
            xsDataInputBest.setAimedCompleteness(xsDataDiffractionPlan.getAimedCompleteness())
            xsDataInputBest.setAimedIOverSigma(xsDataDiffractionPlan.getAimedIOverSigmaAtHighestResolution())
            xsDataInputBest.setBeamMaxExposureTime(xsDataDiffractionPlan.getMaxExposureTimePerDataCollection())
            xsDataInputBest.setComplexity(xsDataDiffractionPlan.getComplexity())
            xsDataInputBest.setAnomalousData(xsDataDiffractionPlan.getAnomalousData())
            xsDataInputBest.setStrategyOption(xsDataDiffractionPlan.getStrategyOption())
            xsDataInputBest.setMinTransmission(xsDataDiffractionPlan.getMinTransmission())
            xsDataInputBest.setNumberOfCrystalPositions(xsDataDiffractionPlan.getNumberOfPositions())
            xsDataInputBest.setDetectorDistanceMin(xsDataDiffractionPlan.getDetectorDistanceMin())
            xsDataInputBest.setDetectorDistanceMax(xsDataDiffractionPlan.getDetectorDistanceMax())
            xsDataInputBest.setUserDefinedRotationStart(xsDataDiffractionPlan.getUserDefinedRotationStart())
            xsDataInputBest.setUserDefinedRotationRange(xsDataDiffractionPlan.getUserDefinedRotationRange())

        # Best Files
        xsDataInputBest.setBestFileContentDat(xsDataStringBestFileContentDat)
        xsDataInputBest.setBestFileContentPar(xsDataStringBestFileContentPar)
        xsDataInputBest.setBestFileContentHKL(listXSDataStringBestFileContentHKL)
        xsDataInputBest.setXdsBackgroundImage(xsDataFileXdsBackgroundImage)

        return xsDataInputBest