PlotMSFlagging.h

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

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1