Beispiel #1
0
    def addRefColumnToTesttab(self, columnname):
        if self.verbose:
            print(bcolors.OKBLUE + "Forwarding reference column " +
                  bcolors.WARNING + columnname + bcolors.OKBLUE + " to " +
                  self.test_MS + bcolors.ENDC)  # DEBUG

        testtab = pt.table(self.test_MS,
                           readonly=False)  # Open test_MS in readonly mode
        reftab = pt.table(self.MS)  # Open reference MS in readonly mode

        # Get column description from testtab
        testcolumnname = "test_" + columnname

        testtab.renamecol(
            columnname,
            testcolumnname)  # rename the existing column in the test table
        refcol_desc = reftab.getcoldesc(columnname)

        # Use ForwardColumnEngine to refer column in testtab to reftab columnname
        testtab.addcols(pt.maketabdesc(
            [pt.makecoldesc(columnname, refcol_desc)]),
                        dminfo={
                            '1': {
                                'TYPE': 'ForwardColumnEngine',
                                'NAME': 'ForwardData',
                                'COLUMNS': [columnname],
                                'SPEC': {
                                    'FORWARDTABLE': reftab.name()
                                }
                            }
                        })

        testtab.flush()
Beispiel #2
0
def addcol(ms, incol, outcol):
    if outcol not in ms.colnames():
        logging.info('Adding column: '+outcol)
        coldmi = ms.getdminfo(incol)
        coldmi['NAME'] = outcol
        ms.addcols(pt.makecoldesc(outcol, ms.getcoldesc(incol)), coldmi)
    if outcol != incol:
        # copy columns val
        logging.info('Set '+outcol+'='+incol)
        pt.taql("update $ms set "+outcol+"="+incol)
Beispiel #3
0
def addcol(ms, incol, outcol):
    if outcol not in ms.colnames():
        logging.info('Adding column: ' + outcol)
        coldmi = ms.getdminfo(incol)
        coldmi['NAME'] = outcol
        ms.addcols(pt.makecoldesc(outcol, ms.getcoldesc(incol)), coldmi)
    if outcol != incol:
        # copy columns val
        logging.info('Set ' + outcol + '=' + incol)
        pt.taql("update $ms set " + outcol + "=" + incol)
Beispiel #4
0
    def addRefColumnToTesttab(self, columnname):
        if self.verbose:
            print bcolors.OKBLUE + "Forwarding reference column " + bcolors.WARNING + columnname + bcolors.OKBLUE + " to " + self.test_MS + bcolors.ENDC           # DEBUG
           
        testtab=pt.table(self.test_MS, readonly=False)          # Open test_MS in readonly mode
        reftab=pt.table(self.MS)                  # Open reference MS in readonly mode
  
        # Get column description from testtab
        testcolumnname = "test_" + columnname
        
        testtab.renamecol(columnname, testcolumnname)           # rename the existing column in the test table
        refcol_desc=reftab.getcoldesc(columnname)  

        # Use ForwardColumnEngine to refer column in testtab to reftab columnname
        testtab.addcols(pt.maketabdesc([pt.makecoldesc(columnname, refcol_desc)]), dminfo={'1':{'TYPE':'ForwardColumnEngine', 'NAME':'ForwardData', 'COLUMNS':[columnname], 'SPEC':{'FORWARDTABLE':reftab.name()}}})

        testtab.flush()
Beispiel #5
0
def main(options):
    ms = options.ms
    if ms == '':
        print 'Error: you have to specify an input MS, use -h for help'
        return
    cols = options.cols
    incol = options.incol

    t = pt.table(ms, readonly=False, ack=False)

    for col in cols.split(','):
        if col not in t.colnames():
            logging.info('Adding the output column ' + col + ' to ' + ms + '.')
            if incol == '':
                # prepare col metadata
                cd = t.getcoldesc('DATA')
                if options.dysco:
                    cd['dataManagerType'] = 'DyscoStMan'
                    cd['dataManagerGroup'] = 'DyscoData'
                    coldmi = {
                        'NAME': col,
                        'SEQNR': 3,
                        'SPEC': {
                            'dataBitCount': 10,
                            'distribution': 'TruncatedGaussian',
                            'distributionTruncation': 2.5,
                            'normalization': 'AF',
                            'studentTNu': 0.0,
                            'weightBitCount': 12
                        },
                        'TYPE': 'DyscoStMan'
                    }
                else:
                    cd['dataManagerType'] = 'StandardStMan'
                    cd['dataManagerGroup'] = 'SSMVar'
                    coldmi = {
                        'NAME': col,
                        'SEQNR': 0,
                        'SPEC': {
                            'ActualCacheSize': 2,
                            'BUCKETSIZE': 32768,
                            'IndexLength': 799832,
                            'PERSCACHESIZE': 2
                        },
                        'TYPE': 'StandardStMan'
                    }

                cd['comment'] = 'Added by addcol2ms'
                t.addcols(pt.makecoldesc(col, cd), coldmi)

                # if non dysco is done by default
                if options.dysco:
                    logging.warning('Setting ' + col + ' = 0')
                    pt.taql("update $t set " + col + "=0")

            else:
                # prepare col metadata
                coldmi = t.getdminfo(incol)
                coldmi['NAME'] = col
                cd = t.getcoldesc(incol)

                cd['comment'] = 'Added by addcol2ms'
                t.addcols(pt.makecoldesc(col, cd), coldmi)

                logging.warning('Setting ' + col + ' = ' + incol)
                pt.taql("update $t set " + col + "=" + incol)

        else:
            logging.warning('Column ' + col + ' already exists.')

    t.close()
Beispiel #6
0
import pyrap.tables as pt
# Get nr of channels
t = pt.table(msname + '/SPECTRAL_WINDOW')
nf = t.getcell('NUM_CHAN', 0)
t.close()
# Get nr of receptors and value (for the datatype)
t = pt.table(msname + '/SYSCAL', readonly=False)
val = t.getcell('TCAL', 0)
shp = [nf, len(val)]
shpstr = str(shp)
# Add a freq-dep column for each freq-indep column
t.addcols(
    pt.maketabdesc(pt.makecoldesc('TCAL_SPECTRUM', val[0], 2, shp),
                   pt.makecoldesc('TSYS_SPECTRUM', val[0], 2,
                                  shp)))  #etc for other columns
t.close()
# Copy the freq-indep values to the freq-dep (TaQL's array function extends the values)
pt.taql(
    'update %s/SYSCAL set TCAL_SPECTRUM=array(TCAL,%s), TSYS_SPECTRUM=array(TSYS,%s)'
    % (msname, shpstr, shpstr))
Beispiel #7
0
import pyrap.tables as pt
# Get nr of channels
t = pt.table (msname + '/SPECTRAL_WINDOW')
nf = t.getcell('NUM_CHAN', 0)
t.close()
# Get nr of receptors and value (for the datatype)
t = pt.table (msname + '/SYSCAL', readonly=False)
val = t.getcell('TCAL', 0)
shp = [nf, len(val)]
shpstr = str(shp)
# Add a freq-dep column for each freq-indep column
t.addcols (pt.maketabdesc(pt.makecoldesc('TCAL_SPECTRUM', val[0], 2, shp),
                                      pt.makecoldesc('TSYS_SPECTRUM', val[0], 2, shp)))   #etc for other columns
t.close()
# Copy the freq-indep values to the freq-dep (TaQL's array function extends the values)
pt.taql ('update %s/SYSCAL set TCAL_SPECTRUM=array(TCAL,%s), TSYS_SPECTRUM=array(TSYS,%s)' % (msname,shpstr,shpstr))