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


Python Format.Format类代码示例

本文整理汇总了Python中dxtbx.format.Format.Format的典型用法代码示例。如果您正苦于以下问题:Python Format类的具体用法?Python Format怎么用?Python Format使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: __init__

  def __init__(self, image_file):
    '''Initialise the image structure from the given file.'''

    Format.__init__(self, image_file)

    assert(self.understand(image_file))
    return
开发者ID:keitaroyam,项目名称:cctbx_fork,代码行数:7,代码来源:FormatXPARM.py

示例2: understand

  def understand(image_file):
    '''See if this looks like an RAXIS format image - clue is first
    5 letters of file should be RAXIS.'''

    if Format.open_file(image_file).read(5) == 'RAXIS':
      return True

    return False
开发者ID:keitaroyam,项目名称:cctbx_fork,代码行数:8,代码来源:FormatRAXIS.py

示例3: _start

  def _start(self):
    self._header_bytes = Format.open_file(self._image_file).read(1024)

    if self._header_bytes[812:822].strip() in ['SGI', 'IRIS']:
      self._f = '>f'
      self._i = '>i'
    else:
      self._f = '<f'
      self._i = '<i'
开发者ID:cctbx,项目名称:cctbx-playground,代码行数:9,代码来源:FormatRAXIS.py

示例4: read_basic_tiff_header

def read_basic_tiff_header(filename):
  '''Read the TIFF header (assuming for the moment a 4k header...) and
  return ... something.'''

  # things we hope to learn from the vanilla TIFF header

  image_width = None
  image_height = None
  image_depth = None
  header_size = None
  byte_order = None

  # OK then let's get started - and let's assume that the size is > 1 kb

  byte_order = tiff_byte_order(filename)
  tiff_header = Format.open_file(filename, 'rb').read(1024)

  if byte_order == LITTLE_ENDIAN:
    _I = '<I'
    _H = '<H'
  else:
    _I = '>I'
    _H = '>H'

  offset = struct.unpack(_I, tiff_header[4:8])[0]

  ntags = struct.unpack(_H, tiff_header[offset:offset + 2])[0]
  start = offset + 2

  for j in range(ntags):
    type_desc = struct.unpack(_H, tiff_header[start:start + 2])[0]
    start += 2
    type_type = struct.unpack(_H, tiff_header[start:start + 2])[0]
    start += 2
    type_size = struct.unpack(_I, tiff_header[start:start + 4])[0]
    start += 4
    if type_type == 4:
      type_offset_or_value = struct.unpack(
          _I, tiff_header[start:start + 4])[0]
      start += 4
    elif type_type == 3:
      type_offset_or_value = struct.unpack(
          _H, tiff_header[start:start + 2])[0]
      start += 4

    if type_desc == 256:
      image_width = type_offset_or_value
    elif type_desc == 257:
      image_height = type_offset_or_value
    elif type_desc == 258:
      image_depth = type_offset_or_value
    elif type_desc == 273:
      header_size = type_offset_or_value

  return image_width, image_height, image_depth, header_size, byte_order
开发者ID:cctbx,项目名称:cctbx-playground,代码行数:55,代码来源:FormatTIFFHelpers.py

示例5: __init__

  def __init__(self, image_file, **kwargs):
    '''
    Initialise the class

    '''
    assert(self.understand(image_file))
    import json
    self.header = json.load(open(image_file))


    self._goniometer_instance = None
    self._detector_instance = None
    self._beam_instance = None
    self._scan_instance = None

    FormatMultiImage.__init__(self, **kwargs)
    Format.__init__(self, image_file, **kwargs)

    self.setup()
    return
开发者ID:cctbx,项目名称:cctbx-playground,代码行数:20,代码来源:FormatEigerStream.py

示例6: _start

  def _start(self):
    self._header_bytes = Format.open_file(self._image_file).read(1024)

    if self._header_bytes[812:822].strip() in ['SGI', 'IRIS']:
      self._f = '>f'
      self._i = '>i'
    else:
      self._f = '<f'
      self._i = '<i'

    from iotbx.detectors.raxis import RAXISImage
    self.detectorbase = RAXISImage(self._image_file)
    self.detectorbase.readHeader()
开发者ID:keitaroyam,项目名称:cctbx_fork,代码行数:13,代码来源:FormatRAXIS.py

示例7: tiff_byte_order

def tiff_byte_order(filename):
  '''Determine the byte order for the file from the magic numbers at the
  very start of the file.'''

  four_bytes = Format.open_file(filename, 'rb').read(4)

  if 'II' in four_bytes[:2]:
    assert(struct.unpack('<H', four_bytes[2:])[0] == 42)
    return LITTLE_ENDIAN
  elif 'MM' in four_bytes[:2]:
    assert(struct.unpack('>H', four_bytes[2:])[0] == 42)
    return BIG_ENDIAN

  raise RuntimeError, '%s not recognised as TIFF' % filename
开发者ID:cctbx,项目名称:cctbx-playground,代码行数:14,代码来源:FormatTIFFHelpers.py

示例8: _start

  def _start(self):
    '''Open the image file, read the image header, copy it into memory
    for future inspection.'''

    Format._start(self)

    self._cif_header = FormatCBF.get_cbf_header(self._image_file)

    self._mime_header = ''

    in_binary_format_section = False

    for record in FormatCBF.open_file(self._image_file, 'rb'):
      if '--CIF-BINARY-FORMAT-SECTION--' in record:
        in_binary_format_section = True
      elif in_binary_format_section and record[0] == 'X':
        self._mime_header += record
      if in_binary_format_section and len(record.strip()) == 0:
        # http://sourceforge.net/apps/trac/cbflib/wiki/ARRAY_DATA%20Category
        #    In an imgCIF file, the encoded binary data begins after
        #    the empty line terminating the header.
        break

    return
开发者ID:dalekreitler,项目名称:cctbx-playground,代码行数:24,代码来源:FormatCBF.py

示例9: get_beam

 def get_beam(self, index=None):
   return Format.get_beam(self)
开发者ID:cctbx,项目名称:cctbx-playground,代码行数:2,代码来源:FormatHDF5Nexus.py

示例10: get_detector

 def get_detector(self, index=None):
   return Format.get_detector(self)
开发者ID:cctbx,项目名称:cctbx-playground,代码行数:2,代码来源:FormatHDF5Nexus.py

示例11: get_goniometer

 def get_goniometer(self, index=None):
   return Format.get_goniometer(self)
开发者ID:cctbx,项目名称:cctbx-playground,代码行数:2,代码来源:FormatHDF5Nexus.py

示例12: __init__

  def __init__(self, image_file, **kwargs):
    '''Initialise the image structure from the given file.'''

    assert(self.understand(image_file))

    Format.__init__(self, image_file, **kwargs)
开发者ID:cctbx,项目名称:cctbx-playground,代码行数:6,代码来源:FormatMarIP.py

示例13: __init__

 def __init__(self, image_file):
   assert(self.understand(image_file))
   FormatMultiImage.__init__(self)
   Format.__init__(self, image_file)
开发者ID:dalekreitler,项目名称:cctbx-playground,代码行数:4,代码来源:FormatHDF5.py

示例14: __init__

  def __init__(self, image_file):
    assert(self.understand(image_file))

    Format.__init__(self, image_file)

    return
开发者ID:keitaroyam,项目名称:cctbx_fork,代码行数:6,代码来源:FormatRAXIS.py

示例15: get_scan

 def get_scan(self, index=None):
   if index == None:
     return Format.get_scan(self)
   else:
     scan = Format.get_scan(self)
     return scan[index]
开发者ID:cctbx,项目名称:cctbx-playground,代码行数:6,代码来源:FormatHDF5Nexus.py


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