def fout(*args, **kwargs): logger.info('Temporarily disabling figure interactivity') pyqtRemoveInputHook() out = fin(*args, **kwargs) pyqtRestoreInputHook() logger.info('Figure interactivity has been restored') return out
def fout(*args,**kwargs): logger.info('Temporarily disabling figure interactivity') pyqtRemoveInputHook() out = fin(*args,**kwargs) pyqtRestoreInputHook() logger.info('Figure interactivity has been restored') return out
def ipdb_set_trace(): '''ipdb version''' try: import ipdb except ImportError: pass else: pyqtRemoveInputHook() ipdb.set_trace(sys._getframe(1)) pyqtRestoreInputHook()
def debug_stop(): '''Recover envionment after a debug_start Notes ----- Basically to handle Qt debugging. When one is done debugging a Qt app, and one wished to continue the app, enter "from <whatever> import debug_stop" then "debug_stop()" then "c<RET>" a number of times to enter back into the event loop. ''' try: from PyQt4.QtCore import pyqtRestoreInputHook pyqtRestoreInputHook() except NameError: pass
def __del__(self): pyqtRestoreInputHook()
def _on_click(self, event): # TODO: ignore method here.... print(vars(event)) if event.inaxes != self.image.axes: return if event.button == 3: return # Middle mouse restarts the selection process if event.button == 2: self.restart() return # Double click to fit stars if not event.dblclick: return x, y = event.xdata, event.ydata xs, ys = self.snap(x, y) # coordinates of maximum intensity within window around click position # print( '!'*100, xs, ys ) if not (xs and ys): return else: print("\n\nSNAPPED", xs, ys, "\n\n") # TODO: NEW METHOD HERE?? # Fitting data, index = self.snap.zoom(xs, ys) # retrieve zoomed image of the star grid = Y, X = grid_like(data) params = self.fit(grid, data) Z = self.psf(params, X, Y) if params is None: return ##try: # update fit plots self.fitplotter.update(X, Y, Z, data) # except: # get dict of fit descriptors from params info = self.psf.get_description(params, index[::-1]) _, sky_sigma = self.psf.background_estimate.cache # cached upon call to self.fit wslice = tuple(map(slice, index, index + data.shape)) # 2D window slice # Add star to collection stars = self.stars star = stars.append( sky_sigma=sky_sigma, slice=wslice, image=data, # rmax = self.rphotmax, **info ) # remove star from image by subtracting model bg = info["sky_mean"] # background value from fit try: self.snap.clean(Z - bg) except: pyqtRemoveInputHook() embed() pyqtRestoreInputHook() # Check apertures and colourise # TODO: ONLY trigger checks on second draw........... psfaps, photaps, skyaps = self.stars.apertures skyaps.auto_colour(check="all", cross=psfaps, edge=self.image_data.shape) photaps.auto_colour(check="all", cross=psfaps, edge=self.image_data.shape) # pyqtRemoveInputHook() # embed() # pyqtRestoreInputHook() stars.model.update(self.fit.get_params_from_cache(), stars.mean_radial_profile(), self.rsky, self.rphotmax) # stars.model.apertures.phot.radii = [self.rphotmax] # stars.model.update_plots() # print( stars.photaps.get_ec() ) # print( 'x'*100 ) # Redraw & blit # self.canvas.restore_region( self.canvas.background ) # stars.draw_all() # stars.model.draw() # self.canvas.blit( self.figure.bbox ) self.canvas.draw()
def debug(self): pyqtRemoveInputHook() pdb.pm() pyqtRestoreInputHook() self.accept()