def doSuccessActionOldSubWedgeAssemble(self, _edPlugin=None): """ - gets the result from the old assembler - converts it to DMv2 - reads DC descriptor file prepared by the BCM - merges the info together """ EDVerbose.DEBUG( "EDPluginControlSubWedgeAssemblyv2_0.doSuccessActionSubWedgeMerge") self.retrieveSuccessMessages( _edPlugin, "EDPluginControlSubWedgeAssemblyv2_0.doSuccessActionOldSubWedgeAssemble" ) if not _edPlugin.isFailure(): # getting the result from the old assembler self.xsDataResultSubWedgeAssemble = _edPlugin.getDataOutput() # converts it to DMv2 # reads DC descriptor file(s) prepared by the BCM swList = self.xsDataResultSubWedgeAssemble.getSubWedge() try: for sw in swList: # get filename imgFname = sw.getImage()[0].getPath().getValue() strMOSFLMTemplate = os.path.dirname( imgFname) + '/edna_' + EDUtilsImage.getTemplate( imgFname, "#") # print strMOSFLMTemplate # read file in #self.xsDatacollection_v2 = XSDataCollection_v2() self.xsDatacollection_v2 = XSDataMXv2.XSDataCollection.parseFile( strMOSFLMTemplate) except IOError: # TEMP: generates the file to be read in ##PARAMS calibDate = '2009-12-10' omegaR = (0, 0, 1) kappaR = (0, 0.707106781187, 0.707106781187) phiR = (0, 0, 1) beamD = (1, 0, 0) polarisationP = (0, 1, 0) exposuretime = 1.0 imagewidth = 1.0 numberimages = 1 wavelength = 1.0 OmegaV = 0.0 KappaV = 90.0 PhiV = 40.0 imgFnames = [] imgFnames.append( self.xsDataResultSubWedgeAssemble.getSubWedge() [0].getImage()[0].getPath().getValue()) self.generateDataCollectionDescriptorForSubWedge( calibDate, omegaR, kappaR, phiR, beamD, polarisationP, exposuretime, imagewidth, numberimages, wavelength, OmegaV, KappaV, PhiV, imgFnames)
def testGetTemplateQuestionMark(self): """ Testing retrieving the image number from a image filename """ strSymbol = "?" strTemplate = EDUtilsImage.getTemplate(self.__strFileName, strSymbol) strTemplateReference = "ref-testscale_1_???.img" EDAssert.equal(strTemplateReference, strTemplate)
def doSuccessActionOldSubWedgeAssemble(self, _edPlugin=None): """ - gets the result from the old assembler - converts it to DMv2 - reads DC descriptor file prepared by the BCM - merges the info together """ EDVerbose.DEBUG("EDPluginControlSubWedgeAssemblyv2_0.doSuccessActionSubWedgeMerge") self.retrieveSuccessMessages(_edPlugin, "EDPluginControlSubWedgeAssemblyv2_0.doSuccessActionOldSubWedgeAssemble") if not _edPlugin.isFailure(): # getting the result from the old assembler self.xsDataResultSubWedgeAssemble = _edPlugin.getDataOutput() # converts it to DMv2 # reads DC descriptor file(s) prepared by the BCM swList = self.xsDataResultSubWedgeAssemble.getSubWedge() try: for sw in swList: # get filename imgFname = sw.getImage()[0].getPath().getValue() strMOSFLMTemplate = os.path.dirname(imgFname) + '/edna_' + EDUtilsImage.getTemplate(imgFname, "#") # print strMOSFLMTemplate # read file in #self.xsDatacollection_v2 = XSDataCollection_v2() self.xsDatacollection_v2 = XSDataMXv2.XSDataCollection.parseFile(strMOSFLMTemplate) except IOError: # TEMP: generates the file to be read in ##PARAMS calibDate = '2009-12-10' omegaR = (0, 0, 1) kappaR = (0, 0.707106781187, 0.707106781187) phiR = (0, 0, 1) beamD = (1, 0, 0) polarisationP = (0, 1, 0) exposuretime = 1.0 imagewidth = 1.0 numberimages = 1 wavelength = 1.0 OmegaV = 0.0 KappaV = 90.0 PhiV = 40.0 imgFnames = [] imgFnames.append(self.xsDataResultSubWedgeAssemble.getSubWedge()[0].getImage()[0].getPath().getValue()) self.generateDataCollectionDescriptorForSubWedge(calibDate, omegaR, kappaR, phiR, beamD, polarisationP, exposuretime, imagewidth, numberimages, wavelength, OmegaV, KappaV, PhiV, imgFnames)
def generateXSDataMOSFLMInputIndexing(_xsDataIndexingInput): """ Translation from XSDataIndexingInput to XSDataMOSFLMInputIndexing. """ EDFactoryPluginStatic.loadModule("XSDataMOSFLMv10") from XSDataMOSFLMv10 import XSDataMOSFLMInputIndexing from XSDataMOSFLMv10 import XSDataMOSFLMBeamPosition from XSDataMOSFLMv10 import XSDataMOSFLMImage EDVerbose.DEBUG( "EDHandlerXSDataMOSFLMv10.generateXSDataMOSFLMInputIndexing") xsDataCollection = _xsDataIndexingInput.getDataCollection() xsDataExperimentalCondition = _xsDataIndexingInput.getExperimentalCondition( ) xsDataCrystal = _xsDataIndexingInput.getCrystal() xsDataSubWedgeList = xsDataCollection.getSubWedge() xsDataMOSFLMInputIndexing = XSDataMOSFLMInputIndexing() if (xsDataExperimentalCondition is None): xsDataExperimentalCondition = xsDataSubWedgeList[ 0].getExperimentalCondition() xsDataBeam = xsDataExperimentalCondition.getBeam() xsDataDetector = xsDataExperimentalCondition.getDetector() xsDataGoniostat = xsDataExperimentalCondition.getGoniostat() dWavelength = xsDataBeam.getWavelength().getValue() dDistance = xsDataDetector.getDistance().getValue() dBeamPositionX = xsDataDetector.getBeamPositionX().getValue() dBeamPositionY = xsDataDetector.getBeamPositionY().getValue() xsDataMOSFLMBeamPosition = XSDataMOSFLMBeamPosition() xsDataMOSFLMBeamPosition.setX(XSDataLength(dBeamPositionX)) xsDataMOSFLMBeamPosition.setY(XSDataLength(dBeamPositionY)) xsDataMOSFLMInputIndexing.setBeam(xsDataMOSFLMBeamPosition) xsDataMOSFLMDetector = EDHandlerXSDataMOSFLMv10.getXSDataMOSFLMDetector( xsDataDetector) xsDataMOSFLMInputIndexing.setDetector(xsDataMOSFLMDetector) xsDataMOSFLMInputIndexing.setWavelength(XSDataWavelength(dWavelength)) xsDataMOSFLMInputIndexing.setDistance(XSDataLength(dDistance)) xsDataSubWedgeFirst = xsDataSubWedgeList[0] xsDataImageFirst = xsDataSubWedgeFirst.getImage()[0] strPath = xsDataImageFirst.getPath().getValue() strFileName = os.path.basename(strPath) strDirectory = os.path.dirname(strPath) if xsDataDetector.type.value == "eiger2_16m": strMOSFLMTemplate = EDUtilsImage.getH5MasterTemplate( strFileName, 1) else: strMOSFLMTemplate = EDUtilsImage.getTemplate(strFileName, "#") xsDataMOSFLMInputIndexing.setTemplate(XSDataString(strMOSFLMTemplate)) xsDataMOSFLMInputIndexing.setDirectory(XSDataString(strDirectory)) if (xsDataCrystal is not None): xsDataSpaceGroup = xsDataCrystal.getSpaceGroup() if (xsDataSpaceGroup is not None): xsDataStringName = xsDataSpaceGroup.getName() if (xsDataStringName is not None): xsDataMOSFLMInputIndexing.setSymmetry( XSDataString(xsDataStringName.getValue())) # Loop through the list of sub wedges for xsDataSubWedge in xsDataSubWedgeList: xsDataImageList = xsDataSubWedge.getImage() xsDataGoniostat = xsDataSubWedge.getExperimentalCondition( ).getGoniostat() fGonioStatOscillationStart = xsDataGoniostat.getRotationAxisStart( ).getValue() fGonioStatOscillationRange = xsDataGoniostat.getOscillationWidth( ).getValue() # First find the lowest image number iLowestImageNumber = None for xsDataImage in xsDataImageList: iImageNumber = xsDataImage.getNumber().getValue() if (iLowestImageNumber is None): iLowestImageNumber = iImageNumber elif (iImageNumber < iLowestImageNumber): iLowestImageNumber = iImageNumber # Loop through the list of images for xsDataImage in xsDataImageList: # Create the MOSFLM image object xsDataMOSFLMImage = XSDataMOSFLMImage() iImageNumber = xsDataImage.getNumber().getValue() xsDataMOSFLMImage.setNumber(XSDataInteger(iImageNumber)) fImageOscillationStart = fGonioStatOscillationStart + ( iImageNumber - iLowestImageNumber) * fGonioStatOscillationRange xsDataMOSFLMImage.setRotationAxisStart( XSDataAngle(fImageOscillationStart)) xsDataMOSFLMImage.setRotationAxisEnd( XSDataAngle(fImageOscillationStart + fGonioStatOscillationRange)) xsDataMOSFLMInputIndexing.addImage(xsDataMOSFLMImage) return xsDataMOSFLMInputIndexing
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 generateDataCollectionDescriptorForSubWedge(self, calibDate, omegaR, kappaR, phiR, beamD, polarisationP, exposuretime, imagewidth, numberimages, wavelength, OmegaV, KappaV, PhiV, imgFnames): ##CONTAINER self.xsDC_v2 = XSDataCollection_v2() ##GonioCalib calib = XSDataMXv2.XSCalibration() cdate = XSDataMXv2.XSDataDate() cdate.setValue(XSDataMXv2.XSDataString(calibDate)) calib.setDate(cdate) #OmegaCalib omegacal = XSDataMXv2.XSCalibratedDisplacementAxis() zdir = XSDataMXv2.XSDataUnitVector() zdir.setV1(omegaR[0]) zdir.setV2(omegaR[1]) zdir.setV3(omegaR[2]) omegacal.setZerodirection(zdir) omegacal.setXSCalibration(calib) #KappaCalib kappacal = XSDataMXv2.XSCalibratedDisplacementAxis() zdir = XSDataMXv2.XSDataUnitVector() zdir.setV1(kappaR[0]) zdir.setV2(kappaR[1]) zdir.setV3(kappaR[2]) kappacal.setZerodirection(zdir) kappacal.setXSCalibration(calib) #PhiCalib phical = XSDataMXv2.XSCalibratedDisplacementAxis() zdir = XSDataMXv2.XSDataUnitVector() zdir.setV1(phiR[0]) zdir.setV2(phiR[1]) zdir.setV3(phiR[2]) phical.setZerodirection(zdir) phical.setXSCalibration(calib) ##goni actgonio = XSDataMXv2.XSRotationalGoniostat() #omega omega = XSDataMXv2.XSGoniostatBaseAxis() omega.setName(XSDataMXv2.XSDataString('Omega')) omega.setIsscannable(XSDataMXv2.XSDataBoolean(1)) omega.addXSCalibratedDisplacementAxis(omegacal) actgonio.setXSGoniostatBaseAxis(omega) #kappa kappa = XSDataMXv2.XSGoniostatRotatableAxis() kappa.setName(XSDataMXv2.XSDataString('Kappa')) kappa.setIsscannable(XSDataMXv2.XSDataBoolean(0)) kappa.addXSCalibratedDisplacementAxis(kappacal) actgonio.addXSGoniostatRotatableAxis(kappa) #phi phi = XSDataMXv2.XSGoniostatRotatableAxis() phi.setName(XSDataMXv2.XSDataString('Phi')) phi.setIsscannable(XSDataMXv2.XSDataBoolean(0)) phi.addXSCalibratedDisplacementAxis(phical) actgonio.addXSGoniostatRotatableAxis(phi) ##beam beam = XSDataMXv2.XSBeam() zdir = XSDataMXv2.XSDataUnitVector() zdir.setV1(polarisationP[0]) zdir.setV2(polarisationP[1]) zdir.setV3(polarisationP[2]) beam.setPolarisatation(zdir) zdir = XSDataMXv2.XSDataUnitVector() zdir.setV1(beamD[0]) zdir.setV2(beamD[1]) zdir.setV3(beamD[2]) beam.setDirection(zdir) ##detector detector = XSDataMXv2.XSDetector() detector.setName(XSDataMXv2.XSDataString('detector')) ###detector.set ##SUBWEDGE sw = XSSubWedge_v2() # template sw.setImagefilenametemplate(XSDataMXv2.XSDataString(EDUtilsImage.getTemplate(imgFnames[0], "#"))) # images for imgFname in imgFnames: img = XSDiffractionImages_v2() img.setFilename(XSDataMXv2.XSDataString(imgFname)) sw.addXSDiffractionImages(img) #RotationExposure rotexp = XSRotationExposure_v2() rotexp.setExposuretime(XSDataMXv2.XSDataTime(exposuretime)) rotexp.setImagewidth(XSDataMXv2.XSDataAngle(imagewidth)) rotexp.setNumberimages(XSDataMXv2.XSDataInteger(numberimages)) rotexp.setXSGoniostatAxis(omega) sw.setXSRotationExposure(rotexp) #Beamsetting beams = XSBeamSetting_v2() w = XSDataMXv2.XSDataWavelength() w.setValue(wavelength) beams.setWavelength(w) beams.setXSBeam(beam) sw.setXSBeamSetting(beams) #RotationalGonioSetting rotgset = XSDataMXv2.XSRotationalGoniostatSetting() rotgset.setXSRotationalGoniostat(actgonio) oang = XSDataMXv2.XSDataAngle() oang.setValue(OmegaV) rotgset.setBaseaxissetting(oang) kang = XSDataMXv2.XSDataAngle() kang.setValue(KappaV) rotgset.addAxissetting(kang) pang = XSDataMXv2.XSDataAngle() pang.setValue(PhiV) rotgset.addAxissetting(pang) sw.setXSRotationalGoniostatSetting(rotgset) #DetectorSetting TODOTODO detset = XSDataMXv2.XSDetectorSetting() #axissetting=(XSDataMXv2.XSDataAngle().setValue(KappaV),XSDataMXv2.XSDataAngle().setValue(PhiV)) #detset.setAxissetting(axissetting) self.xsDC_v2.addXSSubWedge(sw) imgFname = self.xsDataResultSubWedgeAssemble.getSubWedge()[0].getImage()[0].getPath().getValue() self.xsDC_v2.outputFile(os.path.dirname(imgFname) + '/edna_' + EDUtilsImage.getTemplate(imgFname, "#") + '_auto')
def generateXSDataMOSFLMInputIndexing(_xsDataIndexingInput): """ Translation from XSDataIndexingInput to XSDataMOSFLMInputIndexing. """ EDFactoryPluginStatic.loadModule("XSDataMOSFLMv10") from XSDataMOSFLMv10 import XSDataMOSFLMInputIndexing from XSDataMOSFLMv10 import XSDataMOSFLMBeamPosition from XSDataMOSFLMv10 import XSDataMOSFLMImage EDVerbose.DEBUG("EDHandlerXSDataMOSFLMv10.generateXSDataMOSFLMInputIndexing") xsDataCollection = _xsDataIndexingInput.getDataCollection() xsDataExperimentalCondition = _xsDataIndexingInput.getExperimentalCondition() xsDataCrystal = _xsDataIndexingInput.getCrystal() xsDataSubWedgeList = xsDataCollection.getSubWedge() xsDataMOSFLMInputIndexing = XSDataMOSFLMInputIndexing() if (xsDataExperimentalCondition is None): xsDataExperimentalCondition = xsDataSubWedgeList[0].getExperimentalCondition() xsDataBeam = xsDataExperimentalCondition.getBeam() xsDataDetector = xsDataExperimentalCondition.getDetector() xsDataGoniostat = xsDataExperimentalCondition.getGoniostat() dWavelength = xsDataBeam.getWavelength().getValue() dDistance = xsDataDetector.getDistance().getValue() dBeamPositionX = xsDataDetector.getBeamPositionX().getValue() dBeamPositionY = xsDataDetector.getBeamPositionY().getValue() xsDataMOSFLMBeamPosition = XSDataMOSFLMBeamPosition() xsDataMOSFLMBeamPosition.setX(XSDataLength(dBeamPositionX)) xsDataMOSFLMBeamPosition.setY(XSDataLength(dBeamPositionY)) xsDataMOSFLMInputIndexing.setBeam(xsDataMOSFLMBeamPosition) xsDataMOSFLMDetector = EDHandlerXSDataMOSFLMv10.getXSDataMOSFLMDetector(xsDataDetector) xsDataMOSFLMInputIndexing.setDetector(xsDataMOSFLMDetector) xsDataMOSFLMInputIndexing.setWavelength(XSDataWavelength(dWavelength)) xsDataMOSFLMInputIndexing.setDistance(XSDataLength(dDistance)) xsDataSubWedgeFirst = xsDataSubWedgeList[0] xsDataImageFirst = xsDataSubWedgeFirst.getImage()[0] strPath = xsDataImageFirst.getPath().getValue() strFileName = os.path.basename(strPath) strDirectory = os.path.dirname(strPath) strMOSFLMTemplate = EDUtilsImage.getTemplate(strFileName, "#") xsDataMOSFLMInputIndexing.setTemplate(XSDataString(strMOSFLMTemplate)) xsDataMOSFLMInputIndexing.setDirectory(XSDataString(strDirectory)) if (xsDataCrystal is not None): xsDataSpaceGroup = xsDataCrystal.getSpaceGroup() if (xsDataSpaceGroup is not None): xsDataStringName = xsDataSpaceGroup.getName() if (xsDataStringName is not None): xsDataMOSFLMInputIndexing.setSymmetry(XSDataString(xsDataStringName.getValue())) # Loop through the list of sub wedges for xsDataSubWedge in xsDataSubWedgeList: xsDataImageList = xsDataSubWedge.getImage() xsDataGoniostat = xsDataSubWedge.getExperimentalCondition().getGoniostat() fGonioStatOscillationStart = xsDataGoniostat.getRotationAxisStart().getValue() fGonioStatOscillationRange = xsDataGoniostat.getOscillationWidth().getValue() # First find the lowest image number iLowestImageNumber = None for xsDataImage in xsDataImageList: iImageNumber = xsDataImage.getNumber().getValue() if (iLowestImageNumber is None): iLowestImageNumber = iImageNumber elif (iImageNumber < iLowestImageNumber): iLowestImageNumber = iImageNumber # Loop through the list of images for xsDataImage in xsDataImageList: # Create the MOSFLM image object xsDataMOSFLMImage = XSDataMOSFLMImage() iImageNumber = xsDataImage.getNumber().getValue() xsDataMOSFLMImage.setNumber(XSDataInteger(iImageNumber)) fImageOscillationStart = fGonioStatOscillationStart + (iImageNumber - iLowestImageNumber) * fGonioStatOscillationRange xsDataMOSFLMImage.setRotationAxisStart(XSDataAngle(fImageOscillationStart)) xsDataMOSFLMImage.setRotationAxisEnd(XSDataAngle(fImageOscillationStart + fGonioStatOscillationRange)) xsDataMOSFLMInputIndexing.addImage(xsDataMOSFLMImage) return xsDataMOSFLMInputIndexing
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
def process(self, _edObject=None): EDPluginControl.process(self) self.DEBUG("EDPluginControlDozorv1_1.process") msg = "EDPluginControlDozorXmlRpcv1_0 started..." self.sendMessageToMXCuBE("Processing started...", "info") xsDataResultControlDozor = XSDataResultControlDozor() firstFileName = self.dataInput.template.value % ( self.dataInput.first_run_number.value, self.dataInput.first_image_number.value) fWaitFileTimeout = 180 #sec self.waitFileFirst = self.loadPlugin("EDPluginMXWaitFilev1_1", "MXWaitFileFirst") xsDataInputMXWaitFileFirst = XSDataInputMXWaitFile() xsDataInputMXWaitFileFirst.file = XSDataFile( XSDataString(firstFileName)) xsDataInputMXWaitFileFirst.timeOut = XSDataTime(fWaitFileTimeout) self.waitFileFirst.size = XSDataInteger(1000000) self.waitFileFirst.dataInput = xsDataInputMXWaitFileFirst self.waitFileFirst.executeSynchronous() if self.waitFileFirst.dataOutput.timedOut.value: strWarningMessage = "Timeout after %d seconds waiting for the first image %s!" % ( fWaitFileTimeout, firstFileName) #self.addWarningMessage(strWarningMessage) #self.WARNING(strWarningMessage) #self.sendMessageToMXCuBE(strWarningMessage, "error") edPluginControlReadImageHeader = self.loadPlugin( self.strEDPluginControlReadImageHeaderName) xsDataInputReadImageHeader = XSDataInputReadImageHeader() xsDataInputReadImageHeader.image = XSDataFile( XSDataString(firstFileName)) edPluginControlReadImageHeader.dataInput = xsDataInputReadImageHeader edPluginControlReadImageHeader.executeSynchronous() subWedge = edPluginControlReadImageHeader.dataOutput.subWedge xsDataInputDozor = XSDataInputDozor() beam = subWedge.experimentalCondition.beam detector = subWedge.experimentalCondition.detector goniostat = subWedge.experimentalCondition.goniostat xsDataInputDozor.detectorType = detector.type xsDataInputDozor.exposureTime = XSDataDouble(beam.exposureTime.value) xsDataInputDozor.spotSize = XSDataDouble(3.0) xsDataInputDozor.detectorDistance = XSDataDouble( detector.distance.value) xsDataInputDozor.wavelength = XSDataDouble(beam.wavelength.value) orgx = detector.beamPositionY.value / detector.pixelSizeY.value orgy = detector.beamPositionX.value / detector.pixelSizeX.value xsDataInputDozor.orgx = XSDataDouble(orgx) xsDataInputDozor.orgy = XSDataDouble(orgy) # GB: the 50 might need tunig to CPU speed and number of. 2000 is a current limit of Dozor. self.maxChunkSize = 4000 #a min (150 * 2527 * 2463 /detector.numberPixelX.value / detector.numberPixelY.value, 2000) _beamstop = self.beamstop(detector) if _beamstop is not None: #self.WARNING("Setting beamstop shadow: %s"%_beamstop) xsDataInputDozor.ixMin = XSDataInteger(_beamstop['ix_min']) xsDataInputDozor.iyMin = XSDataInteger(_beamstop['iy_min']) xsDataInputDozor.ixMax = XSDataInteger(_beamstop['ix_max']) xsDataInputDozor.iyMax = XSDataInteger(_beamstop['iy_max']) if self.dataInput.pixelMin is not None: xsDataInputDozor.pixelMin = self.dataInput.pixelMin if self.dataInput.pixelMax is not None: xsDataInputDozor.pixelMax = self.dataInput.pixelMax _serial = 0 _startTime = time.time() chunk_list = self.schedule(goniostat.rotationAxisStart.value, goniostat.oscillationWidth.value) for chunk in chunk_list: if not self.poll_file( self.dataInput.template.value % (chunk['run_number'], chunk['first'] + chunk['number_of'] - 1), (beam.exposureTime.value + 0.003) * chunk['number_of'] + 30): self.sendMessageToMXCuBE("Timeout waiting for frame: %d" % (chunk['first'] + chunk['number_of']), level="error") return xsDataInputDozor.oscillationRange = XSDataDouble( chunk['rotation_range']) xsDataInputDozor.startingAngle = XSDataDouble( chunk['rotation_start']) xsDataInputDozor.firstImageNumber = XSDataInteger(chunk['first']) xsDataInputDozor.numberImages = XSDataInteger(chunk['number_of']) strFileName = self.dataInput.template.value % (chunk['run_number'], chunk['first']) strXDSTemplate = EDUtilsImage.getTemplate(strFileName, '?') xsDataInputDozor.nameTemplateImage = XSDataString( os.path.join(os.path.dirname(strFileName), strXDSTemplate)) edPluginDozor = self.loadPlugin(self.strEDPluginDozorName, "Dozor") edPluginDozor.dataInput = xsDataInputDozor edPluginDozor.executeSynchronous() xsDataChunkResultControlImageDozor = XSDataResultControlDozor() dozor_batch_list = [] #[[1,4,3,8,6], #[2, 5, 3, 3, 7],[1, 3, 12, 11, 4],[4, 2, 3, 5, 7]] #ozor_image_dict = {} diff_image_count = 0 xsDataControlImageDozor = XSDataControlImageDozor() for xsDataResultDozor in edPluginDozor.dataOutput.imageDozor: xsDataControlImageDozor = XSDataControlImageDozor() xsDataControlImageDozor.number = xsDataResultDozor.number strFileName = self.dataInput.template.value % ( chunk['run_number'], xsDataControlImageDozor.number.value) xsDataControlImageDozor.image = XSDataFile( XSDataString(strFileName)) xsDataControlImageDozor.spots_num_of = xsDataResultDozor.spots_num_of xsDataControlImageDozor.spots_int_aver = xsDataResultDozor.spots_int_aver xsDataControlImageDozor.spots_resolution = xsDataResultDozor.spots_resolution xsDataControlImageDozor.powder_wilson_scale = xsDataResultDozor.powder_wilson_scale xsDataControlImageDozor.powder_wilson_bfactor = xsDataResultDozor.powder_wilson_bfactor xsDataControlImageDozor.powder_wilson_resolution = xsDataResultDozor.powder_wilson_resolution xsDataControlImageDozor.powder_wilson_correlation = xsDataResultDozor.powder_wilson_correlation xsDataControlImageDozor.powder_wilson_rfactor = xsDataResultDozor.powder_wilson_rfactor xsDataControlImageDozor.score = xsDataResultDozor.score xsDataResultControlDozor.addImageDozor(xsDataControlImageDozor) dozor_batch_list.append( (xsDataControlImageDozor.number.getValue(), xsDataControlImageDozor.spots_num_of.getValue(), xsDataControlImageDozor.spots_int_aver.getValue(), xsDataControlImageDozor.spots_resolution.getValue(), xsDataControlImageDozor.score.getValue())) if xsDataControlImageDozor.spots_num_of.getValue() > 0: diff_image_count += 1 xsDataChunkResultControlImageDozor.addImageDozor( xsDataControlImageDozor) xsDataChunkResultControlImageDozor.exportToFile( "ResultControlDozor_Chunk_%06d.xml" % _serial) self.sendResultToMXCuBE(dozor_batch_list) _serial += 1 self.screen("Chunk %d/%d done in %.3f seconds" % \ (_serial, len(chunk_list), time.time()-_startTime)) self.sendMessageToMXCuBE("Chunk %d/%d done in %.2f sec., num diffr. frames: %d/%d" % \ (_serial, len(chunk_list), time.time() - _startTime, diff_image_count, len(dozor_batch_list) ) ) _startTime = time.time()
def generateXSDataMOSFLMInputIntegration(_xsDataIntegrationInput): """ Translation from XSDataIntegrationInput to XSDataMOSFLMInputIntegration. """ EDVerbose.DEBUG( "EDHandlerXSDataMOSFLMv10.generateXSDataMOSFLMInputIntegration") EDFactoryPluginStatic.loadModule("XSDataMOSFLMv10") from XSDataMOSFLMv10 import XSDataMOSFLMBeamPosition from XSDataMOSFLMv10 import XSDataMOSFLMInputIntegration from XSDataMOSFLMv10 import XSDataMOSFLMNewmat from XSDataMOSFLMv10 import XSDataMOSFLMMissettingsAngles xsDataCrystalRefined = _xsDataIntegrationInput.getCrystalRefined() xsDataIndexingSolutionSelected = _xsDataIntegrationInput.getSelectedIndexingSolution( ) if (xsDataCrystalRefined is None): xsDataCrystalRefined = xsDataIndexingSolutionSelected.getCrystal() xsDataCollection = _xsDataIntegrationInput.getDataCollection() xsDataSubWedge = xsDataCollection.getSubWedge()[0] xsDataImageList = xsDataSubWedge.getImage() xsDataImageFirst = xsDataImageList[0] xsDataGoniostat = xsDataSubWedge.getExperimentalCondition( ).getGoniostat() xsDataCrystal = xsDataIndexingSolutionSelected.getCrystal() xsDataOrientation = xsDataIndexingSolutionSelected.getOrientation() xsDataExperimentalCondition = xsDataIndexingSolutionSelected.getExperimentalConditionRefined( ) xsDataDetector = xsDataExperimentalCondition.getDetector() xsDataBeam = xsDataExperimentalCondition.getBeam() xsDataMatrixA = xsDataOrientation.getMatrixA() xsDataMatrixU = xsDataOrientation.getMatrixU() xsDataCell = xsDataCrystal.getCell() xsDataMOSFLMInputIntegration = XSDataMOSFLMInputIntegration() xsDataMOSFLMNewmat = XSDataMOSFLMNewmat() xsDataMOSFLMNewmat.setRefinedCell(xsDataCell) xsDataMOSFLMNewmat.setAMatrix(xsDataMatrixA) xsDataMOSFLMNewmat.setUMatrix(xsDataMatrixU) xsDataMOSFLMInputIntegration.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()) xsDataMOSFLMInputIntegration.setBeam(xsDataMOSFLMBeamPosition) xsDataMOSFLMInputIntegration.setMosaicity(xsDataCrystal.getMosaicity()) xsDataMOSFLMInputIntegration.setSymmetry( xsDataCrystal.getSpaceGroup().getName()) strPathFirst = xsDataImageFirst.getPath().getValue() strDirectoryFirst = os.path.dirname(strPathFirst) strFilenameFirst = os.path.basename(strPathFirst) fOscillationRange = xsDataGoniostat.getOscillationWidth().getValue() xsDataMOSFLMInputIntegration.setWavelength(xsDataBeam.getWavelength()) xsDataMOSFLMInputIntegration.setDistance(xsDataDetector.getDistance()) xsDataMOSFLMInputIntegration.setDirectory( XSDataString(strDirectoryFirst)) xsDataMOSFLMInputIntegration.setOscillationWidth( XSDataAngle(fOscillationRange)) xsDataMOSFLMDetector = EDHandlerXSDataMOSFLMv10.getXSDataMOSFLMDetector( xsDataDetector) xsDataMOSFLMInputIntegration.setDetector(xsDataMOSFLMDetector) strMOSFLMTemplate = EDUtilsImage.getTemplate(strFilenameFirst, "#") xsDataMOSFLMInputIntegration.setTemplate( XSDataString(strMOSFLMTemplate)) iImageStart = None iImageEnd = None for xsDataImage in xsDataImageList: iImageNumber = xsDataImage.getNumber().getValue() if (iImageStart is None): iImageStart = iImageNumber elif (iImageStart > iImageNumber): iImageStart = iImageNumber if (iImageEnd is None): iImageEnd = iImageNumber elif (iImageEnd < iImageNumber): iImageEnd = iImageNumber xsDataMOSFLMInputIntegration.setImageStart(XSDataInteger(iImageStart)) xsDataMOSFLMInputIntegration.setImageEnd(XSDataInteger(iImageEnd)) xsDataMOSFLMInputIntegration.setRotationAxisStart( xsDataGoniostat.getRotationAxisStart()) # print xsDataMOSFLMInputIntegration.marshal() return xsDataMOSFLMInputIntegration