casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ExtendFlagger.h
Go to the documentation of this file.
1 //# ExtendFlagger.h:
2 //# Copyright (C) 1994,1995,1996,1997,1998,1999,2000,2001,2002,2003-2008
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have receied a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 //#
28 //# ----------------------------------------------------------------------------
29 //# Change Log
30 //# ----------------------------------------------------------------------------
31 //# Date Name Comments
32 
33 
34 #ifndef EXTENDFLAGGER_H
35 #define EXTENDFLAGGER_H
36 
37 //# Includes
38 
39 #include <casa/aips.h>
40 #include <casa/iostream.h>
41 #include <casa/OS/Timer.h>
42 
43 #include <casa/Arrays/Vector.h>
44 #include <casa/Arrays/Array.h>
45 #include <casa/Arrays/Matrix.h>
46 #include <casa/Arrays/Slicer.h>
47 
48 #include <tables/Tables/Table.h>
52 
53 #include <tables/TaQL/ExprNode.h>
54 #include <tables/TaQL/RecordGram.h>
55 
58 
59 
60 namespace casa { //# NAMESPACE CASA - BEGIN
61 
62 // <summary>
63 // class for flaging and extend flagging
64 // </summary>
65 
66 // <use visibility=export>
67 
68 // <reviewed reviewer="" date="" tests="">
69 // </reviewed>
70 
71 // <prerequisite>
72 //#! Classes or concepts you should understand before using this class.
73 // </prerequisite>
74 
75 // <etymology>
76 //
77 //
78 //There will be an "extendflag" T/F parameter and a number of
79 //subparameters. This so that individual extensions can be better
80 //controlled.
81 //
82 //extendflag = T
83 // extendcorr = '' # ''=default,'all' (future: 'half')
84 // extendchan = '' # ''=default,'all'
85 // extendspw = '' # ''=default,'all'
86 // extendant = '' # ''=default,'all'
87 // extendtime = '' # ''=default,'all' (future: 'scan','field')
88 //
89 //In all cases the '' and 'all' options are the ones to implement first.
90 //Next, if time allows, implement the ones in parentheses. More
91 //esoteric ones are given below and would be after these (and probably
92 //need more thought).
93 //
94 //NOTE: the extendchan and extendcorr are "in-row" selection (they
95 //extend the flags to quantities in the same visibility that is plotted
96 //and selected on), while the others are in different rows. The in-row
97 //ones will be implemented first (CAS-714), the rest later (CAS-715).
98 //
99 //Note that these extensions are combined at the end, thus if you choose
100 //'all' for all of these I think you will flag the entire dataset if you
101 //flag any point! So be it. Also, averaging effectively extends the
102 //flags to everything included in the average.
103 //
104 //Individually:
105 //
106 //extendcorr
107 // '' flag only current point(s) correlations
108 // 'all' extend flag to all correlations,
109 // example: if RR selected then flag RR,RL,LR,LL
110 //
111 // Future options:
112 // 'half' extend flag to all correlations with current one
113 // example: if RR selected then flag RR,RL,LR (not LL)
114 // NOTE: if RL selected then this rule would nominally
115 // flag RR,RL,LL but not LR, should probably default to
116 // 'all' in this case?
117 //
118 // Possible other options:
119 // <correlation> take standard correlation selection string
120 // example: extendcorr='RL,LR'
121 //
122 //extendchan
123 // '' flag only current selected channels
124 // 'all' extend flag to all channels
125 //
126 // NOTE: the spw that these apply to is given by extendspw (default is
127 // current)
128 //
129 // Possible other options:
130 // <chan> take standard channel selection/range string (the part after :
131 // in spw string)
132 // example: extendchan='0~4,59~63'
133 //
134 //extendspw
135 // '' flag channel(s) only in current spw
136 // 'all' extend flag to all spw (of current shape if extendchan not 'all')
137 //
138 // NOTE: if extendchan='' and extendspw='all', then only spw of the same
139 //shape as the current spw will have the specified channel
140 //flagged. This is so flagging on "narrow-band" spw will not
141 //flag "wide-band" spw by mistake.
142 // example: if CH 0 of spw with 64 chans is selected, then CH 0 in
143 // all spw of 64 chans will flagged by extension
144 //
145 // Possible other options:
146 // <spw> take standard spw selection/range string (the part before : in
147 // spw string)
148 // example: extendspw='0,3~6'
149 //extendant
150 // '' flag only current point(s) baseline
151 // 'all' flag all baselines (fitting other selection/extension)
152 // BEWARE - this option could delete excessive amounts of data
153 // NOTE: if the user has chosen iteration='antenna' then 'all'
154 // should flag only baselines to the current iteration of antenna.
155 // Likewise if iteration='baseline', extendant='all' should flag
156 // only the current baseline (in this case will act like '').
157 // Otherwise the user would not be iterating.
158 //
159 // Possible other options:
160 // 'ant1' extend flag to all baselines with the current point(s) ANT1
161 // 'ant2' extend flag to all baselines with the current point(s) ANT2
162 // <antenna> take standard antenna selection string
163 // example: extendant='EA11,1&3'
164 //
165 //extendtime
166 // '' flag only current point(s) integration (or average)
167 // 'all' flag all integs matching rest of selection in entire dataset -
168 // BEWARE - this could delete excessive amounts of data
169 // NOTE: if iteration='field' is chosen, then 'all' will flag only
170 // integrations in the current field iteration (not all fields)
171 //
172 // Future options:
173 // 'scan' flag all integs in current scan
174 // 'field' if xaxis='time' then flag all fields that would fall in box
175 // drawn
176 // example: would flag target source between plotted calibrators
177 //
178 // Possible other options:
179 // <timerange> take a standard timerange string
180 // example: extendtime='25:00:00~27:30:00'
181 //
182 //
183 //Note that if the suggested future extend strings using selection
184 //syntax (e.g.extendchan='10~20') is implemented, the extensions could
185 //be to data disjoint from what is actually displayed.
186 //
187 //GUI Developments:
188 //
189 //Eventually, we will want to have an icon on the GUI that will bring up
190 //a menu to change these during flagging. This is particularly useful
191 //for the in-row selections (extendchan and extendcorr).
192 //
193 // </etymology>
194 
195 // <synopsis>
196 //
197 // </synopsis>
198 
199 // <example>
200 // <srcblock>
201 // ExtendFlagger eflg;
202 // eflg.attach(ms);
203 // eflg.setdata();
204 // eflg.setmanualflags();
205 // eflg.run()
206 // </srcblock>
207 // </example>
208 
209 // <motivation>
210 // It has long been on the users wish list to do extended flagging
211 // </motivation>
212 
213 // <thrown>
214 // <li>
215 // <li>
216 // </thrown>
217 
218 // <todo asof="$DATE:$">
219 //
220 // </todo>
221 
222 class FlagIDS {
223  public:
225  bl = "";
226  field = 0;
227  time = "";
228  spw = "";
229  corr = "";
230  chan = "";
231  }
232 
239 
240  FlagIDS &operator=(const FlagIDS &other) {
241  bl = other.bl;
242  field = other.field;
243  time = other.time;
244  spw = other.spw;
245  corr = other.corr;
246  chan = other.chan;
247  return *this;
248  }
249 
250  static int compareID (const void* val1, const void* val2);
251 
252  void show() {
253  std::cout
254  << " time=" << time
255  << " bl=" << bl
256  << " field=" << field
257  << " spw=" << spw
258  << " corr=" << corr
259  << " chan=" << chan
260  << std::endl;
261  }
262 };
263 
264 class FlagID {
265  public:
266  FlagID() {
267  rowNum = 0;
268  //casacore::uInt npts;
269  ant1 = 0;
270  ant2 = 0;
271  field = 0;
272  time = "";
273  spw = 0;
274  corr = "";
275  chan = "";
276  polid = 0;
277  }
278 
280  //casacore::uInt npts;
289 
290  FlagID &operator=(const FlagID &other) {
291  rowNum = other.rowNum;
292  //casacore::uInt npts;
293  ant1 = other.ant1;
294  ant2 = other.ant2;
295  field = other.field;
296  time = other.time;
297  spw = other.spw;
298  corr = other.corr;
299  chan = other.chan;
300  polid = other.polid;
301  return *this;
302  }
303 
304  static int compare (const void* val1, const void* val2);
305 
306  void show() {
307  std::cout << "rowNum=" << rowNum
308  //casacore::uInt npts;
309  << " ant1=" << ant1
310  << " ant2=" << ant2
311  << " field=" << field
312  << " time=" << time
313  << " spw=" << spw
314  << " corr=" << corr
315  << " chan=" << chan
316  << " polid=" << polid
317  << std::endl;
318  }
319 };
320 
322 {
323  public:
324  // Constructor
325  ExtendFlagger();
327  const casacore::String& excorr, const casacore::String& exant,
328  const casacore::String& exspw, const casacore::String& time,
330 
331  // Destructor
332  virtual ~ExtendFlagger();
333 
334  // Operator=
335  // Equate by reference.
336  ExtendFlagger& operator=(const ExtendFlagger&){return *this;}
337 
339  void detach();
340 
342  const casacore::String& array = "", const casacore::String& feed = "",
343  const casacore::String& scan = "", const casacore::String& baseline = "",
344  const casacore::String& uvrange = "", const casacore::String& time = "",
345  const casacore::String& correlation = "", const casacore::String& intent = "");
346 
348 
349  casacore::Bool selectdata(casacore::Bool useoriginalms = true);
350 
352  casacore::Bool autocorr = false);
353 
354  casacore::Bool run(casacore::Bool trial = false, casacore::Bool reset = false);
355 
358 
359  void setField(const casacore::String& field);
360  void setSpw(const casacore::String& spw);
361  void setArray(const casacore::String& array);
362  void setFeed(const casacore::String& feed);
363  void setScan(const casacore::String& scan);
365  void setUvrange(const casacore::String& uvrange);
366  void setTime(const casacore::String& time);
368  void setIntent(const casacore::String& intent);
369  void setUnflag(casacore::Bool unflg);
370 
371  void setExtendChan(const casacore::String& exchan);
372  void setExtendCorr(const casacore::String& excorr);
373  void setExtendSpw(const casacore::String& exspw);
374  void setExtendTime(const casacore::String& extime);
375  void setExtendAnt(const casacore::String& exant);
376  void setExtend(const casacore::String& exchan, const casacore::String& excorr,
377  const casacore::String& exspw, const casacore::String& exant,
378  const casacore::String& extime,
382  casacore::String halfExtendCorr(const casacore::String& corr, const casacore::uInt polid = 0);
384  void show();
385  private:
386 
388  // casacore::Bool useoriginalms;
389 
400 
408 
410 
416 
419 
420 };
421 
422 } //# NAMESPACE CASA - END
423 
424 //#ifndef AIPS_NO_TEMPLATE_SRC
425 //#include <flagging/Flagging/ExtendFlagger.cc>
426 //#endif //# AIPS_NO_TEMPLATE_SRC
427 #endif
428 
casacore::Bool selectdata(casacore::Bool useoriginalms=true)
static int compare(const void *val1, const void *val2)
A 1-D Specialization of the Array class.
int Int
Definition: aipstype.h:50
casacore::uInt ant2
casacore::String spw
virtual ~ExtendFlagger()
Destructor.
casacore::String bl
casacore::String extendSpw
casacore::Vector< casacore::Int > chanNum
virtual void reset()
Overrides PlotTool::reset().
casacore::String extendTime
void setExtend(const casacore::String &exchan, const casacore::String &excorr, const casacore::String &exspw, const casacore::String &exant, const casacore::String &extime, const casacore::Vector< casacore::Vector< casacore::String > > &corrs, const casacore::Vector< casacore::Int > &chans)
ExtendFlagger()
Constructor.
casacore::uInt ant1
casacore::uInt npts;
casacore::String intent
void setArray(const casacore::String &array)
casacore::String clipcolumn
casacore::uInt rowNum
FlagID & operator=(const FlagID &other)
void setExtendSpw(const casacore::String &exspw)
casacore::uInt field
casacore::String halfExtendCorr(const casacore::String &corr, const casacore::uInt polid=0)
class for flaging and extend flagging
casacore::String corr
casacore::String feed
casacore::String time
casacore::uInt field
void setBaseline(const casacore::String &baseline)
casacore::Bool unflag
void setFeed(const casacore::String &feed)
casacore::String opmode
FlagIDS & operator=(const FlagIDS &other)
casacore::Double quackinterval
casacore::String ableSpw(const casacore::Int spw)
void setSpw(const casacore::String &spw)
void setExtendAnt(const casacore::String &exant)
double Double
Definition: aipstype.h:55
void setUvrange(const casacore::String &uvrange)
casacore::String time
casacore::Bool setmanualflags(casacore::Bool unflag=false, casacore::Bool autocorr=false)
void setUnflag(casacore::Bool unflg)
void setExtendTime(const casacore::String &extime)
Flagger: high-performance automated flagging.
Definition: Flagger.h:100
casacore::String uvrange
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
casacore::Bool attach(casacore::MeasurementSet &ms)
void setAbleCorr(const casacore::Vector< casacore::Vector< casacore::String > > &corrName)
casacore::Vector< casacore::Double > cliprange
casacore::String field
casacore::Bool useoriginalms;
casacore::String scan
void setTime(const casacore::String &time)
casacore::uInt spw
void setIntent(const casacore::String &intent)
casacore::String array
casacore::Bool run(casacore::Bool trial=false, casacore::Bool reset=false)
casacore::String chan
casacore::Bool extend2(const casacore::Vector< FlagID > &flagids)
A Table intended to hold astronomical data (a set of Measurements).
casacore::String chan
ExtendFlagger & operator=(const ExtendFlagger &)
Operator= Equate by reference.
casacore::String spw
casacore::Vector< casacore::Vector< casacore::String > > ableCorr
casacore::Bool channelavg
void setExtendChan(const casacore::String &exchan)
casacore::String extendCorr
casacore::String correlation
void setChanNum(const casacore::Vector< casacore::Int > &chanNum)
casacore::Bool initdata(const casacore::String &field="", const casacore::String &spw="", const casacore::String &array="", const casacore::String &feed="", const casacore::String &scan="", const casacore::String &baseline="", const casacore::String &uvrange="", const casacore::String &time="", const casacore::String &correlation="", const casacore::String &intent="")
casacore::Bool setdata()
casacore::String extendChan
casacore::Bool outside
casacore::uInt polid
String: the storage and methods of handling collections of characters.
Definition: String.h:223
casacore::String corr
casacore::String clipexpr
casacore::Bool extend(const casacore::Vector< FlagID > &flagids)
casacore::String time
void setExtendCorr(const casacore::String &excorr)
void setCorrelation(const casacore::String &correlation)
static int compareID(const void *val1, const void *val2)
casacore::String extendAnt
casacore::String baseline
unsigned int uInt
Definition: aipstype.h:51
void setScan(const casacore::String &scan)
void setField(const casacore::String &field)