예제 #1
0
 def __init__(self, data):
     self._err = OErr.OErr()
     self._table = History.History("AIPS HI", data.List, self._err)
     self._table.Open(3, self._err)
     if self._err.isErr:
         raise RuntimeError
     return
예제 #2
0
    def cat(self, disk, userno):
        from obit import AIPSDir

        _userno = OSystem.PGetAIPSuser()
        OSystem.PSetAIPSuser(userno)

        try:
            num_slots = AIPSDir.PNumber(disk, userno, self.err)
        except Exception:
            OErr.PClear(self.err)
            return []

        catalog = []
        for cno in range(1, num_slots):
            entry = AIPSDir.PInfo(disk, userno, cno, self.err)
            if entry:
                entry_dict = {
                    "cno": cno,
                    "name": entry[0:12].strip(),
                    "klass": entry[13:19].strip(),
                    "seq": int(entry[20:25]),
                    "type": entry[26:28],
                    "date": entry[29:40],
                    "time": entry[41:49],
                }
                catalog.append(entry_dict)

        OSystem.PSetAIPSuser(_userno)

        return catalog
예제 #3
0
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))
예제 #4
0
    def _init(self, name, klass, disk, seq, userno):
        from obit import Image
        from .. import AIPS

        self._obit = Image
        self._type = "MA"
        if userno == -1:
            userno = AIPS.userno
            pass
        self._userno = userno
        self._err = OErr.OErr()
        self._squeezed = False
        OSystem.PSetAIPSuser(userno)
        self._data = Image.newPAImage(name, name, klass, disk, seq, True,
                                      self._err)
        if self._err.isErr:
            raise RuntimeError
        return
예제 #5
0
    def _init(self, name, klass, disk, seq, userno):
        from obit import UV
        from .. import AIPS

        self._obit = UV
        self._type = "UV"
        if userno == -1:
            userno = AIPS.userno
        self._userno = userno
        self._err = OErr.OErr()
        OSystem.PSetAIPSuser(userno)
        self._data = UV.newPAUV(name, name, klass, disk, seq, True, self._err)
        if self._err.isErr:
            raise RuntimeError
        self._antennas = []
        self._polarizations = []
        self._sources = []
        self._open = False
        return
예제 #6
0
    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
예제 #7
0
    def __init__(self, data, name, version):
        if not name.startswith("AIPS "):
            name = "AIPS " + name
            pass

        self._err = OErr.OErr()

        if version == 0:
            version = TableList.PGetHigh(data.TableList, name)

        tables = TableList.PGetList(data.TableList, self._err)
        if not [version, name] in tables:
            msg = name + " table"
            if version:
                msg += " version %d" % version
                pass
            msg += " does not exist"
            raise IOError(msg)

        self._table = data.NewTable(3, name, version, self._err)
        self._table.Open(3, self._err)
        if self._err.isErr:
            raise self._err
        header = self._table.Desc.Dict
        self._columns = {}
        self._keys = []
        for column in header["FieldName"]:
            # Convert the AIPS ccolumn names into acceptable Python
            # identifiers.
            key = column.lower()
            key = key.replace(" ", "_")
            key = key.rstrip(".")
            key = key.replace(".", "_")
            self._columns[key] = column
            self._keys.append(key)
            continue
        self.name = name
        self.version = header["version"]
        return
예제 #8
0
            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)

    history = property(lambda self: _AIPSHistory(self._data))

    pass  # class AIPSUVData


err = OErr.OErr()
OSystem.OSystem("", 1, 0, -1, [], -1, [], True, False, err)
예제 #9
0
 def __init__(self):
     self.err = OErr.OErr()
     self.type = None  # Specified in subclasses
예제 #10
0
 def __init__(self):
     self.err = OErr.OErr()