当前位置: 首页>>代码示例>>Python>>正文


Python taskinit.tbtool函数代码示例

本文整理汇总了Python中taskinit.tbtool函数的典型用法代码示例。如果您正苦于以下问题:Python tbtool函数的具体用法?Python tbtool怎么用?Python tbtool使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了tbtool函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: compareSubTables

def compareSubTables(input,reference,order=None,excluded_cols=[]):
    
    tbinput = tbtool()
    tbinput.open(input)
    if order is not None:
        tbinput_sorted = tbinput.taql("SELECT * from " + input + " order by " + order)
    else:
        tbinput_sorted = tbinput
    
    tbreference = tbtool()
    tbreference.open(reference)
    if order is not None:
        tbreference_sorted = tbreference.taql("SELECT * from " + reference + " order by " + order)
    else:
        tbreference_sorted = tbreference
    
    columns = tbinput.colnames()
    for col in columns:
        if not col in excluded_cols:
            col_input = tbinput_sorted.getcol(col)
            col_reference = tbreference_sorted.getcol(col)
            if not (col_input == col_reference).all():
                tbinput.close()
                tbreference.close()
                del tbinput
                del tbreference
                return (False,col)
    
    tbinput.close()
    tbreference.close()
    del tbinput
    del tbreference
    
    return (True,"OK")
开发者ID:schiebel,项目名称:casa,代码行数:34,代码来源:testhelper.py

示例2: test_vla_mixed_polarizations_mms2

    def test_vla_mixed_polarizations_mms2(self):
        
        self.outputms = 'test_vla_mixed_polarizations_2.mms'
        
        mstransform(vis=self.vis,outputvis=self.outputms,scan='16',datacolumn='DATA', createmms=True,
                    separationaxis='spw',spw='16~18',correlation='XX')
        
        # Check that DDI sub-table is consistent with POLARIZATION sub-table
        mytb = tbtool()
        mytb.open(self.outputms + '/POLARIZATION')
        npols = mytb.nrows()
        mytb.close()
        
        mytb = tbtool()
        mytb.open(self.outputms + '/DATA_DESCRIPTION')
        polIds = mytb.getcol('POLARIZATION_ID')
        mytb.close()    
        for id in polIds:
            self.assertTrue(id in range(npols),'PolarizationId in DATA_DESCRIPTION not consistent with POLARIZATION table')
        
#        self.assertTrue(all(polIds < npols), 'PolarizationId in DATA_DESCRIPTION not consistent with POLARIZATION table') 
        
        # Check that flagdata can run properly with output MS
        summary = flagdata(vis=self.outputms,mode='summary')
        self.assertTrue(summary.has_key('correlation'), 'Flagdata failure due to missformated MS') 
开发者ID:schiebel,项目名称:casa,代码行数:25,代码来源:test_mstransform_mms.py

示例3: fixfeedpa

def fixfeedpa(vis,defband='',forceband=''):

    mytb=taskinit.tbtool()

    mytb.open(vis+'/SPECTRAL_WINDOW')
    spwnames=mytb.getcol('NAME')
    mytb.close()
    if len(forceband)>0:
        print 'Forcing band = ',forceband
        spwnames[:]=forceband
        defband=forceband
    mytb.open(vis+'/FEED',nomodify=False)
    spwids=mytb.getcol('SPECTRAL_WINDOW_ID')
    ra=mytb.getcol('RECEPTOR_ANGLE')
    ra[:,:]=0.0
    spwmask=(spwids>-1)
    ra[0,spwmask]=[bandpa(spwnames[ispw]) for ispw in spwids[spwmask]]
    spwmask=pl.logical_not(spwmask)
    if (sum(spwmask)>0):
        if (len(defband)>0):
            print 'NB: Setting spwid=-1 rows in FEED table to RECEPTOR_ANGLE for band='+str(defband)
            ra[0,spwmask]=bandpa(defband)
        else:
            print 'NB: Setting spwid=-1 rows in FEED table to RECEPTOR_ANGLE=(0,pi/2)'
    ra[1,:]=ra[0,:]+(pi/2.)
    mytb.putcol('RECEPTOR_ANGLE',ra)
    mytb.close()
开发者ID:schiebel,项目名称:casa,代码行数:27,代码来源:almapolhelpers.py

示例4: abschanwidth

def abschanwidth(vis="", spw=""):

    """
    Usage: abschanwidth(vis, spw)
           Get the absolute channel width for the given spw.
           Returns 0 upon error.
    """

    if vis == "" or spw == "":
        print "Usage: abschanwidth(vis, spw)"
        return 0

    myvis = vis
    myspw = spw
    mytb = taskinit.tbtool()

    mytb.open(myvis + "/SPECTRAL_WINDOW")
    if spw >= mytb.nrows() or spw < 0:
        print "Error: spw out of range. Min is 0. Max is ", mytb.nrows() - 1
        return 0

    mychw = mytb.getcell("CHAN_WIDTH", spw)[0]
    mytb.close()

    return numpy.fabs(mychw)
开发者ID:radio-astro,项目名称:casa,代码行数:25,代码来源:weights.py

示例5: scanbystate

def scanbystate(vis,undo=False):

    mytb=taskinit.tbtool()

    mytb.open(vis,nomodify=False)
    scans=mytb.getcol('SCAN_NUMBER')
    states=mytb.getcol('STATE_ID')
    print 'Unique STATE_IDs = ',str(pl.unique(states))
    maxstate=states.max()

    if undo:
        d=10**int(floor(log10(scans.min())))
        if d<10:
            mytb.close()
            raise Exception, 'Apparently, nothing to undo'
        scans-=states
        scans/=d
        print 'New SCAN_NUMBER = (SCAN_NUMBER - STATE_ID) / '+str(d)
    else:
        m=10**int(floor(log10(states.max())+1.0))
        scans*=m
        scans+=states
        print 'New SCAN_NUMBER = SCAN_NUMBER * '+str(m)+' + STATE_ID'

    mytb.putcol('SCAN_NUMBER',scans)
    mytb.close()
开发者ID:schiebel,项目名称:casa,代码行数:26,代码来源:almapolhelpers.py

示例6: getnch

def getnch(vis="", spw=""):

    """
    Usage: getnch(vis, spw)
           Get the nchan for the given spw.
           Returns 0 upon error.
    """

    if vis == "" or spw == "":
        print "Usage: abschanwidth(vis, spw)"
        return 0

    myvis = vis
    myspw = spw
    mytb = taskinit.tbtool()

    mytb.open(myvis + "/SPECTRAL_WINDOW")
    if spw >= mytb.nrows() or spw < 0:
        print "Error: spw out of range. Min is 0. Max is ", mytb.nrows() - 1
        return 0

    mynch = mytb.getcell("NUM_CHAN", spw)
    mytb.close()

    return numpy.abs(mynch)
开发者ID:radio-astro,项目名称:casa,代码行数:25,代码来源:weights.py

示例7: dxy

def dxy(dtab,xytab,dout):

    mytb=taskinit.tbtool()

    os.system('cp -r '+dtab+' '+dout)

    # How many spws
    mytb.open(dtab+'/SPECTRAL_WINDOW')
    nspw=mytb.nrows()
    mytb.close()


    for ispw in range(nspw):
        mytb.open(xytab)
        st=mytb.query('SPECTRAL_WINDOW_ID=='+str(ispw))
        x=st.getcol('CPARAM')
        st.close()
        mytb.close()

        mytb.open(dout,nomodify=False)
        st=mytb.query('SPECTRAL_WINDOW_ID=='+str(ispw))
        d=st.getcol('CPARAM')

        # the following assumes all antennas and chans same in both tables.

        # Xinv.D.X:
        d[0,:,:]*=pl.conj(x[0,:,:])
        d[1,:,:]*=x[0,:,:]

        st.putcol('CPARAM',d)
        st.close()
        mytb.close()
开发者ID:schiebel,项目名称:casa,代码行数:32,代码来源:almapolhelpers.py

示例8: getColShape

def getColShape(table,col,start_row=0,nrow=1,row_inc=1):
    """ Get the shape of the given column.
    Keyword arguments:
        table      --    input table or MS
        col        --    column to get the shape
        start_row  --    start row (default 0)
        nrow       --    number of rows to read (default 1)
        row_inc    --    increment of rows to read (default 1)
        
        Return a list of strings with the shape of each row in the column.
    
    """

    col_shape = []
    try:
        try:
            tblocal = tbtool()
            tblocal.open(table)
            col_shape = tblocal.getcolshapestring(col,start_row,nrow,row_inc)
        except:
            print 'Cannot get shape of col %s from table %s '%(col,table)

    finally:
        tblocal.close()
            
    return col_shape
开发者ID:schiebel,项目名称:casa,代码行数:26,代码来源:testhelper.py

示例9: test_unapply_clip_and_unset_flagrow

    def test_unapply_clip_and_unset_flagrow(self):
        '''flagcmd: Check that FLAG_ROW is unset after un-applying a clip agent'''
        # Remove any cmd from table
        flagcmd(vis=self.vis, action='clear', clearall=True)

        # Flag using manual agent
        myinput = "scan='4'"
        filename = create_input(myinput)
        flagcmd(vis=self.vis, inpmode='list', inpfile=filename, action='apply', savepars=False)
        
        # Check FLAG_ROW is all set to true
        mytb = tbtool()
        mytb.open(self.vis)
        selectedtb = mytb.query('SCAN_NUMBER in [4]')
        FLAG_ROW = selectedtb.getcol('FLAG_ROW')
        mytb.close()        
        selectedtb.close()
        self.assertEqual(FLAG_ROW.sum(), FLAG_ROW.size)
        
        # Flag using tfcrop agent from file
        myinput = "scan='4' mode=clip "
        filename = create_input(myinput)
        flagcmd(vis=self.vis, inpmode='list', inpfile=filename, action='apply', savepars=True,
                flagbackup=False)
        
        # Check FLAG_ROW is all set to true
        mytb = tbtool()
        mytb.open(self.vis)
        selectedtb = mytb.query('SCAN_NUMBER in [4]')
        FLAG_ROW = selectedtb.getcol('FLAG_ROW')
        mytb.close()           
        selectedtb.close()
        self.assertEqual(FLAG_ROW.sum(), FLAG_ROW.size)
        
        # Unapply only the tfcrop line
        flagcmd(vis=self.vis, action='unapply', useapplied=True, tablerows=0, savepars=False)
       
        # Check FLAG_ROW is now all set to false
        mytb = tbtool()
        mytb.open(self.vis)
        selectedtb = mytb.query('SCAN_NUMBER in [4]')
        FLAG_ROW = selectedtb.getcol('FLAG_ROW')
        mytb.close()        
        selectedtb.close()
        self.assertEqual(FLAG_ROW.sum(), 0)
开发者ID:radio-astro,项目名称:casa,代码行数:45,代码来源:test_flagcmd.py

示例10: xyamb

def xyamb(xytab,qu,xyout=''):

    mytb=taskinit.tbtool()

    if not isinstance(qu,tuple):
        raise Exception,'qu must be a tuple: (Q,U)'

    if xyout=='':
        xyout=xytab
    if xyout!=xytab:
        os.system('cp -r '+xytab+' '+xyout)

    QUexp=complex(qu[0],qu[1])
    print 'Expected QU = ',qu   # , '  (',pl.angle(QUexp)*180/pi,')'

    mytb.open(xyout,nomodify=False)

    QU=mytb.getkeyword('QU')['QU']
    P=pl.sqrt(QU[0,:]**2+QU[1,:]**2)

    nspw=P.shape[0]
    for ispw in range(nspw):
        st=mytb.query('SPECTRAL_WINDOW_ID=='+str(ispw))
        if (st.nrows()>0):
            q=QU[0,ispw]
            u=QU[1,ispw]
            qufound=complex(q,u)
            c=st.getcol('CPARAM')
            fl=st.getcol('FLAG')
            xyph0=pl.angle(pl.mean(c[0,:,:][pl.logical_not(fl[0,:,:])]),True)
            print 'Spw = '+str(ispw)+': Found QU = '+str(QU[:,ispw])  # +'   ('+str(pl.angle(qufound)*180/pi)+')'
            #if ( (abs(q)>0.0 and abs(qu[0])>0.0 and (q/qu[0])<0.0) or
            #     (abs(u)>0.0 and abs(qu[1])>0.0 and (u/qu[1])<0.0) ):
            if ( pl.absolute(pl.angle(qufound/QUexp)*180/pi)>90.0 ):
                c[0,:,:]*=-1.0
                xyph1=pl.angle(pl.mean(c[0,:,:][pl.logical_not(fl[0,:,:])]),True)
                st.putcol('CPARAM',c)
                QU[:,ispw]*=-1
                print '   ...CONVERTING X-Y phase from '+str(xyph0)+' to '+str(xyph1)+' deg'
            else:
                print '      ...KEEPING X-Y phase '+str(xyph0)+' deg'
            st.close()
    QUr={}
    QUr['QU']=QU
    mytb.putkeyword('QU',QUr)
    mytb.close()
    QUm=pl.mean(QU[:,P>0],1)
    QUe=pl.std(QU[:,P>0],1)
    Pm=pl.sqrt(QUm[0]**2+QUm[1]**2)
    Xm=0.5*atan2(QUm[1],QUm[0])*180/pi

    print 'Ambiguity resolved (spw mean): Q=',QUm[0],'U=',QUm[1],'(rms=',QUe[0],QUe[1],')','P=',Pm,'X=',Xm

    stokes=[1.0,QUm[0],QUm[1],0.0]
    print 'Returning the following Stokes vector: '+str(stokes)
    
    return stokes
开发者ID:schiebel,项目名称:casa,代码行数:57,代码来源:almapolhelpers.py

示例11: clearcal

def clearcal(
    vis=None,
    field=None,
    spw=None,
    intent=None,
    addmodel=None,
    ):

    casalog.origin('clearcal')

    # Do the trivial parallelization
    if ParallelTaskHelper.isParallelMS(vis):
        helper = ParallelTaskHelper('clearcal', locals())
        helper.go()
        return

    # Local versions of the tools
    tblocal = tbtool()
    cblocal = cbtool()
    mslocal = mstool()

    try:

        # we will initialize scr cols only if we don't create them
        doinit = False

        if (type(vis) == str) & os.path.exists(vis):
            tblocal.open(vis)
            doinit = tblocal.colnames().count('CORRECTED_DATA') > 0
            tblocal.close()

            # We ignore selection if creating the scratch columns
            if not doinit:
                casalog.post('Need to create scratch columns; ignoring selection.'
                             )

            cblocal.open(vis, addmodel=addmodel)
        else:
            raise Exception, \
                'Visibility data set not found - please verify the name'

        # If necessary (scr col not just created), initialize scr cols
        if doinit:
            cblocal.selectvis(field=field, spw=spw, intent=intent)
            cblocal.initcalset(1)
        cblocal.close()

        # Write history to the MS
        param_names = clearcal.func_code.co_varnames[:clearcal.func_code.co_argcount]
        param_vals = [eval(p) for p in param_names]
        casalog.post('Updating the history in the output', 'DEBUG1')
        write_history(mslocal, vis, 'clearcal', param_names,
                      param_vals, casalog)
        
    except Exception, instance:

        print '*** Error ***', instance
开发者ID:keflavich,项目名称:casa,代码行数:57,代码来源:task_clearcal.py

示例12: copy_model_RRtoLL

def copy_model_RRtoLL(vis):
    # copy RR column of model_data column to LL
    tb = tbtool()
    tb.open(vis,nomodify=False)
    model_vis = tb.getcol('MODEL_DATA')
    model_vis[3,:,:] = model_vis[0,:,:] # copy RR model column to LL model column
    tb.putcol('MODEL_DATA',model_vis)
    tb.unlock()
    tb.close()
开发者ID:jackievilladsen,项目名称:dynspec,代码行数:9,代码来源:ms2dynspec.py

示例13: getavweight

def getavweight(vis="", field=[], spw=""):

    """
    Usage: getavweight(vis, field, spw)
           Get the average weight for the given field and spw.
           The field parameter takes a list of fields.
    """

    if vis == "" or spw == "" or field == [] or not type(field) == list:
        print "Usage: getavweight(vis, field, spw)"
        print "       The field parameter takes a list of fields."
        return False

    myvis = vis
    myspw = spw
    myfields = field
    mytb = taskinit.tbtool()

    mytb.open(myvis)
    w = mytb.getcol("WEIGHT")
    dd = mytb.getcol("DATA_DESC_ID")
    ff = mytb.getcol("FIELD_ID")
    mytb.close()

    mytb.open(myvis + "/DATA_DESCRIPTION")
    mydds = []

    for i in range(0, mytb.nrows()):
        if mytb.getcell("SPECTRAL_WINDOW_ID", i) != myspw:
            continue
        else:
            mydds.append(i)

    mytb.close()

    mynrows = 0
    mysumw = 0

    npol = len(w)

    if len(mydds) > 0:
        for row in range(0, len(dd)):
            if (dd[row] in mydds) and (ff[row] in myfields):
                mynrows += 1
                for i in range(0, npol):
                    mysumw += w[i][row]

    rval = 0.0

    if mynrows > 0:
        rval = mysumw / float(npol) / float(mynrows)
        print "Average weight is ", rval
    else:
        print "No rows selected."

    return rval
开发者ID:radio-astro,项目名称:casa,代码行数:56,代码来源:weights.py

示例14: copy_data_RRtoLL

def copy_data_RRtoLL(vis):
    # copy RR column of data column to LL
    # doesn't account for different flags on RR and LL
    tb = tbtool()
    tb.open(vis,nomodify=False)
    data_vis = tb.getcol('DATA')
    data_vis[3,:,:] = data_vis[0,:,:] # copy RR model column to LL model column
    tb.putcol('DATA',data_vis)
    tb.unlock()
    tb.close()
开发者ID:jackievilladsen,项目名称:dynspec,代码行数:10,代码来源:ms2dynspec.py

示例15: test_model_keys

 def test_model_keys(self):
     '''partition: CAS-4398, handle the MODEL keywords correctly'''
     
     print '*** Check that MODEL_DATA is not present in MS first'
     mytb = tbtool()
     try:
         mytb.open(self.msfile+'/MODEL_DATA')
     except Exception, instance:
         print '*** Expected exception. \"%s\"'%instance
         mytb.close()
开发者ID:keflavich,项目名称:casa,代码行数:10,代码来源:test_partition.py


注:本文中的taskinit.tbtool函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。