def __init__(self): """ """ EDPluginControl.__init__(self) self.setXSDataInputClass(XSDataInputCharacterisationv2_0) self.setXSDataInputClass(XSDataInputCharacterisation, "mxv1InputCharacterisation") self.setXSDataInputClass(XSDataResultCharacterisation, "mxv1ResultCharacterisation_Reference") self.setXSDataInputClass(XSDataCollection, "mxv2DataCollection") self.setXSDataInputClass(XSDataMXv2.XSDataCollection, "mxv2DataCollection_Reference") self.setXSDataInputClass(kappa_alignment_response, "possibleOrientations") self.strPluginControlCharacterisation = "EDPluginControlCharacterisationv1_3" self.edPluginControlCharacterisation = None self.mxv1InputCharacterisation = None self.mxv1ResultCharacterisation_Reference = None self.mxv2DataCollection = None self.mxv2DataCollection_Reference = None self.strPluginStrategyName = None self.edPluginControlStrategy = None self.xsDataResultCharacterisation = None self.suggestedStrategy = None self.suggestedStrategy = None self.possibleOrientations = None self.newpossibleOrientations = None self.xsDataResultCharacterisationv2_0 = XSDataResultCharacterisationv2_0( )
def preProcess(self, _edObject=None): """ Gets the Configuration Parameters, if found, overrides default parameters """ EDPluginControl.preProcess(self, _edObject) EDVerbose.DEBUG("EDPluginControlCharacterisationv2_0.preProcess...") self.edPluginIndexing = self.loadPlugin(self.strPluginIndexingName, "Indexing") self.edPluginIntegration = self.loadPlugin( self.strPluginIntegrationName, "Integration") self.edPluginStrategy = self.loadPlugin(self.strPluginStrategyName, "Strategy") if (self.edPluginIndexing is not None): EDVerbose.DEBUG( "EDPluginControlCharacterisationv2_0.preProcess: " + self.strPluginIndexingName + " Found... setting Data Input") # create Data Input for indexing xsDataInputStrategy = self.getDataInput( "mxv1InputCharacterisation")[0] xsDataCollection = xsDataInputStrategy.getDataCollection() #xsDataSample = xsDataCollection.getSample() xsDataSubWedgeList = xsDataCollection.getSubWedge() xsDataExperimentalCondition = xsDataSubWedgeList[ 0].getExperimentalCondition() xsDataIndexingInput = XSDataIndexingInput() xsDataIndexingInput.setDataCollection(xsDataCollection) xsDataIndexingInput.setExperimentalCondition( xsDataExperimentalCondition) xsDataDiffractionPlan = xsDataCollection.getDiffractionPlan() xsDataStringForcedSpaceGroup = xsDataDiffractionPlan.getForcedSpaceGroup( ) if (xsDataStringForcedSpaceGroup is not None): xsDataCrystal = XSDataCrystal() xsDataSpaceGroup = XSDataSpaceGroup() xsDataSpaceGroup.setName(xsDataStringForcedSpaceGroup) xsDataCrystal.setSpaceGroup(xsDataSpaceGroup) xsDataIndexingInput.setCrystal(xsDataCrystal) self.edPluginIndexing.setDataInput(xsDataIndexingInput) # Populate characterisation object self.xsDataResultCharacterisationv2_0 = XSDataResultCharacterisationv2_0( ) self.xsDataResultCharacterisation = XSDataResultCharacterisation() self.xsDataResultCharacterisationv2_0.setMxv1ResultCharacterisation( self.xsDataResultCharacterisation) self.xsDataResultCharacterisation.setDataCollection( XSDataCollection.parseString(xsDataCollection.marshal()))
def buildChildren(self, child_, nodeName_): if child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'characterisationResult': obj_ = XSDataResultCharacterisation() obj_.build(child_) self.setCharacterisationResult(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'characterisationResultv2_0': obj_ = XSDataResultCharacterisationv2_0() obj_.build(child_) self.setCharacterisationResultv2_0(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'fileGraph': obj_ = XSDataFile() obj_.build(child_) self.fileGraph.append(obj_) XSDataInput.buildChildren(self, child_, nodeName_)
def finallyProcess(self, _edPlugin=None): EDPluginControl.finallyProcess(self, _edPlugin) xsDataResultCharacterisationv2_0 = XSDataResultCharacterisationv2_0() xsDataResultCharacterisationv2_0.setMxv1ResultCharacterisation( self.xsDataResultCharacterisation) xsDataResultCharacterisationv2_0.setMxv1ResultCharacterisation_Reference( self.xsDataResultCharacterisation) if self.suggestedStrategy is not None: self.setDataOutput(self.suggestedStrategy, "SuggestedStrategy") xsDataResultCharacterisationv2_0.setSuggestedStrategy( self.suggestedStrategy) if self.newpossibleOrientations is not None: self.setDataOutput(self.newpossibleOrientations, "possibleOrientations") xsDataResultCharacterisationv2_0.setPossibleOrientations( self.newpossibleOrientations) self.setDataOutput(xsDataResultCharacterisationv2_0)
def buildChildren(self, child_, nodeName_): if child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'mxv1ResultCharacterisation': obj_ = XSDataResultCharacterisation() obj_.build(child_) self.setMxv1ResultCharacterisation(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'mxv1ResultCharacterisation_Reference': obj_ = XSDataResultCharacterisation() obj_.build(child_) self.setMxv1ResultCharacterisation_Reference(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'mxv2ResultCharacterisation': obj_ = XSDataResultCharacterisationv2_0() obj_.build(child_) self.setMxv2ResultCharacterisation(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'mxv2DataCollection': obj_ = XSDataCollection() obj_.build(child_) self.setMxv2DataCollection(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'mxv2DataCollection_Reference': obj_ = XSDataCollection() obj_.build(child_) self.setMxv2DataCollection_Reference(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'suggestedStrategy': obj_ = XSDataResultStrategy() obj_.build(child_) self.setSuggestedStrategy(obj_) elif child_.nodeType == Node.ELEMENT_NODE and \ nodeName_ == 'possibleOrientations': obj_ = kappa_alignment_response() obj_.build(child_) self.setPossibleOrientations(obj_) XSDataResultInterface.buildChildren(self, child_, nodeName_)
def doCharacterisationSuccess(self, _edPlugin=None): EDVerbose.DEBUG( "EDPluginControlCharAtNewOrientationv2_0.doCharacterisationSuccess" ) self.retrieveSuccessMessages( _edPlugin, "EDPluginControlCharacterisationv2_0.doCharacterisationSuccess") self.xsDataResultCharacterisation = self.edPluginControlCharacterisation.getDataOutput( ) self.suggestedStrategy = None simple = False try: #check if there is anything to compare to #compare; for now, we only check the resolution resRef = 900 for collPlan in self.mxv1ResultCharacterisation_Reference.getStrategyResult( ).getCollectionPlan(): resRef = min( resRef, collPlan.getStrategySummary().getRankingResolution(). getValue()) resNew = 900 for collPlan in self.xsDataResultCharacterisation.getStrategyResult( ).getCollectionPlan(): resNew = min( resNew, collPlan.getStrategySummary().getRankingResolution(). getValue()) #now, we tolerate 15% loss of resolution if resNew > resRef * 1.15: #if there is any alternative, take the next one if self.possibleOrientations is not None and self.possibleOrientations.getPossible_orientation( ) != []: #take it # tol=0.1 # #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 # self.suggestedStrategy=XSDataMXv1.XSDataResultStrategy.parseString(self.getDataInput("mxv1ResultCharacterisation_Reference")[0].getStrategyResult().marshal()) # #take only the first CollectionPlan # self.suggestedStrategy.setCollectionPlan([self.suggestedStrategy.getCollectionPlan()[0]]) # #modify the DC part taking it from the input # self.suggestedStrategy.getCollectionPlan()[0].setCollectionStrategy(self.getDataInput().getDataCollection()) # #and modify the Orientation Orients = self.possibleOrientations.getPossible_orientation( ) omega = Orients[0].getOmega() kappa = Orients[0].getKappa() phi = Orients[0].getPhi() # for dcplan in self.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 # self.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): # self.newpossibleOrientations.addPossible_orientation(Orients[i]) self.suggestedStrategy = EDHandlerXSDataMXv1v1_0.mergeStrategyToNewOrientation( self.mxv1ResultCharacterisation_Reference. getStrategyResult(), self.mxv1InputCharacterisation.getDataCollection(), omega, kappa, phi) self.newpossibleOrientations = EDHandlerXSDataSTACv2_0.removeOrientation( self.possibleOrientations, kappa, phi) else: # #otherwise suggest to go back to the initial orientation and follow the reference DC # self.suggestedStrategy=XSDataMXv1.XSDataResultStrategy.parseString(self.getDataInput("mxv1ResultCharacterisation_Reference")[0].getStrategyResult().marshal()) # #and we have to declare the orientation in Reference to be used # dc = XSDataMXv2.XSDataCollection() dc = self.mxv2DataCollection_Reference omega = dc.getXSSubWedge( )[0].getXSRotationalGoniostatSetting().getBaseaxissetting( ) [kappa, phi] = dc.getXSSubWedge( )[0].getXSRotationalGoniostatSetting().getAxissetting() # for dcplan in self.suggestedStrategy.getCollectionPlan(): # dcplan.setComment(EDHandlerXSDataMXv1v1_0().replaceElements(dcplan.getComment(), "OMEGA=", '%.2f'%omega.getValue())) # dcplan.setComment(EDHandlerXSDataMXv1v1_0().replaceElements(dcplan.getComment(), "KAPPA=", '%.2f'%kappa.getValue())) # dcplan.setComment(EDHandlerXSDataMXv1v1_0().replaceElements(dcplan.getComment(), "PHI=", '%.2f'%phi.getValue())) self.suggestedStrategy = EDHandlerXSDataMXv1v1_0.copyStrategyToNewOrientation( self.mxv1ResultCharacterisation_Reference. getStrategyResult(), '%.2f' % omega.getValue(), '%.2f' % kappa.getValue(), '%.2f' % phi.getValue()) else: simple = True except: EDVerbose.WARNING("Problem in suggesting the strategy") simple = True raise if simple: # #we suggest the currently calculated strategy # self.suggestedStrategy=XSDataMXv1.XSDataResultStrategy.parseString(self._EDPluginControlCharacterisationv1_2__xsDataResultCharacterisation.getStrategyResult().marshal()) # #and we have to add the actual orientation # dc = XSDataMXv2.XSDataCollection() dc = self.mxv2DataCollection omega = dc.getXSSubWedge()[0].getXSRotationalGoniostatSetting( ).getBaseaxissetting() [kappa, phi] = dc.getXSSubWedge( )[0].getXSRotationalGoniostatSetting().getAxissetting() # for dcplan in self.suggestedStrategy.getCollectionPlan(): # dcplan.setComment(EDHandlerXSDataMXv1v1_0.replaceElements(dcplan.getComment(),"OMEGA=",'%.2f'%omega.getValue())) # dcplan.setComment(EDHandlerXSDataMXv1v1_0.replaceElements(dcplan.getComment(),"KAPPA=",'%.2f'%kappa.getValue())) # dcplan.setComment(EDHandlerXSDataMXv1v1_0.replaceElements(dcplan.getComment(),"PHI=",'%.2f'%phi.getValue())) self.suggestedStrategy = EDHandlerXSDataMXv1v1_0.copyStrategyToNewOrientation( self.xsDataResultCharacterisation.getStrategyResult(), '%.2f' % omega.getValue(), '%.2f' % kappa.getValue(), '%.2f' % phi.getValue()) #add the new outputs xsDataResultCharacterisationv2_0 = XSDataResultCharacterisationv2_0() xsDataResultCharacterisationv2_0.setMxv1ResultCharacterisation( self.xsDataResultCharacterisation) xsDataResultCharacterisationv2_0.setMxv1ResultCharacterisation_Reference( self.mxv1ResultCharacterisation_Reference) if self.suggestedStrategy is not None: self.setDataOutput(self.suggestedStrategy, "SuggestedStrategy") xsDataResultCharacterisationv2_0.setSuggestedStrategy( self.suggestedStrategy) if self.newpossibleOrientations is not None: self.setDataOutput(self.newpossibleOrientations, "possibleOrientations") xsDataResultCharacterisationv2_0.setPossibleOrientations( self.newpossibleOrientations) self.setDataOutput(xsDataResultCharacterisationv2_0)