casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Private Types | Private Attributes | List of all members
casa::FlagAgentRFlag Class Reference

A flag agent that implements the 'rflag' flagdata mode. More...

#include <FlagAgentRFlag.h>

Inheritance diagram for casa::FlagAgentRFlag:
casa::FlagAgentBase casa::async::Thread

Public Member Functions

 FlagAgentRFlag (FlagDataHandler *dh, casacore::Record config, casacore::Bool writePrivateFlagCube=false, casacore::Bool flag=true)
 
 ~FlagAgentRFlag ()
 
- Public Member Functions inherited from casa::FlagAgentBase
 FlagAgentBase (FlagDataHandler *dh, casacore::Record config, casacore::uShort iterationApproach, casacore::Bool writePrivateFlagCube=false, casacore::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. More...
 
void setCheckMode (bool enable)
 Set function to activate check mode. More...
 
- Public Member Functions inherited from casa::async::Thread
 Thread ()
 
virtual ~Thread ()
 
pthread_t getId () const
 
pid_t gettid () const
 
bool isTerminationRequested () const
 
void * join ()
 
void startThread ()
 

Protected Member Functions

void setAgentParameters (casacore::Record config)
 Parse configuration parameters. More...
 
bool computeAntennaPairFlags (const vi::VisBuffer2 &visBuffer, VisMapper &visibilities, FlagMapper &flags, casacore::Int antenna1, casacore::Int antenna2, std::vector< casacore::uInt > &rows)
 Compute flags for a given (time,freq) map. More...
 
void passIntermediate (const vi::VisBuffer2 &visBuffer)
 Extract automatically computed thresholds to use them in the next pass. More...
 
void passFinal (const vi::VisBuffer2 &visBuffer)
 Remove automatically computed thresholds for the following scans. More...
 
casacore::Double mean (std::vector< casacore::Double > &data, std::vector< casacore::Double > &counts)
 Convenience function to get simple averages. More...
 
casacore::Double median (std::vector< casacore::Double > &data)
 Convenience function to compute median. More...
 
void noiseVsRef (std::vector< casacore::Double > &data, casacore::Double ref)
 
casacore::Double computeThreshold (std::vector< casacore::Double > &data, std::vector< casacore::Double > &dataSquared, std::vector< casacore::Double > &counts)
 Convenience function to get simple averages. More...
 
void computeAntennaPairFlagsCore (std::pair< casacore::Int, casacore::Int > spw_field, casacore::Double noise, casacore::Double scutoff, casacore::uInt timeStart, casacore::uInt timeStop, casacore::uInt centralTime, VisMapper &visibilities, FlagMapper &flags)
 casacore::Function to be called for each timestep/channel More...
 
void robustMean (casacore::uInt timestep_i, casacore::uInt pol_k, casacore::uInt nChannels, casacore::Double &AverageReal, casacore::Double &AverageImag, casacore::Double &StdReal, casacore::Double &StdImag, casacore::Double &SumWeightReal, casacore::Double &SumWeightImag, VisMapper &visibilities, FlagMapper &flags)
 
void simpleMedian (casacore::uInt timestep_i, casacore::uInt pol_k, casacore::uInt nChannels, casacore::Double &AverageReal, casacore::Double &AverageImag, casacore::Double &StdReal, casacore::Double &StdImag, casacore::Double &SumWeightReal, casacore::Double &SumWeightImag, VisMapper &visibilities, FlagMapper &flags)
 
FlagReport getReport ()
 casacore::Function to return histograms More...
 
FlagReport getReportCore (map< std::pair< casacore::Int, casacore::Int >, std::vector< casacore::Double > > &data, map< std::pair< casacore::Int, casacore::Int >, std::vector< casacore::Double > > &dataSquared, map< std::pair< casacore::Int, casacore::Int >, std::vector< casacore::Double > > &counts, map< std::pair< casacore::Int, casacore::Int >, casacore::Double > &threshold, FlagReport &totalReport, string label, casacore::Double scale)
 casacore::Function to return histograms More...
 
void generateThresholds (map< std::pair< casacore::Int, casacore::Int >, std::vector< casacore::Double > > &data, map< std::pair< casacore::Int, casacore::Int >, std::vector< casacore::Double > > &dataSquared, map< std::pair< casacore::Int, casacore::Int >, std::vector< casacore::Double > > &counts, map< std::pair< casacore::Int, casacore::Int >, casacore::Double > &threshold, string label)
 Dedicated method to generate threshold values. More...
 
- Protected Member Functions inherited from casa::FlagAgentBase
void initialize ()
 
void runCore ()
 Convenience function to be shared by parallel/non-parallel mode. More...
 
void setDataSelection (casacore::Record config)
 
casacore::String sanitizeCorrExpression (casacore::String corrExpression, std::vector< casacore::String > *corrProducts)
 Method to sanitize correlation expression and keep going. More...
 
void generateAllIndex ()
 
void generateRowsIndex (casacore::uInt nRows)
 
void generateChannelIndex (casacore::uInt nChannels)
 
void generatePolarizationIndex (casacore::uInt nPolarizations)
 
std::vector< casacore::uInt > * generateAntennaPairRowsIndex (casacore::Int antenna1, casacore::Int antenna2)
 
void indigen (std::vector< casacore::uInt > &index, casacore::uInt size)
 Generate index for all rows. More...
 
bool find (const casacore::Vector< casacore::Int > &validRange, casacore::Int element)
 For checking ids. More...
 
bool find (const casacore::Matrix< casacore::Double > &validRange, casacore::Double element)
 For checking ranges. More...
 
bool find (const casacore::Matrix< casacore::Int > &validPairs, casacore::Int element1, casacore::Int element2)
 For checking pairs. More...
 
bool find (const casacore::Block< int > &columns, int col)
 For checking columns. More...
 
bool isNaN (casacore::Double number)
 Check if a given number is nan (for visibilities,gains and Tsys primarily) More...
 
bool isNaN (casacore::Float number)
 
bool isZero (casacore::Double number)
 
bool isZero (casacore::Float number)
 
bool isNaNOrZero (casacore::Float number)
 
bool isNaNOrZero (casacore::Double number)
 
bool checkIfProcessBuffer ()
 Check if buffer has to be processed. More...
 
virtual void preProcessBuffer (const vi::VisBuffer2 &visBuffer)
 Common functionality for each visBuffer (don't repeat at the row level) More...
 
void iterateRows ()
 Iterate trough list of rows. More...
 
void iterateInRows ()
 Iterate trough visibilities mapper. More...
 
void iterateAntennaPairs ()
 Iterate trough list of antenna pairs. More...
 
void iterateAntennaPairsFlags ()
 Iterate trough list of antenna pairs w/o loading visibilities. More...
 
void processAntennaPair (casacore::Int antenna1, casacore::Int antenna2)
 Methods to interactively iterate trough list of antenna pairs. More...
 
virtual void iterateAntennaPairsInteractive (antennaPairMap *antennaPairMap_ptr)
 
void setVisibilitiesMap (std::vector< casacore::uInt > *rows, VisMapper *visMap)
 Mapping functions (abs, real, imag, etc.) as requested by Urvashi. More...
 
void setFlagsMap (std::vector< casacore::uInt > *rows, FlagMapper *flagMap)
 
casacore::Bool checkVisExpression (polarizationMap *polMap)
 
virtual bool computeRowFlags (const vi::VisBuffer2 &visBuffer, FlagMapper &flags, casacore::uInt row)
 Compute flags for a given visibilities point. More...
 
virtual bool computeInRowFlags (const vi::VisBuffer2 &visBuffer, VisMapper &visibilities, FlagMapper &flags, casacore::uInt row)
 Compute flags for a given visibilities point. More...
 
virtual bool computeAntennaPairFlags (const vi::VisBuffer2 &visBuffer, FlagMapper &flags, casacore::Int antenna1, casacore::Int antenna2, std::vector< casacore::uInt > &rows)
 Compute flags for a given (time,freq) antenna pair map w/o using visibilities. More...
 
- Protected Member Functions inherited from casa::async::Thread
bool isStarted () const
 

Private Types

enum  optype {
  MEAN,
  ROBUST_MEAN,
  MEDIAN,
  ROBUST_MEDIAN
}
 

Private Attributes

casacore::Bool doflag_p
 General parameters. More...
 
casacore::Bool doplot_p
 
casacore::uInt nTimeSteps_p
 
casacore::Double noiseScale_p
 flagdata task param timedevscale More...
 
casacore::Double scutoffScale_p
 flagdata task param freqdevscale More...
 
casacore::uInt nIterationsRobust_p
 Spectral Robust fit. More...
 
std::vector< casacore::DoublethresholdRobust_p
 
casacore::Double spectralmin_p
 
casacore::Double spectralmax_p
 
casacore::uInt optype_p
 
void(casa::FlagAgentRFlag::* spectralAnalysis_p )(casacore::uInt, casacore::uInt, casacore::uInt, casacore::Double &, casacore::Double &, casacore::Double &, casacore::Double &, casacore::Double &, casacore::Double &, VisMapper &, FlagMapper &)
 
map< std::pair< casacore::Int,
casacore::Int >, std::vector
< casacore::Double > > 
field_spw_frequency_p
 Store frequency to be used in Reports. More...
 
map< std::pair< casacore::Int,
casacore::Int >
, casacore::Double
field_spw_frequencies_p
 
casacore::Double noise_p
 casacore::Time-direction analysis More...
 
map< std::pair< casacore::Int,
casacore::Int >
, casacore::Double
field_spw_noise_map_p
 holds the timedev thresholds for every field-SPW pair More...
 
map< std::pair< casacore::Int,
casacore::Int >
, casacore::Bool
user_field_spw_noise_map_p
 
map< std::pair< casacore::Int,
casacore::Int >, std::vector
< casacore::Double > > 
field_spw_noise_histogram_sum_p
 
map< std::pair< casacore::Int,
casacore::Int >, std::vector
< casacore::Double > > 
field_spw_noise_histogram_sum_squares_p
 
map< std::pair< casacore::Int,
casacore::Int >, std::vector
< casacore::Double > > 
field_spw_noise_histogram_counts_p
 
casacore::Double scutoff_p
 Spectral analysis. More...
 
map< std::pair< casacore::Int,
casacore::Int >
, casacore::Double
field_spw_scutoff_map_p
 holds the freqdev thresholds for every field-SPW pair More...
 
map< std::pair< casacore::Int,
casacore::Int >
, casacore::Bool
user_field_spw_scutoff_map_p
 
map< std::pair< casacore::Int,
casacore::Int >, std::vector
< casacore::Double > > 
field_spw_scutoff_histogram_sum_p
 
map< std::pair< casacore::Int,
casacore::Int >, std::vector
< casacore::Double > > 
field_spw_scutoff_histogram_sum_squares_p
 
map< std::pair< casacore::Int,
casacore::Int >, std::vector
< casacore::Double > > 
field_spw_scutoff_histogram_counts_p
 

Additional Inherited Members

- Public Types inherited from casa::FlagAgentBase
enum  datacolumn {
  DATA,
  CORRECTED,
  MODEL,
  RESIDUAL,
  RESIDUAL_DATA,
  FPARAM,
  CPARAM,
  PARAMERR,
  SNR,
  WEIGHT_SPECTRUM,
  FLOAT_DATA
}
 
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 Types inherited from casa::async::Thread
typedef void *(* ThreadFunction )(void *)
 
- Static Public Member Functions inherited from casa::FlagAgentBase
static FlagAgentBasecreate (FlagDataHandler *dh, casacore::Record config)
 
- Public Attributes inherited from casa::FlagAgentBase
casacore::Bool backgroundMode_p
 Externally visible configuration. More...
 
casacore::LogIO::Command logLevel_p
 
casacore::Bool apply_p
 
casacore::Bool flag_p
 
- Static Protected Member Functions inherited from casa::async::Thread
static void * threadFunction (void *)
 
- Protected Attributes inherited from casa::FlagAgentBase
FlagDataHandlerflagDataHandler_p
 Common used members that must be accessible to derived classes. More...
 
std::unique_ptr< casacore::LogIOlogger_p
 
casacore::String agentName_p
 
casacore::String summaryName_p
 
casacore::String mode_p
 
casacore::uInt64 chunkFlags_p
 Flag counters. More...
 
casacore::uInt64 chunkNaNs_p
 
casacore::uInt64 tableFlags_p
 
casacore::uInt64 tableNaNs_p
 
casacore::uInt64 visBufferFlags_p
 
bool flagRow_p
 
casacore::Bool multiThreading_p
 Multithreading configuration and agent id. More...
 
casacore::Int nThreads_p
 
casacore::Int threadId_p
 
casacore::Bool prepass_p
 Running configuration. More...
 
std::vector< casacore::uIntrowsIndex_p
 Lists of elements to 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. More...
 
std::vector< casacore::uIntchannelIndex_p
 
std::vector< casacore::uIntpolarizationIndex_p
 
casacore::String dataColumn_p
 Needed to be protected for timeavg in clip. More...
 
casacore::Bool timeavg_p
 Pre-averaging parameters. More...
 
casacore::Double timebin_p
 
casacore::Bool channelavg_p
 
casacore::Vector< casacore::Intchanbin_p
 

Detailed Description

A flag agent that implements the 'rflag' flagdata mode.

Uses the FlagAgentBase::ANTENNA_PAIRS iteration approach.

Note that the user interface provided by flagdata is complex/misleading in trying to replicate the use patterns of RFlag in AIPS. This produces a potentially confusing pattern when implementing the virtuals of FlagAgentBase. The per-channel RMS/variance values are calculated in computeAntennaPairFlagsCore(). Then, the overall thresholds (timedev, freqdev) are calculated in getReport(). The different display modes are essentially implemented in getReportCore().

This implementation takes as reference implementation the AIPS task RFlag by Erich Greisen, see The AIPS Cookbook Appendix E : Special Considerations for EVLA data calibration and imaging in AIPS E.5 Detailed Flagging http://www.aips.nrao.edu/cook.html#CEE

Definition at line 54 of file FlagAgentRFlag.h.

Member Enumeration Documentation

Enumerator
MEAN 
ROBUST_MEAN 
MEDIAN 
ROBUST_MEDIAN 

Definition at line 56 of file FlagAgentRFlag.h.

Constructor & Destructor Documentation

casa::FlagAgentRFlag::FlagAgentRFlag ( FlagDataHandler dh,
casacore::Record  config,
casacore::Bool  writePrivateFlagCube = false,
casacore::Bool  flag = true 
)
casa::FlagAgentRFlag::~FlagAgentRFlag ( )

Member Function Documentation

bool casa::FlagAgentRFlag::computeAntennaPairFlags ( const vi::VisBuffer2 visBuffer,
VisMapper visibilities,
FlagMapper flags,
casacore::Int  antenna1,
casacore::Int  antenna2,
std::vector< casacore::uInt > &  rows 
)
protectedvirtual

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

Reimplemented from casa::FlagAgentBase.

void casa::FlagAgentRFlag::computeAntennaPairFlagsCore ( std::pair< casacore::Int, casacore::Int spw_field,
casacore::Double  noise,
casacore::Double  scutoff,
casacore::uInt  timeStart,
casacore::uInt  timeStop,
casacore::uInt  centralTime,
VisMapper visibilities,
FlagMapper flags 
)
protected

casacore::Function to be called for each timestep/channel

casacore::Double casa::FlagAgentRFlag::computeThreshold ( std::vector< casacore::Double > &  data,
std::vector< casacore::Double > &  dataSquared,
std::vector< casacore::Double > &  counts 
)
protected

Convenience function to get simple averages.

void casa::FlagAgentRFlag::generateThresholds ( map< std::pair< casacore::Int, casacore::Int >, std::vector< casacore::Double > > &  data,
map< std::pair< casacore::Int, casacore::Int >, std::vector< casacore::Double > > &  dataSquared,
map< std::pair< casacore::Int, casacore::Int >, std::vector< casacore::Double > > &  counts,
map< std::pair< casacore::Int, casacore::Int >, casacore::Double > &  threshold,
string  label 
)
protected

Dedicated method to generate threshold values.

FlagReport casa::FlagAgentRFlag::getReport ( )
protectedvirtual

casacore::Function to return histograms

Reimplemented from casa::FlagAgentBase.

FlagReport casa::FlagAgentRFlag::getReportCore ( map< std::pair< casacore::Int, casacore::Int >, std::vector< casacore::Double > > &  data,
map< std::pair< casacore::Int, casacore::Int >, std::vector< casacore::Double > > &  dataSquared,
map< std::pair< casacore::Int, casacore::Int >, std::vector< casacore::Double > > &  counts,
map< std::pair< casacore::Int, casacore::Int >, casacore::Double > &  threshold,
FlagReport totalReport,
string  label,
casacore::Double  scale 
)
protected

casacore::Function to return histograms

casacore::Double casa::FlagAgentRFlag::mean ( std::vector< casacore::Double > &  data,
std::vector< casacore::Double > &  counts 
)
protected

Convenience function to get simple averages.

casacore::Double casa::FlagAgentRFlag::median ( std::vector< casacore::Double > &  data)
protected

Convenience function to compute median.

void casa::FlagAgentRFlag::noiseVsRef ( std::vector< casacore::Double > &  data,
casacore::Double  ref 
)
protected
void casa::FlagAgentRFlag::passFinal ( const vi::VisBuffer2 visBuffer)
protectedvirtual

Remove automatically computed thresholds for the following scans.

Reimplemented from casa::FlagAgentBase.

void casa::FlagAgentRFlag::passIntermediate ( const vi::VisBuffer2 visBuffer)
protectedvirtual

Extract automatically computed thresholds to use them in the next pass.

Reimplemented from casa::FlagAgentBase.

void casa::FlagAgentRFlag::robustMean ( casacore::uInt  timestep_i,
casacore::uInt  pol_k,
casacore::uInt  nChannels,
casacore::Double AverageReal,
casacore::Double AverageImag,
casacore::Double StdReal,
casacore::Double StdImag,
casacore::Double SumWeightReal,
casacore::Double SumWeightImag,
VisMapper visibilities,
FlagMapper flags 
)
protected
void casa::FlagAgentRFlag::setAgentParameters ( casacore::Record  config)
protectedvirtual

Parse configuration parameters.

Reimplemented from casa::FlagAgentBase.

void casa::FlagAgentRFlag::simpleMedian ( casacore::uInt  timestep_i,
casacore::uInt  pol_k,
casacore::uInt  nChannels,
casacore::Double AverageReal,
casacore::Double AverageImag,
casacore::Double StdReal,
casacore::Double StdImag,
casacore::Double SumWeightReal,
casacore::Double SumWeightImag,
VisMapper visibilities,
FlagMapper flags 
)
protected

Member Data Documentation

casacore::Bool casa::FlagAgentRFlag::doflag_p
private

General parameters.

Definition at line 151 of file FlagAgentRFlag.h.

casacore::Bool casa::FlagAgentRFlag::doplot_p
private

Definition at line 152 of file FlagAgentRFlag.h.

map< std::pair<casacore::Int,casacore::Int>,casacore::Double > casa::FlagAgentRFlag::field_spw_frequencies_p
private

Definition at line 169 of file FlagAgentRFlag.h.

map< std::pair<casacore::Int,casacore::Int>,std::vector<casacore::Double> > casa::FlagAgentRFlag::field_spw_frequency_p
private

Store frequency to be used in Reports.

Definition at line 168 of file FlagAgentRFlag.h.

map< std::pair<casacore::Int,casacore::Int>,std::vector<casacore::Double> > casa::FlagAgentRFlag::field_spw_noise_histogram_counts_p
private

Definition at line 178 of file FlagAgentRFlag.h.

map< std::pair<casacore::Int,casacore::Int>,std::vector<casacore::Double> > casa::FlagAgentRFlag::field_spw_noise_histogram_sum_p
private

Definition at line 176 of file FlagAgentRFlag.h.

map< std::pair<casacore::Int,casacore::Int>,std::vector<casacore::Double> > casa::FlagAgentRFlag::field_spw_noise_histogram_sum_squares_p
private

Definition at line 177 of file FlagAgentRFlag.h.

map< std::pair<casacore::Int,casacore::Int>,casacore::Double > casa::FlagAgentRFlag::field_spw_noise_map_p
private

holds the timedev thresholds for every field-SPW pair

Definition at line 174 of file FlagAgentRFlag.h.

map< std::pair<casacore::Int,casacore::Int>,std::vector<casacore::Double> > casa::FlagAgentRFlag::field_spw_scutoff_histogram_counts_p
private

Definition at line 187 of file FlagAgentRFlag.h.

map< std::pair<casacore::Int,casacore::Int>,std::vector<casacore::Double> > casa::FlagAgentRFlag::field_spw_scutoff_histogram_sum_p
private

Definition at line 185 of file FlagAgentRFlag.h.

map< std::pair<casacore::Int,casacore::Int>,std::vector<casacore::Double> > casa::FlagAgentRFlag::field_spw_scutoff_histogram_sum_squares_p
private

Definition at line 186 of file FlagAgentRFlag.h.

map< std::pair<casacore::Int,casacore::Int>,casacore::Double > casa::FlagAgentRFlag::field_spw_scutoff_map_p
private

holds the freqdev thresholds for every field-SPW pair

Definition at line 183 of file FlagAgentRFlag.h.

casacore::uInt casa::FlagAgentRFlag::nIterationsRobust_p
private

Spectral Robust fit.

Definition at line 160 of file FlagAgentRFlag.h.

casacore::Double casa::FlagAgentRFlag::noise_p
private

casacore::Time-direction analysis

Definition at line 172 of file FlagAgentRFlag.h.

casacore::Double casa::FlagAgentRFlag::noiseScale_p
private

flagdata task param timedevscale

Definition at line 155 of file FlagAgentRFlag.h.

casacore::uInt casa::FlagAgentRFlag::nTimeSteps_p
private

Definition at line 153 of file FlagAgentRFlag.h.

casacore::uInt casa::FlagAgentRFlag::optype_p
private

Definition at line 164 of file FlagAgentRFlag.h.

casacore::Double casa::FlagAgentRFlag::scutoff_p
private

Spectral analysis.

Definition at line 181 of file FlagAgentRFlag.h.

casacore::Double casa::FlagAgentRFlag::scutoffScale_p
private

flagdata task param freqdevscale

Definition at line 157 of file FlagAgentRFlag.h.

void(casa::FlagAgentRFlag::* casa::FlagAgentRFlag::spectralAnalysis_p)(casacore::uInt, casacore::uInt, casacore::uInt, casacore::Double &, casacore::Double &, casacore::Double &, casacore::Double &, casacore::Double &, casacore::Double &, VisMapper &, FlagMapper &)
private

Definition at line 165 of file FlagAgentRFlag.h.

casacore::Double casa::FlagAgentRFlag::spectralmax_p
private

Definition at line 163 of file FlagAgentRFlag.h.

casacore::Double casa::FlagAgentRFlag::spectralmin_p
private

Definition at line 162 of file FlagAgentRFlag.h.

std::vector<casacore::Double> casa::FlagAgentRFlag::thresholdRobust_p
private

Definition at line 161 of file FlagAgentRFlag.h.

map< std::pair<casacore::Int,casacore::Int>,casacore::Bool > casa::FlagAgentRFlag::user_field_spw_noise_map_p
private

Definition at line 175 of file FlagAgentRFlag.h.

map< std::pair<casacore::Int,casacore::Int>,casacore::Bool > casa::FlagAgentRFlag::user_field_spw_scutoff_map_p
private

Definition at line 184 of file FlagAgentRFlag.h.


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