Source
casalog.post(' ** = Denotes caltable that only corrected a subset of total selected visibilities')
import os
import time
import numpy as np
from taskinit import *
from mstools import write_history
from callibrary import *
import flaghelper as fh
from parallel.parallel_data_helper import ParallelDataHelper
from parallel.parallel_task_helper import ParallelTaskHelper
def applycal(
vis=None,
field=None,
spw=None,
intent=None,
selectdata=None,
timerange=None,
uvrange=None,
antenna=None,
scan=None,
observation=None,
msselect=None,
docallib=None,
callib=None,
gaintable=None,
gainfield=None,
interp=None,
spwmap=None,
calwt=None,
parang=None,
applymode=None,
flagbackup=None,
):
# Python script
casalog.origin('applycal')
# Take care of the trivial parallelization
if ParallelDataHelper.isMMSAndNotServer(vis):
# Back up the flags, if requested (and if necessary)
if flagbackup and applymode != 'calonly' and applymode != 'trial':
fh.backupFlags(aflocal=None, msfile=vis, prename='applycal')
flagbackup = False
# To be safe convert file names to absolute paths.
gaintable = ParallelTaskHelper.findAbsPath(gaintable)
helper = ParallelTaskHelper('applycal', locals())
ret = helper.go()
if ParallelTaskHelper.getAsyncMode():
return ret
else:
return
try:
mycb = cbtool()
if (type(vis) == str) & os.path.exists(vis):
# add CORRECTED_DATA column
mycb.open(filename=vis, compress=False, addcorr=True,
addmodel=False)
else:
raise Exception, \
'Visibility data set not found - please verify the name'
# enforce default if unspecified
if applymode == '':
applymode = 'calflag'
# Back up the flags, if requested (and if necessary)
if flagbackup and applymode != 'calonly' and applymode \
!= 'trial':
fh.backupFlags(aflocal=None, msfile=vis, prename='applycal')
# Do data selection according to selectdata
if selectdata:
# pass all data selection parameters in as specified
mycb.selectvis(
time=timerange,
spw=spw,
scan=scan,
field=field,
intent=intent,
observation=str(observation),
baseline=antenna,
uvrange=uvrange,
chanmode='none',
msselect=msselect,
)
else:
# selectdata=F, so time,scan,baseline,uvrange,msselect=''