import numpy.random as random
from casatasks import casalog
from casatools import calibrater, ms, table
from .mstools import write_history
def sdcal(infile=None, calmode='tsys', fraction='10%', noff=-1,
width=0.5, elongated=False, applytable='', interp='', spwmap={},
outfile='', overwrite=False, field='', spw='', scan='', intent=''):
"""Externally specify calibration solutions of various types."""
handle_composite_mode(locals())
raise UserWarning("Scan input must be ''(=all) in calmode='tsys'.")
raise UserWarning("Spw input must be ''(=all) in calmode='tsys'.")
if isinstance(infile, str) and os.path.exists(infile):
addcorr = calmode == 'apply'
cb.open(filename=infile, compress=False, addcorr=addcorr, addmodel=False)
cb.selectvis(spw=spw, scan=scan, field=field)
raise Exception('Infile data set not found - please verify the name')
if not isinstance(calmode, str):
raise Exception("Calmode must be a string")
if calmode.lower() not in ['tsys', 'ps', 'otfraster', 'otf', 'apply']:
"Calmode must be either 'ps' or 'otfraster' or 'otf' or 'tsys' or 'apply'.")
if (not overwrite) and os.path.exists(outfile):
raise RuntimeError("overwrite is False and output file exists: {}".format(outfile))
if isinstance(applytable, str):
_table_list = [applytable]
if isinstance(applytable, list) or isinstance(applytable, numpy.ndarray):
if len(_table_list) == 0:
raise Exception('Applytable name must be specified.')
for _table_name in _table_list:
if len(_table_name) == 0:
raise Exception('Applytable name must be specified.')
if not os.path.exists(_table_name):
raise Exception("Table doesn't exist: {}".format(_table_name))
warning_msg = '\n'.join([
'The outfile you specified will NOT be created.',
"Calibrated data will be stored in a new 'CORRECTED_DATA' column",
'inserted in the main table of the input MS file.'
casalog.post(warning_msg, priority="WARN")
if(type(spwmap) != list and (type(spwmap) != dict)):