from __future__ import absolute_import
from casatasks.private.casa_transition import is_CASA6
from casatools import calibrater
from casatasks import casalog
from . import correct_ant_posns as getantposns
import correct_ant_posns as getantposns
(_cb,) = gentools(['cb'])
def gencal(vis=None,caltable=None,caltype=None,infile=None,
spw=None,antenna=None,pol=None,
parameter=None,uniform=None):
""" Externally specify calibration solutions af various types
if ((type(vis)==str) & (os.path.exists(vis))):
_cb.open(filename=vis,compress=False,addcorr=False,addmodel=False)
raise ValueError('Visibility data set not found - please verify the name')
raise ValueError('A caltable name must be specified')
if caltype=='tecim' and not (type(infile)==str and os.path.exists(infile)):
raise ValueError('An existing tec map must be specified in infile')
if (caltype=='antpos' and antenna==''):
casalog.post(" Determine antenna position offsets from the baseline correction database")
antenna_offsets=getantposns.correct_ant_posns(vis,False)
if ((len(antenna_offsets)==3) and
(int(antenna_offsets[0])==0) and
(len(antenna_offsets[1])>0) ) :
antenna = antenna_offsets[1]
parameter = antenna_offsets[2]
warnings.simplefilter('error',UserWarning)
warnings.warn('No offsets found. No caltable created.')
_cb.specifycal(caltable=caltable,time="",spw=spw,antenna=antenna,pol=pol,
caltype=caltype,parameter=parameter,infile=infile,
except UserWarning as instance:
casalog.post('*** UserWarning *** %s' % instance, 'WARN')