def testMergeTwoSubWedgesAdjascentInRotationAxis(self):
     # First check two sub wedges which shouldn't be merged
     edPluginSubWedgeMergev10 = self.createPlugin()
     edPluginSubWedgeMergev10.configure()
     xsDataInputSubWedgeMerge = XSDataInputSubWedgeMerge.parseFile(
         self.__strPathToReferenceInput)
     xsDataSubWedge1 = xsDataInputSubWedgeMerge.getSubWedge()[0]
     xsDataSubWedge2 = xsDataInputSubWedgeMerge.getSubWedge()[1]
     xsDataSubWedgeMerged = edPluginSubWedgeMergev10.mergeTwoSubWedgesAdjascentInRotationAxis(
         xsDataSubWedge1, xsDataSubWedge2)
     EDAssert.equal(xsDataSubWedgeMerged, None)
     # Then check two adjascent images
     strPathToInputTwoAdjascentImages = os.path.join(
         self.getPluginTestsDataHome(),
         "XSDataInputSubWedgeMerge_twoAdjascentImages.xml")
     xsDataInputSubWedgeMerge2 = XSDataInputSubWedgeMerge.parseFile(
         strPathToInputTwoAdjascentImages)
     xsDataSubWedge1 = xsDataInputSubWedgeMerge2.getSubWedge()[0]
     xsDataSubWedge2 = xsDataInputSubWedgeMerge2.getSubWedge()[1]
     xsDataSubWedgeMerged = edPluginSubWedgeMergev10.mergeTwoSubWedgesAdjascentInRotationAxis(
         xsDataSubWedge1, xsDataSubWedge2)
     xsDataSubWedgeMergedReference = XSDataSubWedge.parseFile(
         os.path.join(self.getPluginTestsDataHome(),
                      "XSDataSubWedgeMerged_twoImages.xml"))
     EDAssert.equal(xsDataSubWedgeMerged.marshal(),
                    xsDataSubWedgeMergedReference.marshal())
 def createDataCollectionFromImageHeaders(self, _edPlugin):
     """
     This method creates a list of XSDataSubwedges by reading the header of the images
     given as a list of paths as input.
     """
     self.DEBUG(
         "EDPluginControlSubWedgeAssemblev1_1.createDataCollectionFromImageHeaders"
     )
     xsDataInputSubWedgeAssemble = _edPlugin.getDataInput()
     listXSDataFile = xsDataInputSubWedgeAssemble.getFile()
     if (len(listXSDataFile) > 0):
         listSubWedge = []
         iIndex = 1
         for xsDataFile in listXSDataFile:
             xsDataFileCopy = XSDataFile.parseString(xsDataFile.marshal())
             xsDataInputReadImageHeader = XSDataInputReadImageHeader()
             xsDataInputReadImageHeader.setImage(xsDataFileCopy)
             self.__edPluginReadImageHeader = self.loadPlugin(
                 self.__strPluginReadImageHeaderName,
                 "ReadImageHeader_%d" % (iIndex))
             self.__edPluginReadImageHeader.setDataInput(
                 xsDataInputReadImageHeader)
             self.__edPluginReadImageHeader.executeSynchronous()
             xsDataResultReadImageHeader = self.__edPluginReadImageHeader.getDataOutput(
             )
             bSuccess = False
             if (xsDataResultReadImageHeader is not None):
                 xsDataSubWedge = xsDataResultReadImageHeader.getSubWedge()
                 if (xsDataSubWedge is not None):
                     xsDataSubWedge.setSubWedgeNumber(XSDataInteger(iIndex))
                     listSubWedge.append(xsDataSubWedge)
                     bSuccess = True
             if (not bSuccess):
                 # Fix for bug #223: raise an error if an image could not be read
                 strErrorMessage = "EDPluginControlSubWedgeAssemblev1_1.createDataCollectionFromImageHeaders: %s %s" % (
                                     self.__strPluginReadImageHeaderName, \
                                     "Could not read header from image %s" % xsDataFileCopy.getPath().getValue())
                 self.error(strErrorMessage)
                 self.addErrorMessage(strErrorMessage)
                 self.setFailure()
             iIndex += 1
         if (not self.isFailure()):
             xsDataInputSubWedgeMerge = XSDataInputSubWedgeMerge()
             for xsDataSubWedge in listSubWedge:
                 xsDataInputSubWedgeMerge.addSubWedge(xsDataSubWedge)
             self.__edPluginSubWedgeMerge.setDataInput(
                 xsDataInputSubWedgeMerge)
             self.__edPluginSubWedgeMerge.executeSynchronous()
 def testMergeTwoSubWedgesAdjascentInRotationAxis(self):
     # First check two sub wedges which shouldn't be merged
     edPluginSubWedgeMergev10 = self.createPlugin()
     edPluginSubWedgeMergev10.configure()
     xsDataInputSubWedgeMerge = XSDataInputSubWedgeMerge.parseFile(self.__strPathToReferenceInput)
     xsDataSubWedge1 = xsDataInputSubWedgeMerge.getSubWedge()[0]
     xsDataSubWedge2 = xsDataInputSubWedgeMerge.getSubWedge()[1]
     xsDataSubWedgeMerged = edPluginSubWedgeMergev10.mergeTwoSubWedgesAdjascentInRotationAxis(xsDataSubWedge1, xsDataSubWedge2)
     EDAssert.equal(xsDataSubWedgeMerged, None)
     # Then check two adjascent images
     strPathToInputTwoAdjascentImages = os.path.join(self.getPluginTestsDataHome(), "XSDataInputSubWedgeMerge_twoAdjascentImages.xml")
     xsDataInputSubWedgeMerge2 = XSDataInputSubWedgeMerge.parseFile(strPathToInputTwoAdjascentImages)
     xsDataSubWedge1 = xsDataInputSubWedgeMerge2.getSubWedge()[0]
     xsDataSubWedge2 = xsDataInputSubWedgeMerge2.getSubWedge()[1]
     xsDataSubWedgeMerged = edPluginSubWedgeMergev10.mergeTwoSubWedgesAdjascentInRotationAxis(xsDataSubWedge1, xsDataSubWedge2)
     xsDataSubWedgeMergedReference = XSDataSubWedge.parseFile(os.path.join(self.getPluginTestsDataHome(), "XSDataSubWedgeMerged_twoImages.xml"))
     EDAssert.equal(xsDataSubWedgeMerged.marshal(), xsDataSubWedgeMergedReference.marshal())
 def testMergeListOfSubWedgesWithAdjascentRotationAxis(self):
     edPluginSubWedgeMergev10 = self.createPlugin()
     edPluginSubWedgeMergev10.configure()
     # Check a list of nine adjascent images
     strPathToInputNineAdjascentImages = os.path.join(self.getPluginTestsDataHome(), "XSDataInputSubWedgeMerge_nineAdjascentImages.xml")
     xsDataInputSubWedgeMergeNine = XSDataInputSubWedgeMerge.parseFile(strPathToInputNineAdjascentImages)
     xsDataSubWedgeMerged = edPluginSubWedgeMergev10.mergeListOfSubWedgesWithAdjascentRotationAxis(xsDataInputSubWedgeMergeNine.getSubWedge())
     xsDataSubWedgeMergedReference = XSDataSubWedge.parseFile(os.path.join(self.getPluginTestsDataHome(), "XSDataSubWedgeMerged_nineImages.xml"))
     EDAssert.equal(xsDataSubWedgeMerged[0].marshal(), xsDataSubWedgeMergedReference.marshal())
 def createDataCollectionFromImageHeaders(self, _edPlugin):
     """
     This method creates a list of XSDataSubwedges by reading the header of the images
     given as a list of paths as input.
     """
     EDVerbose.DEBUG("EDPluginControlSubWedgeAssemblev1_1.createDataCollectionFromImageHeaders")
     xsDataInputSubWedgeAssemble = _edPlugin.getDataInput()
     listXSDataFile = xsDataInputSubWedgeAssemble.getFile()
     if (len(listXSDataFile) > 0):
         listSubWedge = []
         iIndex = 1
         for xsDataFile in listXSDataFile:
             xsDataFileCopy = XSDataFile.parseString(xsDataFile.marshal())
             xsDataInputReadImageHeader = XSDataInputReadImageHeader()
             xsDataInputReadImageHeader.setImage(xsDataFileCopy)
             self.__edPluginReadImageHeader = self.loadPlugin(self.__strPluginReadImageHeaderName, "ReadImageHeader_%d" % (iIndex))
             self.__edPluginReadImageHeader.setDataInput(xsDataInputReadImageHeader)
             self.__edPluginReadImageHeader.executeSynchronous()
             xsDataResultReadImageHeader = self.__edPluginReadImageHeader.getDataOutput()
             bSuccess = False
             if (xsDataResultReadImageHeader is not None):
                 xsDataSubWedge = xsDataResultReadImageHeader.getSubWedge()
                 if (xsDataSubWedge is not None):
                     xsDataSubWedge.setSubWedgeNumber(XSDataInteger(iIndex))
                     listSubWedge.append(xsDataSubWedge)
                     bSuccess = True
             if (not bSuccess):
                 # Fix for bug #223: raise an error if an image could not be read
                 strErrorMessage = "EDPluginControlSubWedgeAssemblev1_1.createDataCollectionFromImageHeaders: %s %s" % (
                                     self.__strPluginReadImageHeaderName, \
                                     "Could not read header from image %s" % xsDataFileCopy.getPath().getValue())
                 EDVerbose.error(strErrorMessage)
                 self.addErrorMessage(strErrorMessage)
                 self.setFailure()
             iIndex += 1
         if (not self.isFailure()):
             xsDataInputSubWedgeMerge = XSDataInputSubWedgeMerge()
             for xsDataSubWedge in listSubWedge:
                 xsDataInputSubWedgeMerge.addSubWedge(xsDataSubWedge)
             self.__edPluginSubWedgeMerge.setDataInput(xsDataInputSubWedgeMerge)
             self.__edPluginSubWedgeMerge.executeSynchronous()
 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)
 def createDataCollectionFromImageHeaders(self, _edPlugin):
     """
     This method creates a list of XSDataSubwedges by reading the header of the images
     given as a list of paths as input.
     """
     EDVerbose.DEBUG("EDPluginControlSubWedgeAssemblev10.createDataCollectionFromImageHeaders")
     xsDataInputSubWedgeAssemble = _edPlugin.getDataInput()
     listXSDataFile = xsDataInputSubWedgeAssemble.getFile()
     if (len(listXSDataFile) > 0):
         listSubWedge = []
         iIndex = 1
         for xsDataFile in listXSDataFile:
             xsDataFileCopy = XSDataFile.parseString(xsDataFile.marshal())
             xsDataInputReadImageHeader = XSDataInputReadImageHeader()
             xsDataInputReadImageHeader.setImage(xsDataFileCopy)
             self.__edPluginReadImageHeader = self.loadPlugin(self.__strPluginReadImageHeaderName, "ReadImageHeader_%d" % (iIndex))
             self.__edPluginReadImageHeader.setDataInput(xsDataInputReadImageHeader)
             self.__edPluginReadImageHeader.executeSynchronous()
             xsDataResultReadImageHeader = self.__edPluginReadImageHeader.getDataOutput()
             xsDataSubWedge = xsDataResultReadImageHeader.getSubWedge()
             if (xsDataSubWedge is None):
                 # Fix for bug #223: raise an error if an image could not be read
                 errorMessage = EDMessage.ERROR_EXECUTION_03 % ("EDPluginControlSubWedgeAssemblev10.createDataCollectionFromImageHeaders", \
                                                                 self.__strPluginReadImageHeaderName, \
                                                                 "Could not read header from image %s" % xsDataFileCopy.getPath().getValue())
                 EDVerbose.error(errorMessage)
                 self.addErrorMessage(errorMessage)
                 raise RuntimeError, errorMessage
             else:
                 listSubWedge.append(xsDataSubWedge)
             iIndex += 1
         xsDataInputSubWedgeMerge = XSDataInputSubWedgeMerge()
         for xsDataSubWedge in listSubWedge:
             xsDataInputSubWedgeMerge.addSubWedge(xsDataSubWedge)
         self.__edPluginSubWedgeMerge.setDataInput(xsDataInputSubWedgeMerge)
         self.__edPluginSubWedgeMerge.executeSynchronous()
 def testMergeListOfSubWedgesWithAdjascentRotationAxis(self):
     edPluginSubWedgeMergev10 = self.createPlugin()
     edPluginSubWedgeMergev10.configure()
     # Check a list of nine adjascent images
     strPathToInputNineAdjascentImages = os.path.join(
         self.getPluginTestsDataHome(),
         "XSDataInputSubWedgeMerge_nineAdjascentImages.xml")
     xsDataInputSubWedgeMergeNine = XSDataInputSubWedgeMerge.parseFile(
         strPathToInputNineAdjascentImages)
     xsDataSubWedgeMerged = edPluginSubWedgeMergev10.mergeListOfSubWedgesWithAdjascentRotationAxis(
         xsDataInputSubWedgeMergeNine.getSubWedge())
     xsDataSubWedgeMergedReference = XSDataSubWedge.parseFile(
         os.path.join(self.getPluginTestsDataHome(),
                      "XSDataSubWedgeMerged_nineImages.xml"))
     EDAssert.equal(xsDataSubWedgeMerged[0].marshal(),
                    xsDataSubWedgeMergedReference.marshal())
 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)