def _fill(self, index=None): if self._flush: assert self._first == self._data.Desc.Dict["firstVis"] - 1 Obit.UVRewrite(self._data.me, self._err.me) if self._err.isErr: raise RuntimeError self._flush = False pass if index: d = self._data.IODesc.Dict count = InfoList.PGet(self._data.List, "nVisPIO")[4][0] d["firstVis"] = max(0, index - count + 1) self._data.IODesc.Dict = d pass Obit.UVRead(self._data.me, self._err.me) if self._err.isErr: raise RuntimeError shape = len(self._data.VisBuf) / 4 self._buffer = _array(self._data.VisBuf, shape) self._first = self._data.Desc.Dict["firstVis"] - 1 self._count = self._data.Desc.Dict["numVisBuff"] count = InfoList.PGet(self._data.List, "nVisPIO")[4][0] self._buffer.shape = (count, -1) self._index = 0 return
def clrstat(self): """Reset file 'busy' status in the AIPS catalogue.""" cno = Obit.AIPSDirFindCNO( self._data.Disk, self._userno, self._data.Aname, self._data.Aclass, self._type, self._data.Aseq, self._err.me, ) Obit.AIPSDirStatus(self._data.Disk, self._userno, cno, 4, self._err.me) return
def __next__(self): self._index += 1 if self._index + self._first > self._range[1]: try: self._range = self._ranges.pop(0) except BaseException: pass while self._first + self._count < self._range[0]: self._fill() pass if self._index + self._first < self._range[0]: self._index = self._range[0] - self._first pass if self._index + self._first >= self._range[1]: if self._flush: Obit.UVWrite(self._data.me, self._err.me) if self._err.isErr: raise RuntimeError self._flush = False raise StopIteration if self._index >= self._count: self._fill() return self
def attach_table(self, name, version, **kwds): """Attach an extension table to this UV data set. A new extension table is created if the extension table NAME with version VERSION doesn't exist. If VERSION is 0, a new extension table is created with a version that is one higher than the highest available version.""" if not name.startswith("AIPS "): name = "AIPS " + name if version == 0: version = Obit.UVGetHighVer(self._data.me, name) + 1 header = self._data.Desc.Dict jlocif = header["jlocif"] no_if = header["inaxes"][jlocif] if "no_if" in kwds: no_if = kwds["no_if"] pass no_pol = len(self.polarizations) if "no_pol" in kwds: no_pol = kwds["no_pol"] pass data = Obit.UVCastData(self._data.me) if name == "AIPS AI": Obit.TableAI(data, [version], 3, name, kwds["no_term"], self._err.me) elif name == "AIPS CL": Obit.TableCL(data, [version], 3, name, no_pol, no_if, kwds["no_term"], self._err.me) elif name == "AIPS FQ": Obit.TableFQ(data, [version], 3, name, no_if, self._err.me) elif name == "AIPS NI": Obit.TableNI(data, [version], 3, name, kwds["num_coef"], self._err.me) elif name == "AIPS PS": Obit.TablePS(data, [version], 3, name, self._err.me) elif name == "AIPS SN": Obit.TableSN(data, [version], 3, name, no_pol, no_if, self._err.me) elif name == "AIPS SU": Obit.TableSU(data, [version], 3, name, no_if, self._err.me) else: msg = "Attaching %s tables is not implemented yet" % name raise NotImplementedError(msg) if self._err.isErr: raise RuntimeError return _AIPSTable(self._data, name, version)
def attach_table(self, name, version, **kwds): """Attach an extension table to this image. A new extension table is created if the extension table NAME with version VERSION doesn't exist. If VERSION is 0, a new extension table is created with a version that is one higher than the highest available version.""" if not name.startswith("AIPS "): name = "AIPS " + name if version == 0: version = Obit.ImageGetHighVer(self._data.me, name) + 1 no_parms = 0 if "no_parms" in kwds: no_parms = kwds["no_parms"] data = Obit.ImageCastData(self._data.me) if name == "AIPS CC": Obit.TableCC(data, [version], 3, name, no_parms, self._err.me) elif name == "AIPS FG": Obit.TableFG(data, [version], 3, name, self._err.me) elif name == "AIPS PS": Obit.TablePS(data, [version], 3, name, self._err.me) elif name == "AIPS SN": Obit.TableSN(data, [version], 3, name, kwds["no_pol"], kwds["no_if"], self._err.me) else: msg = "Attaching %s tables is not implemented yet" % name raise NotImplementedError(msg) if self._err.isErr: raise RuntimeError return _AIPSTable(self._data, name, version)
def _pixels(self): Obit.ImageRead(self._data.me, self._err.me) if self._err.isErr: raise RuntimeError("Reading image pixels") shape = [] for len in self.header["naxis"]: if self._squeezed and len == 1: continue shape.insert(0, len) continue shape = tuple(shape) pixels = _array(self._data.PixBuf, shape) return pixels
def _disk_list_add(*args): """Add DAxx entries for the directories supplied and update NVOL.""" try: nvol = int(os.environ["NVOL"]) except KeyError: nvol = 0 for i in range(len(args)): os.environ["DA%s" % ehex(nvol + 1 + i, 2, 0)] = args[i] AIPS.disks.append(AIPS.AIPSDisk(None, nvol + 1 + i)) err = OErr.OErr() Obit.AIPSSetDirname(nvol + 1 + i, args[i] + "/", err.me) if err.isErr: raise RuntimeError os.environ["NVOL"] = str(nvol + len(args))
def exists(self, desc): """Checks that this instance of AIPSData refers to a dataset that is actually present in the AIPS catalogue.""" assert not self.err.isErr assert self.type cno = Obit.AIPSDirFindCNO( desc["disk"], desc["userno"], desc["name"], desc["klass"], self.type, desc["seq"], self.err.me, ) if cno == -1: OErr.PClear(self.err) return False return True
def update(self): Obit.ImageWrite(self._data.me, self._err.me) if self._err.isErr: raise RuntimeError("Writing image pixels") pass _AIPSData.update(self)