當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。