示例#1
0
 def _rdhd(self, name):
     """Provide read access to header items via low-level calls."""
     itype = itemtable[name]
     if itype == '?': return self._rdhd_special(name)
     h = self.haccess(name, 'read')
     rv = []
     if len(itype) == 1:
         if itype == 'a': offset = 0
         else:
             t, offset = _miriad.hread_init(h)
             assert(itype == t)
         while True:
             try: c, o = _miriad.hread(h, offset, itype)
             except(IOError): break
             if itype == 'a': c = c[:o]
             rv.append(c)
             offset += o
         if itype == 'a': rv = ''.join(rv)
     else:
         t, offset = _miriad.hread_init(h); assert(t == 'b')
         for t in itype:
             v, o = _miread.hread(h, offset, t)
             rv.append(v); offset += o
     _miriad.hdaccess(h)
     if len(rv) == 1: return rv[0]
     elif type(rv) == str: return rv
     else: return np.array(rv)
示例#2
0
 def _rdhd(self, name):
     """Provide read access to header items via low-level calls."""
     itype = itemtable[name]
     if itype == '?': return self._rdhd_special(name)
     h = self.haccess(name, 'read')
     rv = []
     if len(itype) == 1:
         if itype == 'a': offset = 0
         else:
             t, offset = _miriad.hread_init(h)
             assert(itype == t)
         while True:
             try: c, o = _miriad.hread(h, offset, itype)
             except(IOError): break
             if itype == 'a': c = c[:o]
             rv.append(c)
             offset += o
         if itype == 'a': rv = ''.join(rv)
     else:
         t, offset = _miriad.hread_init(h); assert(t == 'b')
         for t in itype:
             v, o = _miread.hread(h, offset, t)
             rv.append(v); offset += o
     _miriad.hdaccess(h)
     if len(rv) == 1: return rv[0]
     elif type(rv) == str: return rv
     else: return n.array(rv)
示例#3
0
 def _rdhd_special(self, name):
     """Provide read access to special header items of type '?' to _rdhd"""
     if name == 'freqs':
         h = self.haccess(name, 'read')
         c, o = _miriad.hread(h, 0, 'i')
         rv = [c]; offset = 8
         while True:
             try:
                 c, o = _miriad.hread(h, offset, 'i')
                 rv.append(c); offset += 8
                 c, o = _miriad.hread(h, offset, 'd')
                 rv.append(c); offset += 8
                 c, o = _miriad.hread(h, offset, 'd')
                 rv.append(c); offset += 8
             except(IOError): break
         _miriad.hdaccess(h)
         return rv
     else: raise ValueError('Unknown special header: ' + name)
示例#4
0
 def _rdhd_special(self, name):
     """Provide read access to special header items of type '?' to _rdhd"""
     if name == 'freqs':
         h = self.haccess(name, 'read')
         c, o = _miriad.hread(h, 0, 'i')
         rv = [c]; offset = 8
         while True:
             try:
                 c, o = _miriad.hread(h, offset, 'i')
                 rv.append(c); offset += 8
                 c, o = _miriad.hread(h, offset, 'd')
                 rv.append(c); offset += 8
                 c, o = _miriad.hread(h, offset, 'd')
                 rv.append(c); offset += 8
             except(IOError): break
         _miriad.hdaccess(h)
         return rv
     else: raise ValueError('Unknown special header: ' + name)