The other task, flagcmd is a replacement for the previous version of flagcmd. It has a re-factored interface and it can do much more than the previous version. All the flagging modes available in flagdata are also allowed in flagcmd (except again for the summary mode). Several input modes are available: table, list and xml. Actions to perform on the input are: apply, unapply, list, clear, plot and extract.
The other input, as already detailed above is the 'list' mode, which will have the flag commands in a text file or from a list of strings.
The 'xml' input is meant to be used for the online flags from the Flag.xml file in the MS. It also assumes that the Antenna.xml file is present.
For all the input modes, the action='list' can be used to list the flags commands on the screen and optionally to save them to an external output file when the parameter savepars is set to True.
When the action='apply' is used in the inpmode table, the flags will be applied to the MS and the APPLIED column will be updated to True. On the other hand, when action='unapply' the APPLIED column will be set to False for all selected table rows.
# Apply only the flag commands that contain reason='CORRELATOR_DATA_INVALID'. The default action for flagcmd is to apply the flag commands from a table input, therefore it is not necessary to specify inpmode='table' and action='apply'. flagcmd(vis='uid.ms', reason='CORRELATOR_DATA_INVALID')
# Create an input text file with all the flag commands to apply to the MS. > cat flags.txt mode='manual' autocorr=True mode='shadow' mode='clip' clipminmax=[0,2] clipzeros=True correlation='ABS_ALL' mode='tfcrop' spw='9' correlation='ABS_YY' ntime=51.0 mode='extend' extendpols=True # Pass the input to the task flagcmd(vis='uid.ms', inpmode='list', inpfile='flags.txt', action='apply')
# Give the flagging commands in the command line as a list of strings. flagcmd(vis='uid.ms', inpmode='list', inpfile=["mode='manual' autocorr=True", "mode='shadow'", "mode='clip' clipminmax=[0,2] clipzeros=True correlation='ABS_ALL'", "mode='tfcrop' spw='9' correlation='ABS_YY' ntime=51.0", "mode='extend' extendpols=True"], action='apply')
# Create an input text file with all the flag commands to apply to the MS. > cat flags.txt mode='manual' autocorr=True scan='1~3' mode='manual' mode='clip' clipminmax=[0,2] clipzeros=True correlation='ABS_ALL' mode='tfcrop' spw='9' correlation='ABS_YY' ntime=51.0 mode='extend' extendpols=True # Pass the input to the task flagdata(vis='uid.ms', mode='list', inpfile='flags.txt') # Get a summary flagdata(vis='uid.ms', mode='summary')
# Create an input list with all the flag commands to apply to the MS. cmds = ["mode='manual' autocorr=True", "scan='1~3' mode='manual'", "mode='clip' clipminmax=[0,2] clipzeros=True correlation='ABS_ALL'", "mode='tfcrop' spw='9' correlation='ABS_YY' ntime=51.0", "mode='extend' extendpols=True"] # Pass the input to the task flagdata(vis='uid.ms', mode='list', inpfile=cmds) # Get a summary flagdata(vis='uid.ms', mode='summary')
# Apply only the flag commands that contain reason='BAD_ANT'. Let's say the input file contains the following flag commands. > cat flags.txt antenna='DV06' reason='BAD_ANT' mode='clip' clipzeros=True reason='CLIPZEROS' mode='shadow' reason='SHADOW' antenna='DV01' timerange='2012/02/01:09:14:0~09:54:0' reason='BAD_ANT' antenna='DV10;DV23' timerange='2012/02/01:09:15:0~09:54:0' reason='BAD_ANT' # We want to apply the above flag commands in three different MSs, but in the first step we only want to flag the bad antennas, so we will select the cmds by the reason given in the file. flagdata(vis='uid1.ms', inpmode='list', inpfile='flags.txt', reason='BAD_ANT') flagdata(vis='uid2.ms', inpmode='list', inpfile='flags.txt', reason='BAD_ANT') flagdata(vis='uid3.ms', inpmode='list', inpfile='flags.txt', reason='BAD_ANT')
# Sometimes we want to flag using the interface but would like to save those parameters to a file. It may also be useful to write along a reason for those flags. flagdata(vis='uid1.ms', mode='clip', clipzeros=True, savepars=True, outfile='myflagcmd.txt', cmdreason='CLIPZEROS') # This will flag all the zeros in the MS and save the parameters to 'myflagcmd.txt' like below: > cat myflagcmd.txt mode='clip' correlation='ABS_ALL' clipoutside=True datacolumn='DATA'\ channelavg=False clipzeros=True reason='CLIPZEROS' # NOTE: if the outfile is left empty (default case), the task will save the parameters to the FLAG_CMD sub-table.
Keeping the state of the flags stored in the FLAG_CMD sub-table is also not guaranteed. The state can get out-of-sync very easily with the interchangeable use of all flagging tasks such as flagdata, flagcmd, and interactive flagging using plotms. Note that plotms does not write to the FLAG_CMD sub-table.