casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FlagAgentRFlag.h
Go to the documentation of this file.
1 //# FlagAgentRFlag.h: This file contains the interface definition of the FlagAgentRFlag class.
2 //#
3 //# CASA - Common Astronomy Software Applications (http://casa.nrao.edu/)
4 //# Copyright (C) Associated Universities, Inc. Washington DC, USA 2012, All rights reserved.
5 //# Copyright (C) European Southern Observatory, 2012, All rights reserved.
6 //#
7 //# This library is free software; you can redistribute it and/or
8 //# modify it under the terms of the GNU Lesser General Public
9 //# License as published by the Free software Foundation; either
10 //# version 2.1 of the License, or (at your option) any later version.
11 //#
12 //# This library is distributed in the hope that it will be useful,
13 //# but WITHOUT ANY WARRANTY, without even the implied warranty of
14 //# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 //# Lesser General Public License for more details.
16 //#
17 //# You should have received a copy of the GNU Lesser General Public
18 //# License along with this library; if not, write to the Free Software
19 //# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20 //# MA 02111-1307 USA
21 //# $Id: $
22 
23 #ifndef FlagAgentRFlag_H_
24 #define FlagAgentRFlag_H_
25 
28 
29 namespace casa { //# NAMESPACE CASA - BEGIN
30 
54 class FlagAgentRFlag : public FlagAgentBase {
55 
56  enum optype {
57 
62  };
63 
64 public:
65 
66  FlagAgentRFlag(FlagDataHandler *dh, casacore::Record config, casacore::Bool writePrivateFlagCube = false, casacore::Bool flag = true);
68 
69 protected:
70 
71  // Parse configuration parameters
73 
74  // Compute flags for a given (time,freq) map
75  bool computeAntennaPairFlags(const vi::VisBuffer2 &visBuffer, VisMapper &visibilities,FlagMapper &flags,casacore::Int antenna1,casacore::Int antenna2,std::vector<casacore::uInt> &rows);
76 
77  // Extract automatically computed thresholds to use them in the next pass
78  void passIntermediate(const vi::VisBuffer2 &visBuffer);
79 
80  // Remove automatically computed thresholds for the following scans
81  void passFinal(const vi::VisBuffer2 &visBuffer);
82 
83  // Convenience function to get simple averages
84  casacore::Double mean(std::vector<casacore::Double> &data,std::vector<casacore::Double> &counts);
85 
86  // Convenience function to compute median
87  casacore::Double median(std::vector<casacore::Double> &data);
88 
89  //
90  void noiseVsRef(std::vector<casacore::Double> &data, casacore::Double ref);
91 
92  // Convenience function to get simple averages
93  casacore::Double computeThreshold(std::vector<casacore::Double> &data, std::vector<casacore::Double> &dataSquared, std::vector<casacore::Double> &counts);
94 
95  // casacore::Function to be called for each timestep/channel
96  void computeAntennaPairFlagsCore(std::pair<casacore::Int,casacore::Int> spw_field,
97  casacore::Double noise,
98  casacore::Double scutoff,
99  casacore::uInt timeStart,
100  casacore::uInt timeStop,
101  casacore::uInt centralTime,
102  VisMapper &visibilities,
103  FlagMapper &flags);
104 
105  void robustMean( casacore::uInt timestep_i,
106  casacore::uInt pol_k,
107  casacore::uInt nChannels,
108  casacore::Double &AverageReal,
109  casacore::Double &AverageImag,
110  casacore::Double &StdReal,
111  casacore::Double &StdImag,
112  casacore::Double &SumWeightReal,
113  casacore::Double &SumWeightImag,
114  VisMapper &visibilities,
115  FlagMapper &flags);
116 
117  void simpleMedian( casacore::uInt timestep_i,
118  casacore::uInt pol_k,
119  casacore::uInt nChannels,
120  casacore::Double &AverageReal,
121  casacore::Double &AverageImag,
122  casacore::Double &StdReal,
123  casacore::Double &StdImag,
124  casacore::Double &SumWeightReal,
125  casacore::Double &SumWeightImag,
126  VisMapper &visibilities,
127  FlagMapper &flags);
128 
129  // casacore::Function to return histograms
131 
132  // casacore::Function to return histograms
133  FlagReport getReportCore( map< std::pair<casacore::Int,casacore::Int>,std::vector<casacore::Double> > &data,
134  map< std::pair<casacore::Int,casacore::Int>,std::vector<casacore::Double> > &dataSquared,
135  map< std::pair<casacore::Int,casacore::Int>,std::vector<casacore::Double> > &counts,
136  map< std::pair<casacore::Int,casacore::Int>,casacore::Double > &threshold,
137  FlagReport &totalReport,
138  string label,
139  casacore::Double scale);
140 
141  // Dedicated method to generate threshold values
142  void generateThresholds( map< std::pair<casacore::Int,casacore::Int>,std::vector<casacore::Double> > &data,
143  map< std::pair<casacore::Int,casacore::Int>,std::vector<casacore::Double> > &dataSquared,
144  map< std::pair<casacore::Int,casacore::Int>,std::vector<casacore::Double> > &counts,
145  map< std::pair<casacore::Int,casacore::Int>,casacore::Double > &threshold,
146  string label);
147 
148 private:
149 
150  // General parameters
154  // flagdata task param timedevscale
156  // flagdata task param freqdevscale
158 
159  // Spectral Robust fit
161  std::vector<casacore::Double> thresholdRobust_p;
166 
167  // Store frequency to be used in Reports
168  map< std::pair<casacore::Int,casacore::Int>,std::vector<casacore::Double> > field_spw_frequency_p;
169  map< std::pair<casacore::Int,casacore::Int>,casacore::Double > field_spw_frequencies_p;
170 
171  // casacore::Time-direction analysis
173  // holds the timedev thresholds for every field-SPW pair
174  map< std::pair<casacore::Int,casacore::Int>,casacore::Double > field_spw_noise_map_p;
175  map< std::pair<casacore::Int,casacore::Int>,casacore::Bool > user_field_spw_noise_map_p;
176  map< std::pair<casacore::Int,casacore::Int>,std::vector<casacore::Double> > field_spw_noise_histogram_sum_p;
177  map< std::pair<casacore::Int,casacore::Int>,std::vector<casacore::Double> > field_spw_noise_histogram_sum_squares_p;
178  map< std::pair<casacore::Int,casacore::Int>,std::vector<casacore::Double> > field_spw_noise_histogram_counts_p;
179 
180  // Spectral analysis
182  // holds the freqdev thresholds for every field-SPW pair
183  map< std::pair<casacore::Int,casacore::Int>,casacore::Double > field_spw_scutoff_map_p;
184  map< std::pair<casacore::Int,casacore::Int>,casacore::Bool > user_field_spw_scutoff_map_p;
185  map< std::pair<casacore::Int,casacore::Int>,std::vector<casacore::Double> > field_spw_scutoff_histogram_sum_p;
186  map< std::pair<casacore::Int,casacore::Int>,std::vector<casacore::Double> > field_spw_scutoff_histogram_sum_squares_p;
187  map< std::pair<casacore::Int,casacore::Int>,std::vector<casacore::Double> > field_spw_scutoff_histogram_counts_p;
188 };
189 
190 
191 } //# NAMESPACE CASA - END
192 
193 #endif /* FlagAgentRFlag_H_ */
194 
int Int
Definition: aipstype.h:50
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_frequency_p
Store frequency to be used in Reports.
A top level class defining the data handling interface for the flagging module.
casacore::Double noiseScale_p
flagdata task param timedevscale
map< std::pair< casacore::Int, casacore::Int >, std::vector< casacore::Double > > field_spw_noise_histogram_counts_p
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)
casacore::Double computeThreshold(std::vector< casacore::Double > &data, std::vector< casacore::Double > &dataSquared, std::vector< casacore::Double > &counts)
Convenience function to get simple averages.
map< std::pair< casacore::Int, casacore::Int >, std::vector< casacore::Double > > field_spw_scutoff_histogram_sum_p
Everything going into the FlagReport is by value Everything going out of it is by reference...
Definition: FlagReport.h:40
ABSTRACT CLASSES Deliberately vague to be general enough to allow for many different types of data
Definition: PlotData.h:48
map< std::pair< casacore::Int, casacore::Int >, casacore::Double > field_spw_frequencies_p
casacore::Double spectralmin_p
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
casacore::Double spectralmax_p
casacore::Double mean(std::vector< casacore::Double > &data, std::vector< casacore::Double > &counts)
Convenience function to get simple averages.
casacore::uInt nTimeSteps_p
A top level class defining the interface for flagging agents.
std::vector< casacore::Double > thresholdRobust_p
map< std::pair< casacore::Int, casacore::Int >, casacore::Double > field_spw_scutoff_map_p
holds the freqdev thresholds for every field-SPW pair
void passFinal(const vi::VisBuffer2 &visBuffer)
Remove automatically computed thresholds for the following scans.
double Double
Definition: aipstype.h:55
map< std::pair< casacore::Int, casacore::Int >, casacore::Bool > user_field_spw_scutoff_map_p
void setAgentParameters(casacore::Record config)
Parse configuration parameters.
void noiseVsRef(std::vector< casacore::Double > &data, casacore::Double ref)
casacore::uInt optype_p
A hierarchical collection of named fields of various types.
Definition: Record.h:180
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
map< std::pair< casacore::Int, casacore::Int >, casacore::Bool > user_field_spw_noise_map_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_noise_histogram_sum_squares_p
map< std::pair< casacore::Int, casacore::Int >, std::vector< casacore::Double > > field_spw_scutoff_histogram_counts_p
casacore::Double median(std::vector< casacore::Double > &data)
Convenience function to compute median.
casacore::Double noise_p
casacore::Time-direction analysis
VisBuffer2s encapsulate one chunk of visibility data for processing.
Definition: VisBuffer2.h:141
casacore::Double scutoffScale_p
flagdata task param freqdevscale
map< std::pair< casacore::Int, casacore::Int >, casacore::Double > field_spw_noise_map_p
holds the timedev thresholds for every field-SPW pair
FlagAgentRFlag(FlagDataHandler *dh, casacore::Record config, casacore::Bool writePrivateFlagCube=false, casacore::Bool flag=true)
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
FlagReport getReport()
casacore::Function to return histograms
casacore::Bool doplot_p
A flag agent that implements the &#39;rflag&#39; flagdata mode.
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.
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 passIntermediate(const vi::VisBuffer2 &visBuffer)
Extract automatically computed thresholds to use them in the next pass.
casacore::uInt nIterationsRobust_p
Spectral Robust fit.
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.
casacore::Bool doflag_p
General parameters.
unsigned int uInt
Definition: aipstype.h:51
map< std::pair< casacore::Int, casacore::Int >, std::vector< casacore::Double > > field_spw_noise_histogram_sum_p
casacore::Double scutoff_p
Spectral analysis.