from __future__ import absolute_import
from __future__ import print_function
from mstools import write_history
from parallel.parallel_data_helper import ParallelDataHelper
from parallel.parallel_task_helper import ParallelTaskHelper
# get is_CASA6 and is_python3
from casatasks.private.casa_transition import *
from casatools import calibrater, ms
from casatasks import casalog
from .mstools import write_history
from .parallel.parallel_task_helper import ParallelTaskHelper
from mstools import write_history
from parallel.parallel_data_helper import ParallelDataHelper
from parallel.parallel_task_helper import ParallelTaskHelper
def initweights(vis=None,wtmode=None,tsystable=None,gainfield=None,interp=None,spwmap=None,dowtsp=None):
casalog.origin('initweights')
# Do the trivial parallelization
if ParallelTaskHelper.isMPIEnabled() and ParallelDataHelper.isMMSAndNotServer(vis):
tsystable = ParallelTaskHelper.findAbsPath(tsystable)
helper = ParallelTaskHelper('initweights', locals())
param_names = initweights.__code__.co_varnames[:initweights.__code__.co_argcount]
param_vals = [eval(p) for p in param_names]
param_vals = [vars[p] for p in param_names]
param_vals = [eval(p) for p in param_names]
casalog.post('Updating the history in the output', 'DEBUG1')
write_history(ms, vis, 'initweights', param_names,
except Exception as instance:
casalog.post("*** Error \'%s\' updating HISTORY" % (instance),
if ((type(vis)==str) & (os.path.exists(vis))):
if wtmode.upper().find("TSYS") > -1:
if not os.path.exists(tsystable):
raise Exception('Tsys calibration table %s not found' % tsystable)
raise Exception('Visibility data set not found - please verify the name')
# When running in parallel, history will be written in the parallel section above
# normal MSs should write the history here
if ParallelTaskHelper.isMPIClient():
param_names = initweights.__code__.co_varnames[:initweights.__code__.co_argcount]
param_vals = [eval(p) for p in param_names]
param_vals = [vars[p] for p in param_names]
param_vals = [eval(p) for p in param_names]
casalog.post('Updating the history in the output', 'DEBUG1')
write_history(myms, vis, 'initweights', param_names,
except Exception as instance:
casalog.post("*** Error \'%s\' updating HISTORY" % (instance),
casalog.post("*** Error \'%s\' updating HISTORY" % instance,'WARN')
except Exception as instance:
print('*** Error ***',instance)
print('*** Error *** %s' % instance)