def OnRestoreMetrology(self, event): print("Not implemented") return dialog = wx.FileDialog( self, defaultDir="", message="Restore metrology file", style=wx.FD_OPEN, wildcard="Phil files (*.eff; *.def)|*.eff;*.def") if dialog.ShowModal() == wx.ID_OK: path = dialog.GetPath() if (path != ""): from xfel.cftbx.detector.metrology import \ master_phil, metrology_as_transformation_matrices from libtbx import phil frame = self.GetParent().GetParent() stream = open(path) metrology_phil = master_phil.fetch( sources=[phil.parse(stream.read())]) stream.close() # Merge restored metrology into the raw image from libtbx.phil import experimental experimental.merge_params_by_key( frame.pyslip.tiles.raw_image._metrology_params, metrology_phil.extract(), 'serial') img = frame.pyslip.tiles.raw_image img.apply_metrology_from_matrices( metrology_as_transformation_matrices( metrology_phil.extract())) # Update the view, trigger redraw. XXX Duplication # w.r.t. OnUpdateQuad(). tiles = frame.pyslip.tiles tiles.flex_image = frame.pyslip.tiles.raw_image.get_flex_image( brightness=tiles.current_brightness / 100) tiles.flex_image.adjust( color_scheme=tiles.current_color_scheme) tiles.reset_the_cache() tiles.tile_cache = tiles.cache[tiles.zoom_level] tiles.tile_list = tiles.lru[tiles.zoom_level] frame.pyslip.Update() # Update the controls, remember to reset the default values # for the spinners. for serial in range(4): fast, slow = img.get_panel_fast_slow(serial) name_quadrant = ["Q0", "Q1", "Q2", "Q3"][serial] spinner = getattr(self, "_" + name_quadrant + "_fast_ctrl") spinner.SetDefaultValue(fast) spinner.SetValue(fast) spinner = getattr(self, "_" + name_quadrant + "_slow_ctrl") spinner.SetDefaultValue(slow) spinner.SetValue(slow)
def OnRestoreMetrology(self, event): print "Not implemented" return dialog = wx.FileDialog( self, defaultDir="", message="Restore metrology file", style=wx.FD_OPEN, wildcard="Phil files (*.eff; *.def)|*.eff;*.def") if dialog.ShowModal() == wx.ID_OK: path = dialog.GetPath() if (path != "") : from xfel.cftbx.detector.metrology import \ master_phil, metrology_as_transformation_matrices from libtbx import phil frame = self.GetParent().GetParent() stream = open(path) metrology_phil = master_phil.fetch(sources=[phil.parse(stream.read())]) stream.close() # Merge restored metrology into the raw image from libtbx.phil import experimental experimental.merge_params_by_key( frame.pyslip.tiles.raw_image._metrology_params, metrology_phil.extract(), 'serial') img = frame.pyslip.tiles.raw_image img.apply_metrology_from_matrices(metrology_as_transformation_matrices( metrology_phil.extract())) # Update the view, trigger redraw. XXX Duplication # w.r.t. OnUpdateQuad(). tiles = frame.pyslip.tiles tiles.flex_image = frame.pyslip.tiles.raw_image.get_flex_image( brightness=tiles.current_brightness / 100) tiles.flex_image.adjust(color_scheme=tiles.current_color_scheme) tiles.reset_the_cache() tiles.tile_cache = tiles.cache[tiles.zoom_level] tiles.tile_list = tiles.lru[tiles.zoom_level] frame.pyslip.Update() # Update the controls, remember to reset the default values # for the spinners. for serial in xrange(4): fast, slow = img.get_panel_fast_slow(serial) name_quadrant = ["Q0", "Q1", "Q2", "Q3"][serial] spinner = getattr(self, "_" + name_quadrant + "_fast_ctrl") spinner.SetDefaultValue(fast) spinner.SetValue(fast) spinner = getattr(self, "_" + name_quadrant + "_slow_ctrl") spinner.SetDefaultValue(slow) spinner.SetValue(slow)
def readHeader(self): # XXX The functionality provided by this function has largely been # replicated in # rstbx.slip_viewer.tile_generation._get_flex_image_multitile(). # However, several code paths still depend on the member variables # created here. from xfel.cftbx.detector.metrology import metrology_as_transformation_matrices d = easy_pickle.load(self.filename) # Derive the transformation matrices from the metrology in the # image. self._metrology_params = d["METROLOGY"].extract() self._matrices = metrology_as_transformation_matrices( self._metrology_params) self._tiles = d["TILES"] self._keylist = self._tiles.keys( ) #for later use by get_pixel_intensity() # Assert that all ASIC:s are the same size, and that there are # transformation matrices for each ASIC. for (key, asic) in self._tiles.iteritems(): if not hasattr(self, "_asic_focus"): self._asic_focus = asic.focus() else: assert asic.focus() == self._asic_focus assert key in self._matrices # Assert that all specified pixel sizes and saturated values are # equal and not None. for p in self._metrology_params.detector.panel: for s in p.sensor: for a in s.asic: if not hasattr(self, "_pixel_size"): self._pixel_size = a.pixel_size else: assert self._pixel_size == a.pixel_size if not hasattr(self, "_saturation"): self._saturation = a.saturation else: # XXX real-valued equality! See # cctbx_project/scitbx/math/approx_equal.h assert self._saturation == a.saturation assert hasattr(self, "_pixel_size") and self._pixel_size is not None assert hasattr(self, "_saturation") and self._saturation is not None # Determine next multiple of eight. Set size1 and size2 to the # focus of the padded rawdata. self._asic_padded = (8 * int(math.ceil(self._asic_focus[0] / 8)), 8 * int(math.ceil(self._asic_focus[1] / 8))) self.size1 = len(self._tiles) * self._asic_padded[0] self.size2 = self._asic_padded[1]
def readHeader(self): # XXX The functionality provided by this function has largely been # replicated in # rstbx.slip_viewer.tile_generation._get_flex_image_multitile(). # However, several code paths still depend on the member variables # created here. from xfel.cftbx.detector.metrology import metrology_as_transformation_matrices d = easy_pickle.load(self.filename) # Derive the transformation matrices from the metrology in the # image. self._metrology_params = d["METROLOGY"].extract() self._matrices = metrology_as_transformation_matrices( self._metrology_params) self._tiles = d["TILES"] self._keylist = self._tiles.keys() #for later use by get_pixel_intensity() # Assert that all ASIC:s are the same size, and that there are # transformation matrices for each ASIC. for (key, asic) in self._tiles.iteritems(): if not hasattr(self, "_asic_focus"): self._asic_focus = asic.focus() else: assert asic.focus() == self._asic_focus assert key in self._matrices # Assert that all specified pixel sizes and saturated values are # equal and not None. for p in self._metrology_params.detector.panel: for s in p.sensor: for a in s.asic: if not hasattr(self, "_pixel_size"): self._pixel_size = a.pixel_size else: assert self._pixel_size == a.pixel_size if not hasattr(self, "_saturation"): self._saturation = a.saturation else: # XXX real-valued equality! See # cctbx_project/scitbx/math/approx_equal.h assert self._saturation == a.saturation assert hasattr(self, "_pixel_size") and self._pixel_size is not None assert hasattr(self, "_saturation") and self._saturation is not None # Determine next multiple of eight. Set size1 and size2 to the # focus of the padded rawdata. self._asic_padded = (8 * int(math.ceil(self._asic_focus[0] / 8)), 8 * int(math.ceil(self._asic_focus[1] / 8))) self.size1 = len(self._tiles) * self._asic_padded[0] self.size2 = self._asic_padded[1]
def run(argv=None): if (argv is None): argv = sys.argv # XXX Could/should handle effective metrology the same way, except # it does not have a single scope. work_phil = phil.process_command_line(args=argv[1:], master_string=master_str + phil_str + additional_spotfinder_phil_defs) work_params = work_phil.work.extract() app = wx.App(0) wx.SystemOptions.SetOptionInt("osx.openfiledialog.always-show-types", 1) frame = XrayFrame(None, -1, "X-ray image display", size=(800, 720)) frame.Show() # show settings panel frame.OnShowSettings(None) frame.settings_frame.panel.center_ctrl.SetValue(work_params.beam_center) frame.settings_frame.panel.integ_ctrl.SetValue( work_params.show_integration_results) frame.settings_frame.panel.spots_ctrl.SetValue( work_params.show_spotfinder_results) frame.settings.show_effective_tiling = work_params.show_effective_tiling frame.settings_frame.panel.collect_values() if (work_params.effective_metrology is not None): from xfel.cftbx.detector.metrology import \ master_phil, metrology_as_transformation_matrices stream = open(work_params.effective_metrology) metrology_phil = master_phil.fetch(sources=[phil.parse(stream.read())]) stream.close() frame.metrology_matrices = metrology_as_transformation_matrices( metrology_phil.extract()) # Update initial settings with values from the command line. Needs # to be done before image is loaded (but after the frame is # instantiated). frame.params = work_params frame.init_pyslip() frame.pyslip.tiles.user_requests_antialiasing = work_params.anti_aliasing frame.pyslip.tiles.show_untrusted = frame.params.show_untrusted paths = work_phil.remaining_args if (len(paths) == 1 and os.path.basename(paths[0]) == "DISTL_pickle"): assert os.path.isfile(paths[0]) frame.load_distl_output(paths[0]) elif (len(paths) > 0): frame.CHOOSER_SIZE = 1500 # from dxtbx.imageset import ImageSetFactory # sets = ImageSetFactory.new(paths) from dxtbx.model.experiment_list import ExperimentListFactory from rstbx.slip_viewer.frame import chooser_wrapper experiments = ExperimentListFactory.from_filenames(paths) sets = experiments.imagesets() for imgset in sets: for idx in imgset.indices(): frame.add_file_name_or_data(chooser_wrapper(imgset, idx)) idx = sets[0].indices()[0] frame.load_image(chooser_wrapper(sets[0], idx)) app.MainLoop() return 0
def run(argv=None): if (argv is None): argv = sys.argv # XXX Could/should handle effective metrology the same way, except # it does not have a single scope. work_phil = phil.process_command_line( args=argv[1:], master_string=master_str + phil_str + additional_spotfinder_phil_defs) work_params = work_phil.work.extract() app = wx.App(0) wx.SystemOptions.SetOptionInt("osx.openfiledialog.always-show-types", 1) frame = XrayFrame(None, -1, "X-ray image display", size=(800,720)) frame.Show() # show settings panel frame.OnShowSettings(None) frame.settings_frame.panel.center_ctrl.SetValue( work_params.beam_center) frame.settings_frame.panel.integ_ctrl.SetValue( work_params.show_integration_results) frame.settings_frame.panel.spots_ctrl.SetValue( work_params.show_spotfinder_results) frame.settings.show_effective_tiling = work_params.show_effective_tiling frame.settings_frame.panel.collect_values() if (work_params.effective_metrology is not None): from xfel.cftbx.detector.metrology import \ master_phil, metrology_as_transformation_matrices stream = open(work_params.effective_metrology) metrology_phil = master_phil.fetch(sources=[phil.parse(stream.read())]) stream.close() frame.metrology_matrices = metrology_as_transformation_matrices( metrology_phil.extract()) # Update initial settings with values from the command line. Needs # to be done before image is loaded (but after the frame is # instantiated). frame.params = work_params frame.init_pyslip() frame.pyslip.tiles.user_requests_antialiasing = work_params.anti_aliasing frame.pyslip.tiles.show_untrusted = frame.params.show_untrusted paths = work_phil.remaining_args if (len(paths) == 1 and os.path.basename(paths[0]) == "DISTL_pickle"): assert os.path.isfile(paths[0]) frame.load_distl_output(paths[0]) elif (len(paths) > 0): frame.CHOOSER_SIZE = 1500 from dxtbx.imageset import ImageSetFactory from rstbx.slip_viewer.frame import chooser_wrapper sets = ImageSetFactory.new(paths) for imgset in sets: for idx in imgset.indices(): frame.add_file_name_or_data(chooser_wrapper(imgset, idx)) idx = sets[0].indices()[0] frame.load_image(chooser_wrapper(sets[0],idx)) app.MainLoop() return 0