def ShowPlotFrame(self, do_raise=True, clear=True): "make sure plot frame is enabled, and visible" if self.plotframe is None: self.plotframe = PlotFrame(self) self.has_plot = False try: self.plotframe.Show() except PyDeadObjectError: self.plotframe = PlotFrame(self) self.plotframe.Show() if do_raise: self.plotframe.Raise() if clear: self.plotframe.panel.clear() self.plotframe.reset_config()
def onShowIntegration(self, event=None): if self.calib is None or 'poni1' not in self.calib: return shown = False try: self.int_panel.Raise() shown = True except: self.int_panel = None if not shown: self.int_panel = PlotFrame(self) self.show_1dpattern(init=True) else: self.show_1dpattern()
def onAutoIntegration(self, event=None): if not event.IsChecked(): self.int_timer.Stop() return if self.calib is None or 'poni1' not in self.calib: return shown = False try: self.int_panel.Raise() shown = True except: self.int_panel = None if not shown: self.int_panel = PlotFrame(self) self.show_1dpattern(init=True) else: self.show_1dpattern() self.int_timer.Start(500)
def onProfile(self, x0, y0, x1, y1): width = self.ad_cam.SizeX height = self.ad_cam.SizeY x0, y0 = int(x0 * width), int(y0 * height) x1, y1 = int(x1 * width), int(y1 * height) dx, dy = abs(x1 - x0), abs(y1 - y0) if dx < 2 and dy < 2: return outdat = [] if self.colormode == 2: self.data.shape = (self.im_size[1], self.im_size[0], 3) else: self.data.shape = self.im_size[1], self.im_size[0] if dy > dx: _y0 = min(int(y0), int(y1 + 0.5)) _y1 = max(int(y0), int(y1 + 0.5)) for iy in range(_y0, _y1): ix = int(x0 + (iy - int(y0)) * (x1 - x0) / (y1 - y0)) outdat.append((ix, iy)) else: _x0 = min(int(x0), int(x1 + 0.5)) _x1 = max(int(x0), int(x1 + 0.5)) for ix in range(_x0, _x1): iy = int(y0 + (ix - int(x0)) * (y1 - y0) / (x1 - x0)) outdat.append((ix, iy)) if self.lineplotter is None: self.lineplotter = PlotFrame(self, title='Image Profile') else: try: self.lineplotter.Raise() except PyDeadObjectError: self.lineplotter = PlotFrame(self, title='Image Profile') if self.colormode == 2: x, y, r, g, b = [], [], [], [], [] for ix, iy in outdat: x.append(ix) y.append(iy) r.append(self.data[iy, ix, 0]) g.append(self.data[iy, ix, 1]) b.append(self.data[iy, ix, 2]) xlabel = 'Pixel (x)' if dy > dx: x = y xlabel = 'Pixel (y)' self.lineplotter.plot(x, r, color='red', label='red', xlabel=xlabel, ylabel='Intensity', title='Image %i' % self.ad_cam.ArrayCounter_RBV) self.lineplotter.oplot(x, g, color='green', label='green') self.lineplotter.oplot(x, b, color='blue', label='blue') else: x, y, z = [], [], [] for ix, iy in outdat: x.append(ix) y.append(iy) z.append(self.data[iy, ix]) xlabel = 'Pixel (x)' if dy > dx: x = y xlabel = 'Pixel (y)' self.lineplotter.plot(x, z, color='k', xlabel=xlabel, ylabel='Intensity', title='Image %i' % self.ad_cam.ArrayCounter_RBV) self.lineplotter.Show() self.lineplotter.Raise()