def testCreateDataMOSFLMOutputGeneratePrediction(self):
        """
        """
        pluginGeneratePrediction = self.createPlugin()
        pluginGeneratePrediction.setScriptExecutable("cat")
        pluginGeneratePrediction.configure()
        pluginGeneratePrediction.setPredictionImageFileName("prediction.jpg")
        stringBaseName = pluginGeneratePrediction.getBaseName()
        stringNewmatFile = os.path.join(
            self.strUnitTestDataHome, "EDPluginMOSFLMv10_autoindexMat_ok.txt")
        pluginGeneratePrediction.setNewmatFileName(stringNewmatFile)
        from XSDataMOSFLMv10 import XSDataMOSFLMInputGeneratePrediction
        xsDataMOSFLMInputGeneratePrediction = XSDataMOSFLMInputGeneratePrediction.parseFile(
            os.path.join(self.strUnitTestDataHome,
                         "XSDataMOSFLMInputGeneratePrediction_reference.xml"))
        pluginGeneratePrediction.setDataInput(
            xsDataMOSFLMInputGeneratePrediction)
        xsDataMOSFLMOutputGeneratePrediction = pluginGeneratePrediction.createDataMOSFLMOutputGeneratePrediction(
        )
        stringImagePath = xsDataMOSFLMOutputGeneratePrediction.getPredictionImage(
        ).getPath().getValue()
        stringReferenceXML = self.readAndParseFile(
            self.strReferenceDataOutputFile)
        from XSDataMOSFLMv10 import XSDataMOSFLMOutputGeneratePrediction
        xsDataMOSFLMOutputGeneratePredictionReference = XSDataMOSFLMOutputGeneratePrediction.parseString(
            stringReferenceXML)
        xsDataImage = xsDataMOSFLMOutputGeneratePredictionReference.getPredictionImage(
        )
        xsDataImage.setPath(XSDataString(stringImagePath))
        xsDataMOSFLMOutputGeneratePredictionReference.setPredictionImage(
            xsDataImage)
        # Replace path to log file since it cannot be determined by the unit test
        xsDataMOSFLMOutputGeneratePrediction.setPathToLogFile(
            XSDataFile(XSDataString("MOSFLMGeneratePredictionv10.log")))
        EDAssert.equal(xsDataMOSFLMOutputGeneratePredictionReference.marshal(),
                       xsDataMOSFLMOutputGeneratePrediction.marshal())

        self.cleanUp(pluginGeneratePrediction)
    def testCreateDataMOSFLMOutputGeneratePrediction(self):
        """
        """
        pluginGeneratePrediction = self.createPlugin()
        pluginGeneratePrediction.setScriptExecutable("cat")
        pluginGeneratePrediction.configure()
        pluginGeneratePrediction.setPredictionImageFileName("prediction.jpg")
        stringBaseName = pluginGeneratePrediction.getBaseName()
        stringNewmatFile = os.path.join(self.strUnitTestDataHome, "EDPluginMOSFLMv10_autoindexMat_ok.txt")
        pluginGeneratePrediction.setNewmatFileName(stringNewmatFile)
        from XSDataMOSFLMv10 import XSDataMOSFLMInputGeneratePrediction

        xsDataMOSFLMInputGeneratePrediction = XSDataMOSFLMInputGeneratePrediction.parseFile(
            os.path.join(self.strUnitTestDataHome, "XSDataMOSFLMInputGeneratePrediction_reference.xml")
        )
        pluginGeneratePrediction.setDataInput(xsDataMOSFLMInputGeneratePrediction)
        xsDataMOSFLMOutputGeneratePrediction = pluginGeneratePrediction.createDataMOSFLMOutputGeneratePrediction()
        stringImagePath = xsDataMOSFLMOutputGeneratePrediction.getPredictionImage().getPath().getValue()
        stringReferenceXML = self.readAndParseFile(self.strReferenceDataOutputFile)
        from XSDataMOSFLMv10 import XSDataMOSFLMOutputGeneratePrediction

        xsDataMOSFLMOutputGeneratePredictionReference = XSDataMOSFLMOutputGeneratePrediction.parseString(
            stringReferenceXML
        )
        xsDataImage = xsDataMOSFLMOutputGeneratePredictionReference.getPredictionImage()
        xsDataImage.setPath(XSDataString(stringImagePath))
        xsDataMOSFLMOutputGeneratePredictionReference.setPredictionImage(xsDataImage)
        # Replace path to log file since it cannot be determined by the unit test
        xsDataMOSFLMOutputGeneratePrediction.setPathToLogFile(
            XSDataFile(XSDataString("MOSFLMGeneratePredictionv10.log"))
        )
        EDAssert.equal(
            xsDataMOSFLMOutputGeneratePredictionReference.marshal(), xsDataMOSFLMOutputGeneratePrediction.marshal()
        )

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

        xsDataIndexingSolutionSelected = xsDataGeneratePredictionInput.getSelectedIndexingSolution(
        )

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

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

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

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

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

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

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

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

        # The MOSFLM plugin can only handle one image

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

        iImageNumber = xsDataImage.getNumber().getValue()

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

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

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

        xsDataMOSFLMInputGeneratePrediction.setImage(xsDataMOSFLMImage)

        return xsDataMOSFLMInputGeneratePrediction
    def 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
    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
    def generateXSDataMOSFLMInputGeneratePrediction(xsDataGeneratePredictionInput):
        """
        Translation from XSDataGeneratePredictionInput to XSDataMOSFLMInputGeneratePrediction.
        """
        EDVerbose.DEBUG("EDHandlerXSDataMOSFLMv10.generateXSDataMOSFLMInputGeneratePrediction")
        EDFactoryPluginStatic.loadModule("XSDataMOSFLMv10")
        from XSDataMOSFLMv10 import XSDataMOSFLMBeamPosition
        from XSDataMOSFLMv10 import XSDataMOSFLMImage
        from XSDataMOSFLMv10 import XSDataMOSFLMNewmat
        from XSDataMOSFLMv10 import XSDataMOSFLMMissettingsAngles
        from XSDataMOSFLMv10 import XSDataMOSFLMInputGeneratePrediction

        xsDataIndexingSolutionSelected = xsDataGeneratePredictionInput.getSelectedIndexingSolution()

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

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

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

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

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

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

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

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

        strMOSFLMTemplate = EDUtilsImage.getTemplate(strFilenameFirst, "#")
        xsDataMOSFLMInputGeneratePrediction.setTemplate(XSDataString(strMOSFLMTemplate))

        # The MOSFLM plugin can only handle one image 

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

        xsDataMOSFLMImage = XSDataMOSFLMImage()

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

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

        xsDataMOSFLMInputGeneratePrediction.setImage(xsDataMOSFLMImage)

        return xsDataMOSFLMInputGeneratePrediction