def test_generateCommands(self):
     edPlugin = self.getPlugin()
     strInputXML = EDUtilsFile.readFile(
         os.path.join(self.strDataPath, "XSDataInputDozor_reference.xml"))
     xsDataInput = XSDataInputDozor.parseString(strInputXML)
     strCommandText = edPlugin.generateCommands(xsDataInput)
     print(strCommandText)
    def process(self, _edObject=None):
        EDPluginControl.process(self)
        self.DEBUG("EDPluginControlDozorv1_0.process")
        self.sendMessageToMXCuBE("Processing started...", "info")
        EDUtilsParallel.initializeNbThread()
        xsDataResultControlDozor = XSDataResultControlDozor()
        # Check if connection to ISPyB needed
        if self.dataInput.dataCollectionId is not None:
            edPluginRetrieveDataCollection = self.loadPlugin("EDPluginISPyBRetrieveDataCollectionv1_4")
            xsDataInputRetrieveDataCollection = XSDataInputRetrieveDataCollection()
            xsDataInputRetrieveDataCollection.dataCollectionId = self.dataInput.dataCollectionId
            edPluginRetrieveDataCollection.dataInput = xsDataInputRetrieveDataCollection
            edPluginRetrieveDataCollection.executeSynchronous()
            ispybDataCollection = edPluginRetrieveDataCollection.dataOutput.dataCollection
            if self.batchSize is None:
                batchSize = ispybDataCollection.numberOfImages
            else:
                batchSize = self.batchSize
            if batchSize > self.maxBatchSize:
                batchSize = self.maxBatchSize
            if abs(ispybDataCollection.overlap) > 1:
                self.hasOverlap = True
                self.overlap = ispybDataCollection.overlap
            dictImage = self.createImageDictFromISPyB(ispybDataCollection)
        else:
            # No connection to ISPyB, take parameters from input
            if self.dataInput.batchSize is None:
                batchSize = self.maxBatchSize
            else:
                batchSize = self.dataInput.batchSize.value
            dictImage = self.createImageDict(self.dataInput)
        self.screen("Dozor batch size: {0}".format(batchSize))
        if self.dataInput.hdf5BatchSize is not None:
            self.hdf5BatchSize = self.dataInput.hdf5BatchSize.value
        listAllBatches = self.createListOfBatches(dictImage.keys(), batchSize)
        if dictImage[listAllBatches[0][0]].path.value.endswith("h5"):
            # Convert HDF5 images to CBF
            self.screen("HDF5 converter batch size: {0}".format(self.batchSize))
            if self.doRadiationDamage:
                self.cbfTempDir = None
            else:
                self.cbfTempDir = tempfile.mkdtemp(prefix="CbfTemp_")
            listHdf5Batches = self.createListOfBatches(dictImage.keys(), self.batchSize)
            dictImage, self.hasHdf5Prefix = self.convertToCBF(dictImage, listHdf5Batches, self.doRadiationDamage)
        for listBatch in listAllBatches:
            # Read the header from the first image in the batch
            xsDataFile = dictImage[listBatch[0]]
            edPluginControlReadImageHeader = self.loadPlugin(self.strEDPluginControlReadImageHeaderName)
            xsDataInputReadImageHeader = XSDataInputReadImageHeader()
            xsDataInputReadImageHeader.image = xsDataFile
            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 = XSDataInteger(3)
            xsDataInputDozor.detectorDistance = XSDataDouble(detector.distance.value)
            xsDataInputDozor.wavelength = XSDataDouble(beam.wavelength.value)
#            xsDataInputDozor.fractionPolatization : XSDataDouble optional
            orgx = detector.beamPositionY.value / detector.pixelSizeY.value
            orgy = detector.beamPositionX.value / detector.pixelSizeX.value
            xsDataInputDozor.orgx = XSDataDouble(orgx)
            xsDataInputDozor.orgy = XSDataDouble(orgy)
            xsDataInputDozor.oscillationRange = XSDataDouble(goniostat.oscillationWidth.value)
#            xsDataInputDozor.imageStep : XSDataDouble optional
            xsDataInputDozor.startingAngle = XSDataDouble(goniostat.rotationAxisStart.value)
            xsDataInputDozor.firstImageNumber = subWedge.image[0].number
            xsDataInputDozor.numberImages = XSDataInteger(len(listBatch))
            if self.hasOverlap:
                xsDataInputDozor.overlap = XSDataAngle(self.overlap)
            strFileName = subWedge.image[0].path.value
            strPrefix = EDUtilsImage.getPrefix(strFileName)
            strSuffix = EDUtilsImage.getSuffix(strFileName)
            if EDUtilsPath.isEMBL():
                strXDSTemplate = "%s_?????.%s" % (strPrefix, strSuffix)
            elif self.hasHdf5Prefix and not self.hasOverlap:
                strXDSTemplate = "%s_??????.%s" % (strPrefix, strSuffix)
            else:
                strXDSTemplate = "%s_????.%s" % (strPrefix, strSuffix)
            xsDataInputDozor.nameTemplateImage = XSDataString(os.path.join(os.path.dirname(strFileName), strXDSTemplate))
            xsDataInputDozor.wedgeNumber = self.dataInput.wedgeNumber
            xsDataInputDozor.radiationDamage = self.dataInput.radiationDamage
            edPluginDozor = self.loadPlugin(self.strEDPluginDozorName, "Dozor_%05d" % subWedge.image[0].number.value)
            edPluginDozor.dataInput = xsDataInputDozor
            edPluginDozor.execute()
            edPluginDozor.synchronize()
            indexImage = 0
            imageDozorBatchList = []

            for xsDataResultDozor in edPluginDozor.dataOutput.imageDozor:
                xsDataControlImageDozor = XSDataControlImageDozor()
                xsDataControlImageDozor.number = xsDataResultDozor.number
                xsDataControlImageDozor.image = dictImage[listBatch[indexImage]]
                xsDataControlImageDozor.spotsNumOf = xsDataResultDozor.spotsNumOf
                xsDataControlImageDozor.spotsIntAver = xsDataResultDozor.spotsIntAver
                xsDataControlImageDozor.spotsResolution = xsDataResultDozor.spotsResolution
                xsDataControlImageDozor.powderWilsonScale = xsDataResultDozor.powderWilsonScale
                xsDataControlImageDozor.powderWilsonBfactor = xsDataResultDozor.powderWilsonBfactor
                xsDataControlImageDozor.powderWilsonResolution = xsDataResultDozor.powderWilsonResolution
                xsDataControlImageDozor.powderWilsonCorrelation = xsDataResultDozor.powderWilsonCorrelation
                xsDataControlImageDozor.powderWilsonRfactor = xsDataResultDozor.powderWilsonRfactor
                xsDataControlImageDozor.mainScore = xsDataResultDozor.mainScore
                xsDataControlImageDozor.spotScore = xsDataResultDozor.spotScore
                xsDataControlImageDozor.visibleResolution = xsDataResultDozor.visibleResolution
                xsDataControlImageDozor.spotFile = xsDataResultDozor.spotFile
                xsDataControlImageDozor.angle = xsDataResultDozor.angle
                xsDataResultControlDozor.addImageDozor(xsDataControlImageDozor)
                if xsDataResultControlDozor.inputDozor is None:
                    xsDataResultControlDozor.inputDozor = XSDataDozorInput().parseString(xsDataInputDozor.marshal())
                indexImage += 1

                dozorSpotListShape = []
                dozorSpotList = []
                spotFile = None
                if xsDataControlImageDozor.spotFile is not None:
                    spotFile = xsDataControlImageDozor.spotFile.path.value
                    if os.path.exists(spotFile):
                        numpyArray = numpy.loadtxt(spotFile, skiprows=3)
                        dozorSpotList = base64.b64encode(numpyArray.tostring())
                        dozorSpotListShape.append(numpyArray.shape[0])
                        if len(numpyArray.shape) > 1:
                            dozorSpotListShape.append(numpyArray.shape[1])

                imageDozorDict = {"index": xsDataControlImageDozor.number.value,
                                  "imageName": xsDataControlImageDozor.image.path.value,
                                  "dozor_score": xsDataControlImageDozor.mainScore.value,
                                  "dozorSpotsNumOf" : xsDataControlImageDozor.spotsNumOf.value,
                                  "dozorSpotFile": spotFile,
                                  "dozorSpotList" : dozorSpotList,
                                  "dozorSpotListShape": dozorSpotListShape,
                                  "dozorSpotsIntAver": xsDataControlImageDozor.spotsIntAver.value,
                                  "dozorSpotsResolution": xsDataControlImageDozor.spotsResolution.value
                                  }
                imageDozorBatchList.append(imageDozorDict)

            xsDataResultControlDozor.halfDoseTime = edPluginDozor.dataOutput.halfDoseTime
            xsDataResultControlDozor.pngPlots = edPluginDozor.dataOutput.pngPlots

            self.sendResultToMXCuBE(imageDozorBatchList)
            self.sendMessageToMXCuBE("Batch processed")
        self.dataOutput = xsDataResultControlDozor
        if self.cbfTempDir is not None:
            if self.dataInput.keepCbfTmpDirectory is not None and self.dataInput.keepCbfTmpDirectory.value:
                self.dataOutput.pathToCbfDirectory = XSDataFile(XSDataString(self.cbfTempDir))
            else:
                shutil.rmtree(self.cbfTempDir)
 def test_generateCommands(self):
     edPlugin = self.getPlugin()
     strInputXML = EDUtilsFile.readFile(os.path.join(self.strDataPath, "XSDataInputDozor_reference.xml"))
     xsDataInput = XSDataInputDozor.parseString(strInputXML)
     strCommandText = edPlugin.generateCommands(xsDataInput)
     print strCommandText
 def process(self, _edObject=None):
     EDPluginControl.process(self)
     self.DEBUG("EDPluginControlDozorv1_0.process")
     xsDataResultControlDozor = XSDataResultControlDozor()
     # Check if connection to ISPyB needed
     if self.dataInput.dataCollectionId is not None:
         edPluginRetrieveDataCollection = self.loadPlugin("EDPluginISPyBRetrieveDataCollectionv1_4")
         xsDataInputRetrieveDataCollection = XSDataInputRetrieveDataCollection()
         xsDataInputRetrieveDataCollection.dataCollectionId = self.dataInput.dataCollectionId
         edPluginRetrieveDataCollection.dataInput = xsDataInputRetrieveDataCollection
         edPluginRetrieveDataCollection.executeSynchronous()
         ispybDataCollection = edPluginRetrieveDataCollection.dataOutput.dataCollection
         batchSize = ispybDataCollection.numberOfImages
         if batchSize > self.maxBatchSize:
             batchSize = self.maxBatchSize
         if abs(ispybDataCollection.overlap) > 1:
             self.hasOverlap = True
             self.overlap = ispybDataCollection.overlap
         dictImage = self.createImageDictFromISPyB(ispybDataCollection)
     else:
         # No connection to ISPyB, take parameters from input
         if self.dataInput.batchSize is None:
             batchSize = 1
         else:
             batchSize = self.dataInput.batchSize.value
         dictImage = self.createImageDict(self.dataInput)
     listAllBatches = self.createListOfBatches(dictImage.keys(), batchSize)
     if dictImage[listAllBatches[0][0]].path.value.endswith("h5"):
         # Convert HDF5 images to CBF
         self.cbfTempDir = tempfile.mkdtemp(prefix="CbfTemp_")
         dictImage, self.hasHdf5Prefix = self.convertToCBF(dictImage)
     for listBatch in listAllBatches:
         # Read the header from the first image in the batch
         xsDataFile = dictImage[listBatch[0]]
         edPluginControlReadImageHeader = self.loadPlugin(self.strEDPluginControlReadImageHeaderName)
         xsDataInputReadImageHeader = XSDataInputReadImageHeader()
         xsDataInputReadImageHeader.image = xsDataFile
         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 = XSDataInteger(3)
         xsDataInputDozor.detectorDistance = XSDataDouble(detector.distance.value)
         xsDataInputDozor.wavelength = XSDataDouble(beam.wavelength.value)
         #            xsDataInputDozor.fractionPolatization : XSDataDouble optional
         orgx = detector.beamPositionY.value / detector.pixelSizeY.value
         orgy = detector.beamPositionX.value / detector.pixelSizeX.value
         xsDataInputDozor.orgx = XSDataDouble(orgx)
         xsDataInputDozor.orgy = XSDataDouble(orgy)
         xsDataInputDozor.oscillationRange = XSDataDouble(goniostat.oscillationWidth.value)
         #            xsDataInputDozor.imageStep : XSDataDouble optional
         xsDataInputDozor.startingAngle = XSDataDouble(goniostat.rotationAxisStart.value)
         xsDataInputDozor.firstImageNumber = subWedge.image[0].number
         xsDataInputDozor.numberImages = XSDataInteger(len(listBatch))
         if self.hasOverlap:
             xsDataInputDozor.overlap = XSDataAngle(self.overlap)
         strFileName = subWedge.image[0].path.value
         strPrefix = EDUtilsImage.getPrefix(strFileName)
         strSuffix = EDUtilsImage.getSuffix(strFileName)
         if EDUtilsPath.isEMBL():
             strXDSTemplate = "%s_?????.%s" % (strPrefix, strSuffix)
         elif self.hasHdf5Prefix and not self.hasOverlap:
             strXDSTemplate = "%s_??????.%s" % (strPrefix, strSuffix)
         else:
             strXDSTemplate = "%s_????.%s" % (strPrefix, strSuffix)
         xsDataInputDozor.nameTemplateImage = XSDataString(
             os.path.join(os.path.dirname(strFileName), strXDSTemplate)
         )
         xsDataInputDozor.wedgeNumber = self.dataInput.wedgeNumber
         xsDataInputDozor.radiationDamage = self.dataInput.radiationDamage
         edPluginDozor = self.loadPlugin(self.strEDPluginDozorName, "Dozor_%05d" % subWedge.image[0].number.value)
         edPluginDozor.dataInput = xsDataInputDozor
         edPluginDozor.executeSynchronous()
         indexImage = 0
         for xsDataResultDozor in edPluginDozor.dataOutput.imageDozor:
             xsDataControlImageDozor = XSDataControlImageDozor()
             xsDataControlImageDozor.number = xsDataResultDozor.number
             xsDataControlImageDozor.image = dictImage[listBatch[indexImage]]
             xsDataControlImageDozor.spotsNumOf = xsDataResultDozor.spotsNumOf
             xsDataControlImageDozor.spotsIntAver = xsDataResultDozor.spotsIntAver
             xsDataControlImageDozor.spotsResolution = xsDataResultDozor.spotsResolution
             xsDataControlImageDozor.powderWilsonScale = xsDataResultDozor.powderWilsonScale
             xsDataControlImageDozor.powderWilsonBfactor = xsDataResultDozor.powderWilsonBfactor
             xsDataControlImageDozor.powderWilsonResolution = xsDataResultDozor.powderWilsonResolution
             xsDataControlImageDozor.powderWilsonCorrelation = xsDataResultDozor.powderWilsonCorrelation
             xsDataControlImageDozor.powderWilsonRfactor = xsDataResultDozor.powderWilsonRfactor
             xsDataControlImageDozor.mainScore = xsDataResultDozor.mainScore
             xsDataControlImageDozor.spotScore = xsDataResultDozor.spotScore
             xsDataControlImageDozor.visibleResolution = xsDataResultDozor.visibleResolution
             xsDataControlImageDozor.spotFile = xsDataResultDozor.spotFile
             xsDataControlImageDozor.angle = xsDataResultDozor.angle
             xsDataResultControlDozor.addImageDozor(xsDataControlImageDozor)
             if xsDataResultControlDozor.inputDozor is None:
                 xsDataResultControlDozor.inputDozor = XSDataDozorInput().parseString(xsDataInputDozor.marshal())
             indexImage += 1
         xsDataResultControlDozor.halfDoseTime = edPluginDozor.dataOutput.halfDoseTime
     self.dataOutput = xsDataResultControlDozor
     if self.cbfTempDir is not None:
         shutil.rmtree(self.cbfTempDir)
Esempio n. 5
0
    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()
Esempio n. 6
0
    def process(self, _edObject=None):
        EDPluginControl.process(self)
        self.DEBUG("EDPluginControlDozorv1_0.process")
        xsDataResultControlDozor = XSDataResultControlDozor()
        for xsDataFile in self.dataInput.image:
            edPluginControlReadImageHeader = self.loadPlugin(self.strEDPluginControlReadImageHeaderName)
            xsDataInputReadImageHeader = XSDataInputReadImageHeader()
            xsDataInputReadImageHeader.image = xsDataFile
            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(5.0)
            xsDataInputDozor.detectorDistance = XSDataDouble(detector.distance.value)
            xsDataInputDozor.wavelength = XSDataDouble(beam.wavelength.value)
#            xsDataInputDozor.fractionPolatization : XSDataDouble optional
            orgx = detector.beamPositionY.value / detector.pixelSizeY.value
            orgy = detector.beamPositionX.value / detector.pixelSizeX.value
            xsDataInputDozor.orgx = XSDataDouble(orgx)
            xsDataInputDozor.orgy = XSDataDouble(orgy)
            xsDataInputDozor.oscillationRange = XSDataDouble(goniostat.oscillationWidth.value)
#            xsDataInputDozor.imageStep : XSDataDouble optional
            xsDataInputDozor.startingAngle = XSDataDouble(goniostat.rotationAxisStart.value)
            xsDataInputDozor.firstImageNumber = subWedge.image[0].number
            xsDataInputDozor.numberImages = XSDataInteger(1)
            strFileName = subWedge.image[0].path.value
            strPrefix = EDUtilsImage.getPrefix(strFileName)
            strSuffix = EDUtilsImage.getSuffix(strFileName)
            strXDSTemplate = "%s_????.%s" % (strPrefix, strSuffix)
            xsDataInputDozor.nameTemplateImage = XSDataString(os.path.join(os.path.dirname(strFileName), strXDSTemplate))
            edPluginDozor = self.loadPlugin(self.strEDPluginDozorName, "Dozor")
            edPluginDozor.dataInput = xsDataInputDozor
            edPluginDozor.executeSynchronous()
            if edPluginDozor.dataOutput.imageDozor != []:
                xsDataResultDozor = edPluginDozor.dataOutput.imageDozor[0]
                xsDataControlImageDozor = XSDataControlImageDozor()
                xsDataControlImageDozor.image = xsDataFile
                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)
        self.dataOutput = xsDataResultControlDozor