Exemple #1
0
 def testGenerateStrategyShortSummary(self):
     edPluginStrategy = self.createPlugin()
     strReferenceOutputFile = os.path.join(self.getPluginTestsDataHome(), "XSDataResultStrategy_2_sweep.xml")
     strXML = self.readAndParseFile(strReferenceOutputFile)
     xsDataStrategyResult = XSDataResultStrategy.parseString(strXML)
     edPluginStrategy.generateStrategyShortSummary(xsDataStrategyResult)
     for strLine in edPluginStrategy.getDataOutput("strategyShortSummary")[0].getValue().split("\n"):
         EDVerbose.unitTest(strLine)
 def testGenerateStrategyShortSummary(self):
     edPluginStrategy = self.createPlugin()
     strReferenceOutputFile = os.path.join(self.getPluginTestsDataHome(), "XSDataResultStrategy_2_sweep.xml")
     strXML = self.readAndParseFile(strReferenceOutputFile)
     xsDataStrategyResult = XSDataResultStrategy.parseString(strXML)
     edPluginStrategy.generateStrategyShortSummary(xsDataStrategyResult)
     for strLine in edPluginStrategy.getDataOutput("strategyShortSummary")[0].getValue().split("\n"):
         self.unitTest(strLine)
    def mergeStrategyToNewOrientation(_xsDataResultStrategy, _xsDataCollection, _fOmega, _fKappa, _fPhi):
        '''
        _xsDataResultStrategy: reference strategy results as the template for the new strategy
        _xsDataCollection: The data collection that will be merged in
        
        result:
        suggestedStrategy(XSDataResultStrategy): the strategy resulted from the merge
        '''
#        suggestedStrategy = None
#        try:
#            newpossibleOrientations=XSDataSTACv01.kappa_alignment_response.parseString(_possible_orientation.marshal())
#        except:
#            newpossibleOrientations=None
        #so we will copy the strategy of collecting the reference images inputed to here but at the new orientation
        #get the full strategy from the Reference
        EDFactoryPluginStatic.loadModule("XSDataMXv1")
        from XSDataMXv1 import XSDataResultStrategy
        suggestedStrategy = XSDataResultStrategy.parseString(_xsDataResultStrategy.marshal())
        #take only the first CollectionPlan
        if len(suggestedStrategy.getCollectionPlan()) > 0:
            suggestedStrategy.setCollectionPlan([suggestedStrategy.getCollectionPlan()[0]])
            #modify the DC part taking it from the input 
            suggestedStrategy.getCollectionPlan()[0].setCollectionStrategy(_xsDataCollection)
            #and modify the Orientation
          #  dc = XSDataMXv2.XSDataCollection()
          #  dc = self.getDataInput("mxv2DataCollection_Reference")[0]
    #        Orients = _possible_orientation.getPossible_orientation()
    #        omega = Orients[0].getOmega()
    #        kappa = Orients[0].getKappa()
    #        phi = Orients[0].getPhi()
            suggestedStrategy = EDHandlerXSDataMXv1v1_0.copyStrategyToNewOrientation(suggestedStrategy, _fOmega, _fKappa, _fPhi, "MERGED")
    #        for dcplan in suggestedStrategy.getCollectionPlan():
    #            dcplan.setComment(EDHandlerXSDataMXv1v1_0().replaceElements(dcplan.getComment(), "OMEGA=", omega))
    #            dcplan.setComment(EDHandlerXSDataMXv1v1_0().replaceElements(dcplan.getComment(), "KAPPA=", kappa))
    #            dcplan.setComment(EDHandlerXSDataMXv1v1_0().replaceElements(dcplan.getComment(), "PHI=", phi))
            #finally take the suggested new orientation out of the list of further possible ones
    #        if newpossibleOrientations is not None:
    #            newpossibleOrientations.setPossible_orientation([])
    #            for i in range(1, Orients.__len__()):
    #                if (math.fabs(float(Orients[i].getKappa())-float(kappa))<tol and math.fabs(float(Orients[i].getPhi())-float(phi))<tol):
    #                    newpossibleOrientations.addPossible_orientation(Orients[i])
    #        return [suggestedStrategy,newpossibleOrientations]
        return suggestedStrategy
 def copyStrategyToNewOrientation(_xsDataResultStrategy, _fOmega, _fKappa, _fPhi, _strategy = "COPIED"):
     '''
     _xsDataResultStrategy: the strategy results in which the orientation should be changed
     omega,kappa,phi: the new orientation
     
     result:
     suggestedStrategy(XSDataResultStrategy): the strategy in which the orientation is changed
     '''
     #we suggest the currently calculated strategy
     EDFactoryPluginStatic.loadModule("XSDataMXv1")
     from XSDataMXv1 import XSDataResultStrategy
     suggestedStrategy = XSDataResultStrategy.parseString(_xsDataResultStrategy.marshal())
     #and we have to add the actual orientation
     EDFactoryPluginStatic.loadModule("EDHandlerXSDataCommon")
     from EDHandlerXSDataCommon import EDHandlerXSDataCommon
     for dcplan in suggestedStrategy.getCollectionPlan():
         dcplan.setComment(EDHandlerXSDataCommon.replaceElements(dcplan.getComment(), "OMEGA=", str(_fOmega)))
         dcplan.setComment(EDHandlerXSDataCommon.replaceElements(dcplan.getComment(), "KAPPA=", str(_fKappa)))
         dcplan.setComment(EDHandlerXSDataCommon.replaceElements(dcplan.getComment(), "PHI=", str(_fPhi)))
         dcplan.setComment(EDHandlerXSDataCommon.replaceElements(dcplan.getComment(), "STRATEGY=", str(_strategy)))
     return suggestedStrategy
Exemple #5
0
from EDFactoryPluginStatic import EDFactoryPluginStatic
EDFactoryPluginStatic.loadModule("XSDataMXv1")

from XSDataMXv1 import XSDataResultStrategy
xsDataResultStrategy = XSDataResultStrategy.parseString(mxv1StrategyResult)
xsDataCollectionPlan = xsDataResultStrategy.getCollectionPlan()[0]
xsDataCollectionStrategy = xsDataCollectionPlan.getCollectionStrategy()
xsDataSubWedge = xsDataCollectionStrategy.getSubWedge()[0]
xsDataExperimentalCondition = xsDataSubWedge.getExperimentalCondition()
exposureTime = xsDataExperimentalCondition.getBeam().getExposureTime(
).getValue()
detectorDistance = xsDataExperimentalCondition.getDetector().getDistance(
).getValue()
oscillationWidth = xsDataExperimentalCondition.getGoniostat(
).getOscillationWidth().getValue()
rotationAxisStart = xsDataExperimentalCondition.getGoniostat(
).getRotationAxisStart().getValue()
rotationAxisEnd = xsDataExperimentalCondition.getGoniostat(
).getRotationAxisEnd().getValue()
noImages = int((rotationAxisEnd - rotationAxisStart) / oscillationWidth)
runNumberDataCollection = run_number

print "Suggested strategy:"
print "Oscillation start: %.2f" % rotationAxisStart
print "Oscillation width: %.2f" % oscillationWidth
print "No images: %d" % noImages
print "Exposure time: %.2f" % exposureTime
print "Detector distance: %.2f" % detectorDistance
print "Run number: %d " % runNumberDataCollection
from EDFactoryPluginStatic import EDFactoryPluginStatic
EDFactoryPluginStatic.loadModule("XSDataMXv1")


from XSDataMXv1 import XSDataResultStrategy
xsDataResultStrategy = XSDataResultStrategy.parseString(suggestedStrategy)

for xsDataCollectionPlan in xsDataResultStrategy:
    if xsDataCollectionPlan.getCollectionPlanNumber().getValue() == collectionPlanIndex:
        break
from EDFactoryPluginStatic import EDFactoryPluginStatic

EDFactoryPluginStatic.loadModule("XSDataMXv1")

from XSDataMXv1 import XSDataResultStrategy

xsDataResultStrategy = XSDataResultStrategy.parseString(suggestedStrategy)

for xsDataCollectionPlan in xsDataResultStrategy:
    if xsDataCollectionPlan.getCollectionPlanNumber().getValue(
    ) == collectionPlanIndex:
        break
from EDFactoryPluginStatic import EDFactoryPluginStatic
EDFactoryPluginStatic.loadModule("XSDataMXv1")


from XSDataMXv1 import XSDataResultStrategy
xsDataResultStrategy = XSDataResultStrategy.parseString(mxv1StrategyResult)
xsDataCollectionPlan = xsDataResultStrategy.getCollectionPlan()[0]
xsDataCollectionStrategy = xsDataCollectionPlan.getCollectionStrategy()
xsDataSubWedge = xsDataCollectionStrategy.getSubWedge()[0]
xsDataExperimentalCondition = xsDataSubWedge.getExperimentalCondition()
exposureTime = xsDataExperimentalCondition.getBeam().getExposureTime().getValue()
detectorDistance = xsDataExperimentalCondition.getDetector().getDistance().getValue()
oscillationWidth = xsDataExperimentalCondition.getGoniostat().getOscillationWidth().getValue()
rotationAxisStart = xsDataExperimentalCondition.getGoniostat().getRotationAxisStart().getValue()
rotationAxisEnd = xsDataExperimentalCondition.getGoniostat().getRotationAxisEnd().getValue()
noImages = int( (rotationAxisEnd - rotationAxisStart) / oscillationWidth)
runNumberDataCollection = run_number

print "Suggested strategy:"
print "Oscillation start: %.2f" % rotationAxisStart
print "Oscillation width: %.2f" % oscillationWidth
print "No images: %d" % noImages
print "Exposure time: %.2f" % exposureTime
print "Detector distance: %.2f" % detectorDistance
print "Run number: %d " % runNumberDataCollection