from __future__ import absolute_import
from casatasks.private.casa_transition import is_CASA6
from casatasks import casalog
from casatools import calibrater
from . import correct_ant_posns as getantposns
from .jyperk import gen_factor_via_web_api, JyPerKReader4File
import correct_ant_posns as getantposns
(_cb,) = gentools(['cb'])
def gencal(vis=None, caltable=None, caltype=None, infile='None',
endpoint='asdm', timeout=180, retry=3, retry_wait_time=5, ant_pos_time_limit=0,
spw=None, antenna=None, pol=None,
parameter=None, uniform=None):
"""Externally specify calibration solutions of various types.
vis {str} -- The file path stored the visibility data.
caltable {str} -- A file name which store the caltable.
caltype {str} -- The calibration type.
Subparameter of caltype='gc|gceff|tecim|jyperk'
infile {str} -- Specifies the name of the file to read.
subparameter of caltype='jyperk:
endpoint {str} -- The endpoint of the Jy/K DB Web API to access.
options are 'asdm' (default), 'model-fit', 'interpolation'.
timeout {int} -- Maximum waiting time [sec] for the Web API access,
retry {int} -- Number of retry when the Web API access fails,
retry_wait_time {int} -- Waiting time [sec] until next query
when the Web API access fails, defaults to 5 sec.
spw {str} -- The spectral windows.
antenna {str} -- Select data based on antenna/baseline.
pol {str} -- Polarization selection for specified parameters.
parameter {doubleVec} -- The calibration values.
uniform {bool} -- Assume uniform calibration values across the array.
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 == 'jyperk' and endpoint not in ['asdm', 'interpolation', 'model-fit']:
raise ValueError('When the caltype is jyperk, endpoint must be one of asdm, interpolation or model-fit')
if not ((type(vis) == str) and (os.path.exists(vis))):
raise ValueError('Visibility data set not found - please verify the name')
if caltype not in ['antpos', 'jyperk']:
gencal = __gencal_factory[gencal_type]
gencal.gencal(vis=vis, caltable=caltable, caltype=caltype, infile=infile,
endpoint=endpoint, timeout=timeout, retry=retry, retry_wait_time=retry_wait_time,
ant_pos_time_limit=ant_pos_time_limit, spw=spw, antenna=antenna, pol=pol, parameter=parameter, uniform=uniform)
def gencal(cls, vis=None, caltable=None, caltype=None, infile='None',
endpoint='asdm', timeout=180, retry=3, retry_wait_time=5, ant_pos_time_limit=0,
spw=None, antenna=None, pol=None,
parameter=None, uniform=None):
_cb.open(filename=vis, compress=False, addcorr=False, addmodel=False)
_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')