PlotMSSelection.h

Go to the documentation of this file.
00001 //# PlotMSSelection.h: MS Selection 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 PLOTMSSELECTION_H_
00028 #define PLOTMSSELECTION_H_
00029 
00030 #include <casa/Containers/Record.h>
00031 #include <ms/MSSel/MSSelection.h>
00032 #include <plotms/PlotMS/PlotMSConstants.h>
00033 
00034 #include <map>
00035 
00036 namespace casa {
00037 
00038 //# Forward declarations
00039 class MeasurementSet;
00040 class NewCalTable;
00041 
00042 // Specifies an MS selection.  See the mssSetData method in
00043 // ms/MSSel/MSSelectionTools.h for details.
00044 class PlotMSSelection {
00045 public:
00046     // Static //
00047     
00048     // Enum and methods to define the different fields for an MS selection.
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               FIELD, SPW, TIMERANGE, UVRANGE, ANTENNA, SCAN,
00055               CORR, ARRAY, OBSERVATION, INTENT, FEED, MSSELECT)
00056     PMS_ENUM2(Field, fields, fieldStrings, field,
00057               "field", "spw", "timerange", "uvrange", "antenna", "scan",
00058               "corr", "array", "observation", "intent", "feed", "msselect")
00059     // </group>
00060               
00061     // Returns the default value for the given selection field.  Returns an
00062     // empty String except for FIELD which returns "2".
00063     static String defaultValue(Field f);
00064     
00065     
00066     // Non-Static //
00067     
00068     // Default constructor.
00069     PlotMSSelection();
00070     
00071     // Copy constructor.  See operator=().
00072     PlotMSSelection(const PlotMSSelection& copy);
00073     
00074     // Destructor.
00075     ~PlotMSSelection();
00076     
00077     
00078     // Converts this object to/from a record.  The record keys are the values
00079     // of the Field enum in String form, and the values are the String values.
00080     // <group>
00081     void fromRecord(const RecordInterface& record);
00082     Record toRecord() const;
00083     // </group>
00084     
00085     //Print out an abbreviated summary of the selection.
00086     String toStringShort() const;
00087 
00088     // Applies this selection using the first MS into the second MS.  (See the
00089     // mssSetData method in ms/MSSel/MSSelectionTools.h for details.)
00090     void apply(MeasurementSet& ms, MeasurementSet& selectedMS,
00091                Vector<Vector<Slice> >& chansel,
00092                Vector<Vector<Slice> >& corrsel);
00093         
00094     // Applies this selection to a NewCaltable
00095     void apply(NewCalTable& ct, NewCalTable& selectedCT,
00096                Vector<Vector<Slice> >& chansel,
00097                Vector<Vector<Slice> >& corrsel);
00098         
00099     // Gets/Sets the value for the given selection field.
00100     // <group>
00101     const String& getValue(Field f) const;
00102     void getValue(Field f, String& value) const { value = getValue(f); }
00103     void setValue(Field f, const String& value);
00104     // </group>
00105     
00106     // Convenience methods for returning the standard selection fields.
00107     // <group>
00108     const String& field() const     { return getValue(FIELD);     }
00109     const String& spw() const       { return getValue(SPW);       }
00110     const String& timerange() const { return getValue(TIMERANGE); }
00111     const String& uvrange() const   { return getValue(UVRANGE);   }
00112     const String& antenna() const   { return getValue(ANTENNA);   }
00113     const String& scan() const      { return getValue(SCAN);      }
00114     const String& corr() const      { return getValue(CORR);      }
00115     const String& array() const     { return getValue(ARRAY);     }
00116     const String& observation() const {return getValue(OBSERVATION);}
00117     const String& intent() const    { return getValue(INTENT);}
00118     const String& feed() const      { return getValue(FEED);}
00119     const String& msselect() const  { return getValue(MSSELECT);  }
00120     const Int& forceNew() const     { return forceNew_; }
00121     // </group>
00122     
00123     // Convenience methods for setting the standard selection fields.
00124     // <group>
00125     void setField(const String& v)     { setValue(FIELD, v);     }
00126     void setSpw(const String& v)       { setValue(SPW, v);       }
00127     void setTimerange(const String& v) { setValue(TIMERANGE, v); }
00128     void setUvrange(const String& v)   { setValue(UVRANGE, v);   }
00129     void setAntenna(const String& v)   { setValue(ANTENNA, v);   }
00130     void setScan(const String& v)      { setValue(SCAN, v);      }
00131     void setCorr(const String& v)      { setValue(CORR, v);      }
00132     void setArray(const String& v)     { setValue(ARRAY, v);     }
00133     void setObservation(const String& v) {setValue(OBSERVATION, v); }
00134     void setIntent(const String& v)    { setValue(INTENT, v); }
00135     void setFeed(const String& v)      { setValue(FEED, v); }
00136     void setMsselect(const String& v)  { setValue(MSSELECT, v);  }
00137     void setForceNew(const Int& forcenew) { forceNew_ = forcenew; }
00138     // </group>
00139     
00140     // Equality operators.
00141     // <group>
00142     bool operator==(const PlotMSSelection& other) const;
00143     bool operator!=(const PlotMSSelection& other) const {
00144         return !(operator==(other)); }
00145 
00146     bool fieldsEqual(const PlotMSSelection& other) const;
00147     bool fieldsNotEqual(const PlotMSSelection& other) const {
00148         return !fieldsEqual(other); }
00149 
00150     // </group>
00151     
00152     // Copy operator.
00153     PlotMSSelection& operator=(const PlotMSSelection& copy);
00154     
00155     //Return lists of antennas that have been selected.
00156     Vector<int> getSelectedAntennas1();
00157     Vector<int> getSelectedAntennas2();
00158 
00159     //Returns whether or not any selections have been made.
00160     bool isEmpty() const;
00161 private:    
00162     // Selection field values.
00163     std::map<Field, String> itsValues_;
00164 
00165 
00166 
00167     // Force appearance of new selection (even when not new)
00168     Int forceNew_;
00169         Vector<int> selAnts;
00170         Vector<int> selAnts2;
00171     
00172     // Initializes the values to their defaults.
00173     void initDefaults();
00174 
00175 };
00176 
00177 }
00178 
00179 #endif /* PLOTMSSELECTION_H_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1