PlotMSAveraging.h

Go to the documentation of this file.
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 namespace casa {
00035 
00036 // Specifies averaging parameters for an MS.
00037 class PlotMSAveraging {
00038 public:
00039     // Static //
00040     
00041     // Enum and methods to define the different fields for an MS averaging.
00042     // All fields have a bool flag for on/off, and some of them also have a
00043     // double value (see fieldHasValue()).  Fields are off by default, with a
00044     // default double value of 0 if applicable.  Some fields are in mutually
00045     // exclusive groups (see fieldMutuallyExclusiveGroup()).
00046     // **If these are changed, also update: convenience methods below,
00047     // xmlcasa/implement/plotms/plotms*, xmlcasa/tasks/plotms.xml,
00048     // xmlcasa/scripts/task_plotms.py.**
00049     // <group>
00050     PMS_ENUM1(Field, fields, fieldStrings, field,
00051               CHANNEL, TIME, SCAN, FIELD, BASELINE, ANTENNA, SPW, 
00052               SCALARAVE)
00053     PMS_ENUM2(Field, fields, fieldStrings, field,
00054               "channel", "time", "scan", "field", "baseline", 
00055               "antenna", "spw",
00056               "scalar")
00057     // </group>
00058               
00059     // Returns whether the given field has a double value associated with it or
00060     // not.
00061     static bool fieldHasValue(Field f);
00062     
00063     // Returns the list of fields, NOT including the given, with which the
00064     // given field is mutually exclusive.  In a mutually exclusive group, only
00065     // one field can be turned on at a given time (although they can all be
00066     // off at the same time).
00067     static const vector<Field>& fieldMutuallyExclusiveGroup(Field f);
00068     
00069     // Returns true if the given field is in a mutually exclusive group, false
00070     // otherwise.  See fieldMutuallyExclusiveGroup().
00071     static bool fieldIsInMutuallyExclusiveGroup(Field f) {
00072         return fieldMutuallyExclusiveGroup(f).size() > 0; }
00073     
00074     
00075     // Non-Static //
00076     
00077     // Constructor, which uses default values.
00078     PlotMSAveraging();
00079     
00080     // Destructor.
00081     ~PlotMSAveraging();
00082     
00083     
00084     // Converts this object to/from a record.  Each field will have a key that
00085     // is its enum name, with a bool value for its flag value.  Fields that
00086     // also have double values will have an additional key that is its enum
00087     // name + "Value" (i.e. "channelValue" for CHANNEL) with a double value.
00088     // <group>
00089     void fromRecord(const RecordInterface& record);
00090     Record toRecord(bool useStrings = false) const;
00091     // </group>
00092     
00093     // Gets/Sets the on/off flag for the given field.
00094     // <group>
00095     bool getFlag(Field f) const;
00096     void getFlag(Field f, bool& flag) const { flag = getFlag(f); }
00097     void setFlag(Field f, bool on);
00098     // </group>
00099     
00100     // Gets/Sets the double value for the given field, if applicable.
00101     // <group>
00102     double getValue(Field f) const;
00103     void getValue(Field f, double& value) const { value = getValue(f); }
00104     void setValue(Field f, double value);
00105     // </group>
00106     
00107     // Gets/Sets the value for the given field as a String.  Blank means a
00108     // false value (or a field that does not have a double value); otherwise
00109     // the double value in String form is used.
00110     // <group>
00111     String getValueStr(Field f) const;
00112     void getValue(Field f, String& value) const { value = getValueStr(f); }
00113     void setValue(Field f, const String& value);
00114     // </group>
00115 
00116 
00117     // If any explicit averaging is turned ON, return True
00118     bool anyAveraging() const { return (channel() || time() || 
00119                                   baseline() || antenna() ||spw()); }
00120     
00121     // Convenience methods for returning the standard field values.
00122     // <group>
00123     bool channel() const { return getFlag(CHANNEL); }
00124     double channelValue() const { return getValue(CHANNEL); }
00125     String channelStr() const { return getValueStr(CHANNEL); }
00126     bool time() const { return getFlag(TIME); }
00127     double timeValue() const { return getValue(TIME); }
00128     String timeStr() const { return getValueStr(TIME); }
00129     bool scan() const { return getFlag(SCAN); }
00130     bool field() const { return getFlag(FIELD); }
00131     bool baseline() const { return getFlag(BASELINE); }
00132     bool antenna() const { return getFlag(ANTENNA); }
00133     bool spw() const { return getFlag(SPW); }
00134     bool scalarAve() const { return getFlag(SCALARAVE); }
00135     // </group>
00136     
00137     // Convenience methods for setting the standard field values.
00138     // <group>
00139     void setChannel(const String& value) { setValue(CHANNEL, value); }
00140     void setChannel(bool flag) { setFlag(CHANNEL, flag); }
00141     void setChannelValue(double value) { setValue(CHANNEL, value); }
00142     void setTime(const String& value) { setValue(TIME, value); }
00143     void setTime(bool flag) { setFlag(TIME, flag); }
00144     void setTimeValue(double value) { setValue(TIME, value); }
00145     void setScan(bool flag) { setFlag(SCAN, flag); }
00146     void setField(bool flag) { setFlag(FIELD, flag); }
00147     void setBaseline(bool flag) { setFlag(BASELINE, flag); }
00148     void setAntenna(bool flag) { setFlag(ANTENNA, flag); }
00149     void setSpw(bool flag) { setFlag(SPW, flag); }
00150     void setScalarAve(bool flag) { setFlag(SCALARAVE,flag); }
00151     // </group>
00152     
00153     
00154     // Equality operators.
00155     // <group>
00156     bool operator==(const PlotMSAveraging& other) const;
00157     bool operator!=(const PlotMSAveraging& other) const {
00158         return !(operator==(other)); }
00159     // </group>
00160     
00161     // Print out a summary of the averaging state:
00162     String summary() const;
00163 
00164     //Print out an abbreviated summary of the averaging state.
00165     String toStringShort() const;
00166 
00167 private:
00168     // Averaging field flags.
00169     std::map<Field, bool> itsFlags_;
00170     
00171     // Averaging field double values.
00172     std::map<Field, double> itsValues_;
00173 
00174     
00175     // Sets the default values.
00176     void setDefaults();
00177     
00178     
00179     // String constant for what to append to the enum name in the record to
00180     // get the key for the double value.
00181     static const String RKEY_VALUE;
00182 };
00183 
00184 }
00185 
00186 #endif /* PLOTMSAVERAGING_H_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1