Exemple #1
0
def get_items():
    file_list = glob.glob(pickle_glob)
    format_class = None
    for item in file_list:
        #print item
        serial_no = int(item[-16:-11])
        #print serial_no
        image_file = image_glob % serial_no
        #print image_file
        if format_class is None:
            format_class = Registry.find(image_file)
        i = format_class(image_file)
        Z = i.get_smv_header(image_file)
        ABC = Z[1]["DIRECT_SPACE_ABC"]
        abc = tuple([float(a) for a in ABC.split(",")])
        G = generate_data_from_streams([item])
        stills_process = next(G)
        yield (dict(serial_no=serial_no,
                    ABC=abc,
                    stills_process=stills_process))
Exemple #2
0
  def from_files(cls,
                 raw_input=None,
                 pickle_list=[],
                 dials_refls=[],
                 dials_expts=[],
                 _prefix='cluster_from_file',
                 _message='Made from list of individual files',
                 n_images=None,
                 dials=False,
                 json=False,
                 **kwargs):
    """Constructor to get a cluster from a list of individual files.
    :param pickle_list: list of pickle files
    :param dials_refls: list of DIALS integrated reflections
    :param dials_expts: list of DIALS experiment jsons
    :param n_images: find at most this number of images
    :param dials: use the dials_refls and dials_expts arguments to construct the clusters (default: False)
    :param use_b: Boolean. If True, intialise Scale and B. If False, use only
    mean intensity scalling.
    """

    data = []

    def sort_dials_raw_input(raw):
      expts = []
      refls = []
      for path in raw:
        if path.endswith(".pickle"):
          refls.append(path)
        elif path.endswith(".json"):
          expts.append(path)
      return (refls, expts)

    def done():
      if n_images is None:
        return False
      return len(data) >= n_images

    if dials:
      if raw_input is not None:
        r, e = sort_dials_raw_input(raw_input)
        dials_refls.extend(r)
        dials_expts.extend(e)
      for r, e in zip(dials_refls, dials_expts):
        this_frame = SingleDialsFrameFromFiles(refls_path=r, expts_path=e, **kwargs)
        if hasattr(this_frame, 'miller_array'):
          data.append(this_frame)
          if done():
            break
        else:
          logger.info('skipping reflections {} and experiments {}'.format(r, e))
    elif json:
      if raw_input is not None:
        r, e = sort_dials_raw_input(raw_input)
        dials_expts.extend(e)
      dials_expts_ids = [os.path.join(os.path.dirname(e), os.path.basename(e).split("_")[0])
                         for e in dials_expts]
      for e in dials_expts:
        name = os.path.join(os.path.dirname(e), os.path.basename(e).split("_")[0])
        this_frame = SingleDialsFrameFromJson(expts_path=e,  **kwargs)
        this_frame.name=name
        data.append(this_frame)
        if done():
            break
    else:
      if raw_input is not None:
        pickle_list.extend(raw_input)
      print "There are %d input files"%(len(pickle_list))
      from xfel.command_line.print_pickle import generate_data_from_streams
      for data_dict in generate_data_from_streams(pickle_list):
        this_frame = SingleFrame(dicti=data_dict, **kwargs)
        if hasattr(this_frame, 'miller_array'):
          data.append(this_frame)
          if done():
            break
        else:
          logger.info('skipping file {}'.format(os.path.basename(path)))
      print "%d lattices will be analyzed"%(len(data))

    return cls(data, _prefix, _message)
Exemple #3
0
from __future__ import division
import sys
"""Simply convert integration pickles to a text file with unit cell and
space group symbol"""
from xfel.command_line.print_pickle import generate_data_from_streams
if __name__ == "__main__":
    args = sys.argv[1:]

    for data in generate_data_from_streams(args, verbose=False):

        obs = data["observations"][0]

        unit_cell = obs.unit_cell()
        params = unit_cell.parameters()
        for p in params:
            print p,

        space_group = obs.space_group_info().type().lookup_symbol()
        print "".join(space_group.split())