def __init__(self, ip="192.168.5.19", fps=30, poni=None, json=None, writer=None, cake=None): QtGui.QWidget.__init__(self) try: uic.loadUi(UIC, self) except AttributeError as error: logger.error( "I looks like your installation suffers from this bug: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=697348" ) raise RuntimeError( "Please upgrade your installation of PyQt (or apply the patch)" ) self.ip = str(ip) self.fps = float(fps) self.label_ip.setText(str(ip)) self.label_fps.setText(str(fps)) self.cam = self.iface = self.ctrl = self.acq = None self.cam = Basler.Camera(self.ip) self.iface = Basler.Interface(self.cam) self.ctrl = Core.CtControl(self.iface) self.is_playing = False self.cake = int(cake) self.connect(self.pushButton_play, SIGNAL("clicked()"), self.start_acq) self.connect(self.pushButton_stop, SIGNAL("clicked()"), self.stop_acq) self.last_frame = None self.last = time.time() if poni: worker = pyFAI.worker.Worker(ai=pyFAI.load(poni)) elif json: worker = pyFAI.worker.Worker() worker.setJsonConfig(json) else: worker = None self.processLink = LinkPyFAI(worker, writer) self.extMgr = self.ctrl.externalOperation() self.myOp = self.extMgr.addOp(Core.USER_LINK_TASK, "pyFAILink", 0) self.myOp.setLinkTask(self.processLink) self.callback = StartAcqCallback(self.ctrl, self.processLink) self.myOp.registerCallback(self.callback) self.timer = QtCore.QTimer() self.connect(self.timer, SIGNAL("timeout()"), self.update_img) self.writer = writer self.dLayout = QtGui.QHBoxLayout(self.frame) if self.cake <= 1: self.variablePlot = pg.PlotWidget(parent=self.frame) else: self.variablePlot = pg.ImageView(parent=self.frame) self.dLayout.addWidget(self.variablePlot)
def __init__(self, ip="192.168.5.19", fps=30, poni=None, json=None, writer=None, cake=None): QtGui.QWidget.__init__(self) try: uic.loadUi(UIC, self) except AttributeError as error: logger.error("I looks like your installation suffers from this bug: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=697348") raise RuntimeError("Please upgrade your installation of PyQt (or apply the patch)") self.ip = str(ip) self.fps = float(fps) self.label_ip.setText(str(ip)) self.label_fps.setText(str(fps)) self.cam = self.iface = self.ctrl = self.acq = None self.cam = Basler.Camera(self.ip) self.iface = Basler.Interface(self.cam) self.ctrl = Core.CtControl(self.iface) self.is_playing = False self.cake = int(cake) self.connect(self.pushButton_play, SIGNAL("clicked()"), self.start_acq) self.connect(self.pushButton_stop, SIGNAL("clicked()"), self.stop_acq) self.last_frame = None self.last = time.time() if poni: worker = pyFAI.worker.Worker(azimuthalIntegrator=pyFAI.load(poni)) elif json: worker = pyFAI.worker.Worker() worker.setJsonConfig(json) else: worker = None self.processLink = LinkPyFAI(worker, writer) self.extMgr = self.ctrl.externalOperation() self.myOp = self.extMgr.addOp(Core.USER_LINK_TASK, "pyFAILink", 0) self.myOp.setLinkTask(self.processLink) self.callback = StartAcqCallback(self.ctrl, self.processLink) self.myOp.registerCallback(self.callback) self.timer = QtCore.QTimer() self.connect(self.timer, SIGNAL("timeout()"), self.update_img) self.writer = writer self.dLayout = QtGui.QHBoxLayout(self.frame) if self.cake <= 1: self.variablePlot = pg.PlotWidget(parent=self.frame) else: self.variablePlot = pg.ImageView(parent=self.frame) self.dLayout.addWidget(self.variablePlot)
def integrate_shell(options, args): import json config = json.load(open(options.json)) ai = pyFAI.worker.make_ai(config) worker = pyFAI.worker.Worker(azimuthalIntegrator=ai) # TODO this will init again the azimuthal integrator, there is a problem on the architecture worker.setJsonConfig(options.json) worker.safe = False # all processing are expected to be the same. start_time = time.time() # Skip unexisting files image_filenames = [] for item in args: if os.path.exists(item) and os.path.isfile(item): image_filenames.append(item) else: logger.warning("File %s do not exists. Ignored." % item) image_filenames = sorted(image_filenames) progress_bar = ProgressBar("Integration", len(image_filenames), 20) # Integrate files one by one for i, item in enumerate(image_filenames): logger.debug("Processing %s" % item) if len(item) > 100: message = os.path.basename(item) else: message = item progress_bar.update(i + 1, message=message) img = fabio.open(item) multiframe = img.nframes > 1 custom_ext = True if options.output: if os.path.isdir(options.output): outpath = os.path.join(options.output, os.path.splitext(os.path.basename(item))[0]) else: outpath = os.path.abspath(options.output) custom_ext = False else: outpath = os.path.splitext(item)[0] if custom_ext: if multiframe: outpath = outpath + "_pyFAI.h5" else: if worker.do_2D(): outpath = outpath + ".azim" else: outpath = outpath + ".dat" if multiframe: writer = HDF5Writer(outpath) writer.init(config) for i in range(img.nframes): fimg = img.getframe(i) normalization_factor = get_monitor_value(fimg, options.monitor_key) data = img.data res = worker.process(data=data, metadata=fimg.header, normalization_factor=normalization_factor) if not worker.do_2D(): res = res.T[1] writer.write(res, index=i) writer.close() else: normalization_factor = get_monitor_value(img, options.monitor_key) data = img.data writer = DefaultAiWriter(outpath, worker.ai) worker.process(data, normalization_factor=normalization_factor, writer=writer) writer.close() progress_bar.clear() logger.info("Processing done in %.3fs !" % (time.time() - start_time))
def integrate_shell(options, args): import json with open(options.json) as f: config = json.load(f) ai = pyFAI.worker.make_ai(config) worker = pyFAI.worker.Worker(azimuthalIntegrator=ai) # TODO this will init again the azimuthal integrator, there is a problem on the architecture worker.setJsonConfig(options.json) worker.safe = False # all processing are expected to be the same. start_time = time.time() # Skip unexisting files image_filenames = [] for item in args: if os.path.exists(item) and os.path.isfile(item): image_filenames.append(item) else: logger.warning("File %s do not exists. Ignored.", item) image_filenames = sorted(image_filenames) progress_bar = ProgressBar("Integration", len(image_filenames), 20) # Integrate files one by one for i, item in enumerate(image_filenames): logger.debug("Processing %s", item) if len(item) > 100: message = os.path.basename(item) else: message = item progress_bar.update(i + 1, message=message) img = fabio.open(item) multiframe = img.nframes > 1 custom_ext = True if options.output: if os.path.isdir(options.output): outpath = os.path.join( options.output, os.path.splitext(os.path.basename(item))[0]) else: outpath = os.path.abspath(options.output) custom_ext = False else: outpath = os.path.splitext(item)[0] if custom_ext: if multiframe: outpath = outpath + "_pyFAI.h5" else: if worker.do_2D(): outpath = outpath + ".azim" else: outpath = outpath + ".dat" if multiframe: writer = HDF5Writer(outpath) writer.init(config) for i in range(img.nframes): fimg = img.getframe(i) normalization_factor = get_monitor_value( fimg, options.monitor_key) data = img.data res = worker.process(data=data, metadata=fimg.header, normalization_factor=normalization_factor) if not worker.do_2D(): res = res.T[1] writer.write(res, index=i) writer.close() else: normalization_factor = get_monitor_value(img, options.monitor_key) data = img.data writer = DefaultAiWriter(outpath, worker.ai) worker.process(data, normalization_factor=normalization_factor, writer=writer) writer.close() progress_bar.clear() logger.info("Processing done in %.3fs !", (time.time() - start_time)) return 0