Source
raise Exception( 'There are no unapplied flags in the input. Set useapplied=True to also use the previously-applied flags.' )
from __future__ import absolute_import
from __future__ import print_function
import os
import copy
import numpy as np
from collections import defaultdict
# get is_CASA6 and is_python3
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
# naked tool constructors ala CASA6
agentflagger = casac.agentflagger
ms = casac.ms
# not really local
qalocal = qa
tblocal = tb
# common function to use to get a dictionary item iterator
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
):
#
# Task flagcmd
# Reads flag commands from file or string and applies to MS
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:
# Use a default ntime to open the MS. The user-set ntime will be
# used in the tool later
ntime = 0.0
# Open the MS and attach it to the tool
if (type(vis) == str) & os.path.exists(vis):
aflocal.open(vis, ntime)
else:
raise Exception( 'Visibility data set not found - please verify the name' )
# Check if vis is a cal table:
# typevis = 1 --> cal table
# typevis = 0 --> MS
# typevis = 2 --> MMS
iscal = False
typevis = fh.isCalTable(vis)
if typevis == 1:
iscal = True