当前位置: 首页>>代码示例>>Python>>正文


Python Registry.find方法代码示例

本文整理汇总了Python中dxtbx.format.Registry.Registry.find方法的典型用法代码示例。如果您正苦于以下问题:Python Registry.find方法的具体用法?Python Registry.find怎么用?Python Registry.find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dxtbx.format.Registry.Registry的用法示例。


在下文中一共展示了Registry.find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run

# 需要导入模块: from dxtbx.format.Registry import Registry [as 别名]
# 或者: from dxtbx.format.Registry.Registry import find [as 别名]
  def run(self):
    from dxtbx.imageset import MultiFileReader, ImageSet
    from dxtbx.format.Registry import Registry

    # Get the filenames
    filenames = self.get_file_list()

    # Create the format class
    format_class = Registry.find(filenames[0])

    # Create the reader
    reader = MultiFileReader(format_class, filenames)

    # Create the imageset
    imageset = ImageSet(reader)

    # Run a load of tests
    self.tst_get_item(imageset)
    self.tst_len(imageset, len(filenames))
    self.tst_iter(imageset)
    self.tst_indices(imageset, range(0, 9))
    self.tst_paths(imageset, filenames)
    self.tst_is_valid(imageset)
    self.tst_get_detectorbase(imageset, range(len(filenames)), 9)
    self.tst_get_models(imageset, range(len(filenames)), 9)
开发者ID:cctbx,项目名称:cctbx-playground,代码行数:27,代码来源:tst_imageset.py

示例2: make_imageset

# 需要导入模块: from dxtbx.format.Registry import Registry [as 别名]
# 或者: from dxtbx.format.Registry.Registry import find [as 别名]
  def make_imageset(filenames, format_class=None, check_format=True,
                    single_file_indices=None, format_kwargs=None):
    '''Create an image set'''
    from dxtbx.format.Registry import Registry
    from format.FormatMultiImage import FormatMultiImage

    # Get the format object
    if format_class == None and check_format:
      format_class = Registry.find(filenames[0])
    if format_class is None:
      reader = NullReader(filenames, single_file_indices is not None)
    else:
      if issubclass(format_class, FormatMultiImage):
        assert len(set(filenames)) == 1
        if format_kwargs is None:
          format_kwargs = {}
        format_instance = format_class(filenames[0], **format_kwargs)
        reader = SingleFileReader(format_instance)
      else:
        reader = MultiFileReader(format_class, filenames,
                                 format_kwargs=format_kwargs)

    # Return the imageset
    return ImageSet(reader, indices=single_file_indices,
                    format_kwargs=format_kwargs)
开发者ID:cctbx,项目名称:cctbx-playground,代码行数:27,代码来源:imageset.py

示例3: pydiffdump_fast

# 需要导入模块: from dxtbx.format.Registry import Registry [as 别名]
# 或者: from dxtbx.format.Registry.Registry import find [as 别名]
def pydiffdump_fast(files):
  '''First find the class, then read every frame with it.'''

  s = time.time()

  format = Registry.find(files[0])

  scan = None

  for f in files:

    i = format(f)
    print 'Beam:'
    print i.get_xbeam()
    print 'Goniometer:'
    print i.get_xgoniometer()
    print 'Detector:'
    print i.get_xdetector()
    print 'Scan:'
    print i.get_xscan()

    if scan is None:
      scan = i.get_xscan()
    else:
      scan += i.get_xscan()

  print scan

  return time.time() - s
开发者ID:hainm,项目名称:xia2,代码行数:31,代码来源:pydiffdump.py

示例4: dxtbx_spotfinder_factory

# 需要导入模块: from dxtbx.format.Registry import Registry [as 别名]
# 或者: from dxtbx.format.Registry.Registry import find [as 别名]
def dxtbx_spotfinder_factory(phil_params):

  from dxtbx.format.Registry import Registry
  reader = Registry.find(phil_params.distl.image[0])
  from spotfinder.dxtbx_toolbox.practical_heuristics import heuristics_base
  Spotfinder = heuristics_base(phil_params)
  return Spotfinder
开发者ID:cctbx,项目名称:cctbx-playground,代码行数:9,代码来源:wrappers.py

示例5: pydiffdump

# 需要导入模块: from dxtbx.format.Registry import Registry [as 别名]
# 或者: from dxtbx.format.Registry.Registry import find [as 别名]
def pydiffdump(files):
  '''Print the class which claims to work with each file.'''

  s = time.time()

  for f in files:

    print f

    format = Registry.find(f)

    print format.__name__

    if format.understand(f):
      i = format(f)

      print 'Beam:'
      print i.get_beam()
      print 'Goniometer:'
      print i.get_goniometer()
      print 'Detector:'
      print i.get_detector()
      print 'Scan:'
      print i.get_scan()

  return time.time() - s
开发者ID:hainm,项目名称:xia2,代码行数:28,代码来源:pydiffdump.py

示例6: TestRegistry2

# 需要导入模块: from dxtbx.format.Registry import Registry [as 别名]
# 或者: from dxtbx.format.Registry.Registry import find [as 别名]
def TestRegistry2(files):
  '''First find the class, then read every frame with it.'''

  s = time.time()

  format = Registry.find(files[0])

  b0 = format(files[0]).get_beam()
  g0 = format(files[0]).get_goniometer()
  d0 = format(files[0]).get_detector()

  for f in files:

    print f

    i = format(f)
    print i.get_beam()
    print i.get_goniometer()
    print i.get_detector()
    print i.get_scan()
    print i.get_cube()

    print i.get_beam() == b0, i.get_goniometer() == g0, \
          i.get_detector() == d0

  return time.time() - s
开发者ID:cctbx,项目名称:cctbx-playground,代码行数:28,代码来源:TestRegistry.py

示例7: from_template

# 需要导入模块: from dxtbx.format.Registry import Registry [as 别名]
# 或者: from dxtbx.format.Registry.Registry import find [as 别名]
  def from_template(template, image_range=None, check_headers=False,
                    check_format=True):
    '''Create a new sweep from a template.

    Params:
        template The template argument
        image_range The image range
        check_headers Check the headers to ensure all images are valid

    Returns:
        A list of sweeps

    '''
    import os
    from dxtbx.format.Registry import Registry
    from dxtbx.sweep_filenames import template_image_range

    if not check_format: assert not check_headers

    # Check the template is valid
    if template.count('#') < 1:
      raise ValueError("Invalid template")

    # Get the template format
    pfx = template.split('#')[0]
    sfx = template.split('#')[-1]
    template_format = '%s%%0%dd%s' % (pfx, template.count('#'), sfx)

    # Get the template image range
    if image_range is None:
      image_range = template_image_range(template)

    # Set the image range
    array_range = (image_range[0] - 1, image_range[1])

    # Create the sweep file list
    filenames = SweepFileList(template_format, array_range)

    # Get the format class
    if check_format:
      format_class = Registry.find(filenames[0])
      from format.FormatMultiImage import FormatMultiImage
      if issubclass(format_class, FormatMultiImage):
        assert len(filenames) == 1
        format_instance = format_class(filenames[0])
        reader = SingleFileReader(format_instance)
      else:
        reader = MultiFileReader(format_class, filenames)
    else:
      reader = NullReader(filenames)

    # Create the sweep object
    sweep = ImageSweep(reader)

    # Check the sweep is valid
    if check_headers and not sweep.is_valid():
      raise RuntimeError('Invalid sweep of images')

    # Return the sweep
    return [sweep]
开发者ID:cctbx,项目名称:cctbx-playground,代码行数:62,代码来源:imageset.py

示例8: cbf_file_to_basis_dict

# 需要导入模块: from dxtbx.format.Registry import Registry [as 别名]
# 或者: from dxtbx.format.Registry.Registry import find [as 别名]
def cbf_file_to_basis_dict(path):
  """ Maps a cbf file to a dictionary of tuples and basis objects, in the same form as the above from
  read_optical_metrology_from_flat_file
  @param path cbf file path """
  from dxtbx.format.Registry import Registry
  reader = Registry.find(path)
  instance = reader(path)
  return map_detector_to_basis_dict(instance.get_detector())
开发者ID:keitaroyam,项目名称:cctbx_fork,代码行数:10,代码来源:cspad_cbf_tbx.py

示例9: find_format

# 需要导入模块: from dxtbx.format.Registry import Registry [as 别名]
# 或者: from dxtbx.format.Registry.Registry import find [as 别名]
 def find_format(self, filename):
   ''' Check the current and child formats, otherwise search the registry. '''
   from dxtbx.format.Registry import Registry
   try:
     if self._format_class == None or not self.understand(filename):
       self._format_class = Registry.find(filename)
     self._format_class = self.check_child_formats(filename)
   except Exception:
     return None
   return self._format_class
开发者ID:keitaroyam,项目名称:cctbx_fork,代码行数:12,代码来源:datablock.py

示例10: __call__

# 需要导入模块: from dxtbx.format.Registry import Registry [as 别名]
# 或者: from dxtbx.format.Registry.Registry import find [as 别名]
 def __call__(self, filename):
   ''' Check the current and child formats, otherwise search the registry. '''
   from dxtbx.format.Registry import Registry
   try:
     if self._format_class == None or not self.understand(filename):
       self._format_class = Registry.find(filename)
     self._format_class = self.check_child_formats(filename)
     if self._verbose:
       print 'Using %s for %s' % (self._format_class.__name__, filename)
   except Exception:
     return None
   return self._format_class
开发者ID:keitaroyam,项目名称:cctbx_fork,代码行数:14,代码来源:datablock.py

示例11: oneImage

# 需要导入模块: from dxtbx.format.Registry import Registry [as 别名]
# 或者: from dxtbx.format.Registry.Registry import find [as 别名]
  def oneImage(self,framenumber):
    self.reporters[framenumber] = []

    from dxtbx.format.Registry import Registry
    filename = self.phil_params.distl.image[framenumber]
    reader = Registry.find(filename)
    img = reader(filename)

    detector = img.get_detector()
    beam = img.get_beam()
    S0 = beam.get_s0()
    data = img.get_raw_data()
    scan = img.get_scan()
    print scan
    if scan is None:
      print "No scan"
      RR = (0,1)
    else:
      print scan.get_oscillation()
      RR = scan.get_oscillation_range()

    from spotfinder.dxtbx_toolbox import Distl

    sfall = Distl(params = self.phil_params, detector = detector, beam = beam, data = data)

    resolutions = flex.double()
    spotlist = []
    from dials.model.data import ReflectionList,Reflection
    reflections = ReflectionList()


    for ip,panel in enumerate(detector):
      for spot in sfall.finderlist[ip].spots:
        resolutions.append( panel.get_resolution_at_pixel(S0, (spot.ctr_mass_x(), spot.ctr_mass_y())) )
        spotlist.append(spot)
        refl = Reflection()
        refl.panel_number = ip
        refl.centroid_position = (spot.ctr_mass_x(), spot.ctr_mass_y(),0.0)
        refl.centroid_variance = (0.5,0.5,0.0)
        reflections.append(refl)


    selection = (resolutions>0.0)
    if self.phil_params.distl.res.outer is not None:
      selection = (selection and (resolutions>self.phil_params.distl.res.outer))
    if self.phil_params.distl.res.inner is not None:
      selection = (selection and (resolutions<self.phil_params.distl.res.inner))

    reflections = reflections.select(selection)

    return dict(detector=detector, beam=beam, reflections=reflections, scan = scan,
                gonio = img.get_goniometer())
开发者ID:cctbx,项目名称:cctbx-playground,代码行数:54,代码来源:practical_heuristics.py

示例12: load

# 需要导入模块: from dxtbx.format.Registry import Registry [as 别名]
# 或者: from dxtbx.format.Registry.Registry import find [as 别名]
def load(filename):
  """Use DXTBX to get the files from the input filename.

  Params:
      filename The input filename

  Returns:
      The dxtbx format instance

  """
  from dxtbx.format.Registry import Registry
  format_instance = Registry.find(filename)
  return format_instance(filename)
开发者ID:dalekreitler,项目名称:cctbx-playground,代码行数:15,代码来源:__init__.py

示例13: _create_sweep

# 需要导入模块: from dxtbx.format.Registry import Registry [as 别名]
# 或者: from dxtbx.format.Registry.Registry import find [as 别名]
    def _create_sweep(filelist, check_headers):
        """Create a sweep"""
        import os
        from dxtbx.format.Registry import Registry

        # Extract info from filelist
        template, indices, is_sweep = filelist

        # Get the template format
        count = template.count("#")
        if count > 0:
            pfx = template.split("#")[0]
            sfx = template.split("#")[-1]
            template_format = "%s%%0%dd%s" % (pfx, template.count("#"), sfx)
            filenames = [template_format % index for index in indices]
        else:
            filenames = [template]

        # Sort the filenames
        filenames = sorted(filenames)

        # Get the format object
        format_class = Registry.find(filenames[0])

        # Get the first image and our understanding
        first_image = filenames[0]

        # Get the directory and first filename and set the template format
        directory, first_image_name = os.path.split(first_image)
        first_image_number = indices[0]

        # Get the template format
        pfx = template.split("#")[0]
        sfx = template.split("#")[-1]
        template_format = "%s%%0%dd%s" % (pfx, template.count("#"), sfx)

        # Set the image range
        array_range = (min(indices) - 1, max(indices))

        # Create the sweep file list
        filenames = SweepFileList(template_format, array_range)

        # Create the sweep object
        sweep = ImageSweep(MultiFileReader(format_class, filenames))

        # Check the sweep is valid
        if check_headers and not sweep.is_valid():
            raise RuntimeError("Invalid sweep of images")

        # Return the sweep
        return sweep
开发者ID:keitaroyam,项目名称:cctbx_fork,代码行数:53,代码来源:imageset.py

示例14: print_detector_info2

# 需要导入模块: from dxtbx.format.Registry import Registry [as 别名]
# 或者: from dxtbx.format.Registry.Registry import find [as 别名]
def print_detector_info2(image):
    """
    Print out information on the detector given an image
    """

    format_instance = Registry.find(image)
    instance = format_instance(image)
    # adds parameters (iotbx)
    temp = instance.get_detectorbase()

    print "\nInformation from dxtbx Registry"
    print "================================="
    for key, val in temp.parameters.iteritems():
        print "%20s::%s" % (key, val)
开发者ID:RAPD,项目名称:RAPD,代码行数:16,代码来源:detector_utils.py

示例15: cbf2img

# 需要导入模块: from dxtbx.format.Registry import Registry [as 别名]
# 或者: from dxtbx.format.Registry.Registry import find [as 别名]
def cbf2img(file):

  from dxtbx.format.Registry import Registry
  import sys, os

  f = None
  if file.split(".")[-1].lower() == "cbf" and os.path.exists(file):
    if f is None:
      f = Registry.find(file)
    img = f(file)
    db = img.get_detectorbase()
    db.readHeader()
    db.read()
    db.show_header()
    destpath = file.rstrip(".cbf") + ".img"
    print "Writing %s as %s"%(file,destpath)

    db.debug_write(destpath)
开发者ID:vanbenschoten,项目名称:combat,代码行数:20,代码来源:combat.py


注:本文中的dxtbx.format.Registry.Registry.find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。