casa
$Rev:20696$
|
00001 //# PlotMSFlagging.h: Flagging 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 PLOTMSFLAGGING_H_ 00028 #define PLOTMSFLAGGING_H_ 00029 00030 #include <plotms/PlotMS/PlotMSConstants.h> 00031 #include <plotms/PlotMS/PlotMSSelection.h> 00032 00033 #include <casa/namespace.h> 00034 00035 namespace casa { 00036 00037 // Specifies flagging parameters (including possibly flag extension) for an MS. 00038 class PlotMSFlagging { 00039 public: 00040 // Static // 00041 00042 // Enum and methods to define the different fields for an MS flagging. All 00043 // fields have a bool flag for on/off, and some of them also have a double 00044 // value (see fieldHasValue()) or a PlotMSSelection value (see 00045 // fieldHasSelectionValue()). Most fields are off by default (see 00046 // fieldDefault()), with a default double value of 0 or empty/default 00047 // PlotMSSelection value if applicable. Some fields are in mutually 00048 // exclusive groups (see fieldMutuallyExclusiveGroup()). 00049 // **If these are changed, also update: convenience methods below, 00050 // xmlcasa/implement/plotms/plotms*, xmlcasa/tasks/plotms.xml, 00051 // xmlcasa/scripts/task_plotms.py.** 00052 // <group> 00053 PMS_ENUM1(Field, fields, fieldStrings, field, 00054 EXTEND, CORR, CORR_ALL, 00055 CORR_POLN_DEP, CHANNEL, SPW, ANTENNA, 00056 ANTENNA_ANTENNA, ANTENNA_BASELINES, TIME, 00057 SCANS, FIELD, SEL_SELECTED, SEL_ALTERNATE) 00058 PMS_ENUM2(Field, fields, fieldStrings, field, 00059 "extend", "correlation", "correlation:all", 00060 "correlation:poln-dep", "channel", "spw", "antenna", 00061 "antenna:antenna-based", "antenna:all-baselines", "time", 00062 "scans", "field", "selection:selected", "selection:alternate") 00063 // </group> 00064 00065 // Returns whether the given field has a double value associated with it or 00066 // not. 00067 static bool fieldHasValue(Field f); 00068 00069 // Returns whether the given field has a PlotMSSelection value associated 00070 // with it or not. 00071 static bool fieldHasSelectionValue(Field f); 00072 00073 // Returns whether the given field is on or off by default. This is 00074 // important for mutually exclusive groups, which need to know which field 00075 // in that group is on to begin with. 00076 static bool fieldDefault(Field f); 00077 00078 // Returns the list of fields, NOT including the given, with which the 00079 // given field is mutually exclusive. In a mutually exclusive group, only 00080 // and exactly one field can be turned on at a given time. NOTE: this is 00081 // different from mutually exclusive groups in PlotMSAveraging, because 00082 // here it is NOT allowed to have all fields in a group turned off. 00083 static const vector<Field>& fieldMutuallyExclusiveGroup(Field f); 00084 00085 // Returns true if the given field is in a mutually exclusive group, false 00086 // otherwise. See fieldMutuallyExclusiveGroup(). 00087 static bool fieldIsInMutuallyExclusiveGroup(Field f) { 00088 return fieldMutuallyExclusiveGroup(f).size() > 0; } 00089 00090 00091 // Non-Static // 00092 00093 // Default constructor. 00094 PlotMSFlagging(); 00095 00096 // Destructor. 00097 ~PlotMSFlagging(); 00098 00099 // Converts this object to/from a record. Each field will have a key that 00100 // is its enum name, with a bool value for its flag value. Fields that 00101 // also have double values will have an additional key that is its enum 00102 // name + "Value" for double values, or its enum name + "SelectionValue" 00103 // for PlotMSSelection values. PlotMSSelection values are stored in Record 00104 // form (see PlotMSSelection::fromRecord()). The MS objects (the MS, the 00105 // selected MS, and the vis set) are NOT included in the record. 00106 // <group> 00107 void fromRecord(const RecordInterface& record); 00108 Record toRecord(bool useStrings = false) const; 00109 // </group> 00110 00111 // Gets/Sets the on/off flag for the given field. 00112 // <group> 00113 bool getFlag(Field f) const; 00114 void getFlag(Field f, bool& flag) const { flag = getFlag(f); } 00115 void setFlag(Field f, bool on); 00116 // </group> 00117 00118 // Gets/Sets the double value for the given field, if applicable. 00119 // <group> 00120 double getValue(Field f) const; 00121 void getValue(Field f, double& value) const { value = getValue(f); } 00122 void setValue(Field f, double value); 00123 // </group> 00124 00125 // Gets/Sets the value for the given field as a String. Only applicable 00126 // for special cases (correlation, antenna). 00127 // Correlation: "", "all", or "poln-dep". 00128 // Antenna: "", "all", or antenna-based value. 00129 // <group> 00130 String getValueStr(Field f) const; 00131 void getValue(Field f, String& value) const { value = getValueStr(f); } 00132 void setValue(Field f, const String& value); 00133 // </group> 00134 00135 // Gets/Sets the selection value for the given field, if applicable. 00136 // <group> 00137 PlotMSSelection getSelectionValue(Field f) const; 00138 void getSelectionValue(Field f, PlotMSSelection& value) const { 00139 value = getSelectionValue(f); } 00140 void setSelectionValue(Field f, const PlotMSSelection& value); 00141 // </group> 00142 00143 00144 // Convenience methods for returning the standard field values. 00145 // <group> 00146 bool extend() const { return getFlag(EXTEND); } 00147 bool corr() const { return (extend() && getFlag(CORR)); } 00148 bool corrAll() const { return (corr() && getFlag(CORR_ALL)); } 00149 bool corrPolnDep() const { return (corr() && getFlag(CORR_POLN_DEP)); } 00150 String corrStr() const { return getValueStr(CORR); } 00151 bool channel() const { return (extend() && getFlag(CHANNEL)); } 00152 bool spw() const { return (extend() && getFlag(SPW)); } 00153 bool antenna() const { return (extend() && getFlag(ANTENNA)); } 00154 bool antennaAntennaBased() const { return (antenna() && getFlag(ANTENNA_ANTENNA)); } 00155 double antennaAntennaBasedValue() const{ return getValue(ANTENNA_ANTENNA);} 00156 bool antennaBaselinesBased() const { return (antenna() && getFlag(ANTENNA_BASELINES)); } 00157 String antennaStr() const { return getValueStr(ANTENNA); } 00158 bool time() const { return (extend() && getFlag(TIME)); } 00159 bool scans() const { return (time() && getFlag(SCANS)); } 00160 bool field() const { return (time() && getFlag(FIELD)); } 00161 bool selectionSelected() const { return (extend() && getFlag(SEL_SELECTED)); } 00162 bool selectionAlternate() const { return (extend() && getFlag(SEL_ALTERNATE)); } 00163 PlotMSSelection selectionAlternateSelection() const { 00164 return getSelectionValue(SEL_ALTERNATE); } 00165 // </group> 00166 00167 // Convenience methods for setting the standard field values. 00168 // <group> 00169 void setExtend(bool flag) { setFlag(EXTEND, flag); } 00170 void setCorr(bool flag) { setFlag(CORR, flag); } 00171 void setCorrAll(bool flag) { setFlag(CORR_ALL, flag); } 00172 void setCorrPolnDep(bool flag) { setFlag(CORR_POLN_DEP, flag); } 00173 void setCorr(const String& value) { setValue(CORR, value); } 00174 void setChannel(bool flag) { setFlag(CHANNEL, flag); } 00175 void setSpw(bool flag) { setFlag(SPW, flag); } 00176 void setAntenna(bool flag) { setFlag(ANTENNA, flag); } 00177 void setAntennaAntennaBased(bool flag) { setFlag(ANTENNA_ANTENNA, flag); } 00178 void setAntennaAntennaBasedValue(double value) { 00179 setValue(ANTENNA_ANTENNA, value); } 00180 void setAntennaBaselinesBased(bool flag){setFlag(ANTENNA_BASELINES, flag);} 00181 void setAntenna(const String& value) { setValue(ANTENNA, value); } 00182 void setTime(bool flag) { setFlag(TIME, flag); } 00183 void setScans(bool flag) { setFlag(SCANS, flag); } 00184 void setField(bool flag) { setFlag(FIELD, flag); } 00185 void setSelectionSelected(bool flag) { setFlag(SEL_SELECTED, flag); } 00186 void setSelectionAlternate(bool flag) { setFlag(SEL_ALTERNATE, flag); } 00187 void setSelectionAlternateSelection(const PlotMSSelection& value) { 00188 setSelectionValue(SEL_ALTERNATE, value); } 00189 // </group> 00190 00191 00192 // Equality operators. 00193 // <group> 00194 bool operator==(const PlotMSFlagging& other) const; 00195 bool operator!=(const PlotMSFlagging& other) const { 00196 return !(operator==(other)); } 00197 // </group> 00198 00199 private: 00200 00201 // Flagging field flags. 00202 map<Field, bool> itsFlags_; 00203 00204 // Flagging field double values. 00205 map<Field, double> itsValues_; 00206 00207 // Flagging field selection values. 00208 map<Field, PlotMSSelection> itsSelectionValues_; 00209 00210 00211 // Sets the default values. 00212 void setDefaults(); 00213 00214 00215 // String constant for what to append to the enum name in the record to 00216 // get the key for the value. 00217 // <group> 00218 static const String RKEY_VALUE; 00219 static const String RKEY_SELVALUE; 00220 // </group> 00221 }; 00222 00223 } 00224 00225 #endif /* PLOTMSFLAGGING_H_ */