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()