Ejemplo n.º 1
0
def modify_casa_headers(parset, casa_file):
    table = pyrap_table(casa_file, ack=False)
    origin_location = table.getkeyword("ATTRGROUPS")["LOFAR_ORIGIN"]
    origin_table = pyrap_table(origin_location, ack=False, readonly=False)

    for parset_field, value in parset.items():
        if parset_field == "tau_time":
            tau_time = value
            print "setting tau_time to %s" % (tau_time)
            starttime = origin_table.getcell("START", 0)
            entime = starttime + tau_time
            origin_table.putcell("END", 0, entime)
        else:
            print "WARNING: this script does not support setting %s for a CASA table" % parset_field
    origin_table.close()
    table.close()
Ejemplo n.º 2
0
def modify_lofarcasa_tau_time(parset, casa_file):
    table = pyrap_table(casa_file, ack=False)
    origin_location = table.getkeyword("ATTRGROUPS")['LOFAR_ORIGIN']
    origin_table = pyrap_table(origin_location, ack=False, readonly=False)

    for parset_field, value in parset.items():
        if parset_field == 'tau_time':
            tau_time = value
            logger.info("setting tau_time to %s" % (tau_time))
            starttime = origin_table.getcell('START', 0)
            entime = starttime + tau_time
            origin_table.putcell('END', 0, entime)
        else:
            raise ValueError("WARNING: this script does not support setting %s "
                             "for a CASA table" % parset_field)
    origin_table.close()
    table.close()
Ejemplo n.º 3
0
def modify_lofarcasa_tau_time(parset, casa_file):
    table = pyrap_table(casa_file, ack=False)
    origin_location = table.getkeyword("ATTRGROUPS")['LOFAR_ORIGIN']
    origin_table = pyrap_table(origin_location, ack=False, readonly=False)

    for parset_field, value in parset.items():
        if parset_field == 'tau_time':
            tau_time = value
            logger.info("setting tau_time to %s" % (tau_time))
            starttime = origin_table.getcell('START', 0)
            entime = starttime + tau_time
            origin_table.putcell('END', 0, entime)
        else:
            raise ValueError(
                "WARNING: this script does not support setting %s "
                "for a CASA table" % parset_field)
    origin_table.close()
    table.close()
Ejemplo n.º 4
0
def casa_detect(filename):
    """
    Detect which telescope produced CASA data, return corresponding accessor.

    Checks for known CASA table types where we expect additional metadata.
    If the telescope is unknown we return nothing.
    """
    table = pyrap_table(filename.encode(), ack=False)
    telescope = table.getkeyword('coords')['telescope']
    return casa_telescope_keyword_mapping.get(telescope, None)
Ejemplo n.º 5
0
def casa_detect(filename):
    """
    Detect which telescope produced CASA data, return corresponding accessor.

    Checks for known CASA table types where we expect additional metadata.
    If the telescope is unknown we return nothing.
    """
    table = pyrap_table(filename.encode(), ack=False)
    telescope = table.getkeyword('coords')['telescope']
    return casa_telescope_keyword_mapping.get(telescope, None)
Ejemplo n.º 6
0
 def open_subtables(self):
     """open all subtables defined in the LOFAR format
     args:
         table: a pyrap table handler to a LOFAR CASA table
     returns:
         a dict containing all LOFAR CASA subtables
     """
     subtables = {}
     for subtable in subtable_names:
         subtable_location = self.table.getkeyword("ATTRGROUPS")[subtable]
         subtables[subtable] = pyrap_table(subtable_location, ack=False)
     return subtables
Ejemplo n.º 7
0
def open_subtables(table):
    """open all subtables defined in the LOFAR format
    args:
        table: a pyrap table handler to a LOFAR CASA table
    returns:
        a dict containing all LOFAR CASA subtables
    """
    subtables = {}
    for subtable in subtable_names:
        subtable_location = table.getkeyword("ATTRGROUPS")[subtable]
        subtables[subtable] = pyrap_table(subtable_location, ack=False)
    return subtables
Ejemplo n.º 8
0
def iscasa(filename):
    """returns True if filename is a lofar casa directory"""
    if not os.path.isdir(filename):
        return False
    for file in casafiles:
        casafile = os.path.join(filename, file)
        if not os.path.isfile(casafile):
            return False
    try:
        table = pyrap_table(filename.encode(), ack=False)
    except RuntimeError:
        return False
    return True
Ejemplo n.º 9
0
    def __init__(self, url, plane=0, beam=None):
        super(LofarCasaImage, self).__init__(url, plane, beam)

        table = pyrap_table(self.url.encode(), ack=False)
        subtables = open_subtables(table)
        self._taustart_ts = parse_taustartts(subtables)
        self._tau_time = parse_tautime(subtables)

        # Additional, LOFAR-specific metadata
        self._antenna_set = parse_antennaset(subtables)
        self._ncore, self._nremote, self._nintl =  parse_stations(subtables)
        self._subbandwidth = parse_subbandwidth(subtables)
        self._subbands = parse_subbands(subtables)
Ejemplo n.º 10
0
    def __init__(self, url, plane=0, beam=None):
        self._url = url
        table = pyrap_table(self.url.encode(), ack=False)
        self._data = parse_data(table, plane)
        self._wcs = parse_coordinates(table)
        self._centre_ra, self._centre_decl = parse_phase_centre(table)
        self._freq_eff, self._freq_bw = parse_frequency(table)

        if beam:
            (bmaj, bmin, bpa) = beam
            self._beam = degrees2pixels(
                bmaj, bmin, bpa, self.pixelsize[0], self.pixelsize[1]
            )
        else:
            self._beam = parse_beam(table, self.pixelsize)
Ejemplo n.º 11
0
def iscasa(filename):
    """returns True if filename is a lofar casa directory"""
    if not os.path.isdir(filename):
        return False
    for file_ in casafiles:
        casafile = os.path.join(filename, file_)
        if not os.path.isfile(casafile):
            logger.debug("%s doesn't contain %s" % (filename, file_))
            return False
    try:
        table = pyrap_table(filename.encode(), ack=False)
        table.close()
    except RuntimeError as e:
        logger.debug("directory looks casacore, but cannot open: %s" % str(e))
        return False
    return True
Ejemplo n.º 12
0
def iscasa(filename):
    """returns True if filename is a lofar casa directory"""
    if not os.path.isdir(filename):
        return False
    for file_ in casafiles:
        casafile = os.path.join(filename, file_)
        if not os.path.isfile(casafile):
            logger.debug("%s doesn't contain %s" % (filename, file_))
            return False
    try:
        table = pyrap_table(filename.encode(), ack=False)
        table.close()
    except RuntimeError as e:
        logger.debug("directory looks casacore, but cannot open: %s" % str(e))
        return False
    return True
Ejemplo n.º 13
0
    def __init__(self, url, plane=0, beam=None):
        super(CasaImage, self).__init__()
        self.url = url
        self.table = pyrap_table(self.url.encode(), ack=False)
        self.data = self.parse_data(plane)
        self.wcs = self.parse_coordinates()
        self.centre_ra, self.centre_decl = self.parse_phase_centre()
        self.freq_eff, self.freq_bw = self.parse_frequency()
        self.pixelsize = self.parse_pixelsize()

        if beam:
            (bmaj, bmin, bpa) = beam
        else:
            bmaj, bmin, bpa = self.parse_beam()
        self.beam = self.degrees2pixels(bmaj, bmin, bpa, self.pixelsize[0],
                                        self.pixelsize[1])
Ejemplo n.º 14
0
    def __init__(self, url, plane=0, beam=None):
        super(CasaImage, self).__init__()
        self.url = url
        self.table = pyrap_table(self.url.encode(), ack=False)
        self.data = self.parse_data(plane)
        self.wcs = self.parse_coordinates()
        self.centre_ra, self.centre_decl = self.parse_phase_centre()
        self.freq_eff, self.freq_bw = self.parse_frequency()
        self.pixelsize = self.parse_pixelsize()

        if beam:
            (bmaj, bmin, bpa) = beam
        else:
            bmaj, bmin, bpa = self.parse_beam()
        self.beam = self.degrees2pixels(
            bmaj, bmin, bpa, self.pixelsize[0], self.pixelsize[1])
Ejemplo n.º 15
0
    def __init__(self, url, plane=0, beam=None):
        super(CasaImage, self).__init__()  # Set defaults
        self.url = url

        self.table = pyrap_table(self.url.encode(), ack=False)
        self.telescope = self.table.getkeyword('coords')['telescope']
        self.data = parse_data(self.table, plane)
        self.wcs = parse_coordinates(self.table)
        self.pixelsize = parse_pixelsize(self.wcs)
        self.centre_ra, self.centre_decl = parse_phase_centre(self.table)
        self.freq_eff, self.freq_bw = parse_frequency(self.table)

        if beam:
            (bmaj, bmin, bpa) = beam
            self.beam = degrees2pixels(bmaj, bmin, bpa,
                                       self.pixelsize[0], self.pixelsize[1])
        else:
            self.beam = parse_beam(self.table, self.pixelsize)
Ejemplo n.º 16
0
    def __init__(self, url, plane=0, beam=None):
        super(Kat7CasaImage, self).__init__(url, plane, beam)

        table = pyrap_table(self.url.encode(), ack=False)
        self._taustart_ts = parse_taustartts(table)