casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PlotMSFlagging.h
Go to the documentation of this file.
1 //# PlotMSFlagging.h: Flagging parameters.
2 //# Copyright (C) 2009
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 received 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 #ifndef PLOTMSFLAGGING_H_
28 #define PLOTMSFLAGGING_H_
29 
32 
33 namespace casa {
34 
35 // Specifies flagging parameters (including possibly flag extension) for an MS.
37 public:
38  // Static //
39 
40  // Enum and methods to define the different fields for an casacore::MS flagging. All
41  // fields have a bool flag for on/off, and some of them also have a double
42  // value (see fieldHasValue()) or a PlotMSSelection value (see
43  // fieldHasSelectionValue()). Most fields are off by default (see
44  // fieldDefault()), with a default double value of 0 or empty/default
45  // PlotMSSelection value if applicable. Some fields are in mutually
46  // exclusive groups (see fieldMutuallyExclusiveGroup()).
47  // **If these are changed, also update: convenience methods below,
48  // xmlcasa/implement/plotms/plotms*, xmlcasa/tasks/plotms.xml,
49  // xmlcasa/scripts/task_plotms.py.**
50  // <group>
52  EXTEND, CORR, CORR_ALL,
53  CORR_POLN_DEP, CHANNEL, SPW, ANTENNA,
54  ANTENNA_ANTENNA, ANTENNA_BASELINES, TIME,
55  SCANS, FIELD, SEL_SELECTED, SEL_ALTERNATE)
57  "extend", "correlation", "correlation:all",
58  "correlation:poln-dep", "channel", "spw", "antenna",
59  "antenna:antenna-based", "antenna:all-baselines", "time",
60  "scans", "field", "selection:selected", "selection:alternate")
61  // </group>
62 
63  // Returns whether the given field has a double value associated with it or
64  // not.
65  static bool fieldHasValue(Field f);
66 
67  // Returns whether the given field has a PlotMSSelection value associated
68  // with it or not.
69  static bool fieldHasSelectionValue(Field f);
70 
71  // Returns whether the given field is on or off by default. This is
72  // important for mutually exclusive groups, which need to know which field
73  // in that group is on to begin with.
74  static bool fieldDefault(Field f);
75 
76  // Returns the list of fields, NOT including the given, with which the
77  // given field is mutually exclusive. In a mutually exclusive group, only
78  // and exactly one field can be turned on at a given time. NOTE: this is
79  // different from mutually exclusive groups in PlotMSAveraging, because
80  // here it is NOT allowed to have all fields in a group turned off.
81  static const std::vector<Field>& fieldMutuallyExclusiveGroup(Field f);
82 
83  // Returns true if the given field is in a mutually exclusive group, false
84  // otherwise. See fieldMutuallyExclusiveGroup().
85  static bool fieldIsInMutuallyExclusiveGroup(Field f) {
86  return fieldMutuallyExclusiveGroup(f).size() > 0; }
87 
88 
89  // Non-Static //
90 
91  // Default constructor.
93 
94  // Destructor.
96 
97  // Converts this object to/from a record. Each field will have a key that
98  // is its enum name, with a bool value for its flag value. Fields that
99  // also have double values will have an additional key that is its enum
100  // name + "Value" for double values, or its enum name + "SelectionValue"
101  // for PlotMSSelection values. PlotMSSelection values are stored in Record
102  // form (see PlotMSSelection::fromRecord()). The casacore::MS objects (the casacore::MS, the
103  // selected casacore::MS, and the vis set) are NOT included in the record.
104  // <group>
105  void fromRecord(const casacore::RecordInterface& record);
106  casacore::Record toRecord(bool useStrings = false) const;
107  // </group>
108 
109  // Gets/Sets the on/off flag for the given field.
110  // <group>
111  bool getFlag(Field f) const;
112  void getFlag(Field f, bool& flag) const { flag = getFlag(f); }
113  void setFlag(Field f, bool on);
114  // </group>
115 
116  // Gets/Sets the double value for the given field, if applicable.
117  // <group>
118  double getValue(Field f) const;
119  void getValue(Field f, double& value) const { value = getValue(f); }
120  void setValue(Field f, double value);
121  // </group>
122 
123  // Gets/Sets the value for the given field as a String. Only applicable
124  // for special cases (correlation, antenna).
125  // Correlation: "", "all", or "poln-dep".
126  // Antenna: "", "all", or antenna-based value.
127  // <group>
128  casacore::String getValueStr(Field f) const;
129  void getValue(Field f, casacore::String& value) const { value = getValueStr(f); }
130  void setValue(Field f, const casacore::String& value);
131  // </group>
132 
133  // Gets/Sets the selection value for the given field, if applicable.
134  // <group>
135  PlotMSSelection getSelectionValue(Field f) const;
136  void getSelectionValue(Field f, PlotMSSelection& value) const {
137  value = getSelectionValue(f); }
138  void setSelectionValue(Field f, const PlotMSSelection& value);
139  // </group>
140 
141 
142  // Convenience methods for returning the standard field values.
143  // <group>
144  bool extend() const { return getFlag(EXTEND); }
145  bool corr() const { return (extend() && getFlag(CORR)); }
146  bool corrAll() const { return (corr() && getFlag(CORR_ALL)); }
147  bool corrPolnDep() const { return (corr() && getFlag(CORR_POLN_DEP)); }
148  casacore::String corrStr() const { return getValueStr(CORR); }
149  bool channel() const { return (extend() && getFlag(CHANNEL)); }
150  bool spw() const { return (extend() && getFlag(SPW)); }
151  bool antenna() const { return (extend() && getFlag(ANTENNA)); }
152  bool antennaAntennaBased() const { return (antenna() && getFlag(ANTENNA_ANTENNA)); }
153  double antennaAntennaBasedValue() const{ return getValue(ANTENNA_ANTENNA);}
154  bool antennaBaselinesBased() const { return (antenna() && getFlag(ANTENNA_BASELINES)); }
155  casacore::String antennaStr() const { return getValueStr(ANTENNA); }
156  bool time() const { return (extend() && getFlag(TIME)); }
157  bool scans() const { return (time() && getFlag(SCANS)); }
158  bool field() const { return (time() && getFlag(FIELD)); }
159  bool selectionSelected() const { return (extend() && getFlag(SEL_SELECTED)); }
160  bool selectionAlternate() const { return (extend() && getFlag(SEL_ALTERNATE)); }
162  return getSelectionValue(SEL_ALTERNATE); }
163  // </group>
164 
165  // Convenience methods for setting the standard field values.
166  // <group>
167  void setExtend(bool flag) { setFlag(EXTEND, flag); }
168  void setCorr(bool flag) { setFlag(CORR, flag); }
169  void setCorrAll(bool flag) { setFlag(CORR_ALL, flag); }
170  void setCorrPolnDep(bool flag) { setFlag(CORR_POLN_DEP, flag); }
171  void setCorr(const casacore::String& value) { setValue(CORR, value); }
172  void setChannel(bool flag) { setFlag(CHANNEL, flag); }
173  void setSpw(bool flag) { setFlag(SPW, flag); }
174  void setAntenna(bool flag) { setFlag(ANTENNA, flag); }
175  void setAntennaAntennaBased(bool flag) { setFlag(ANTENNA_ANTENNA, flag); }
177  setValue(ANTENNA_ANTENNA, value); }
178  void setAntennaBaselinesBased(bool flag){setFlag(ANTENNA_BASELINES, flag);}
179  void setAntenna(const casacore::String& value) { setValue(ANTENNA, value); }
180  void setTime(bool flag) { setFlag(TIME, flag); }
181  void setScans(bool flag) { setFlag(SCANS, flag); }
182  void setField(bool flag) { setFlag(FIELD, flag); }
183  void setSelectionSelected(bool flag) { setFlag(SEL_SELECTED, flag); }
184  void setSelectionAlternate(bool flag) { setFlag(SEL_ALTERNATE, flag); }
186  setSelectionValue(SEL_ALTERNATE, value); }
187  // </group>
188 
189 
190  // Equality operators.
191  // <group>
192  bool operator==(const PlotMSFlagging& other) const;
193  bool operator!=(const PlotMSFlagging& other) const {
194  return !(operator==(other)); }
195  // </group>
196 
197 private:
198 
199  // Flagging field flags.
200  std::map<Field, bool> itsFlags_;
201 
202  // Flagging field double values.
203  std::map<Field, double> itsValues_;
204 
205  // Flagging field selection values.
206  std::map<Field, PlotMSSelection> itsSelectionValues_;
207 
208 
209  // Sets the default values.
210  void setDefaults();
211 
212 
213  // casacore::String constant for what to append to the enum name in the record to
214  // get the key for the value.
215  // <group>
218  // </group>
219 };
220 
221 }
222 
223 #endif /* PLOTMSFLAGGING_H_ */
void setScans(bool flag)
void setChannel(bool flag)
bool selectionSelected() const
void setTime(bool flag)
PlotMSSelection getSelectionValue(Field f) const
Gets/Sets the selection value for the given field, if applicable.
void getSelectionValue(Field f, PlotMSSelection &value) const
static const casacore::String RKEY_SELVALUE
void setSelectionValue(Field f, const PlotMSSelection &value)
#define PMS_ENUM2(NAME, ALLMETHOD, ALLSTRMETHOD, CONVMETHOD,...)
~PlotMSFlagging()
Destructor.
void setCorr(const casacore::String &value)
static bool fieldDefault(Field f)
Returns whether the given field is on or off by default.
void setCorrPolnDep(bool flag)
bool channel() const
bool antennaBaselinesBased() const
void setSelectionAlternate(bool flag)
Specifies an casacore::MS selection.
static bool fieldIsInMutuallyExclusiveGroup(Field f)
Returns true if the given field is in a mutually exclusive group, false otherwise.
static const casacore::String RKEY_VALUE
casacore::String constant for what to append to the enum name in the record to get the key for the va...
void setAntennaAntennaBasedValue(double value)
static const std::vector< Field > & fieldMutuallyExclusiveGroup(Field f)
Returns the list of fields, NOT including the given, with which the given field is mutually exclusive...
void setAntenna(bool flag)
void fromRecord(const casacore::RecordInterface &record)
Converts this object to/from a record.
double getValue(Field f) const
Gets/Sets the double value for the given field, if applicable.
casacore::String antennaStr() const
void setAntennaAntennaBased(bool flag)
std::map< Field, double > itsValues_
Flagging field double values.
bool corrAll() const
void setAntennaBaselinesBased(bool flag)
void getValue(Field f, casacore::String &value) const
static bool fieldHasSelectionValue(Field f)
Returns whether the given field has a PlotMSSelection value associated with it or not...
std::map< Field, PlotMSSelection > itsSelectionValues_
Flagging field selection values.
Specifies flagging parameters (including possibly flag extension) for an MS.
bool getFlag(Field f) const
Gets/Sets the on/off flag for the given field.
bool antenna() const
void setSpw(bool flag)
casacore::Record toRecord(bool useStrings=false) const
bool operator==(const PlotMSFlagging &other) const
Equality operators.
A hierarchical collection of named fields of various types.
Definition: Record.h:180
PlotMSSelection selectionAlternateSelection() const
PlotMSFlagging()
Non-Static //.
bool antennaAntennaBased() const
void setField(bool flag)
void setDefaults()
Sets the default values.
std::map< Field, bool > itsFlags_
Flagging field flags.
void setFlag(Field f, bool on)
void setValue(Field f, double value)
void setSelectionAlternateSelection(const PlotMSSelection &value)
casacore::String corrStr() const
double antennaAntennaBasedValue() const
void setCorr(bool flag)
void setCorrAll(bool flag)
casacore::String getValueStr(Field f) const
Gets/Sets the value for the given field as a String.
void getFlag(Field f, bool &flag) const
bool selectionAlternate() const
String: the storage and methods of handling collections of characters.
Definition: String.h:223
void setAntenna(const casacore::String &value)
bool corrPolnDep() const
PMS_ENUM1(Field, fields, fieldStrings, field, EXTEND, CORR, CORR_ALL, CORR_POLN_DEP, CHANNEL, SPW, ANTENNA, ANTENNA_ANTENNA, ANTENNA_BASELINES, TIME, SCANS, FIELD, SEL_SELECTED, SEL_ALTERNATE) PMS_ENUM2(Field
Static //.
Abstract base class for Record classes.
LatticeExprNode all(const LatticeExprNode &expr)
void setExtend(bool flag)
Convenience methods for setting the standard field values.
bool extend() const
Convenience methods for returning the standard field values.
void setSelectionSelected(bool flag)
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
void getValue(Field f, double &value) const
bool operator!=(const PlotMSFlagging &other) const