def distribute_reflections_over_hkl_chunks(self, reflections):
        '''Distribute reflections, according to their HKLs, over pre-set HKL chunks'''
        total_reflection_count = reflections.size()
        total_distributed_reflection_count = 0

        if total_reflection_count > 0:
            # set up two lists to be passed to the C++ extension: HKLs and chunk ids. It's basically a hash table to look up chunk ids by HKLs
            hkl_list = flex.miller_index()
            chunk_id_list = flex.int()

            for i in range(len(self.hkl_split_set)):
                for j in range(len(self.hkl_split_set[i])):
                    hkl = (int(self.hkl_split_set[i][j][0]),
                           int(self.hkl_split_set[i][j][1]),
                           int(self.hkl_split_set[i][j][2]))
                    hkl_list.append(hkl)
                    chunk_id_list.append(i)

            # distribute reflections over hkl chunks, using a C++ extension
            from xfel.merging import get_hkl_chunks_cpp
            get_hkl_chunks_cpp(reflections, hkl_list, chunk_id_list,
                               self.hkl_chunks)
            for chunk in self.hkl_chunks:
                total_distributed_reflection_count += len(chunk)

        self.logger.log(
            "Distributed %d out of %d reflections" %
            (total_distributed_reflection_count, total_reflection_count))
        self.logger.log("Memory usage: %d MB" % get_memory_usage())

        reflections.clear()
Esempio n. 2
0
  def distribute_reflections_over_hkl_chunks(self, reflections):

    total_reflection_count = reflections.size()
    total_distributed_reflection_count = 0

    if total_reflection_count > 0:

      # set up two lists to be passed to the C++ extension: hkl's and chunk ids. It's basically a hash table to look up chunk ids by hkl's
      hkl_list = flex.miller_index()
      chunk_id_list = flex.int()

      for i in range(len(self.hkl_split_set)):
        for j in range(len(self.hkl_split_set[i])):
          hkl = (self.hkl_split_set[i][j][0], self.hkl_split_set[i][j][1], self.hkl_split_set[i][j][2])
          hkl_list.append(hkl)
          chunk_id_list.append(i)

      # distribute reflections over hkl chunks
      from xfel.merging import get_hkl_chunks_cpp
      get_hkl_chunks_cpp(reflections, hkl_list, chunk_id_list, self.hkl_chunks)

      for i in range(len(self.hkl_chunks)):
        total_distributed_reflection_count += len(self.hkl_chunks[i])

    self.mpi_log_write("\nRank %d managed to distribute %d out of %d reflections"%(self.rank, total_distributed_reflection_count, total_reflection_count))
    self.mpi_log_write("\nRANK %d: %s"%(self.rank, get_memory_usage()))

    reflections.clear()