Esempio n. 1
0
 def setUp_vis_a(self):
     # 308 scans, spw=0, data
     if testmms:
         os.system('cp -RL ' + datapath + vis_a + ' .')
     elif (not os.path.exists(vis_a)):
         importuvfits(fitsfile=os.environ.get('CASAPATH').split()[0] + '/data/regression/ngc4826/fitsfiles/ngc4826.ll.fits5', # 10 MB
                      vis=vis_a)
Esempio n. 2
0
 def setUp_vis_a(self):
     # 308 scans, spw=0, data
     if testmms:
         os.system('cp -RL ' + datapath + vis_a + ' .')
     elif (not os.path.exists(vis_a)):
         importuvfits(
             fitsfile=os.environ.get('CASAPATH').split()[0] +
             '/data/regression/ngc4826/fitsfiles/ngc4826.ll.fits5',  # 10 MB
             vis=vis_a)
Esempio n. 3
0
def main(thislist, axis='auto', numsubms=4):

    if thislist == []:
        print 'Need list of tasks to run.'
        usage()
        os._exit(0)

    print "Will create MMS for the following tasks %s" % thislist
    print

    # Loop through task list
    for t in thislist:
        if t not in TASKLIST:
            print 'ERROR: task ' + t + ' is not in TASKLIST. Run this script with -l for the full list.'
            os._exit(0)

#       if t == 'flagdata':


#            axis='scan'

        mmstest(t, axis, numsubms)

    from tasks import partition, importuvfits

    #    if 'listvis' in thislist:
    #        # NOTE for test_listvis data:
    #        # You need to run partition by hand to create an MMS for the single-dish data set
    #        SDPATH = DATAPATH + 'unittest/listvis/'
    #        SDMMS = './unittest_mms/listvis/'
    #
    #        partition(vis=SDPATH+'OrionS_rawACSmod', outputvis=SDMMS+'OrionS_rawACSmod.mms',
    #                  datacolumn='float_data', createmms=True, flagbackup=False)

    if 'split' in thislist:
        # some additional MMSs
        SPLITMMSPATH = './unittest_mms/split/'
        specialcase = [
            '0420+417/0420+417.ms', 'viewertest/ctb80-vsm.ms',
            'split/labelled_by_time+ichan.ms'
        ]
        for myms in specialcase:
            shutil.rmtree(SPLITMMSPATH + os.path.basename(myms),
                          ignore_errors=True)
            partition(vis=DATAPATH + myms,
                      outputvis=SPLITMMSPATH + os.path.basename(myms),
                      datacolumn='all',
                      flagbackup=False)

        # workaround for a partition shortcoming: column keywords not copied
        tb.open(SPLITMMSPATH + 'hasfc.mms/SUBMSS/hasfc.0000.ms/',
                nomodify=False)
        tb.putcolkeyword('FLAG_CATEGORY', 'CATEGORY',
                         ['FLAG_CMD', 'ORIGINAL', 'USER'])
        tb.close()

    if 'wvrgcal' in thislist:
        WVRGCALMMSPATH = './unittest_mms/wvrgcal/'
        WVRGCALPATH = DATAPATH + 'unittest/wvrgcal/input/'
        origwd = os.getcwd()
        os.chdir(WVRGCALMMSPATH)
        shutil.rmtree('input', ignore_errors=True)
        os.mkdir('input')
        os.chdir('input')
        mydirs = os.listdir(WVRGCALPATH)
        for d in mydirs:
            print d
            if os.path.splitext(d)[1] == '.ms':
                partition(vis=WVRGCALPATH + d,
                          outputvis=d,
                          datacolumn='all',
                          numsubms=5,
                          flagbackup=False)
            else:
                os.symlink(WVRGCALPATH + d, d)
        os.chdir(origwd)

    if ('concat' in thislist):
        CONCATMMSPATH = './unittest_mms/concat/'
        CONCATPATH = DATAPATH + 'unittest/concat/input/'
        origwd = os.getcwd()
        os.chdir(CONCATMMSPATH)
        shutil.rmtree('input', ignore_errors=True)
        os.mkdir('input')
        os.chdir('input')
        mydirs = os.listdir(CONCATPATH)
        for d in mydirs:
            print d
            if os.path.splitext(d)[1] == '.ms':
                partition(vis=CONCATPATH + d,
                          outputvis=d,
                          datacolumn='all',
                          numsubms=6,
                          flagbackup=False)
            else:
                os.symlink(CONCATPATH + d, d)
        os.chdir(origwd)

    if ('cvel' in thislist):

        CVELPATH = DATAPATH + 'ngc4826/fitsfiles/'
        MMSPATH = './unittest_mms/cvel/'
        mmsdir = MMSPATH + 'ngc4826.mms'
        tempdir = 'makemmsdirtemp'
        os.system('mkdir ' + tempdir)
        importuvfits(fitsfile=CVELPATH + 'ngc4826.ll.fits5',
                     vis=tempdir + '/ngc4826.ms')
        partition(vis=tempdir + '/ngc4826.ms',
                  outputvis=MMSPATH + 'ngc4826.mms',
                  separationaxis='scan',
                  flagbackup=False,
                  datacolumn='all')
        os.system('rm -rf ' + tempdir)

        CVELPATH = DATAPATH + 'cvel/input/'
        cvelfiles = [
            'jupiter6cm.demo-thinned.ms',
            'g19_d2usb_targets_line-shortened-thinned.ms',
            'evla-highres-sample-thinned.ms'
        ]
        MMSPATH = './unittest_mms/cvel/'
        thisdir = os.getcwd()
        for cvelms in cvelfiles:
            mmsname = cvelms.replace('.ms', '.mms')
            partition(vis=CVELPATH + cvelms,
                      outputvis=MMSPATH + mmsname,
                      separationaxis='scan',
                      flagbackup=False,
                      datacolumn='all',
                      numsubms=4)
            os.chdir(MMSPATH)
            os.system('ln -s ' + mmsname + ' ' + cvelms)
            os.chdir(thisdir)

        # Create the jup.mms file
        mmsname = 'jup.mms'
        output = MMSPATH + mmsname
        split2(vis=MMSPATH + '/jupiter6cm.demo-thinned.mms',
               outputvis=output,
               field='JUPITER',
               datacolumn='data')
        tblocal = tbtool()
        tblocal.open(output, nomodify=False)
        a = tblocal.getcol('TIME')
        delta = (54709. * 86400 - a[0])
        a = a + delta
        strt = a[0]
        tblocal.putcol('TIME', a)
        a = tblocal.getcol('TIME_CENTROID')
        a = a + delta
        tblocal.putcol('TIME_CENTROID', a)
        tblocal.close()
        tblocal.open(output + '/OBSERVATION', nomodify=False)
        a = tblocal.getcol('TIME_RANGE')
        delta = strt - a[0][0]
        a = a + delta
        tblocal.putcol('TIME_RANGE', a)
        tblocal.close()
        tblocal.open(output + '/FIELD', nomodify=False)
        a = tblocal.getcol('TIME')
        delta = strt - a[0]
        a = a + delta
        tblocal.putcol('TIME', a)
        tblocal.close()
        mslocal = mstool()
        mslocal.open(output, nomodify=False)
        mslocal.addephemeris(
            0,
            os.environ.get('CASAPATH').split()[0] +
            '/data/ephemerides/JPL-Horizons/Jupiter_54708-55437dUTC.tab',
            'Jupiter_54708-55437dUTC', 0)
        mslocal.close()

        CVELMS = DATAPATH + 'fits-import-export/input/test.ms'
        MMSPATH = './unittest_mms/cvel/'
        thisdir = os.getcwd()
        partition(vis=CVELMS,
                  outputvis=MMSPATH + 'test.mms',
                  separationaxis='scan',
                  flagbackup=False,
                  datacolumn='all',
                  numsubms=4)
        os.chdir(MMSPATH)
        os.system('ln -s test.mms test.ms')
        os.chdir(thisdir)

    if ('fixvis' in thislist):
        MSPATH = os.environ.get(
            'CASAPATH').split()[0] + '/data/regression/0420+417/'
        MSNAME = MSPATH + '0420+417.ms'
        MMSPATH = './unittest_mms/fixvis/'
        MMSNAME = MMSPATH + '0420+417.mms'
        partition(vis=MSNAME,
                  outputvis=MMSNAME,
                  datacolumn='all',
                  separationaxis=axis,
                  numsubms=numsubms,
                  flagbackup=False)
        # Create symlink
        thisdir = os.getcwd()
        os.chdir(MMSPATH)
        os.system('ln -s 0420+417.mms 0420+417.ms')
        os.chdir(thisdir)
Esempio n. 4
0
def main(thislist, axis='auto', numsubms=4):
    
    if thislist == []:
        print 'Need list of tasks to run.'
        usage()
        os._exit(0)
        
    print "Will create MMS for the following tasks %s"%thislist
    print
    
    # Loop through task list
    for t in thislist:
        if t not in TASKLIST:
            print 'ERROR: task '+t+' is not in TASKLIST. Run this script with -l for the full list.'
            os._exit(0)
            
 #       if t == 'flagdata':
#            axis='scan'
            
        mmstest(t, axis, numsubms)

    from tasks import partition,importuvfits

#    if 'listvis' in thislist:
#        # NOTE for test_listvis data:
#        # You need to run partition by hand to create an MMS for the single-dish data set
#        SDPATH = DATAPATH + 'unittest/listvis/'
#        SDMMS = './unittest_mms/listvis/'
#    
#        partition(vis=SDPATH+'OrionS_rawACSmod', outputvis=SDMMS+'OrionS_rawACSmod.mms', 
#                  datacolumn='float_data', createmms=True, flagbackup=False)

    if 'split' in thislist:
        # some additional MMSs
        SPLITMMSPATH = './unittest_mms/split/'
        specialcase = ['0420+417/0420+417.ms',
                       'viewertest/ctb80-vsm.ms',
                       'split/labelled_by_time+ichan.ms']
        for myms in specialcase:
            shutil.rmtree(SPLITMMSPATH+os.path.basename(myms), ignore_errors=True)
            partition(vis=DATAPATH+myms, outputvis=SPLITMMSPATH+os.path.basename(myms), 
                      datacolumn='all', flagbackup=False)

        # workaround for a partition shortcoming: column keywords not copied
        tb.open(SPLITMMSPATH+'hasfc.mms/SUBMSS/hasfc.0000.ms/', nomodify=False)
        tb.putcolkeyword('FLAG_CATEGORY','CATEGORY', ['FLAG_CMD', 'ORIGINAL', 'USER'])
        tb.close()


    if 'wvrgcal' in thislist:
        WVRGCALMMSPATH = './unittest_mms/wvrgcal/'
        WVRGCALPATH = DATAPATH+'unittest/wvrgcal/input/'
        origwd = os.getcwd()
        os.chdir(WVRGCALMMSPATH)
        shutil.rmtree('input', ignore_errors=True)
        os.mkdir('input')
        os.chdir('input')
        mydirs = os.listdir(WVRGCALPATH)
        for d in mydirs:
            print d
            if  os.path.splitext(d)[1]=='.ms':
                partition(vis=WVRGCALPATH+d, outputvis=d, datacolumn='all', numsubms=5,
                          flagbackup=False)
            else:
                os.symlink(WVRGCALPATH+d, d)
        os.chdir(origwd)

    if ('concat' in thislist):
        CONCATMMSPATH = './unittest_mms/concat/'
        CONCATPATH = DATAPATH+'unittest/concat/input/'
        origwd = os.getcwd()
        os.chdir(CONCATMMSPATH)
        shutil.rmtree('input', ignore_errors=True)
        os.mkdir('input')
        os.chdir('input')
        mydirs = os.listdir(CONCATPATH)
        for d in mydirs:
            print d
            if os.path.splitext(d)[1]=='.ms':
                partition(vis=CONCATPATH+d, outputvis=d, datacolumn='all', numsubms=6,
                          flagbackup=False)
            else:
                os.symlink(CONCATPATH+d, d)
        os.chdir(origwd)
        
    if ('cvel' in thislist):

        CVELPATH = DATAPATH + 'ngc4826/fitsfiles/'
        MMSPATH = './unittest_mms/cvel/'
        mmsdir = MMSPATH+'ngc4826.mms'
        tempdir = 'makemmsdirtemp'
        os.system('mkdir '+tempdir)
        importuvfits(fitsfile=CVELPATH+'ngc4826.ll.fits5',vis=tempdir+'/ngc4826.ms') 
        partition(vis=tempdir+'/ngc4826.ms',outputvis=MMSPATH+'ngc4826.mms',separationaxis='scan',flagbackup=False,datacolumn='all')
        os.system('rm -rf '+tempdir)      
        
        CVELPATH = DATAPATH + 'cvel/input/'
        cvelfiles =['jupiter6cm.demo-thinned.ms','g19_d2usb_targets_line-shortened-thinned.ms','evla-highres-sample-thinned.ms']
        MMSPATH = './unittest_mms/cvel/'
        thisdir = os.getcwd()
        for cvelms in cvelfiles:
            mmsname = cvelms.replace('.ms','.mms')
            partition(vis=CVELPATH+cvelms,outputvis=MMSPATH+mmsname,separationaxis='scan',flagbackup=False,datacolumn='all', numsubms=4)
            os.chdir(MMSPATH)
            os.system('ln -s '+ mmsname + ' ' + cvelms)
            os.chdir(thisdir)
            
        # Create the jup.mms file
        mmsname = 'jup.mms'
        output = MMSPATH+mmsname
        split2(vis=MMSPATH+'/jupiter6cm.demo-thinned.mms', outputvis=output, field='JUPITER', datacolumn='data')
        tblocal = tbtool()
        tblocal.open(output, nomodify=False)
        a = tblocal.getcol('TIME')
        delta = (54709.*86400-a[0])
        a = a + delta
        strt = a[0]
        tblocal.putcol('TIME', a)
        a = tblocal.getcol('TIME_CENTROID')
        a = a + delta
        tblocal.putcol('TIME_CENTROID', a)
        tblocal.close()
        tblocal.open(output+'/OBSERVATION', nomodify=False)
        a = tblocal.getcol('TIME_RANGE')
        delta = strt - a[0][0]
        a = a + delta
        tblocal.putcol('TIME_RANGE', a)
        tblocal.close()
        tblocal.open(output+'/FIELD', nomodify=False)
        a = tblocal.getcol('TIME')
        delta = strt - a[0]
        a = a + delta
        tblocal.putcol('TIME', a)
        tblocal.close()
        mslocal = mstool()
        mslocal.open(output, nomodify=False)
        mslocal.addephemeris(0,os.environ.get('CASAPATH').split()[0]+'/data/ephemerides/JPL-Horizons/Jupiter_54708-55437dUTC.tab',
                        'Jupiter_54708-55437dUTC', 0)
        mslocal.close()
        
        CVELMS = DATAPATH + 'fits-import-export/input/test.ms'
        MMSPATH = './unittest_mms/cvel/'
        thisdir = os.getcwd()
        partition(vis=CVELMS, outputvis=MMSPATH+'test.mms', separationaxis='scan',flagbackup=False,datacolumn='all', numsubms=4)
        os.chdir(MMSPATH)
        os.system('ln -s test.mms test.ms')
        os.chdir(thisdir)
                
    if ('fixvis' in thislist):
        MSPATH = os.environ.get('CASAPATH').split()[0]+'/data/regression/0420+417/'
        MSNAME = MSPATH + '0420+417.ms'
        MMSPATH = './unittest_mms/fixvis/'
        MMSNAME = MMSPATH + '0420+417.mms'
        partition(vis=MSNAME, outputvis=MMSNAME, datacolumn='all', separationaxis=axis,numsubms=numsubms,flagbackup=False)
        # Create symlink
        thisdir = os.getcwd()
        os.chdir(MMSPATH)
        os.system('ln -s 0420+417.mms 0420+417.ms')
        os.chdir(thisdir)