def testSetDataModelInput(self):
        """
        """
        edPluginBest = self.createPlugin()
        xsPluginItemGood01 = self.getPluginConfiguration(os.path.join(self.strDataPath, "XSConfiguration.xml"))
        edPluginBest.setConfiguration(xsPluginItemGood01)
        edPluginBest.setScriptExecutable("cat")
        edPluginBest.configure()

        from XSDataBestv10 import XSDataBestInput

        xsDataBestInput = XSDataBestInput()

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

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

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

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

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

        xsDataBestInput.outputFile(self.strObtainedInputFile)

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

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

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

        self.cleanUp(edPluginBest)
Esempio n. 2
0
    def getXSDataBestInput(self, _xsDataBeam, _xsDataSample, _xsDataDetector, _xsDataGoniostat, _xsDataDiffractionPlan,
                               _oedStrBestFileContentDat, _oedStrBestFileContentPar, _oedListBestFileContentHKL):
        xsDataBestInput = XSDataBestInput()

        # 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()

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

        xsDataBestInput.setCrystalSusceptibility(xsDataSusceptibility)

        # crystalShape
        # Default value is 1 (We assume that Xtal is smaller than beam)
        xsDataFloatCrystalShape = _xsDataSample.getShape()
        if(xsDataFloatCrystalShape is None):
            xsDataBestInput.setCrystalShape(XSDataFloat(1))
        else:
            xsDataBestInput.setCrystalShape(xsDataFloatCrystalShape)

        # Detector
        xsDataBestInput.setDetectorType(_xsDataDetector.getType())

        # Beam
        xsDataBestInput.setBeamExposureTime(_xsDataBeam.getExposureTime())
        xsDataBestInput.setBeamMinExposureTime(_xsDataBeam.getMinExposureTimePerImage())

        # Goniostat
        xsDataBestInput.setGoniostatMaxRotationSpeed(_xsDataGoniostat.getMaxOscillationSpeed())
        xsDataBestInput.setGoniostatMinRotationWidth(_xsDataGoniostat.getMinOscillationWidth())

        # Diffraction plan
        xsDataBestInput.setAimedResolution(_xsDataDiffractionPlan.getAimedResolution())
        xsDataBestInput.setAimedRedundancy(_xsDataDiffractionPlan.getAimedMultiplicity())
        xsDataBestInput.setAimedCompleteness(_xsDataDiffractionPlan.getAimedCompleteness())
        xsDataBestInput.setAimedIOverSigma(_xsDataDiffractionPlan.getAimedIOverSigmaAtHighestResolution())
        xsDataBestInput.setBeamMaxExposureTime(_xsDataDiffractionPlan.getMaxExposureTimePerDataCollection())
        xsDataBestInput.setComplexity(_xsDataDiffractionPlan.getComplexity())

        # Best Files
        xsDataBestInput.setBestFileContentDat(_oedStrBestFileContentDat)
        xsDataBestInput.setBestFileContentPar(_oedStrBestFileContentPar)
        xsDataBestInput.setBestFileContentHKL(_oedListBestFileContentHKL)

        return xsDataBestInput
Esempio n. 3
0
    def testSetDataModelInput(self):
        """
        """
        edPluginBest = self.createPlugin()
        xsPluginItemGood01 = self.getPluginConfiguration(
            os.path.join(self.strDataPath, "XSConfiguration.xml"))
        edPluginBest.setConfiguration(xsPluginItemGood01)
        edPluginBest.setScriptExecutable("cat")
        edPluginBest.configure()

        from XSDataBestv10 import XSDataBestInput
        xsDataBestInput = XSDataBestInput()

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

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

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

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

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

        xsDataBestInput.outputFile(self.strObtainedInputFile)

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

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

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

        self.cleanUp(edPluginBest)