def read_frames(self):
        from xfel.cxi.util import is_odd_numbered

        cursor = self._db.cursor()
        cursor.execute("""SELECT
    frame_id_1_base,wavelength,c_c,slope,offset,res_ori_1,res_ori_2,res_ori_3,
    res_ori_4,res_ori_5,res_ori_6,res_ori_7,res_ori_8,res_ori_9,
    unique_file_name
    FROM _frame""")
        ALL = cursor.fetchall()
        from cctbx.crystal_orientation import crystal_orientation
        orientations = [
            crystal_orientation(
                (a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13]),
                False) for a in ALL
        ]
        return dict(frame_id=flex.int([a[0] - 1 for a in ALL]),
                    wavelength=flex.double([a[1] for a in ALL]),
                    cc=flex.double([a[2] for a in ALL]),
                    slope=flex.double([a[3] for a in ALL]),
                    offset=flex.double([a[4] for a in ALL]),
                    odd_numbered=flex.bool(
                        [is_odd_numbered(a[14]) for a in ALL]),
                    orientation=orientations,
                    unit_cell=[CO.unit_cell() for CO in orientations],
                    unique_file_name=[a[14] for a in ALL])
  def read_frames_updated_detail(self):
    from cctbx.crystal_orientation import crystal_orientation
    from xfel.cxi.util import is_odd_numbered

    frames = {'frame_id': flex.int(),
              'wavelength': flex.double(),
              'cc': flex.double(),
              'G': flex.double(),
              'BFACTOR': flex.double(),
              'RS': flex.double(),
              'odd_numbered': flex.bool(),
              'thetax': flex.double(),
              'thetay': flex.double(),
              'orientation': [],
              'unit_cell': [],
              'unique_file_name': []}
    stream = open(self.params.output.prefix + '_frame.db', 'r')
    for row in stream:
      items = row.split()
      CO = crystal_orientation([float(t) for t in items[8:17]], True)
      unique_file_name = eval(items[19])
      frames['frame_id'].append(int(items[0]))
      frames['wavelength'].append(float(items[1]))
      frames['cc'].append(float(items[20]))
      frames['G'].append(float(items[5]))
      frames['BFACTOR'].append(float(items[6]))
      frames['RS'].append(float(items[7]))
      frames['thetax'].append(float(items[17]))
      frames['thetay'].append(float(items[18]))
      frames['odd_numbered'].append(is_odd_numbered(unique_file_name))
      frames['orientation'].append(CO)
      frames['unit_cell'].append(CO.unit_cell())
      frames['unique_file_name'].append(unique_file_name)
    stream.close()
    return frames
    def read_frames_legacy_detail(self):
        from cctbx.crystal_orientation import crystal_orientation
        from xfel.cxi.util import is_odd_numbered

        # XXX issues with spaces in the file name, and leading and
        # trailing single quotes (stripped below).

        frames = {
            'frame_id': flex.int(),
            'wavelength': flex.double(),
            'cc': flex.double(),
            'slope': flex.double(),
            'offset': flex.double(),
            'odd_numbered': flex.bool(),
            'domain_size_ang': flex.double(),
            'half_mosaicity_deg': flex.double(),
            'orientation': [],
            'unit_cell': [],
            'unique_file_name': []
        }
        stream = open(self.params.output.prefix + '_frame.db', 'r')
        for row in stream:
            items = row.split()
            CO = crystal_orientation([float(t) for t in items[8:17]], False)
            unique_file_name = eval(items[24])
            frames['frame_id'].append(int(items[0]))
            frames['wavelength'].append(float(items[1]))
            frames['cc'].append(float(items[5]))
            frames['slope'].append(float(items[6]))
            frames['offset'].append(float(items[7]))
            frames['domain_size_ang'].append(float(items[23]))
            frames['half_mosaicity_deg'].append(float(items[20]))
            frames['odd_numbered'].append(
                is_odd_numbered(unique_file_name,
                                use_hash=self.params.hash_filenames))
            frames['orientation'].append(CO)
            frames['unit_cell'].append(CO.unit_cell())
            frames['unique_file_name'].append(unique_file_name)
        stream.close()
        return frames
 def read_frames(self):
   from xfel.cxi.util import is_odd_numbered
   db = self.connection()
   cursor = db.cursor()
   cursor.execute("""SELECT
   frame_id_1_base,wavelength,c_c,slope,offset,res_ori_1,res_ori_2,res_ori_3,
   res_ori_4,res_ori_5,res_ori_6,res_ori_7,res_ori_8,res_ori_9,
   unique_file_name
   FROM `%s_frame`"""%self.params.mysql.runtag)
   ALL = cursor.fetchall()
   from cctbx.crystal_orientation import crystal_orientation
   orientations = [crystal_orientation(
    (a[5],a[6],a[7],a[8],a[9],a[10],a[11],a[12],a[13]),False) for a in ALL]
   return dict( frame_id = flex.int( [a[0]-1 for a in ALL] ),
              wavelength = flex.double( [a[1] for a in ALL] ),
                      cc = flex.double( [a[2] for a in ALL] ),
                   slope = flex.double( [a[3] for a in ALL] ),
                  offset = flex.double( [a[4] for a in ALL] ),
            odd_numbered = flex.bool( [is_odd_numbered(a[14]) for a in ALL] ),
             orientation = orientations,
               unit_cell = [CO.unit_cell() for CO in orientations],
        unique_file_name = [a[14] for a in ALL] )
    def read_frames_updated_detail(self):
        from cctbx.crystal_orientation import crystal_orientation
        from xfel.cxi.util import is_odd_numbered

        frames = {
            'frame_id': flex.int(),
            'wavelength': flex.double(),
            'cc': flex.double(),
            'G': flex.double(),
            'BFACTOR': flex.double(),
            'RS': flex.double(),
            'odd_numbered': flex.bool(),
            'thetax': flex.double(),
            'thetay': flex.double(),
            'orientation': [],
            'unit_cell': [],
            'unique_file_name': []
        }
        stream = open(self.params.output.prefix + '_frame.db', 'r')
        for row in stream:
            items = row.split()
            CO = crystal_orientation([float(t) for t in items[8:17]], True)
            unique_file_name = eval(items[19])
            frames['frame_id'].append(int(items[0]))
            frames['wavelength'].append(float(items[1]))
            frames['cc'].append(float(items[20]))
            frames['G'].append(float(items[5]))
            frames['BFACTOR'].append(float(items[6]))
            frames['RS'].append(float(items[7]))
            frames['thetax'].append(float(items[17]))
            frames['thetay'].append(float(items[18]))
            frames['odd_numbered'].append(
                is_odd_numbered(unique_file_name,
                                use_hash=self.params.hash_filenames))
            frames['orientation'].append(CO)
            frames['unit_cell'].append(CO.unit_cell())
            frames['unique_file_name'].append(unique_file_name)
        stream.close()
        return frames
  def read_frames_legacy_detail(self):
    from cctbx.crystal_orientation import crystal_orientation
    from xfel.cxi.util import is_odd_numbered

    # XXX issues with spaces in the file name, and leading and
    # trailing single quotes (stripped below).

    frames = {'frame_id': flex.int(),
              'wavelength': flex.double(),
              'cc': flex.double(),
              'slope': flex.double(),
              'offset': flex.double(),
              'odd_numbered': flex.bool(),
              'domain_size_ang': flex.double(),
              'half_mosaicity_deg': flex.double(),
              'orientation': [],
              'unit_cell': [],
              'unique_file_name': []}
    stream = open(self.params.output.prefix + '_frame.db', 'r')
    for row in stream:
      items = row.split()
      CO = crystal_orientation([float(t) for t in items[8:17]], False)
      unique_file_name = eval(items[24])
      frames['frame_id'].append(int(items[0]))
      frames['wavelength'].append(float(items[1]))
      frames['cc'].append(float(items[5]))
      frames['slope'].append(float(items[6]))
      frames['offset'].append(float(items[7]))
      frames['domain_size_ang'].append(float(items[23]))
      frames['half_mosaicity_deg'].append(float(items[20]))
      frames['odd_numbered'].append(is_odd_numbered(unique_file_name))
      frames['orientation'].append(CO)
      frames['unit_cell'].append(CO.unit_cell())
      frames['unique_file_name'].append(unique_file_name)
    stream.close()
    return frames
Exemple #7
0
  def read_all(self):
    # XXX Should not be used any more--migrate C++ into
    # cxi/merging_database_fs.py?
    print "reading observations from flat-file database"
    self.frames = dict( frame_id=flex.int(),
                        wavelength=flex.double(),
                        cc=flex.double(),
                        slope=flex.double(),
                        offset=flex.double(),
                        odd_numbered=flex.bool(),
                        orientation=[],
                        unit_cell=[])
    self.millers = dict(merged_asu_hkl=flex.miller_index())
    G = open(self.params.output.prefix+"_miller.db","r")
    for line in G.xreadlines():
      tokens = line.strip().split()
      self.millers["merged_asu_hkl"].append((int(tokens[1]),int(tokens[2]),int(tokens[3])))

# --- start C++ read
    parser = column_parser()
    parser.set_int("hkl_id",0)
    parser.set_double("i",1)
    parser.set_double("sigi",2)
    parser.set_int("frame_id",5)
    parser.set_int("H",7)
    parser.set_int("K",8)
    parser.set_int("L",9)

    G = open(self.params.output.prefix+"_observation.db","r")
    for line in G.xreadlines():
      parser.parse_from_line(line)
    self.observations = dict(hkl_id=parser.get_int("hkl_id"),
                             i=parser.get_double("i"),
                             sigi=parser.get_double("sigi"),
                             frame_id=parser.get_int("frame_id"),
                             H=parser.get_int("H"),
                             K=parser.get_int("K"),
                             L=parser.get_int("L"),
                             )
    self._observations = parser
    G.close()
# --- done with C++ read

    G = open(self.params.output.prefix+"_frame.db","r")
    for line in G.xreadlines():
      tokens = line.strip().split()
      self.frames["frame_id"].append(int(tokens[0]))
      self.frames["wavelength"].append(float(tokens[1]))
      self.frames["cc"].append(float(tokens[5]))
      self.frames["slope"].append(float(tokens[6]))
      self.frames["offset"].append(float(tokens[7]))
      self.frames["odd_numbered"].append( is_odd_numbered(tokens[17]) )
      # components of orientation direct matrix
      odm = (float(tokens[8]), float(tokens[9]), float(tokens[10]),
             float(tokens[11]), float(tokens[12]), float(tokens[13]),
             float(tokens[14]), float(tokens[15]), float(tokens[16]),)
      CO = crystal_orientation(odm, False)
      self.frames["orientation"].append(CO)
      self.frames["unit_cell"].append(CO.unit_cell())
    G.close()
    parser = column_parser()
    parser.set_int("frame_id",0)
    parser.set_double("wavelength",1)
    parser.set_double("cc",5)
    parser.set_double("slope",6)
    parser.set_double("offset",7)
    G = open(self.params.output.prefix+"_frame.db","r")
    for line in G.xreadlines():
      parser.parse_from_line(line)
    self._frames = parser