Beispiel #1
0
  def summary(self, block_size, block_size_units):
    ''' Print a summary of the integration stuff. '''
    from libtbx.table_utils import format as table
    from dials.util.command_line import heading
    from logging import info

    # Compute the task table
    if self._experiments.all_stills():
      rows = [["#", "Group", "Frame From", "Frame To"]]
      for i in range(len(self)):
        job = self._manager.job(i)
        group = job.index()
        f0, f1 = job.frames()
        rows.append([str(i), str(group), str(f0), str(f1)])
    elif self._experiments.all_sweeps():
      rows = [["#", "Group", "Frame From", "Frame To", "Angle From", "Angle To"]]
      for i in range(len(self)):
        job = self._manager.job(i)
        group = job.index()
        expr = job.expr()
        f0, f1 = job.frames()
        scan = self._experiments[expr[0]].scan
        p0 = scan.get_angle_from_array_index(f0)
        p1 = scan.get_angle_from_array_index(f1)
        rows.append([str(i), str(group), str(f0), str(f1), str(p0), str(p1)])
    else:
      raise RuntimeError('Experiments must be all sweeps or all stills')
    task_table = table(rows, has_header=True, justify="right", prefix=" ")
Beispiel #2
0
  def summary(self):
    '''
    Get a summary of the processing

    '''
    from libtbx.table_utils import format as table

    # Compute the task table
    if self.experiments.all_stills():
      rows = [["#",
               "Group",
               "Frame From",
               "Frame To",
               "# Reflections"]]
      for i in range(len(self)):
        job = self.manager.job(i)
        group = job.index()
        f0, f1 = job.frames()
        n = self.manager.num_reflections(i)
        rows.append([str(i), str(group), str(f0), str(f1), str(n)])
    elif self.experiments.all_sweeps():
      rows = [["#",
               "Group",
               "Frame From",
               "Frame To",
               "Angle From",
               "Angle To",
               "# Reflections"]]
      for i in range(len(self)):
        job = self.manager.job(i)
        group = job.index()
        expr = job.expr()
        f0, f1 = job.frames()
        scan = self.experiments[expr[0]].scan
        p0 = scan.get_angle_from_array_index(f0)
        p1 = scan.get_angle_from_array_index(f1)
        n = self.manager.num_reflections(i)
        rows.append([str(i), str(group), str(f0), str(f1), str(p0), str(p1), str(n)])
    else:
      raise RuntimeError('Experiments must be all sweeps or all stills')

    # The job table
    task_table = table(rows, has_header=True, justify="right", prefix=" ")

    # The format string
    if self.params.block.size is None:
      block_size = "auto"
    else:
      block_size = str(self.params.block.size)
    fmt = (
      'Processing reflections in the following blocks of images:\n'
      '\n'
      ' block_size: %s %s\n'
      '\n'
      '%s\n'
    )
    return fmt % (block_size, self.params.block.units, task_table)
Beispiel #3
0
 def __str__(self):
   ''' Convert to string. '''
   from libtbx.table_utils import format as table
   rows = [
     ["Read time"        , "%.2f seconds" % (self.read)       ],
     ["Pre-process time" , "%.2f seconds" % (self.initialize) ],
     ["Process time"     , "%.2f seconds" % (self.process)    ],
     ["Post-process time", "%.2f seconds" % (self.finalize)   ],
     ["Total time"       , "%.2f seconds" % (self.total)      ],
     ["User time"        , "%.2f seconds" % (self.user)       ],
   ]
   return table(rows, justify='right', prefix=' ')
Beispiel #4
0
 def __str__(self):
   ''' Convert to string. '''
   from libtbx.table_utils import format as table
   rows = [
     ["Read time"        , "%.2f seconds" % (self.read)       ],
     ["Pre-process time" , "%.2f seconds" % (self.initialize) ],
     ["Process time"     , "%.2f seconds" % (self.process)    ],
     ["Post-process time", "%.2f seconds" % (self.finalize)   ],
     ["Total time"       , "%.2f seconds" % (self.total)      ],
     ["User time"        , "%.2f seconds" % (self.user)       ],
   ]
   return table(rows, justify='right', prefix=' ')
    def __str__(self):
        """ Convert to string. """
        from libtbx.table_utils import format as table

        rows = [
            ["Read time", "%.2f seconds" % (self.read)],
            ["Extract time", "%.2f seconds" % (self.extract)],
            ["Pre-process time",
             "%.2f seconds" % (self.initialize)],
            ["Process time", "%.2f seconds" % (self.process)],
            ["Post-process time",
             "%.2f seconds" % (self.finalize)],
            ["Total time", "%.2f seconds" % (self.total)],
            ["User time", "%.2f seconds" % (self.user)],
        ]
        return table(rows, justify="right", prefix=" ")
Beispiel #6
0
    def as_str(self, prefix=''):
        '''
    Return the table as a string

    :return: The string

    '''
        from libtbx.table_utils import format as table
        rows = [[col[1] for col in self.cols]]
        for i, row in enumerate(self.rows):
            rows.append([str(x) for x in row])
        text = [
            prefix + self.title,
            table(rows, has_header=True, justify='left', prefix=prefix), ''
        ]
        return '\n'.join(text)
Beispiel #7
0
  def as_str(self, prefix=''):
    '''
    Return the table as a string

    :return: The string

    '''
    from libtbx.table_utils import format as table
    rows = [[col[1] for col in self.cols]]
    for i in range(len(self.rows)):
      rows.append([str(x) for x in self.rows[i]])
    text = [
      prefix + self.title,
      table(rows, has_header=True, justify='left', prefix=prefix),
      ''
    ]
    return '\n'.join(text)
Beispiel #8
0
    def as_str(self, prefix=""):
        """
        Return the table as a string

        :return: The string
        """
        from libtbx.table_utils import format as table

        rows = [[col[1] for col in self.cols]]
        for i, row in enumerate(self.rows):
            rows.append([str(x) for x in row])
        text = [
            prefix + self.title,
            table(rows, has_header=True, justify="left", prefix=prefix),
            "",
        ]
        return "\n".join(text)
Beispiel #9
0
    def summary(self, block_size, block_size_units):
        ''' Print a summary of the integration stuff. '''
        from libtbx.table_utils import format as table
        from dials.util.command_line import heading

        # Compute the task table
        if self._experiments.all_stills():
            rows = [["#", "Group", "Frame From", "Frame To"]]
            for i in range(len(self)):
                job = self._manager.job(i)
                group = job.index()
                f0, f1 = job.frames()
                rows.append([str(i), str(group), str(f0), str(f1)])
        elif self._experiments.all_sweeps():
            rows = [[
                "#", "Group", "Frame From", "Frame To", "Angle From",
                "Angle To"
            ]]
            for i in range(len(self)):
                job = self._manager.job(i)
                group = job.index()
                expr = job.expr()
                f0, f1 = job.frames()
                scan = self._experiments[expr[0]].scan
                p0 = scan.get_angle_from_array_index(f0)
                p1 = scan.get_angle_from_array_index(f1)
                rows.append(
                    [str(i),
                     str(group),
                     str(f0),
                     str(f1),
                     str(p0),
                     str(p1)])
        else:
            raise RuntimeError('Experiments must be all sweeps or all stills')
        task_table = table(rows, has_header=True, justify="right", prefix=" ")
Beispiel #10
0
  def run(self):
    '''Execute the script.'''
    from dials.util.options import flatten_datablocks
    from time import time
    from dials.util import log
    from libtbx.utils import Sorry
    import datetime
    start_time = time()

    # Parse the command line
    params, options = self.parser.parse_args(show_diff_phil=False)

    # Configure the logging
    log.config(
      params.verbosity,
      info=params.output.log,
      debug=params.output.debug_log)

    from dials.util.version import dials_version
    logger.info(dials_version())

    # Log the diff phil
    diff_phil = self.parser.diff_phil.as_str()
    if diff_phil is not '':
      logger.info('The following parameters have been modified:\n')
      logger.info(diff_phil)

    # Ensure we have a data block
    datablocks = flatten_datablocks(params.input.datablock)
    if len(datablocks) == 0:
      self.parser.print_help()
      return

    # Extend the first datablock
    datablock = datablocks[0]
    for db in datablocks[1:]:
      if datablock.format_class() != db.format_class():
        raise Sorry("Datablocks must have the same format")
      datablock.extend(db)

    # Get the imagesets and sweeps
    stills = datablock.extract_stills()
    sweeps = datablock.extract_sweeps()
    if len(stills) > 0:
      raise Sorry("Sets of still images are currently unsupported")
    logger.info("Number of sweeps = %d" % len(sweeps))

    # Sort the sweeps by timestamps
    logger.info("Sorting sweeps based on timestamp")
    sweeps = sorted(sweeps, key=lambda x: x.get_scan().get_epochs()[0])

    # Count the number of datasets from each day
    from collections import Counter
    counter = Counter()
    for s in sweeps:
      timestamp = s.get_scan().get_epochs()[0]
      timestamp = datetime.datetime.fromtimestamp(timestamp)
      timestamp = timestamp.strftime('%Y-%m-%d')
      counter[timestamp] += 1

    # Print the number of datasets on each day
    for timestamp in sorted(counter.keys()):
      logger.info("%d datasets collected on %s" % (counter[timestamp], timestamp))

    # Loop though and see if any models might be shared
    b_list = [ s.get_beam() for s in sweeps ]
    d_list = [ s.get_detector() for s in sweeps ]
    g_list = [ s.get_goniometer() for s in sweeps ]
    b_index = []
    d_index = []
    g_index = []
    for i in range(len(sweeps)):
      b = b_list[i]
      d = d_list[i]
      g = g_list[i]
      bn = i
      dn = i
      gn = i
      if i > 0:
        bj = b_index[-1]
        dj = d_index[-1]
        gj = g_index[-1]
        if b.is_similar_to(b_list[bj]):
          bn = bj
        if d.is_similar_to(d_list[dj]):
          dn = dj
        if g.is_similar_to(g_list[gj]):
          gn = gj
      b_index.append(bn)
      d_index.append(dn)
      g_index.append(gn)

    # Print a table of possibly shared models
    from libtbx.table_utils import format as table
    rows = [["Sweep", "ID", "Beam", "Detector", "Goniometer", "Date", "Time"]]
    for i in range(len(sweeps)):
      timestamp = sweeps[i].get_scan().get_epochs()[0]
      timestamp = datetime.datetime.fromtimestamp(timestamp)
      date_str = timestamp.strftime('%Y-%m-%d')
      time_str = timestamp.strftime('%H:%M:%S')
      row = [
        '%s' % sweeps[i].get_template(),
        '%s' % i,
        '%s' % b_index[i],
        '%s' % d_index[i],
        '%s' % g_index[i],
        '%s' % date_str,
        '%s' % time_str]
      rows.append(row)
    logger.info(table(rows, has_header=True, justify='left', prefix=' '))

    # Print the time
    logger.info("Time Taken: %f" % (time() - start_time))
    def run(self):
        """Execute the script."""
        from dials.util.options import flatten_experiments
        from dxtbx.imageset import ImageSequence
        from time import time
        from dials.util import log
        import datetime

        start_time = time()

        # Parse the command line
        params, options = self.parser.parse_args(show_diff_phil=False)

        # Configure the logging
        log.config(verbosity=options.verbose, logfile=params.output.log)

        from dials.util.version import dials_version

        logger.info(dials_version())

        # Log the diff phil
        diff_phil = self.parser.diff_phil.as_str()
        if diff_phil != "":
            logger.info("The following parameters have been modified:\n")
            logger.info(diff_phil)

        # Ensure we have a data block
        experiments = flatten_experiments(params.input.experiments)
        if len(experiments) == 0:
            self.parser.print_help()
            return

        # Get the list of sequences
        sequences = []
        for experiment in experiments:
            if isinstance(experiment.imageset, ImageSequence):
                sequences.append(experiment.imageset)
        logger.info("Number of sequences = %d" % len(sequences))

        # Sort the sequences by timestamps
        logger.info("Sorting sequences based on timestamp")
        sequences = sorted(sequences,
                           key=lambda x: x.get_scan().get_epochs()[0])

        # Count the number of datasets from each day
        from collections import Counter

        counter = Counter()
        for s in sequences:
            timestamp = s.get_scan().get_epochs()[0]
            timestamp = datetime.datetime.fromtimestamp(timestamp)
            timestamp = timestamp.strftime("%Y-%m-%d")
            counter[timestamp] += 1

        # Print the number of datasets on each day
        for timestamp in sorted(counter.keys()):
            logger.info("%d datasets collected on %s" %
                        (counter[timestamp], timestamp))

        # Loop though and see if any models might be shared
        b_list = [s.get_beam() for s in sequences]
        d_list = [s.get_detector() for s in sequences]
        g_list = [s.get_goniometer() for s in sequences]
        b_index = []
        d_index = []
        g_index = []
        for i in range(len(sequences)):
            b = b_list[i]
            d = d_list[i]
            g = g_list[i]
            bn = i
            dn = i
            gn = i
            if i > 0:
                bj = b_index[-1]
                dj = d_index[-1]
                gj = g_index[-1]
                if b.is_similar_to(b_list[bj]):
                    bn = bj
                if d.is_similar_to(d_list[dj]):
                    dn = dj
                if g.is_similar_to(g_list[gj]):
                    gn = gj
            b_index.append(bn)
            d_index.append(dn)
            g_index.append(gn)

        # Print a table of possibly shared models
        from libtbx.table_utils import format as table

        rows = [[
            "Sequence", "ID", "Beam", "Detector", "Goniometer", "Date", "Time"
        ]]
        for i in range(len(sequences)):
            timestamp = sequences[i].get_scan().get_epochs()[0]
            timestamp = datetime.datetime.fromtimestamp(timestamp)
            date_str = timestamp.strftime("%Y-%m-%d")
            time_str = timestamp.strftime("%H:%M:%S")
            row = [
                "%s" % sequences[i].get_template(),
                "%s" % i,
                "%s" % b_index[i],
                "%s" % d_index[i],
                "%s" % g_index[i],
                "%s" % date_str,
                "%s" % time_str,
            ]
            rows.append(row)
        logger.info(table(rows, has_header=True, justify="left", prefix=" "))

        # Print the time
        logger.info("Time Taken: %f" % (time() - start_time))
Beispiel #12
0
  def run(self):
    '''Execute the script.'''
    from dials.array_family import flex
    from dials.util.options import flatten_datablocks
    from time import time
    from dials.util import log
    from libtbx.utils import Sorry
    import datetime
    start_time = time()

    # Parse the command line
    params, options = self.parser.parse_args(show_diff_phil=False)

    # Configure the logging
    log.config(
      params.verbosity,
      info=params.output.log,
      debug=params.output.debug_log)

    from dials.util.version import dials_version
    logger.info(dials_version())

    # Log the diff phil
    diff_phil = self.parser.diff_phil.as_str()
    if diff_phil is not '':
      logger.info('The following parameters have been modified:\n')
      logger.info(diff_phil)

    # Ensure we have a data block
    datablocks = flatten_datablocks(params.input.datablock)
    if len(datablocks) == 0:
      self.parser.print_help()
      return

    # Extend the first datablock
    datablock = datablocks[0]
    for db in datablocks[1:]:
      if datablock.format_class() != db.format_class():
        raise Sorry("Datablocks must have the same format")
      datablock.extend(db)

    # Get the imagesets and sweeps
    stills = datablock.extract_stills()
    sweeps = datablock.extract_sweeps()
    if len(stills) > 0:
      raise Sorry("Sets of still images are currently unsupported")
    logger.info("Number of sweeps = %d" % len(sweeps))

    # Sort the sweeps by timestamps
    logger.info("Sorting sweeps based on timestamp")
    sweeps = sorted(sweeps, key=lambda x: x.get_scan().get_epochs()[0])

    # Count the number of datasets from each day
    from collections import Counter
    counter = Counter()
    for s in sweeps:
      timestamp = s.get_scan().get_epochs()[0]
      timestamp = datetime.datetime.fromtimestamp(timestamp)
      timestamp = timestamp.strftime('%Y-%m-%d')
      counter[timestamp] += 1

    # Print the number of datasets on each day
    for timestamp in sorted(counter.keys()):
      logger.info("%d datasets collected on %s" % (counter[timestamp], timestamp))

    # Loop though and see if any models might be shared
    b_list = [ s.get_beam() for s in sweeps ]
    d_list = [ s.get_detector() for s in sweeps ]
    g_list = [ s.get_goniometer() for s in sweeps ]
    b_index = []
    d_index = []
    g_index = []
    for i in range(len(sweeps)):
      b = b_list[i]
      d = d_list[i]
      g = g_list[i]
      bn = i
      dn = i
      gn = i
      if i > 0:
        bj = b_index[-1]
        dj = d_index[-1]
        gj = g_index[-1]
        if b.is_similar_to(b_list[bj]):
          bn = bj
        if d.is_similar_to(d_list[dj]):
          dn = dj
        if g.is_similar_to(g_list[gj]):
          gn = gj
      b_index.append(bn)
      d_index.append(dn)
      g_index.append(gn)

    # Print a table of possibly shared models
    from libtbx.table_utils import format as table
    rows = [["Sweep", "ID", "Beam", "Detector", "Goniometer", "Date", "Time"]]
    for i in range(len(sweeps)):
      timestamp = sweeps[i].get_scan().get_epochs()[0]
      timestamp = datetime.datetime.fromtimestamp(timestamp)
      date_str = timestamp.strftime('%Y-%m-%d')
      time_str = timestamp.strftime('%H:%M:%S')
      row = [
        '%s' % sweeps[i].get_template(),
        '%s' % i,
        '%s' % b_index[i],
        '%s' % d_index[i],
        '%s' % g_index[i],
        '%s' % date_str,
        '%s' % time_str]
      rows.append(row)
    logger.info(table(rows, has_header=True, justify='left', prefix=' '))

    # Print the time
    logger.info("Time Taken: %f" % (time() - start_time))