from __future__ import absolute_import
from __future__ import print_function
import os
import copy
import numpy as np
from collections import defaultdict
from casatasks.private.casa_transition import *
if is_CASA6:
from casatasks import casalog
from casatools import ms, quanta, table, agentflagger
from .mstools import write_history
from . import flaghelper as fh
qalocal = quanta( )
tblocal = table( )
else:
from taskinit import casalog, casac, qa, tb
from mstools import write_history
import flaghelper as fh
agentflagger = casac.agentflagger
ms = casac.ms
qalocal = qa
tblocal = tb
if is_python3:
def lociteritems(adict):
return adict.items()
else:
def lociteritems(adict):
return adict.iteritems()
def flagcmd(
vis=None,
inpmode=None,
inpfile=None,
tablerows=None,
reason=None,
useapplied=None,
tbuff=None,
ants=None,
action=None,
flagbackup=None,
clearall=None,
rowlist=None,
plotfile=None,
savepars=None,
outfile=None,
overwrite=None
):
try:
from xml.dom import minidom
except:
raise Exception( 'Failed to load xml.dom.minidom into python' )
casalog.origin('flagcmd')
aflocal = agentflagger()
mslocal = ms()
mslocal2 = ms()
try:
ntime = 0.0
if (type(vis) == str) & os.path.exists(vis):
aflocal.open(vis, ntime)
else:
raise Exception( 'Visibility data set not found - please verify the name' )
iscal = False
typevis = fh.isCalTable(vis)
if typevis == 1:
iscal = True