def integrate_one_image(data, **kwargs): from xfel.cxi.display_spots import run_one_index_core from labelit.dptbx.error import NoAutoIndex from libtbx.utils import Sorry from spotfinder.exception import SpotfinderError from labelit.exception import AutoIndexError from iotbx.detectors.cspad_detector_formats import detector_format_version as detector_format_function from iotbx.detectors.cspad_detector_formats import reverse_timestamp basename = kwargs.get("integration_basename") if (basename is None): basename = "" dirname = kwargs.get("integration_dirname") if (dirname is None): dirname = "integration" if (not os.path.isdir(dirname)): import errno try: os.makedirs(dirname) except OSError as exc: if exc.errno==errno.EEXIST: pass path = os.path.join(dirname, basename \ + data['TIMESTAMP'] \ + ("_%05d.pickle" % data['SEQUENCE_NUMBER'])) args = ["indexing.data=dummy", "beam_search_scope=0.5", "lepage_max_delta = 3.0", "spots_pickle = None", "subgroups_pickle = None", "refinements_pickle = None", "rmsd_tolerance = 5.0", "mosflm_rmsd_tolerance = 5.0", "indexing.completeness_pickle=%s"%path, "difflimit_sigma_cutoff=2.0", #"indexing.open_wx_viewer=True" ] detector_format_version = detector_format_function( data['DETECTOR_ADDRESS'], reverse_timestamp(data['TIMESTAMP'])[0]) args += ["distl.detector_format_version=%s" % detector_format_version] from xfel.phil_preferences import load_cxi_phil horizons_phil = load_cxi_phil(data["xtal_target"], args) horizons_phil.indexing.data = data print "XFEL processing: %s"%path try: return run_one_index_core(horizons_phil) except NoAutoIndex,e: print "NoAutoIndex", data['TIMESTAMP'], e info = e.info
called by easy_run.fully_buffered, protecting the calling program from boost errors. ''' import sys from xfel.phil_preferences import load_cxi_phil from xfel.cxi.display_spots import run_one_index_core from libtbx import easy_pickle if __name__ == "__main__": # should be invoked like this: "iota.bulletproof tmppath target args" tmppath = sys.argv[1] target = sys.argv[2] args = sys.argv[3:] try: # index the image horizons_phil = load_cxi_phil(target, args) info = run_one_index_core(horizons_phil) # save specific results from the info object to be used by iota int_final = info.last_saved_best easy_pickle.dump(tmppath, int_final) except Exception, e: if hasattr(e, "classname"): error_message = "{}: {}".format(e.classname, e[0].replace('\n',' ')[:50]) else: error_message = "{}".format(str(e).replace('\n', ' ')[:50]) # save the error message to be picked up by iota easy_pickle.dump(tmppath, error_message)
lines = [] linenum = 1 for line in f: if ((line.strip() != "") and (line[0] != '.')): if ((framenum == -1) or (framenum == linenum)): lines.append(line) linenum = linenum + 1 f.close() from spotfinder.applications.xfel import cxi_phil horizons_phil = cxi_phil.cxi_versioned_extract(args) print "indexing..." t0 = clock() # indexing can be slow. would be good to save indexing info and read it back in results = run_one_index_core(horizons_phil) tel = clock() - t0 print "done indexing (", tel, " sec)" latsize = latxdim * latydim * latzdim print "Lattice size = ", latsize lat = np.zeros(latsize, dtype=np.float32) ct = np.zeros(latsize, dtype=np.float32) #name_of_interest = results.organizer.Files.filenames.FN[0] AI = results.indexing_ai i0 = latxdim / 2 - 1 j0 = latydim / 2 - 1 k0 = latzdim / 2 - 1 mask_tag = 32767
# read input file with list of diffraction images and scale factors f = open(ifname,"r") lines = [] for line in f: if ((line.strip()!="") and (line[0] != '.')): lines.append(line) f.close() from spotfinder.applications.xfel import cxi_phil horizons_phil = cxi_phil.cxi_versioned_extract(args) print "indexing..." t0 = clock() # indexing can be slow. would be good to save indexing info and read it back in results = run_one_index_core(horizons_phil) tel = clock()-t0 print "done indexing (",tel," sec)" latsize = latxdim*latydim*latzdim lat = np.zeros(latsize, dtype=np.float32) ct = np.zeros(latsize, dtype=np.float32) #name_of_interest = results.organizer.Files.filenames.FN[0] AI = results.indexing_ai i0=latxdim/2-1 j0=latydim/2-1 k0=latzdim/2-1 mask_tag = 32767 # fileidx = 0
called by easy_run.fully_buffered, protecting the calling program from boost errors. ''' import sys from xfel.phil_preferences import load_cxi_phil from xfel.cxi.display_spots import run_one_index_core from libtbx import easy_pickle if __name__ == "__main__": # should be invoked like this: "iota.bulletproof tmppath target args" tmppath = sys.argv[1] target = sys.argv[2] args = sys.argv[3:] try: # index the image horizons_phil = load_cxi_phil(target, args) info = run_one_index_core(horizons_phil) # save specific results from the info object to be used by iota int_final = info.last_saved_best easy_pickle.dump(tmppath, int_final) except Exception, e: if hasattr(e, "classname"): error_message = "{}: {}".format(e.classname, e[0].replace('\n', ' ')[:50]) else: error_message = "{}".format(str(e).replace('\n', ' ')[:50]) # save the error message to be picked up by iota easy_pickle.dump(tmppath, error_message)