The new Calibration Table format can be handled by the tasks flagdata, flagcmd and the AgentFlagger tool in a transparent way, just like a Measurement Set Table. If the calibration table was created before CASA 4.1, the cal table handler will create a dummy OBSERVATION column and OBSERVATION sub-table in the input calibration table to adapt it to the new cal table format. There is limited support for older cal tables, therefore we recommend the user to re-create his/her calibrations using CASA 4.1 before running flagdata.
There is an open-time check that inspects the table type and uses the appropriate FlagDataHandler implementation for all the I/O operations:
CASA <2>: flagdata('X7ef.tsys', mode='unflag')
CASA <2>: af.open('X7ef.tsys') INFO AgentFlagger::open Table type is Calibration Out[2]: True
Support for the new Calibration Table format has been introduced transparently, so it is possible to flag them using any of the already available modes for Measurement Sets. However, due to the nature of the data in calibration tables, it only makes sense to use the following flag agent groups:
# Using the flagdata task flagdata('X7ef.tsys',mode='clip',clipzeros=True,clipminmax=[0.,600.],datacolumn='FPARAM' )
# Using the agentflagger tool af.open('X7ef.tsys') af.selectdata() agentClip={'mode':'clip','clipzeros':True,'clipminmax':[0.,600.],'datacolumn':'FPARAM'} af.parseagentparameters(agentClip) af.init() af.run() af.done()
# using the flagdata task flagdata('X7ef.tsys', antenna='DV09')
# Using the agentflagger tool af.open('X7ef.tsys') af.selectdata() agentManual={'mode':'manual','antenna':'DV09'} af.parseagentparameters(agentManual) af.init() af.run() af.done()
# using the flagdata task flagdata('X7ef.tsys', mode='summary', spwchan=True)
# using the agentflagger tool af.open('X7ef.tsys') af.selectdata() agentSummary={'mode':'summary', 'spwchan':True} af.parseagentparameters(agentSummary) af.init() summary = af.run() af.done()
Notice that the parameters names and types are the same as described in the flagdata command-line help.
# giving the correct datacolumn in the task flagdata(vis='cal.fewscans.bpass', mode='clip', datacolumn='CPARAM', clipminmax=[0.,6.],clipzeros=True) # using the default datacolumn in the agentflagger tool af.open('cal.fewscans.bpass') af.selectdata() af.parseclipparameters(clipminmax=[0.,6.],datacolumn='CPARAM', clipzeros=True) INFO AgentFlagger::parseAgentParameters Validating data column CPARAM based on input type INFO AgentFlagger::parseAgentParameters Will use data column CPARAM af.init() af.run() af.done()
There is no default data column for cal tables. The task has DATA as the default for MSs. Once the framework has detected the input to be a cal table, it will try to use the given data column. If that does not exist (such as DATA), it will try to use FPARAM, then CPARAM. If none of the them exist, it will exit with an error.
# using the flagdata task flagdata(vis='cal.fewscans.bpass', mode='clip', clipminmax=[0.,6.]) # using the default datacolumn in the agentflagger tool ... af.parseclipparameters(clipminmax=[0.,6.]) INFO AgentFlagger::parseAgentParameters Validating data column DATA based on input type WARN AgentFlagger::validateDataColumn Only FPARAM, CPARAM and SNR are supported for cal tables INFO AgentFlagger::parseAgentParameters Will use data column CPARAM ...
When flagging using mode RFlag, it is important to notice that RFlag mixes the data from all the solutions (similar to the parallel and cross-hand correlation products in an MS) to determine the flagging thresholds. If some of the solutions have higher ranges than others, they will dominate the algorithm, thus showing results only for the higher ones. We recommend that the usual way to proceed is to run flagdata using only the parallel-hand correlation products (or analogous for cal tables) and then extend it to the cross-hand correlation products to obtain the correct results.
agentClip={'mode':'clip',clipminmax':[0.,600.],'datacolumn':'FPARAM','correlation':'Sol1'} af.parseagentparameters(agentClip) af.init() ... INFO Clip::setAgentParameters Visibility expression is REAL SOL1 agentClip={'mode':'clip','clipminmax':[0.,600.],'datacolumn':'CPARAM','correlation':''} af.parseagentparameters(agentClip) af.init() ... INFO Clip::setAgentParameters Visibility expression is ABS SOL1,SOL2
agentClip={'mode':'clip','clipminmax':[0.,6.]} af.parseagentparameters(agentClip) AgentFlagger::parseAgentParameters Validating data column DATA based on input type AgentFlagger::validateDataColumn Only FPARAM, CPARAM and SNR are supported for cal tables AgentFlagger::parseAgentParameters Will use data column CPARAM af.init() ... INFO Clip::setAgentParameters Visibility expression is ABS SOL1,SOL2,SOL3,SOL4
As far as meta-data selection is concerned, we are bounded to what MSSelection interface for Calibration Tables offers (currently field, scan, time, spw, antenna and observation selections). There are two ways to apply meta-data selections that can be used independently or combined together:
# using the flagdata task flagdata(vis='X7ef.tsys', field='TW Hya') # using the agentflagger tool af.open('X7ef.tsys') af.selectdata(field='TW Hya') agentManual={'mode':'manual'} af.parseagentparameters(agentManual) af.init() af.run() af.done()
# using the flagdata task flagdata(vis='X7ef.tsys', antenna='DV09') # using the agentflagger tool af.open('X7ef.tsys') af.selectdata() agentManual={'mode':'manual','antenna':'DV09'} af.parseagentparameters(agentManual) af.init() af.run() af.done()
# using the flagdata task flagdata(vis='X7ef.tsys', field='TW Hya', antenna='DV09') # using the agentflagger tool af.open('X7ef.tsys') af.selectdata(field='TW Hya') agentManual={'mode':'manual','antenna':'DV09'} af.parseagentparameters(agentManual) af.init() af.run() af.done()
As with MeasurementSet tables, the re-factored flagger framework allows running several flagging agents at the same time, to reduce I/O overhead, for instance:
# using the flagdata task flagdata(vis='cal.fewscans.bpass', mode='list', inpfile=["mode='rflag' datacolumn='CPARAM' correlation='Sol1'", mode='tfcrop' datacolumn='CPARAM' correlation='Sol1'"]) # using the agentflagger tool af.open('cal.fewscans.bpass') af.selectdata() agentRflag={'mode':'rflag','datacolumn':'CPARAM','correlation':'Sol1'} agentTfcrop={'mode':'tfcrop','datacolumn':'CPARAM','correlation':'Sol1'} af.parseagentparameters(agentRflag) af.parseagentparameters(agentTfcrop) af.init() af.run(writeflags=True) af.done()
# using the flagdata task flagdata(vis='X7ef.tsys', mode='unflag') flagdata(vis='X7ef.tsys', mode='clip',clipminmax=[0.,600.],datacolumn='FPARAM',correlation='Sol1', display='data') # using the agentflagger tool af.open('X7ef.tsys') af.selectdata() agentUnflag={'mode':'unflag'} agentClip={'mode':'clip','clipminmax':[0.,600.],'datacolumn':'FPARAM','correlation':'Sol1'} agentDisplay={'mode':'display','datadisplay':True} af.parseagentparameters(agentUnflag) af.parseagentparameters(agentClip) af.parseagentparameters(agentDisplay) af.init() af.run(writeflags=True) af.done()
# using the flagdata task flagdata(vis='X7ef.tsys', mode='unflag') flagdata(vis='X7ef.tsys', spw='*:0~9;118~127', display='data') # using the agentflagger tool af.open('X7ef.tsys') af.selectdata() agentUnflag={'mode':'unflag'} agentManual={'mode':'manual','spw':'*:0~9;118~127'} agentDisplay={'mode':'display','datadisplay':True} af.parseagentparameters(agentUnflag) af.parseagentparameters(agentManual) af.parseagentparameters(agentDisplay) af.init() af.run(writeflags=True) af.done()
# using the flagdata task flagdata(vis='X7ef.tsys', mode='unflag') flagdata(vis='X7ef.tsys', antenna='DV09') # next command will return the summary with baseline counting flagdata(vis='X7ef.tsys', mode='summary', basecnt=True) # using the agentflagger tool af.open('X7ef.tsys') af.selectdata() agentUnflag={'mode':'unflag'} agentManual={'mode':'manual','antenna':'DV09'} agentSummary={'mode':'summary'} af.parseagentparameters(agentUnflag) af.parseagentparameters(agentManual) af.parseagentparameters(agentSummary) af.init() summary = af.run(writeflags=True) af.done() CASA <12>: summary Out[12]: {'nreport': 2, 'report0': {'antenna': {'DV04': {'flagged': 0.0, 'total': 14336.0}, 'DV06': {'flagged': 0.0, 'total': 14336.0}, 'DV07': {'flagged': 0.0, 'total': 14336.0}, 'DV08': {'flagged': 0.0, 'total': 14336.0}, 'DV09': {'flagged': 14336.0, 'total': 14336.0}, 'DV10': {'flagged': 0.0, 'total': 14336.0}, 'PM01': {'flagged': 0.0, 'total': 14336.0}, 'PM02': {'flagged': 0.0, 'total': 14336.0}, 'PM03': {'flagged': 0.0, 'total': 14336.0}},