Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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":
try:
c = str(c[:o], "utf-8")
except TypeError:
c = c[:o]
rv.append(c)
offset += o
if itype == "a":
rv = "".join(rv)
else:
t, offset = _miriad.hread_init(h)
try:
c = str(c[:o], "utf-8")
except TypeError:
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 = _miriad.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)
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)
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
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)
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: