casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Private Attributes
casa::FlagAgentBase Class Reference

A top level class defining the interface for flagging agents. More...

#include <FlagAgentBase.h>

Inheritance diagram for casa::FlagAgentBase:
casa::async::Thread casa::FlagAgentClipping casa::FlagAgentDisplay casa::FlagAgentElevation casa::FlagAgentExtension casa::FlagAgentManual casa::FlagAgentQuack casa::FlagAgentRFlag casa::FlagAgentShadow casa::FlagAgentSummary casa::FlagAgentTimeFreqCrop

List of all members.

Public Types

enum  datacolumn {
  DATA,
  CORRECTED,
  MODEL,
  RESIDUAL,
  RESIDUAL_DATA,
  FPARAM,
  CPARAM,
  PARAMERR,
  SNR
}
enum  iteration {
  ROWS,
  ROWS_PREPROCESS_BUFFER,
  IN_ROWS,
  IN_ROWS_PREPROCESS_BUFFER,
  ANTENNA_PAIRS,
  ANTENNA_PAIRS_FLAGS,
  ANTENNA_PAIRS_INTERACTIVE,
  ANTENNA_PAIRS_PREPROCESS_BUFFER
}

Public Member Functions

 FlagAgentBase (FlagDataHandler *dh, Record config, uShort iterationApproach, Bool writePrivateFlagCube=false, Bool flag=true)
virtual ~FlagAgentBase ()
void start ()
void terminate ()
void queueProcess ()
void chunkSummary ()
void tableSummary ()
void completeProcess ()
void * run ()
void setProfiling (bool enable)
 Set function to activate profiling.
void setCheckMode (bool enable)
 Set function to activate check mode.
virtual FlagReport getReport ()
 Get a report Record from the agent, at the end of the run The report returned by getReport() can be of multiple types -- a single report of type "none" : FlagReport("none",agentName_p) -- a single report of type "plot" : FlagReport("plot",agentName_p) -- a list of reports : FlagReport repList("list"); repList.addReport( FlagReport("plot",agentName_p) ); repList.addReport( FlagReport("plot",agentName_p) );.

Static Public Member Functions

static FlagAgentBasecreate (FlagDataHandler *dh, Record config)

Public Attributes

Bool backgroundMode_p
 Externally visible configuration.
LogIO::Command logLevel_p
Bool apply_p
Bool flag_p

Protected Member Functions

void initialize ()
void runCore ()
 Convenience function to be shared by parallel/non-parallel mode.
void setDataSelection (Record config)
virtual void setAgentParameters (Record config)
 TODO: This class must be re-implemented in the derived classes.
String sanitizeCorrExpression (String corrExpression, std::vector< String > *corrProducts)
 Method to sanitize correlation expression and keep going.
void generateAllIndex ()
void generateRowsIndex (uInt nRows)
void generateChannelIndex (uInt nChannels)
void generatePolarizationIndex (uInt nPolarizations)
std::vector< uInt > * generateAntennaPairRowsIndex (Int antenna1, Int antenna2)
void indigen (vector< uInt > &index, uInt size)
 Generate index for all rows.
bool find (Vector< Int > &validRange, Int element)
 For checking ids.
bool find (Matrix< Double > &validRange, Double element)
 For checking ranges.
bool find (Matrix< Int > &validPairs, Int element1, Int element2)
 For checking pairs.
bool find (Block< int > &columns, int col)
 For checking columns.
bool isNaN (Double number)
 Check if a given number is nan (for visibilities,gains and Tsys primarily)
bool isNaN (Float number)
bool isZero (Double number)
bool isZero (Float number)
bool isNaNOrZero (Float number)
bool isNaNOrZero (Double number)
bool checkIfProcessBuffer ()
 Check if buffer has to be processed.
virtual void preProcessBuffer (const vi::VisBuffer2 &visBuffer)
 Common functionality for each visBuffer (don't repeat at the row level)
void iterateRows ()
 Iterate trough list of rows.
void iterateInRows ()
 Iterate trough visibilities mapper.
void iterateAntennaPairs ()
 Iterate trough list of antenna pairs.
void iterateAntennaPairsFlags ()
 Iterate trough list of antenna pairs w/o loading visibilities.
void processAntennaPair (Int antenna1, Int antenna2)
 Methods to interactively iterate trough list of antenna pairs.
virtual void iterateAntennaPairsInteractive (antennaPairMap *antennaPairMap_ptr)
virtual void passIntermediate (const vi::VisBuffer2 &visBuffer)
 Iter-passes method.
virtual void passFinal (const vi::VisBuffer2 &visBuffer)
void setVisibilitiesMap (std::vector< uInt > *rows, VisMapper *visMap)
 Mapping functions as requested by Urvashi.
void setFlagsMap (std::vector< uInt > *rows, FlagMapper *flagMap)
Bool checkVisExpression (polarizationMap *polMap)
virtual bool computeRowFlags (const vi::VisBuffer2 &visBuffer, FlagMapper &flags, uInt row)
 Compute flags for a given visibilities point.
virtual bool computeInRowFlags (const vi::VisBuffer2 &visBuffer, VisMapper &visibilities, FlagMapper &flags, uInt row)
 Compute flags for a given visibilities point.
virtual bool computeAntennaPairFlags (const vi::VisBuffer2 &visBuffer, VisMapper &visibilities, FlagMapper &flags, Int antenna1, Int antenna2, vector< uInt > &rows)
 Compute flags for a given (time,freq) antenna pair map.
virtual bool computeAntennaPairFlags (const vi::VisBuffer2 &visBuffer, FlagMapper &flags, Int antenna1, Int antenna2, vector< uInt > &rows)
 Compute flags for a given (time,freq) antenna pair map w/o using visibilities.

Protected Attributes

FlagDataHandlerflagDataHandler_p
 Common used members that must be accessible to derived classes.
casa::LogIOlogger_p
String agentName_p
String mode_p
uInt64 chunkFlags_p
 Flag counters.
uInt64 chunkNaNs_p
uInt64 tableFlags_p
uInt64 tableNaNs_p
uInt64 visBufferFlags_p
bool flagRow_p
Bool multiThreading_p
 Multithreading configuration and agent id.
Int nThreads_p
Int threadId_p
Bool prepass_p
 Running configuration.
vector< uIntrowsIndex_p
 Lists of elements to be process jagonzal (CAS-4312): We need channelIndex_p available for the Rflag agent, in order to take into account channel selection for the frequency mapping.
vector< uIntchannelIndex_p
vector< uIntpolarizationIndex_p

Private Attributes

vi::VisBuffer2visibilityBuffer_p
Cube< Bool > * commonFlagCube_p
 MS-related objects.
Cube< Bool > * originalFlagCube_p
Cube< Bool > * privateFlagCube_p
Vector< Bool > * commonFlagRow_p
Vector< Bool > * originalFlagRow_p
Vector< Bool > * privateFlagRow_p
casa::String arraySelection_p
 Own data selection ranges.
casa::String fieldSelection_p
casa::String scanSelection_p
casa::String timeSelection_p
casa::String spwSelection_p
casa::String channelSelection_p
casa::String baselineSelection_p
casa::String uvwSelection_p
casa::String polarizationSelection_p
casa::String observationSelection_p
casa::String scanIntentSelection_p
bool filterRows_p
bool filterPols_p
bool filterChannels_p
Bool flagAutoCorrelations_p
Bool antennaNegation_p
Vector< IntarrayList_p
 Own data selection indexes.
Vector< IntfieldList_p
Vector< IntscanList_p
Matrix< DoubletimeList_p
Vector< IntspwList_p
Matrix< IntchannelList_p
Vector< Intantenna1List_p
Vector< Intantenna2List_p
Matrix< IntbaselineList_p
Matrix< DoubleuvwList_p
Bool uvwUnits_p
OrderedMap< Int, Vector< Int > > polarizationList_p
Vector< IntobservationList_p
Vector< IntscanIntentList_p
volatile Bool terminationRequested_p
 Thread state parameters.
volatile Bool threadTerminated_p
volatile Bool processing_p
String expression_p
 Data source configuration.
String dataColumn_p
uShort dataReference_p
Bool profiling_p
 Debugging configuration.
Bool checkFlags_p
uShort iterationApproach_p
 Running mode configuration.
Bool writePrivateFlagCube_p
 Flagging mode configuration.

Detailed Description

A top level class defining the interface for flagging agents.

Intended use:

Public interface

Prerequisite

Etymology

FlagAgentBase stands for a generic class, specific to the flagging operations

Synopsis

This is a top-level class defining the interface for flagging agents. There are various methods (virtual) that must be re-implemented by the specific derived classes, depending on the implemented algorithm. Here we find three categories:

Additionally there are public non-virtual methods to:

Motivation

The motivation for the FlagAgentBase class is having all the iteration and filtering capabilities grouped in one single class, with a common interface for all the agents w/o introducing anything specific to the implementation of each algorithm, thus improving modularization and maintainability.

Example

The top level interface of a flagging agent is quite simple once it is configured, this is due to the fact that most of the complexity lies in the FlagDataHandler-FlagAgentBase interaction, which is hidden from the application layer (already explained in the FlagDataHandler documentation).

    // Create FlagDataHandler
    FlagDataHandler *dh = new FlagMSHandler(inputFile,iterationMode);
   
    // First of all define a configuration record (e.g.: quack)
    Record agentConfig;
    agentConfig.define("mode","quack");
    agentConfig.define("quackinterval",(Double)20);
   
    // Use the factory method to create the agent, and put it into a FlagAgentList
    FlagAgentList agentList;
    FlagAgentBase *agent = FlagAgentBase::create(dh,agentConfig);
    agentList.push_back(agent);
   
    // Iterate over chunks
    while (dh->nextChunk())
    {
       // Iterates over buffers
          while (dh->nextBuffer())
       {
          // Apply agents on current VisBuffer
          agentList.apply();
   
          // Flush flags (only effective if there is a write access to the flag cube)
          dh->flushFlags();
       }
   
        // Print chunk stats from each agent
        agentList.chunkSummary();
    }
   
    // Print total stats from each agent
    agentList.tableSummary();
   
    // Stop flag agent
    agentList.terminate();

Definition at line 165 of file FlagAgentBase.h.


Member Enumeration Documentation

Enumerator:
DATA 
CORRECTED 
MODEL 
RESIDUAL 
RESIDUAL_DATA 
FPARAM 
CPARAM 
PARAMERR 
SNR 

Definition at line 169 of file FlagAgentBase.h.

Enumerator:
ROWS 
ROWS_PREPROCESS_BUFFER 
IN_ROWS 
IN_ROWS_PREPROCESS_BUFFER 
ANTENNA_PAIRS 
ANTENNA_PAIRS_FLAGS 
ANTENNA_PAIRS_INTERACTIVE 
ANTENNA_PAIRS_PREPROCESS_BUFFER 

Definition at line 182 of file FlagAgentBase.h.


Constructor & Destructor Documentation

casa::FlagAgentBase::FlagAgentBase ( FlagDataHandler dh,
Record  config,
uShort  iterationApproach,
Bool  writePrivateFlagCube = false,
Bool  flag = true 
)
virtual casa::FlagAgentBase::~FlagAgentBase ( ) [virtual]

Member Function Documentation

Check if buffer has to be processed.

virtual bool casa::FlagAgentBase::computeAntennaPairFlags ( const vi::VisBuffer2 visBuffer,
VisMapper visibilities,
FlagMapper flags,
Int  antenna1,
Int  antenna2,
vector< uInt > &  rows 
) [protected, virtual]

Compute flags for a given (time,freq) antenna pair map.

Reimplemented in casa::FlagAgentDisplay, casa::FlagAgentRFlag, and casa::FlagAgentTimeFreqCrop.

virtual bool casa::FlagAgentBase::computeAntennaPairFlags ( const vi::VisBuffer2 visBuffer,
FlagMapper flags,
Int  antenna1,
Int  antenna2,
vector< uInt > &  rows 
) [protected, virtual]

Compute flags for a given (time,freq) antenna pair map w/o using visibilities.

Reimplemented in casa::FlagAgentExtension.

virtual bool casa::FlagAgentBase::computeInRowFlags ( const vi::VisBuffer2 visBuffer,
VisMapper visibilities,
FlagMapper flags,
uInt  row 
) [protected, virtual]

Compute flags for a given visibilities point.

Reimplemented in casa::FlagAgentClipping.

virtual bool casa::FlagAgentBase::computeRowFlags ( const vi::VisBuffer2 visBuffer,
FlagMapper flags,
uInt  row 
) [protected, virtual]

Compute flags for a given visibilities point.

Reimplemented in casa::FlagAgentShadow, casa::FlagAgentQuack, casa::FlagAgentElevation, casa::FlagAgentSummary, and casa::FlagAgentManual.

static FlagAgentBase* casa::FlagAgentBase::create ( FlagDataHandler dh,
Record  config 
) [static]
bool casa::FlagAgentBase::find ( Vector< Int > &  validRange,
Int  element 
) [protected]

For checking ids.

bool casa::FlagAgentBase::find ( Matrix< Double > &  validRange,
Double  element 
) [protected]

For checking ranges.

bool casa::FlagAgentBase::find ( Matrix< Int > &  validPairs,
Int  element1,
Int  element2 
) [protected]

For checking pairs.

bool casa::FlagAgentBase::find ( Block< int > &  columns,
int  col 
) [protected]

For checking columns.

std::vector<uInt>* casa::FlagAgentBase::generateAntennaPairRowsIndex ( Int  antenna1,
Int  antenna2 
) [protected]
void casa::FlagAgentBase::generateChannelIndex ( uInt  nChannels) [protected]
void casa::FlagAgentBase::generatePolarizationIndex ( uInt  nPolarizations) [protected]
void casa::FlagAgentBase::generateRowsIndex ( uInt  nRows) [protected]

Get a report Record from the agent, at the end of the run The report returned by getReport() can be of multiple types -- a single report of type "none" : FlagReport("none",agentName_p) -- a single report of type "plot" : FlagReport("plot",agentName_p) -- a list of reports : FlagReport repList("list"); repList.addReport( FlagReport("plot",agentName_p) ); repList.addReport( FlagReport("plot",agentName_p) );.

Reimplemented in casa::FlagAgentRFlag, casa::FlagAgentDisplay, and casa::FlagAgentSummary.

void casa::FlagAgentBase::indigen ( vector< uInt > &  index,
uInt  size 
) [protected]

Generate index for all rows.

void casa::FlagAgentBase::initialize ( ) [protected]
bool casa::FlagAgentBase::isNaN ( Double  number) [protected]

Check if a given number is nan (for visibilities,gains and Tsys primarily)

bool casa::FlagAgentBase::isNaN ( Float  number) [protected]
bool casa::FlagAgentBase::isNaNOrZero ( Float  number) [protected]
bool casa::FlagAgentBase::isNaNOrZero ( Double  number) [protected]
bool casa::FlagAgentBase::isZero ( Double  number) [protected]
bool casa::FlagAgentBase::isZero ( Float  number) [protected]

Iterate trough list of antenna pairs.

Iterate trough list of antenna pairs w/o loading visibilities.

virtual void casa::FlagAgentBase::iterateAntennaPairsInteractive ( antennaPairMap antennaPairMap_ptr) [protected, virtual]

Reimplemented in casa::FlagAgentDisplay.

void casa::FlagAgentBase::iterateInRows ( ) [protected]

Iterate trough visibilities mapper.

void casa::FlagAgentBase::iterateRows ( ) [protected]

Iterate trough list of rows.

virtual void casa::FlagAgentBase::passFinal ( const vi::VisBuffer2 visBuffer) [protected, virtual]

Reimplemented in casa::FlagAgentRFlag.

virtual void casa::FlagAgentBase::passIntermediate ( const vi::VisBuffer2 visBuffer) [protected, virtual]

Iter-passes method.

Reimplemented in casa::FlagAgentRFlag.

virtual void casa::FlagAgentBase::preProcessBuffer ( const vi::VisBuffer2 visBuffer) [protected, virtual]

Common functionality for each visBuffer (don't repeat at the row level)

Reimplemented in casa::FlagAgentShadow, casa::FlagAgentDisplay, casa::FlagAgentSummary, and casa::FlagAgentElevation.

void casa::FlagAgentBase::processAntennaPair ( Int  antenna1,
Int  antenna2 
) [protected]

Methods to interactively iterate trough list of antenna pairs.

void* casa::FlagAgentBase::run ( ) [virtual]

Implements casa::async::Thread.

void casa::FlagAgentBase::runCore ( ) [protected]

Convenience function to be shared by parallel/non-parallel mode.

String casa::FlagAgentBase::sanitizeCorrExpression ( String  corrExpression,
std::vector< String > *  corrProducts 
) [protected]

Method to sanitize correlation expression and keep going.

virtual void casa::FlagAgentBase::setAgentParameters ( Record  config) [protected, virtual]
void casa::FlagAgentBase::setCheckMode ( bool  enable) [inline]

Set function to activate check mode.

Definition at line 210 of file FlagAgentBase.h.

References checkFlags_p.

void casa::FlagAgentBase::setDataSelection ( Record  config) [protected]
void casa::FlagAgentBase::setFlagsMap ( std::vector< uInt > *  rows,
FlagMapper flagMap 
) [protected]
void casa::FlagAgentBase::setProfiling ( bool  enable) [inline]

Set function to activate profiling.

Definition at line 207 of file FlagAgentBase.h.

References profiling_p.

void casa::FlagAgentBase::setVisibilitiesMap ( std::vector< uInt > *  rows,
VisMapper visMap 
) [protected]

Mapping functions as requested by Urvashi.

void casa::FlagAgentBase::terminate ( ) [virtual]

Reimplemented from casa::async::Thread.


Member Data Documentation

Definition at line 316 of file FlagAgentBase.h.

Definition at line 373 of file FlagAgentBase.h.

Definition at line 374 of file FlagAgentBase.h.

Definition at line 364 of file FlagAgentBase.h.

Definition at line 215 of file FlagAgentBase.h.

Own data selection indexes.

Definition at line 367 of file FlagAgentBase.h.

Own data selection ranges.

Definition at line 349 of file FlagAgentBase.h.

Externally visible configuration.

Definition at line 213 of file FlagAgentBase.h.

Definition at line 375 of file FlagAgentBase.h.

Definition at line 355 of file FlagAgentBase.h.

Definition at line 407 of file FlagAgentBase.h.

Definition at line 372 of file FlagAgentBase.h.

Definition at line 354 of file FlagAgentBase.h.

Definition at line 394 of file FlagAgentBase.h.

Referenced by setCheckMode().

Flag counters.

Definition at line 320 of file FlagAgentBase.h.

Definition at line 321 of file FlagAgentBase.h.

MS-related objects.

Definition at line 340 of file FlagAgentBase.h.

Definition at line 344 of file FlagAgentBase.h.

Definition at line 389 of file FlagAgentBase.h.

Definition at line 390 of file FlagAgentBase.h.

Data source configuration.

Definition at line 388 of file FlagAgentBase.h.

Definition at line 368 of file FlagAgentBase.h.

Definition at line 350 of file FlagAgentBase.h.

Definition at line 362 of file FlagAgentBase.h.

Definition at line 361 of file FlagAgentBase.h.

Definition at line 360 of file FlagAgentBase.h.

Definition at line 216 of file FlagAgentBase.h.

Definition at line 363 of file FlagAgentBase.h.

Common used members that must be accessible to derived classes.

Definition at line 314 of file FlagAgentBase.h.

Definition at line 325 of file FlagAgentBase.h.

Running mode configuration.

Definition at line 397 of file FlagAgentBase.h.

Definition at line 315 of file FlagAgentBase.h.

Definition at line 214 of file FlagAgentBase.h.

Definition at line 317 of file FlagAgentBase.h.

Multithreading configuration and agent id.

Definition at line 328 of file FlagAgentBase.h.

Definition at line 329 of file FlagAgentBase.h.

Definition at line 379 of file FlagAgentBase.h.

Definition at line 358 of file FlagAgentBase.h.

Definition at line 341 of file FlagAgentBase.h.

Definition at line 345 of file FlagAgentBase.h.

Definition at line 408 of file FlagAgentBase.h.

Definition at line 378 of file FlagAgentBase.h.

Definition at line 357 of file FlagAgentBase.h.

Running configuration.

Definition at line 333 of file FlagAgentBase.h.

Definition at line 342 of file FlagAgentBase.h.

Definition at line 346 of file FlagAgentBase.h.

Definition at line 385 of file FlagAgentBase.h.

Debugging configuration.

Definition at line 393 of file FlagAgentBase.h.

Referenced by setProfiling().

Lists of elements to be process jagonzal (CAS-4312): We need channelIndex_p available for the Rflag agent, in order to take into account channel selection for the frequency mapping.

Definition at line 406 of file FlagAgentBase.h.

Definition at line 380 of file FlagAgentBase.h.

Definition at line 359 of file FlagAgentBase.h.

Definition at line 369 of file FlagAgentBase.h.

Definition at line 351 of file FlagAgentBase.h.

Definition at line 371 of file FlagAgentBase.h.

Definition at line 353 of file FlagAgentBase.h.

Definition at line 322 of file FlagAgentBase.h.

Definition at line 323 of file FlagAgentBase.h.

Thread state parameters.

Reimplemented from casa::async::Thread.

Definition at line 383 of file FlagAgentBase.h.

Definition at line 330 of file FlagAgentBase.h.

Definition at line 384 of file FlagAgentBase.h.

Definition at line 370 of file FlagAgentBase.h.

Definition at line 352 of file FlagAgentBase.h.

Definition at line 376 of file FlagAgentBase.h.

Definition at line 356 of file FlagAgentBase.h.

Definition at line 377 of file FlagAgentBase.h.

Definition at line 324 of file FlagAgentBase.h.

Definition at line 337 of file FlagAgentBase.h.

Flagging mode configuration.

Definition at line 400 of file FlagAgentBase.h.


The documentation for this class was generated from the following file: