Пример #1
0
 def mergeTwoSubWedgesAdjascentInRotationAxis(self, _subWedge1, _subWedge2):
     """
     This method takes as input two sub wedges and merges them to an unique subwedge, if possible,
     and returns the resulting merged sub wedge. If the merge is not possible a None is returned.
     """
     EDVerbose.DEBUG(
         "EDPluginSubWedgeMergev1_1.mergeTwoSubWedgesAdjascentInRotationAxis"
     )
     xsDataSubWedgeMerged = None
     # First check that the two sub wedges have identical experimental conditions
     if (self.isSameExperimentalConditionInSubWedge(_subWedge1,
                                                    _subWedge2)):
         # Check if sub wedges are adjascent:
         dRoationAxisEnd1 = _subWedge1.getExperimentalCondition(
         ).getGoniostat().getRotationAxisEnd().getValue()
         dRoationAxisStart2 = _subWedge2.getExperimentalCondition(
         ).getGoniostat().getRotationAxisStart().getValue()
         #print dRoationAxisEnd1, dRoationAxisStart2
         if (self.compareTwoValues(dRoationAxisEnd1, dRoationAxisStart2,
                                   0.001)):
             # Same sub wedge! Let's merge them
             xsDataSubWedgeMerged = XSDataSubWedge.parseString(
                 _subWedge1.marshal())
             xsDataSubWedge2 = XSDataSubWedge.parseString(
                 _subWedge2.marshal())
             dRoationAxisEnd2 = xsDataSubWedge2.getExperimentalCondition(
             ).getGoniostat().getRotationAxisEnd().getValue()
             xsDataSubWedgeMerged.getExperimentalCondition().getGoniostat(
             ).setRotationAxisEnd(XSDataAngle(dRoationAxisEnd2))
             for xsDataImage in xsDataSubWedge2.getImage():
                 xsDataSubWedgeMerged.addImage(xsDataImage)
     return xsDataSubWedgeMerged
 def mergeListOfSubWedgesWithAdjascentRotationAxis(self, _listOfSubWedgesWithIdenticalExperimentalConditions):
     """
     This method merges sub wedges in a list if they are adjascent in phi.
     """
     self.DEBUG("EDPluginSubWedgeMergev1_1.mergeSubWedgesWithAdjascentRotationAxis")
     # Copy the incoming list to a new list
     listOfSubWedgesWithIdenticalExperimentalConditions = []
     for xsDataSubWedge in _listOfSubWedgesWithIdenticalExperimentalConditions:
         listOfSubWedgesWithIdenticalExperimentalConditions.append(XSDataSubWedge.parseString(xsDataSubWedge.marshal()))
     listOfMergedSubWedges = []
     if (len(listOfSubWedgesWithIdenticalExperimentalConditions) == 0):
         pass
     elif (len(listOfSubWedgesWithIdenticalExperimentalConditions) == 1):
         listOfMergedSubWedges = listOfSubWedgesWithIdenticalExperimentalConditions
     else:
         # First sort the list as function of rotation axis start
         listOfSubWedgesWithIdenticalExperimentalConditions.sort(lambda x, y: cmp(x.getExperimentalCondition().getGoniostat().getRotationAxisStart().getValue(), \
                                                                                     y.getExperimentalCondition().getGoniostat().getRotationAxisStart().getValue()))
         # Then loop through the subwedges and merge them if possible
         listRemainingSubWedges = listOfSubWedgesWithIdenticalExperimentalConditions
         oCurrentSubWedge = listRemainingSubWedges[0]
         listRemainingSubWedges = listRemainingSubWedges[1:]
         while (len(listRemainingSubWedges) > 0):
             oNextSubWedge = listRemainingSubWedges[0]
             listRemainingSubWedges = listRemainingSubWedges[1:]
             xsDataSubWedgeMerged = self.mergeTwoSubWedgesAdjascentInRotationAxis(oCurrentSubWedge, oNextSubWedge)
             if (xsDataSubWedgeMerged is None):
                 listOfMergedSubWedges.append(oCurrentSubWedge)
                 oCurrentSubWedge = oNextSubWedge
             else:
                 oCurrentSubWedge = xsDataSubWedgeMerged
         listOfMergedSubWedges.append(oCurrentSubWedge)
     return listOfMergedSubWedges
Пример #3
0
 def mergeListOfSubWedgesWithAdjascentRotationAxis(self, _listOfSubWedgesWithIdenticalExperimentalConditions):
     """
     This method merges sub wedges in a list if they are adjascent in phi.
     """
     EDVerbose.DEBUG("EDPluginSubWedgeMergev10.mergeSubWedgesWithAdjascentRotationAxis")
     # Copy the incoming list to a new list
     listOfSubWedgesWithIdenticalExperimentalConditions = []
     for xsDataSubWedge in _listOfSubWedgesWithIdenticalExperimentalConditions:
         listOfSubWedgesWithIdenticalExperimentalConditions.append(XSDataSubWedge.parseString(xsDataSubWedge.marshal()))
     listOfMergedSubWedges = []
     if (len(listOfSubWedgesWithIdenticalExperimentalConditions) == 0):
         pass
     elif (len(listOfSubWedgesWithIdenticalExperimentalConditions) == 1):
         listOfMergedSubWedges = listOfSubWedgesWithIdenticalExperimentalConditions
     else:
         # First sort the list as function of rotation axis start
         listOfSubWedgesWithIdenticalExperimentalConditions.sort(lambda x, y: cmp(x.getExperimentalCondition().getGoniostat().getRotationAxisStart().getValue(), \
                                                                                     y.getExperimentalCondition().getGoniostat().getRotationAxisStart().getValue()))
         # Then loop through the subwedges and merge them if possible
         listRemainingSubWedges = listOfSubWedgesWithIdenticalExperimentalConditions
         oCurrentSubWedge = listRemainingSubWedges[0]
         listRemainingSubWedges = listRemainingSubWedges[1:]
         while (len(listRemainingSubWedges) > 0):
             oNextSubWedge = listRemainingSubWedges[0]
             listRemainingSubWedges = listRemainingSubWedges[1:]
             xsDataSubWedgeMerged = self.mergeTwoSubWedgesAdjascentInRotationAxis(oCurrentSubWedge, oNextSubWedge)
             if (xsDataSubWedgeMerged is None):
                 listOfMergedSubWedges.append(oCurrentSubWedge)
                 oCurrentSubWedge = oNextSubWedge
             else:
                 oCurrentSubWedge = xsDataSubWedgeMerged
         listOfMergedSubWedges.append(oCurrentSubWedge)
     return listOfMergedSubWedges
 def mergeTwoSubWedgesAdjascentInRotationAxis(self, _subWedge1, _subWedge2):
     """
     This method takes as input two sub wedges and merges them to an unique subwedge, if possible,
     and returns the resulting merged sub wedge. If the merge is not possible a None is returned.
     """
     self.DEBUG("EDPluginSubWedgeMergev1_1.mergeTwoSubWedgesAdjascentInRotationAxis")
     xsDataSubWedgeMerged = None
     # First check that the two sub wedges have identical experimental conditions
     if (self.isSameExperimentalConditionInSubWedge(_subWedge1, _subWedge2)):
         # Check if sub wedges are adjascent:
         dRoationAxisEnd1 = _subWedge1.getExperimentalCondition().getGoniostat().getRotationAxisEnd().getValue()
         dRoationAxisStart2 = _subWedge2.getExperimentalCondition().getGoniostat().getRotationAxisStart().getValue()
         #print dRoationAxisEnd1, dRoationAxisStart2
         if (self.compareTwoValues(dRoationAxisEnd1, dRoationAxisStart2, 0.001)):
             # Same sub wedge! Let's merge them
             xsDataSubWedgeMerged = XSDataSubWedge.parseString(_subWedge1.marshal())
             xsDataSubWedge2 = XSDataSubWedge.parseString(_subWedge2.marshal())
             dRoationAxisEnd2 = xsDataSubWedge2.getExperimentalCondition().getGoniostat().getRotationAxisEnd().getValue()
             xsDataSubWedgeMerged.getExperimentalCondition().getGoniostat().setRotationAxisEnd(XSDataAngle(dRoationAxisEnd2))
             for xsDataImage in xsDataSubWedge2.getImage():
                 xsDataSubWedgeMerged.addImage(xsDataImage)
     return xsDataSubWedgeMerged