casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PlotMSAveraging.h
Go to the documentation of this file.
1 //# PlotMSAveraging.h: Averaging 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 PLOTMSAVERAGING_H_
28 #define PLOTMSAVERAGING_H_
29 
31 
32 #include <map>
33 
34 namespace casa {
35 
36 // Specifies averaging parameters for an MS.
38 public:
39  // Static //
40 
41  // Enum and methods to define the different fields for an casacore::MS averaging.
42  // All fields have a bool flag for on/off, and some of them also have a
43  // double value (see fieldHasValue()). Fields are off by default, with a
44  // default double value of 0 if applicable. Some fields are in mutually
45  // exclusive groups (see fieldMutuallyExclusiveGroup()).
46  // **If these are changed, also update: convenience methods below,
47  // xmlcasa/implement/plotms/plotms*, xmlcasa/tasks/plotms.xml,
48  // xmlcasa/scripts/task_plotms.py.**
49  // <group>
51  CHANNEL, TIME, SCAN, FIELD, BASELINE, ANTENNA, SPW,
52  SCALARAVE)
54  "channel", "time", "scan", "field", "baseline",
55  "antenna", "spw",
56  "scalar")
57  // </group>
58 
59  // Returns whether the given field has a double value associated with it or
60  // not.
61  static bool fieldHasValue(Field f);
62 
63  // Returns the list of fields, NOT including the given, with which the
64  // given field is mutually exclusive. In a mutually exclusive group, only
65  // one field can be turned on at a given time (although they can all be
66  // off at the same time).
67  static const std::vector<Field>& fieldMutuallyExclusiveGroup(Field f);
68 
69  // Returns true if the given field is in a mutually exclusive group, false
70  // otherwise. See fieldMutuallyExclusiveGroup().
71  static bool fieldIsInMutuallyExclusiveGroup(Field f) {
72  return fieldMutuallyExclusiveGroup(f).size() > 0; }
73 
74 
75  // Non-Static //
76 
77  // Constructor, which uses default values.
79 
80  // Destructor.
82 
83 
84  // Converts this object to/from a record. Each field will have a key that
85  // is its enum name, with a bool value for its flag value. Fields that
86  // also have double values will have an additional key that is its enum
87  // name + "Value" (i.e. "channelValue" for CHANNEL) with a double value.
88  // <group>
89  void fromRecord(const casacore::RecordInterface& record);
90  casacore::Record toRecord(bool useStrings = false) const;
91  // </group>
92 
93  // Gets/Sets the on/off flag for the given field.
94  // <group>
95  bool getFlag(Field f) const;
96  void getFlag(Field f, bool& flag) const { flag = getFlag(f); }
97  void setFlag(Field f, bool on);
98  // </group>
99 
100  // Gets/Sets the double value for the given field, if applicable.
101  // <group>
102  double getValue(Field f) const;
103  void getValue(Field f, double& value) const { value = getValue(f); }
104  void setValue(Field f, double value);
105  // </group>
106 
107  // Gets/Sets the value for the given field as a String. Blank means a
108  // false value (or a field that does not have a double value); otherwise
109  // the double value in casacore::String form is used.
110  // <group>
111  casacore::String getValueStr(Field f) const;
112  void getValue(Field f, casacore::String& value) const { value = getValueStr(f); }
113  void setValue(Field f, const casacore::String& value);
114  // </group>
115 
116 
117  // If any explicit averaging is turned ON, return true
118  bool anyAveraging() const { return (channel() || time() ||
119  baseline() || antenna() ||spw()); }
120 
121  // Convenience methods for returning the standard field values.
122  // <group>
123  bool channel() const { return getFlag(CHANNEL); }
124  double channelValue() const { return getValue(CHANNEL); }
125  casacore::String channelStr() const { return getValueStr(CHANNEL); }
126  bool time() const { return getFlag(TIME); }
127  double timeValue() const { return getValue(TIME); }
128  casacore::String timeStr() const { return getValueStr(TIME); }
129  bool scan() const { return getFlag(SCAN); }
130  bool field() const { return getFlag(FIELD); }
131  bool baseline() const { return getFlag(BASELINE); }
132  bool antenna() const { return getFlag(ANTENNA); }
133  bool spw() const { return getFlag(SPW); }
134  bool scalarAve() const { return getFlag(SCALARAVE); }
135  // </group>
136 
137  // Convenience methods for setting the standard field values.
138  // <group>
139  void setChannel(const casacore::String& value) { setValue(CHANNEL, value); }
140  void setChannel(bool flag) { setFlag(CHANNEL, flag); }
141  void setChannelValue(double value) { setValue(CHANNEL, value); }
142  void setTime(const casacore::String& value) { setValue(TIME, value); }
143  void setTime(bool flag) { setFlag(TIME, flag); }
144  void setTimeValue(double value) { setValue(TIME, value); }
145  void setScan(bool flag) { setFlag(SCAN, flag); }
146  void setField(bool flag) { setFlag(FIELD, flag); }
147  void setBaseline(bool flag) { setFlag(BASELINE, flag); }
148  void setAntenna(bool flag) { setFlag(ANTENNA, flag); }
149  void setSpw(bool flag) { setFlag(SPW, flag); }
150  void setScalarAve(bool flag) { setFlag(SCALARAVE,flag); }
151  // </group>
152 
153 
154  // Equality operators.
155  // <group>
156  bool operator==(const PlotMSAveraging& other) const;
157  bool operator!=(const PlotMSAveraging& other) const {
158  return !(operator==(other)); }
159  // </group>
160 
161  // Print out a summary of the averaging state:
162  casacore::String summary() const;
163 
164  //Print out an abbreviated summary of the averaging state.
166 
167 private:
168  // Averaging field flags.
169  std::map<Field, bool> itsFlags_;
170 
171  // Averaging field double values.
172  std::map<Field, double> itsValues_;
173 
174 
175  // Sets the default values.
176  void setDefaults();
177 
178 
179  // casacore::String constant for what to append to the enum name in the record to
180  // get the key for the double value.
182 };
183 
184 }
185 
186 #endif /* PLOTMSAVERAGING_H_ */
casacore::String summary() const
Print out a summary of the averaging state:
void getValue(Field f, double &value) const
Specifies averaging parameters for an MS.
void fromRecord(const casacore::RecordInterface &record)
Converts this object to/from a record.
double timeValue() const
~PlotMSAveraging()
Destructor.
std::map< Field, bool > itsFlags_
Averaging field flags.
#define PMS_ENUM2(NAME, ALLMETHOD, ALLSTRMETHOD, CONVMETHOD,...)
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 do...
void setScan(bool flag)
void setValue(Field f, double value)
PlotMSAveraging()
Non-Static //.
void setTime(const casacore::String &value)
void setTimeValue(double value)
double getValue(Field f) const
Gets/Sets the double value for the given field, if applicable.
casacore::Record toRecord(bool useStrings=false) const
void setTime(bool flag)
void setChannel(bool flag)
void getValue(Field f, casacore::String &value) const
void setFlag(Field f, bool on)
casacore::String timeStr() const
bool anyAveraging() const
If any explicit averaging is turned ON, return true.
void getFlag(Field f, bool &flag) const
PMS_ENUM1(Field, fields, fieldStrings, field, CHANNEL, TIME, SCAN, FIELD, BASELINE, ANTENNA, SPW, SCALARAVE) PMS_ENUM2(Field
Static //.
bool channel() const
Convenience methods for returning the standard field values.
void setField(bool flag)
casacore::String channelStr() const
bool getFlag(Field f) const
Gets/Sets the on/off flag for the given field.
void setDefaults()
Sets the default values.
void setSpw(bool flag)
A hierarchical collection of named fields of various types.
Definition: Record.h:180
void setAntenna(bool flag)
std::map< Field, double > itsValues_
Averaging field double values.
bool operator==(const PlotMSAveraging &other) const
Equality operators.
void setBaseline(bool flag)
static bool fieldIsInMutuallyExclusiveGroup(Field f)
Returns true if the given field is in a mutually exclusive group, false otherwise.
casacore::String getValueStr(Field f) const
Gets/Sets the value for the given field as a String.
double channelValue() const
casacore::String toStringShort() const
Print out an abbreviated summary of the averaging state.
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...
String: the storage and methods of handling collections of characters.
Definition: String.h:223
static scalar bool fieldHasValue(Field f)
Returns whether the given field has a double value associated with it or not.
Abstract base class for Record classes.
void setScalarAve(bool flag)
void setChannelValue(double value)
void setChannel(const casacore::String &value)
Convenience methods for setting the standard field values.
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
bool operator!=(const PlotMSAveraging &other) const