Example #1
0
    def __init__(self, horizons_phil, args):
        self.last_saved_best = None
        self.horizons_phil = horizons_phil
        if self.horizons_phil.spotfinder == "distl":
            print "Importing DISTL"
            from labelit.command_line.stats_index import AutoIndexOrganizer
        elif self.horizons_phil.spotfinder == "speck":
            print "Importing SPECK"
            from rstbx.new_horizons.stats_index import AutoIndexOrganizer

        self.organizer = AutoIndexOrganizer(
            verbose=self.horizons_phil.distl.bins.verbose,
            argument_module=args,
            horizons_phil=horizons_phil,
            delegate=self.index_and_integrate)
Example #2
0
    def __init__(self, *args):
        #application programmer interface for screen, using identical inputs
        # to the command line interface
        args = list(args)
        labelit_phil.merge_command_line(args)
        E = Empty()
        E.argv = ['Empty']
        for x in xrange(len(args)):
            E.argv.append(args[x])
        E.horizons_phil = labelit_commands

        self.establish_dict_for_refinement = establish_dict_for_refinement
        self.index_and_refine = index_and_refine
        self.best_character_to_IndexPrinter = best_character_to_IndexPrinter

        self.Org = AutoIndexOrganizer(
            verbose=labelit_commands.distl.bins.verbose, argument_module=E)
        self.Org.setIndexingDelegate(self.index_and_integrate)
        # legacy:algorithm control could be excercised here
        self.horizons_phil = labelit_commands
Example #3
0
  def __init__(self,horizons_phil,args):
    self.last_saved_best = None
    self.horizons_phil = horizons_phil
    if self.horizons_phil.spotfinder=="distl":
      print "Importing DISTL"
      from labelit.command_line.stats_index import AutoIndexOrganizer
    elif self.horizons_phil.spotfinder=="speck":
      print "Importing SPECK"
      from rstbx.new_horizons.stats_index import AutoIndexOrganizer

    self.organizer = AutoIndexOrganizer(
      verbose = self.horizons_phil.distl.bins.verbose,
      argument_module = args,
      horizons_phil = horizons_phil,
      delegate = self.index_and_integrate)
  def __init__(self,*args):
    #application programmer interface for screen, using identical inputs
    # to the command line interface
    args = list(args)
    labelit_phil.merge_command_line(args)
    E = Empty()
    E.argv=['Empty']
    for x in xrange(len(args)):
      E.argv.append(args[x])
    E.horizons_phil=labelit_commands

    self.establish_dict_for_refinement = establish_dict_for_refinement
    self.index_and_refine = index_and_refine
    self.best_character_to_IndexPrinter = best_character_to_IndexPrinter

    self.Org = AutoIndexOrganizer(
      verbose=labelit_commands.distl.bins.verbose,argument_module=E)
    self.Org.setIndexingDelegate(self.index_and_integrate)
      # legacy:algorithm control could be excercised here
    self.horizons_phil = labelit_commands
Example #5
0
class api:
    def __init__(self, *args):
        #application programmer interface for screen, using identical inputs
        # to the command line interface
        args = list(args)
        labelit_phil.merge_command_line(args)
        E = Empty()
        E.argv = ['Empty']
        for x in xrange(len(args)):
            E.argv.append(args[x])
        E.horizons_phil = labelit_commands

        self.establish_dict_for_refinement = establish_dict_for_refinement
        self.index_and_refine = index_and_refine
        self.best_character_to_IndexPrinter = best_character_to_IndexPrinter

        self.Org = AutoIndexOrganizer(
            verbose=labelit_commands.distl.bins.verbose, argument_module=E)
        self.Org.setIndexingDelegate(self.index_and_integrate)
        # legacy:algorithm control could be excercised here
        self.horizons_phil = labelit_commands

    def __call__(self):
        return self.Org.process()

    def index_and_integrate(self, frames, files, spotfinder_results):
        self.frames = frames
        self.files = files
        self.spotfinder_results = spotfinder_results
        pd = self.establish_dict_for_refinement(frames, spotfinder_results)
        #------------------------------------------------------------
        ai, P = self.index_and_refine(pd, files, spotfinder_results, 0)
        self.indexing_ai = ai
        #------------------------------------------------------------
        if labelit_commands.compatibility_allow == False:
            M = self.best_character_to_IndexPrinter(
                ai, P, pd, horizons_phil=self.horizons_phil)
        else:
            from labelit.diffraction.compatibility import \
              best_compatibility_to_IndexPrinter
            M = best_compatibility_to_IndexPrinter(
                ai,
                P,
                pd,
                files,
                spotfinder_results,
                horizons_phil=self.horizons_phil)
        #------------------------------------------------------------
        if "writer" in labelit_commands.__dict__:
            labelit_commands.writer.make_image_plots_detail(
                ai=ai,
                pd=pd,
                inframes=files,
                spotfinder_results=spotfinder_results)
        if not labelit_commands.index_only:
            IC = IntegrateCharacters(M, pd)
            IC.write_mosflm_matrices()
            IC.find_best()
            IC.show()
        return pd

    def create_case_only(self, frames, file, spotfinder_results):
        self.pd = self.establish_dict_for_refinement(frames)

    def analyze_one(self, solution):
        inputpd = self.Org.process()

        settings = pickle.load(open("LABELIT_possible", "rb"))
        setting = [
            setting for setting in settings if setting["counter"] == solution
        ][0]

        from labelit.preferences import labelit_commands as param

        pixel_size = float(inputpd['pixel_size'])
        self.pixel_size = pixel_size

        from labelit.dptbx import AutoIndexEngine, Parameters
        ai = AutoIndexEngine(inputpd['endstation'])

        P = Parameters(xbeam=setting["refined x beam"],
                       ybeam=setting["refined y beam"],
                       distance=setting["refined distance"],
                       twotheta=float(inputpd["twotheta"]))
        ai.setBase(P)
        ai.setWavelength(float(inputpd['wavelength']))
        ai.setMaxcell(float(inputpd['ref_maxcel']))
        print "Deltaphi is", float(inputpd['deltaphi'])
        ai.setDeltaphi(float(inputpd['deltaphi']) * math.pi / 180.)
        ai.setMosaicity(setting["mosaicity"])
        ai.setOrientation(setting["orient"])
        #why aren't hexagonal constraints applied here???
        print inputpd["osc_start"]

        image_centers = [(math.pi / 180.) * float(x)
                         for x in inputpd["osc_start"].values()]

        limiting_resolution = param.distl_highres_limit
        print "Limiting resolution", limiting_resolution

        #predict the spots
        spots = ai.predict_all(image_centers[0], limiting_resolution)
        pre2m = spots.vec3()
        self.pre2m = pre2m

        hkllist = spots.hkl()
        cell = ai.getOrientation().unit_cell()
        print cell
        for hkl in hkllist:
            #print "%25s %5.2f"%(str(hkl),cell.d(hkl))
            assert cell.d(hkl) >= limiting_resolution
        print "Number of hkls:", (hkllist).size(),
        print "all inside the %4.2f Angstrom limiting sphere." % limiting_resolution
        print "The unit cell is", cell
        self.solution_setting_ai = ai
        self.solution_pd = inputpd
        self.image_centers = image_centers
        self.one_setting = setting
        return [ai.getOrientation().unit_cell(), hkllist]

    def parameters(self):
        image_centers = [(math.pi / 180.) * float(x)
                         for x in self.solution_pd["osc_start"].values()]
        P = dict(
            image_center_radians=image_centers,
            wavelength=float(self.solution_pd['wavelength']),
            deltaphi=float(self.solution_pd['deltaphi']),
            mosaicity_degrees=self.solution_setting_ai.getMosaicity(),
            orientation=self.solution_setting_ai.getOrientation(),
        )
        return P
class api:
  def __init__(self,*args):
    #application programmer interface for screen, using identical inputs
    # to the command line interface
    args = list(args)
    labelit_phil.merge_command_line(args)
    E = Empty()
    E.argv=['Empty']
    for x in xrange(len(args)):
      E.argv.append(args[x])
    E.horizons_phil=labelit_commands

    self.establish_dict_for_refinement = establish_dict_for_refinement
    self.index_and_refine = index_and_refine
    self.best_character_to_IndexPrinter = best_character_to_IndexPrinter

    self.Org = AutoIndexOrganizer(
      verbose=labelit_commands.distl.bins.verbose,argument_module=E)
    self.Org.setIndexingDelegate(self.index_and_integrate)
      # legacy:algorithm control could be excercised here
    self.horizons_phil = labelit_commands

  def __call__(self):
    return self.Org.process()

  def index_and_integrate(self,frames,files,spotfinder_results):
    self.frames = frames
    self.files = files
    self.spotfinder_results = spotfinder_results
    pd = self.establish_dict_for_refinement(frames,spotfinder_results)
    #------------------------------------------------------------
    ai,P = self.index_and_refine(pd,files,spotfinder_results,0)
    self.indexing_ai = ai
    #------------------------------------------------------------
    if labelit_commands.compatibility_allow==False:
      M = self.best_character_to_IndexPrinter(ai,P,pd,horizons_phil=self.horizons_phil)
    else:
      from labelit.diffraction.compatibility import \
        best_compatibility_to_IndexPrinter
      M = best_compatibility_to_IndexPrinter(ai,P,pd,files,spotfinder_results,horizons_phil=self.horizons_phil)
    #------------------------------------------------------------
    if labelit_commands.__dict__.has_key("writer"):
      labelit_commands.writer.make_image_plots_detail(
        ai=ai,pd=pd,inframes=files,spotfinder_results=spotfinder_results)
    if not labelit_commands.index_only:
      IC = IntegrateCharacters(M,pd)
      IC.write_mosflm_matrices()
      IC.find_best()
      IC.show()
    return pd

  def create_case_only(self,frames,file,spotfinder_results):
    self.pd = self.establish_dict_for_refinement(frames)

  def analyze_one(self,solution):
    inputpd = self.Org.process()

    settings = pickle.load(open("LABELIT_possible","rb"))
    setting = [setting for setting in settings if setting["counter"]==solution][0]

    from labelit.preferences import labelit_commands as param

    pixel_size = float(inputpd['pixel_size'])
    self.pixel_size = pixel_size

    from labelit.dptbx import AutoIndexEngine, Parameters
    ai = AutoIndexEngine(inputpd['endstation'])

    P = Parameters(xbeam=setting["refined x beam"],ybeam=setting["refined y beam"],
             distance=setting["refined distance"],twotheta=float(inputpd["twotheta"]))
    ai.setBase(P)
    ai.setWavelength(float(inputpd['wavelength']))
    ai.setMaxcell(float(inputpd['ref_maxcel']))
    print "Deltaphi is",float(inputpd['deltaphi'])
    ai.setDeltaphi(float(inputpd['deltaphi'])*math.pi/180.)
    ai.setMosaicity(setting["mosaicity"])
    ai.setOrientation(setting["orient"])
    #why aren't hexagonal constraints applied here???
    print inputpd["osc_start"]

    image_centers = [(math.pi/180.)*float(x) for x in inputpd["osc_start"].values()]

    limiting_resolution = param.distl_highres_limit
    print "Limiting resolution",limiting_resolution

    #predict the spots
    spots = ai.predict_all(image_centers[0],limiting_resolution)
    pre2m = spots.vec3()
    self.pre2m = pre2m

    hkllist = spots.hkl()
    cell = ai.getOrientation().unit_cell()
    print cell
    for hkl in hkllist:
      #print "%25s %5.2f"%(str(hkl),cell.d(hkl))
      assert cell.d(hkl)>=limiting_resolution
    print "Number of hkls:",(hkllist).size(),
    print "all inside the %4.2f Angstrom limiting sphere."%limiting_resolution
    print "The unit cell is",cell
    self.solution_setting_ai = ai
    self.solution_pd = inputpd
    self.image_centers = image_centers
    self.one_setting = setting
    return [ai.getOrientation().unit_cell(),hkllist]

  def parameters(self):
    image_centers = [(math.pi/180.)*float(x) for x in self.solution_pd["osc_start"].values()]
    P = dict( image_center_radians = image_centers,
              wavelength = float(self.solution_pd['wavelength']),
              deltaphi = float(self.solution_pd['deltaphi']),
              mosaicity_degrees = self.solution_setting_ai.getMosaicity(),
              orientation = self.solution_setting_ai.getOrientation(),
              )
    return P
Example #7
0
class new_horizons_state:
    def __init__(self, horizons_phil, args):
        self.last_saved_best = None
        self.horizons_phil = horizons_phil
        if self.horizons_phil.spotfinder == "distl":
            print "Importing DISTL"
            from labelit.command_line.stats_index import AutoIndexOrganizer
        elif self.horizons_phil.spotfinder == "speck":
            print "Importing SPECK"
            from rstbx.new_horizons.stats_index import AutoIndexOrganizer

        self.organizer = AutoIndexOrganizer(
            verbose=self.horizons_phil.distl.bins.verbose,
            argument_module=args,
            horizons_phil=horizons_phil,
            delegate=self.index_and_integrate)

    def process(self):
        self.organizer.process()
        self.spotfinder_results = self.organizer.S
        self.frames = self.organizer.frames

    def index_and_integrate(self, frames, files, spotfinder_results):
        self.pd = establish_dict_for_refinement(frames, spotfinder_results)
        self.spotfinder_results = spotfinder_results
        self.frames = frames
        #------------------------------------------------------------
        ai, P = index_and_refine(pd=self.pd,
                                 rawframes=files,
                                 spotfinder_results=spotfinder_results,
                                 verbose=False,
                                 horizon_phil=self.horizons_phil)
        self.indexing_ai = ai
        #------------------------------------------------------------
        if self.horizons_phil.compatibility_allow == False:
            M = best_character_to_IndexPrinter(ai, P, self.pd, True,
                                               self.horizons_phil)
        else:
            from labelit.diffraction.compatibility import best_compatibility_to_IndexPrinter
            M = best_compatibility_to_IndexPrinter(ai, P, self.pd, files,
                                                   spotfinder_results)
        #------------------------------------------------------------
        if "writer" in self.horizons_phil.__dict__:
            self.horizons_phil.writer.make_image_plots_detail(
                ai=ai,
                pd=self.pd,
                inframes=files,
                spotfinder_results=spotfinder_results)

        if not self.horizons_phil.index_only:
            if 0:
                from labelit.dps import IntegrateCharacters
                IC = IntegrateCharacters(M, self.pd)
                IC.write_mosflm_matrices()
                IC.find_best()
                IC.show()
            if 1:
                from rstbx.new_horizons.oscillation_shots import IntegrateCharacters
                IC = IntegrateCharacters(M, self.pd, self.horizons_phil, files,
                                         spotfinder_results)
                IC.find_best()
                self.last_saved_best = IC.save_best()
                IC.show()
        # Lattice character information added for special UCSF/ LLNL project (5/2014):
        self.pd["lattice_characters"] = M.best()
        for item in self.pd["lattice_characters"]:
            del item["minimizer"]
        return self.pd
Example #8
0
class new_horizons_state:
  def __init__(self,horizons_phil,args):
    self.last_saved_best = None
    self.horizons_phil = horizons_phil
    if self.horizons_phil.spotfinder=="distl":
      print "Importing DISTL"
      from labelit.command_line.stats_index import AutoIndexOrganizer
    elif self.horizons_phil.spotfinder=="speck":
      print "Importing SPECK"
      from rstbx.new_horizons.stats_index import AutoIndexOrganizer

    self.organizer = AutoIndexOrganizer(
      verbose = self.horizons_phil.distl.bins.verbose,
      argument_module = args,
      horizons_phil = horizons_phil,
      delegate = self.index_and_integrate)
  def process(self):
    self.organizer.process()
    self.spotfinder_results = self.organizer.S
    self.frames = self.organizer.frames

  def index_and_integrate(self,frames,files,spotfinder_results):
    self.pd = establish_dict_for_refinement(frames,spotfinder_results)
    self.spotfinder_results = spotfinder_results
    self.frames = frames
    #------------------------------------------------------------
    ai,P = index_and_refine(pd = self.pd,
                            rawframes = files,
                            spotfinder_results = spotfinder_results,
                            verbose = False,
                            horizon_phil = self.horizons_phil)
    self.indexing_ai = ai
    #------------------------------------------------------------
    if self.horizons_phil.compatibility_allow==False:
      M = best_character_to_IndexPrinter(ai,P,self.pd,True,self.horizons_phil)
    else:
      from labelit.diffraction.compatibility import best_compatibility_to_IndexPrinter
      M = best_compatibility_to_IndexPrinter(ai,P,self.pd,files,
          spotfinder_results)
    #------------------------------------------------------------
    if self.horizons_phil.__dict__.has_key("writer"):
      self.horizons_phil.writer.make_image_plots_detail(
        ai=ai,pd=self.pd,inframes=files,spotfinder_results=spotfinder_results)

    if not self.horizons_phil.index_only:
     if 0:
      from labelit.dps import IntegrateCharacters
      IC = IntegrateCharacters(M,self.pd)
      IC.write_mosflm_matrices()
      IC.find_best()
      IC.show()
     if 1:
      from rstbx.new_horizons.oscillation_shots import IntegrateCharacters
      IC = IntegrateCharacters(M,self.pd,self.horizons_phil,files,
        spotfinder_results)
      IC.find_best()
      self.last_saved_best = IC.save_best()
      IC.show()
    # Lattice character information added for special UCSF/ LLNL project (5/2014):
    self.pd["lattice_characters"]=M.best()
    for item in self.pd["lattice_characters"]: del item["minimizer"]
    return self.pd