def display(self, experiments, reflections): import wx from dials.util.image_viewer.spotfinder_frame import SpotFrame app = wx.App() self.frame = SpotFrame( None, -1, "X-ray image display", size=(800, 720), pos=(100, 100), params=self.params, experiments=experiments, reflections=reflections, ) self.frame.SetSize((1024, 780)) self.frame.Show() imagesets = self.frame.imagesets for imageset in imagesets: for idx in range(len(imageset.indices())): self.frame.add_file_name_or_data(chooser_wrapper( imageset, idx)) # Make sure we load the first image as the current one self.frame.load_image(chooser_wrapper(imagesets[0], 0)) # debug_memory_usage() app.MainLoop()
class spot_wrapper(object): def __init__(self, params): self.params = params self.frame = None def display(self, datablock, experiments, reflections): import wx from dials.util.image_viewer.spotfinder_frame import SpotFrame app = wx.App() self.frame = SpotFrame(None, -1, "X-ray image display", size=(800,720), pos=(100,100), params=self.params, datablock=datablock, experiments=experiments, reflections=reflections) self.frame.SetSize((1024,780)) self.frame.Show() imagesets = self.frame.imagesets for imageset in imagesets: for idx in xrange(len(imageset.indices())): self.frame.add_file_name_or_data(chooser_wrapper(imageset, idx)) self.frame.load_image(chooser_wrapper(imagesets[0], 0)) debug_memory_usage() app.MainLoop() def load_image(self, filename): from dials.util.spotfinder_frame import create_load_image_event if self.frame is not None: create_load_image_event(self.frame, filename)
def display(self, datablock, experiments, reflections): import wx from dials.util.image_viewer.spotfinder_frame import SpotFrame app = wx.App() self.frame = SpotFrame(None, -1, "X-ray image display", size=(800,720), pos=(100,100), params=self.params, datablock=datablock, experiments=experiments, reflections=reflections) self.frame.SetSize((1024,780)) self.frame.Show() imagesets = self.frame.imagesets for imageset in imagesets: for idx in xrange(len(imageset.indices())): self.frame.add_file_name_or_data(chooser_wrapper(imageset, idx)) self.frame.load_image(chooser_wrapper(imagesets[0], 0)) print 'Memory usage: %.1f MB' % (int(resource.getrusage(resource.RUSAGE_SELF).ru_maxrss) / 1024) app.MainLoop()
def display(self, experiments, reflections): import wx from dials.util.image_viewer.spotfinder_frame import SpotFrame app = wx.App() self.frame = SpotFrame( None, -1, "X-ray image display", size=(800, 720), pos=(100, 100), params=self.params, experiments=experiments, reflections=reflections, ) self.frame.SetSize((1024, 780)) self.frame.Show() imagesets = self.frame.imagesets for imageset in imagesets: for idx in range(len(imageset.indices())): self.frame.add_file_name_or_data(chooser_wrapper( imageset, idx)) # Make sure we load the first image as the current one self.frame.load_image(chooser_wrapper(imagesets[0], 0)) # If ZMQ required, setup the endpoint to dispatch messages to wx if self.params.zmq_endpoint is not None: self._setup_zmq_endpoint(self.params.zmq_endpoint) # debug_memory_usage() app.MainLoop() # Shut down the ZMQ endpoint if we created one if self.params.zmq_endpoint is not None: self._shutdown_zmq_endpoint()
class spot_wrapper: def __init__(self, params): self.params = params self.frame = None self._zmq_thread = None def display(self, experiments, reflections): import wx from dials.util.image_viewer.spotfinder_frame import SpotFrame app = wx.App() self.frame = SpotFrame( None, -1, "X-ray image display", size=(800, 720), pos=(100, 100), params=self.params, experiments=experiments, reflections=reflections, ) self.frame.SetSize((1024, 780)) self.frame.Show() imagesets = self.frame.imagesets for imageset in imagesets: for idx in range(len(imageset.indices())): self.frame.add_file_name_or_data(chooser_wrapper(imageset, idx)) # Make sure we load the first image as the current one self.frame.load_image(chooser_wrapper(imagesets[0], 0)) # If ZMQ required, setup the endpoint to dispatch messages to wx if self.params.zmq_endpoint is not None: self._setup_zmq_endpoint(self.params.zmq_endpoint) # debug_memory_usage() app.MainLoop() # Shut down the ZMQ endpoint if we created one if self.params.zmq_endpoint is not None: self._shutdown_zmq_endpoint() def load_image(self, filename): from dials.util.spotfinder_frame import create_load_image_event if self.frame is not None: create_load_image_event(self.frame, filename) def _setup_zmq_endpoint(self, endpoint: str) -> None: """Create and bind a ZMQ endpoint""" try: import zmq except ImportError: sys.exit("Error: ZMQ Endpoint requested but pyzmq not installed; aborting") print("ZeroMQ binding requested at", endpoint) self.zmq_context = zmq.Context() self.zmq_socket = self.zmq_context.socket(zmq.PULL) self.zmq_socket.bind(endpoint) self._zmq_thread = ZMQEventListener(self.zmq_socket, self.frame) self._zmq_thread.start() def _shutdown_zmq_endpoint(self): """Close the ZMQ endpoint""" print("Shutting down ZMQ endpoint") # Wait for the thread to end if self._zmq_thread is not None: self._zmq_thread.stop = True self._zmq_thread.join() self.zmq_socket.close()