from types import CodeType
from casatasks import casalog
from casatools import calibrater, imager, measures
from casatools import ms as mstool
from casatools import mstransformer, table
from . import flaghelper as fh
from casatasks.private.mstools import write_history
from casatasks.private.parallel.parallel_data_helper import ParallelDataHelper
from casatasks.private.update_spw import update_spwchan
@contextlib.contextmanager
def tool_manager(vis, ctor, *args, **kwargs):
if vis and "open" in dir(tool):
tool.open(vis, *args, **kwargs)
elif "done" in dir(tool):
def table_manager(vis, *args, **kwargs):
return tool_manager(vis, table, *args, **kwargs)
def calibrater_manager(vis, *args, **kwargs):
return tool_manager(vis, calibrater, *args, **kwargs)
def measures_manager(*args, **kwargs):
return tool_manager(None, measures, *args, **kwargs)
def mstransformer_manager(*args, **kwargs):
return tool_manager(None, mstransformer, *args, **kwargs)
def mstool_manager(vis, *args, **kwargs):
return tool_manager(vis, mstool, *args, **kwargs)
if (os.path.isdir(filename)
and os.path.exists(filename + '/table.info')
and os.path.exists(filename + '/table.dat')):
f = open(filename + '/table.info',encoding=sys.getdefaultencoding( ))
if (lines.find('Measurement Set') != -1):
@contextlib.contextmanager
def table_selector(table, taql, *args, **kwargs):
with table_manager(table, *args, **kwargs) as tb:
def sdtask_decorator(func):
"""This is a decorator function for sd tasks.
Currently the decorator does:
1) set origin to the logger