casa
$Rev:20696$
|
00001 //# PlotMSAveraging.h: Averaging parameters. 00002 //# Copyright (C) 2009 00003 //# Associated Universities, Inc. Washington DC, USA. 00004 //# 00005 //# This library is free software; you can redistribute it and/or modify it 00006 //# under the terms of the GNU Library General Public License as published by 00007 //# the Free Software Foundation; either version 2 of the License, or (at your 00008 //# option) any later version. 00009 //# 00010 //# This library is distributed in the hope that it will be useful, but WITHOUT 00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00013 //# License for more details. 00014 //# 00015 //# You should have received a copy of the GNU Library General Public License 00016 //# along with this library; if not, write to the Free Software Foundation, 00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00018 //# 00019 //# Correspondence concerning AIPS++ should be addressed as follows: 00020 //# Internet email: aips2-request@nrao.edu. 00021 //# Postal address: AIPS++ Project Office 00022 //# National Radio Astronomy Observatory 00023 //# 520 Edgemont Road 00024 //# Charlottesville, VA 22903-2475 USA 00025 //# 00026 //# $Id: $ 00027 #ifndef PLOTMSAVERAGING_H_ 00028 #define PLOTMSAVERAGING_H_ 00029 00030 #include <plotms/PlotMS/PlotMSConstants.h> 00031 00032 #include <map> 00033 00034 #include <casa/namespace.h> 00035 00036 namespace casa { 00037 00038 // Specifies averaging parameters for an MS. 00039 class PlotMSAveraging { 00040 public: 00041 // Static // 00042 00043 // Enum and methods to define the different fields for an MS averaging. 00044 // All fields have a bool flag for on/off, and some of them also have a 00045 // double value (see fieldHasValue()). Fields are off by default, with a 00046 // default double value of 0 if applicable. Some fields are in mutually 00047 // exclusive groups (see fieldMutuallyExclusiveGroup()). 00048 // **If these are changed, also update: convenience methods below, 00049 // xmlcasa/implement/plotms/plotms*, xmlcasa/tasks/plotms.xml, 00050 // xmlcasa/scripts/task_plotms.py.** 00051 // <group> 00052 PMS_ENUM1(Field, fields, fieldStrings, field, 00053 CHANNEL, TIME, SCAN, FIELD, BASELINE, ANTENNA, SPW, 00054 SCALARAVE) 00055 PMS_ENUM2(Field, fields, fieldStrings, field, 00056 "channel", "time", "scan", "field", "baseline", 00057 "antenna", "spw", 00058 "scalar") 00059 // </group> 00060 00061 // Returns whether the given field has a double value associated with it or 00062 // not. 00063 static bool fieldHasValue(Field f); 00064 00065 // Returns the list of fields, NOT including the given, with which the 00066 // given field is mutually exclusive. In a mutually exclusive group, only 00067 // one field can be turned on at a given time (although they can all be 00068 // off at the same time). 00069 static const vector<Field>& fieldMutuallyExclusiveGroup(Field f); 00070 00071 // Returns true if the given field is in a mutually exclusive group, false 00072 // otherwise. See fieldMutuallyExclusiveGroup(). 00073 static bool fieldIsInMutuallyExclusiveGroup(Field f) { 00074 return fieldMutuallyExclusiveGroup(f).size() > 0; } 00075 00076 00077 // Non-Static // 00078 00079 // Constructor, which uses default values. 00080 PlotMSAveraging(); 00081 00082 // Destructor. 00083 ~PlotMSAveraging(); 00084 00085 00086 // Converts this object to/from a record. Each field will have a key that 00087 // is its enum name, with a bool value for its flag value. Fields that 00088 // also have double values will have an additional key that is its enum 00089 // name + "Value" (i.e. "channelValue" for CHANNEL) with a double value. 00090 // <group> 00091 void fromRecord(const RecordInterface& record); 00092 Record toRecord(bool useStrings = false) const; 00093 // </group> 00094 00095 // Gets/Sets the on/off flag for the given field. 00096 // <group> 00097 bool getFlag(Field f) const; 00098 void getFlag(Field f, bool& flag) const { flag = getFlag(f); } 00099 void setFlag(Field f, bool on); 00100 // </group> 00101 00102 // Gets/Sets the double value for the given field, if applicable. 00103 // <group> 00104 double getValue(Field f) const; 00105 void getValue(Field f, double& value) const { value = getValue(f); } 00106 void setValue(Field f, double value); 00107 // </group> 00108 00109 // Gets/Sets the value for the given field as a String. Blank means a 00110 // false value (or a field that does not have a double value); otherwise 00111 // the double value in String form is used. 00112 // <group> 00113 String getValueStr(Field f) const; 00114 void getValue(Field f, String& value) const { value = getValueStr(f); } 00115 void setValue(Field f, const String& value); 00116 // </group> 00117 00118 00119 // If any explicit averaging is turned ON, return True 00120 bool anyAveraging() const { return (channel() || time() || 00121 baseline() || antenna() ||spw()); } 00122 00123 // Convenience methods for returning the standard field values. 00124 // <group> 00125 bool channel() const { return getFlag(CHANNEL); } 00126 double channelValue() const { return getValue(CHANNEL); } 00127 String channelStr() const { return getValueStr(CHANNEL); } 00128 bool time() const { return getFlag(TIME); } 00129 double timeValue() const { return getValue(TIME); } 00130 String timeStr() const { return getValueStr(TIME); } 00131 bool scan() const { return getFlag(SCAN); } 00132 bool field() const { return getFlag(FIELD); } 00133 bool baseline() const { return getFlag(BASELINE); } 00134 bool antenna() const { return getFlag(ANTENNA); } 00135 bool spw() const { return getFlag(SPW); } 00136 bool scalarAve() const { return getFlag(SCALARAVE); } 00137 // </group> 00138 00139 // Convenience methods for setting the standard field values. 00140 // <group> 00141 void setChannel(const String& value) { setValue(CHANNEL, value); } 00142 void setChannel(bool flag) { setFlag(CHANNEL, flag); } 00143 void setChannelValue(double value) { setValue(CHANNEL, value); } 00144 void setTime(const String& value) { setValue(TIME, value); } 00145 void setTime(bool flag) { setFlag(TIME, flag); } 00146 void setTimeValue(double value) { setValue(TIME, value); } 00147 void setScan(bool flag) { setFlag(SCAN, flag); } 00148 void setField(bool flag) { setFlag(FIELD, flag); } 00149 void setBaseline(bool flag) { setFlag(BASELINE, flag); } 00150 void setAntenna(bool flag) { setFlag(ANTENNA, flag); } 00151 void setSpw(bool flag) { setFlag(SPW, flag); } 00152 void setScalarAve(bool flag) { setFlag(SCALARAVE,flag); } 00153 // </group> 00154 00155 00156 // Equality operators. 00157 // <group> 00158 bool operator==(const PlotMSAveraging& other) const; 00159 bool operator!=(const PlotMSAveraging& other) const { 00160 return !(operator==(other)); } 00161 // </group> 00162 00163 // Print out a summary of the averaging state: 00164 String summary() const; 00165 00166 private: 00167 // Averaging field flags. 00168 map<Field, bool> itsFlags_; 00169 00170 // Averaging field double values. 00171 map<Field, double> itsValues_; 00172 00173 00174 // Sets the default values. 00175 void setDefaults(); 00176 00177 00178 // String constant for what to append to the enum name in the record to 00179 // get the key for the double value. 00180 static const String RKEY_VALUE; 00181 }; 00182 00183 } 00184 00185 #endif /* PLOTMSAVERAGING_H_ */