00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef FLAGGING_FLAGGER_H
00028 #define FLAGGING_FLAGGER_H
00029
00030 #include <flagging/Flagging/RFCommon.h>
00031 #include <flagging/Flagging/RFABase.h>
00032 #include <flagging/Flagging/FlagVersion.h>
00033
00034 #include <ms/MeasurementSets/MeasurementSet.h>
00035 #include <ms/MSSel/MSSelection.h>
00036 #include <measures/Measures/MDirection.h>
00037 #include <measures/Measures/MPosition.h>
00038 #include <measures/Measures/MRadialVelocity.h>
00039 #include <casa/Logging/LogIO.h>
00040 #include <casa/Arrays/Vector.h>
00041 #include <casa/Containers/Record.h>
00042 #include <casa/Quanta/Quantum.h>
00043
00044 namespace casa {
00045
00046 class VisSet;
00047 class RFChunkStats;
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100 class Flagger : public FlaggerEnums
00101 {
00102 protected:
00103
00104 std::shared_ptr<RFABase> createAgent ( const String &name,RFChunkStats &chunk,const RecordInterface &parms, bool &only_selector );
00105
00106
00107 const RecordInterface & setupAgentDefaults ();
00108
00109
00110 void printAgentReports ( );
00111
00112 void printSummaryReport ( RFChunkStats &chunk );
00113 Bool selectDataChannel();
00114
00115 MeasurementSet ms;
00116 MeasurementSet originalms;
00117 std::vector<std::shared_ptr<RFABase> > acc;
00118
00119
00120 MeasurementSet *mssel_p;
00121 VisSet *vs_p;
00122 bool scan_looping;
00123 String msname_p;
00124 Bool nullSelect_p;
00125 Bool setdata_p;
00126 Bool selectdata_p;
00127 String dataMode_p;
00128
00129
00130
00131
00132
00133 Vector<String> correlations_p;
00134 Vector<Int> datafieldids_p;
00135 Vector<Int> datadescids_p;
00136 MRadialVelocity mDataStart_p;
00137 MRadialVelocity mDataStep_p;
00138
00139
00140 uInt nant,nifr,nfeed,nfeedcorr;
00141 Vector<Int> ifr2ant1,ifr2ant2;
00142 Vector<String> antnames;
00143 Vector<Double> spwfreqs;
00144
00145 Record agent_defaults;
00146
00147 static LogIO os;
00148
00149 public:
00150
00151 Flagger ();
00152
00153 Flagger ( MeasurementSet &ms );
00154
00155 ~Flagger ();
00156
00157
00158 bool attach( MeasurementSet &ms, Bool setupAgentDefaults=True );
00159
00160
00161 Bool selectdata(Bool useoriginalms=False,
00162 String field="", String spw="", String array="", String feed="", String scan="",
00163 String baseline="", String uvrange="", String time="",
00164 String correlation="", String intent="", String observation="");
00165
00166
00167 Bool setdata(String field, String spw, String array, String feed, String scan,
00168 String baseline, String uvrange, String time,
00169 String correlation, String intent, String observation="");
00170
00171
00172 Bool setmanualflags(Bool autocorr,
00173 Bool unflag,
00174 String clipexpr,
00175 Vector<Double> cliprange,
00176 String clipcolumn,
00177 Bool outside,
00178 Bool channel_average,
00179 Double quackinterval=0.0,
00180 String quackmode=String("beg"),
00181 Bool quackincrement=Bool(false),
00182 String opmode=String("flag"),
00183 Double diameter = -1.0,
00184 Double lowerlimit = -1.0,
00185 Double upperlimit = 91.0);
00186
00187
00188
00189 Bool clearflagselections(Int recordindex);
00190 Bool printflagselections();
00191
00192
00193 Bool fillSelections(Record &rec);
00194
00195
00196 Bool setautoflagparams(String algorithm, Record ¶meters);
00197
00198
00199 Record getautoflagparams(String algorithm);
00200
00201 Bool addAgent(RecordInterface &newAgent);
00202
00203
00204 void detach();
00205
00206 Record run(Bool trial, Bool reset);
00207
00208 void summary ( const RecordInterface &agents );
00209
00210
00211 Bool saveFlagVersion(String versionname, String comment, String merge);
00212 Bool restoreFlagVersion(Vector<String> versionname, String merge);
00213 Bool deleteFlagVersion(Vector<String> versionname);
00214 Bool getFlagVersionList( Vector<String> &verlist);
00215
00216
00217
00218 const MeasurementSet & measSet() const { return ms; }
00219
00220
00221 uInt numAnt () const
00222 { return nant; };
00223
00224
00225 uInt numIfr () const
00226 { return nifr; };
00227
00228
00229 uInt numFeed () const
00230 { return nfeed; };
00231
00232
00233 uInt numFeedCorr () const
00234 { return nfeedcorr; };
00235
00236
00237 const Vector<String> & antNames() const
00238 { return antnames; };
00239
00240
00241 uInt ifrNumber ( Int ant1,Int ant2 ) const;
00242
00243
00244 Vector<Int> ifrNumbers ( Vector<Int> ant1,Vector<Int> ant2 ) const;
00245
00246
00247 void ifrToAnt ( uInt &ant1,uInt &ant2,uInt ifr ) const;
00248
00249
00250 const RecordInterface & defaultAgents () const
00251 { return agent_defaults; }
00252
00253
00254 static const RecordInterface & defaultOptions ();
00255
00256
00257 static LogIO & logSink () { return os; }
00258
00259
00260 static void reform_baselinelist(Matrix<Int> &baselinelist, unsigned nant);
00261
00262 static int my_aipspp_sum(const Array<Bool> &a);
00263
00264 private:
00265
00266 Flagger( const Flagger & ) {};
00267
00268 Flagger& operator=(const Flagger &) { return *this; };
00269
00270 void printAgentRecord(String &, uInt, const RecordInterface &);
00271
00272
00273 LogSink logSink_p;
00274
00275
00276 MeasurementSet *originalms_p;
00277
00278
00279 MSSelection *msselection_p;
00280 bool spw_selection;
00281
00282
00283 Record *agents_p;
00284 Int agentCount_p;
00285
00286
00287 Record *opts_p;
00288
00289
00290 static const bool dbg;
00291
00292 Bool quack_agent_exists;
00293
00294 };
00295
00296
00297 }
00298
00299 #endif
00300