예제 #1
0
    def get_maxima(self, threshold = 5.0):
      '''Run diffdump, printpeaks to get a list of diffraction maxima
      at their image positions, to allow for further analysis.'''

      if not self._image:
        raise RuntimeError, 'image not set'

      if not os.path.exists(self._image):
        raise RuntimeError, 'image %s does not exist' % \
              self._image

      dd = Diffdump()
      dd.set_image(self._image)
      header = dd.readheader()

      beam = header['raw_beam']
      pixel = header['pixel']

      template, directory = image2template_directory(self._image)
      image_number = image2image(os.path.split(self._image)[-1])

      spot_file = '%s.spt' % template_number2image(
          template, image_number)

      self.start()

      self.input('template "%s"' % template)
      self.input('directory "%s"' % directory)
      self.input('findspots local find %d file %s' % \
                 (image_number, spot_file))
      self.input('go')

      self.close_wait()

      self.check_for_errors()

      output = open(os.path.join(self.get_working_directory(),
                                 spot_file)).readlines()

      os.remove(os.path.join(self.get_working_directory(),
                             spot_file))

      peaks = []

      for record in output[3:-2]:
        lst = record.split()
        x = float(lst[0])
        y = float(lst[1])
        i = float(lst[4]) / float(lst[5])
        x /= pixel[0]
        y /= pixel[1]

        if i < threshold:
          continue

        # this is Mosflm right? Swap X & Y!!

        peaks.append((y, x, i))

      return peaks
예제 #2
0
파일: Printpeaks.py 프로젝트: hainm/xia2
    def get_maxima(self):
      '''Run diffdump, printpeaks to get a list of diffraction maxima
      at their image positions, to allow for further analysis.'''

      if not self._image:
        raise RuntimeError, 'image not set'

      if not os.path.exists(self._image):
        raise RuntimeError, 'image %s does not exist' % \
              self._image

      dd = Diffdump()
      dd.set_image(self._image)
      header = dd.readheader()

      beam = header['raw_beam']
      pixel = header['pixel']

      self.add_command_line(self._image)
      self.start()
      self.close_wait()

      self.check_for_errors()

      # results were ok, so get all of the output out
      output = self.get_all_output()

      peaks = []

      for record in output:

        if not 'Peak' in record[:4]:
          continue

        lst = record.replace(':', ' ').split()
        x = float(lst[4])
        y = float(lst[6])
        i = float(lst[-1])
        x += beam[0]
        y += beam[1]
        x /= pixel[0]
        y /= pixel[1]

        peaks.append((x, y, i))

      return peaks