Source
xxxxxxxxxx
flagcmd(vis=self.vis, action='apply', inpmode='list',inpfile=self.filename, savepars=True, outfile=newfile,
#########################################################################
# test_task_flagcmd.py
# Copyright (C) 2018
# Associated Universities, Inc. Washington DC, USA.
#
# This script is free software; you can redistribute it and/or modify it
# under the terms of the GNU Library General Public License as published by
# the Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# This library is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
# License for more details.
#
#
# Based on the requirements listed in casadocs found here:
# https://casadocs.readthedocs.io/en/stable/api/tt/casatasks.flagging.flagcmd.html
#
##########################################################################
import shutil
import unittest
import os
import filecmp
from casatasks import flagcmd, flagdata, flagmanager
from casatools import ctsys, agentflagger, table
from collections import OrderedDict
# Local copy of the agentflagger tool
aflocal = agentflagger()
# Path for data
datapath = ctsys.resolve("unittest/flagcmd/")
#
# Test of flagcmd task. It uses flagdata to unflag and summary
#
def check_eq(result, total, flagged):
print("%s of %s data was flagged, expected %s of %s" % \
(result['flagged'], result['total'], flagged, total))
assert result['total'] == total, \
"%s data in total; %s expected" % (result['total'], total)
assert result['flagged'] == flagged, \
"%s flags set; %s expected" % (result['flagged'], flagged)
def create_input(str_text,fname=''):
'''Save the string in a text file'''
if fname=='':
inp = 'flagcmd.txt'
else:
inp=fname
cmd = str_text
# remove file first
if os.path.exists(inp):
os.system('rm -f '+ inp)
# save it in a file