00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef FlagAgentRFlag_H_
00024 #define FlagAgentRFlag_H_
00025
00026 #include <flagging/Flagging/FlagAgentBase.h>
00027 #include <casa/Utilities/DataType.h>
00028
00029 namespace casa {
00030
00031 class FlagAgentRFlag : public FlagAgentBase {
00032
00033 enum optype {
00034
00035 MEAN,
00036 ROBUST_MEAN,
00037 MEDIAN,
00038 ROBUST_MEDIAN
00039 };
00040
00041 public:
00042
00043 FlagAgentRFlag(FlagDataHandler *dh, Record config, Bool writePrivateFlagCube = false, Bool flag = true);
00044 ~FlagAgentRFlag();
00045
00046 protected:
00047
00048
00049 void setAgentParameters(Record config);
00050
00051
00052 bool computeAntennaPairFlags(const vi::VisBuffer2 &visBuffer, VisMapper &visibilities,FlagMapper &flags,Int antenna1,Int antenna2,vector<uInt> &rows);
00053
00054
00055 void passIntermediate(const vi::VisBuffer2 &visBuffer);
00056
00057
00058 void passFinal(const vi::VisBuffer2 &visBuffer);
00059
00060
00061 Double mean(vector<Double> &data,vector<Double> &counts);
00062
00063
00064 Double median(vector<Double> &data);
00065
00066
00067 void noiseVsRef(vector<Double> &data, Double ref);
00068
00069
00070 Double computeThreshold(vector<Double> &data, vector<Double> &dataSquared, vector<Double> &counts);
00071
00072
00073 void computeAntennaPairFlagsCore( pair<Int,Int> spw_field,
00074 Double noise,
00075 Double scutof,
00076 uInt timeStart,
00077 uInt timeStop,
00078 uInt centralTime,
00079 VisMapper &visibilities,
00080 FlagMapper &flags);
00081
00082 void robustMean( uInt timestep_i,
00083 uInt pol_k,
00084 uInt nChannels,
00085 Double &AverageReal,
00086 Double &AverageImag,
00087 Double &StdReal,
00088 Double &StdImag,
00089 Double &SumWeightReal,
00090 Double &SumWeightImag,
00091 VisMapper &visibilities,
00092 FlagMapper &flags);
00093
00094 void simpleMedian( uInt timestep_i,
00095 uInt pol_k,
00096 uInt nChannels,
00097 Double &AverageReal,
00098 Double &AverageImag,
00099 Double &StdReal,
00100 Double &StdImag,
00101 Double &SumWeightReal,
00102 Double &SumWeightImag,
00103 VisMapper &visibilities,
00104 FlagMapper &flags);
00105
00106
00107 FlagReport getReport();
00108
00109
00110 FlagReport getReportCore( map< pair<Int,Int>,vector<Double> > &data,
00111 map< pair<Int,Int>,vector<Double> > &dataSquared,
00112 map< pair<Int,Int>,vector<Double> > &counts,
00113 map< pair<Int,Int>,Double > &threshold,
00114 FlagReport &totalReport,
00115 string label,
00116 Double scale);
00117
00118
00119 void generateThresholds( map< pair<Int,Int>,vector<Double> > &data,
00120 map< pair<Int,Int>,vector<Double> > &dataSquared,
00121 map< pair<Int,Int>,vector<Double> > &counts,
00122 map< pair<Int,Int>,Double > &threshold,
00123 string label,
00124 Double scale);
00125
00126 private:
00127
00128
00129 Bool doflag_p;
00130 Bool doplot_p;
00131 uInt nTimeSteps_p;
00132 Double noiseScale_p;
00133 Double scutofScale_p;
00134
00135
00136 uInt nIterationsRobust_p;
00137 vector<Double> thresholdRobust_p;
00138 Double spectralmin_p;
00139 Double spectralmax_p;
00140 uInt optype_p;
00141 void (casa::FlagAgentRFlag::*spectralAnalysis_p)(uInt,uInt,uInt,Double&,Double&,Double&,Double&,Double&,Double&,VisMapper&,FlagMapper&);
00142
00143
00144 map< pair<Int,Int>,vector<Double> > field_spw_frequency_p;
00145 map< pair<Int,Int>,Double > field_spw_frequencies_p;
00146
00147
00148 Double noise_p;
00149 map< pair<Int,Int>,Double > field_spw_noise_map_p;
00150 map< pair<Int,Int>,Bool > user_field_spw_noise_map_p;
00151 map< pair<Int,Int>,vector<Double> > field_spw_noise_histogram_sum_p;
00152 map< pair<Int,Int>,vector<Double> > field_spw_noise_histogram_sum_squares_p;
00153 map< pair<Int,Int>,vector<Double> > field_spw_noise_histogram_counts_p;
00154
00155
00156 Double scutof_p;
00157 map< pair<Int,Int>,Double > field_spw_scutof_map_p;
00158 map< pair<Int,Int>,Bool > user_field_spw_scutof_map_p;
00159 map< pair<Int,Int>,vector<Double> > field_spw_scutof_histogram_sum_p;
00160 map< pair<Int,Int>,vector<Double> > field_spw_scutof_histogram_sum_squares_p;
00161 map< pair<Int,Int>,vector<Double> > field_spw_scutof_histogram_counts_p;
00162 };
00163
00164
00165 }
00166
00167 #endif
00168