casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
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 <plotms/PlotMS/PlotMSConstants.h>
00032 
00033 #include <map>
00034 
00035 #include <casa/namespace.h>
00036 using namespace std;
00037 
00038 namespace casa {
00039 
00040 //# Forward declarations
00041 class MeasurementSet;
00042 class NewCalTable;
00043 
00044 // Specifies an MS selection.  See the mssSetData method in
00045 // ms/MeasurementSets/MSSelectionTools.h for details.
00046 class PlotMSSelection {
00047 public:
00048     // Static //
00049     
00050     // Enum and methods to define the different fields for an MS selection.
00051     // **If these are changed, also update: convenience methods below,
00052     // xmlcasa/implement/plotms/plotms*, xmlcasa/tasks/plotms.xml,
00053     // xmlcasa/scripts/task_plotms.py.**
00054     // <group>
00055     PMS_ENUM1(Field, fields, fieldStrings, field,
00056               FIELD, SPW, TIMERANGE, UVRANGE, ANTENNA, SCAN,
00057               CORR, ARRAY, OBSERVATION, MSSELECT)
00058     PMS_ENUM2(Field, fields, fieldStrings, field,
00059               "field", "spw", "timerange", "uvrange", "antenna", "scan",
00060               "corr", "array", "observation", "msselect")
00061     // </group>
00062               
00063     // Returns the default value for the given selection field.  Returns an
00064     // empty String except for FIELD which returns "2".
00065     static String defaultValue(Field f);
00066     
00067     
00068     // Non-Static //
00069     
00070     // Default constructor.
00071     PlotMSSelection();
00072     
00073     // Copy constructor.  See operator=().
00074     PlotMSSelection(const PlotMSSelection& copy);
00075     
00076     // Destructor.
00077     ~PlotMSSelection();
00078     
00079     
00080     // Converts this object to/from a record.  The record keys are the values
00081     // of the Field enum in String form, and the values are the String values.
00082     // <group>
00083     void fromRecord(const RecordInterface& record);
00084     Record toRecord() const;
00085     // </group>
00086     
00087     // Applies this selection using the first MS into the second MS.  (See the
00088     // mssSetData method in ms/MeasurementSets/MSSelectionTools.h for details.)
00089     void apply(MeasurementSet& ms, MeasurementSet& selectedMS,
00090                Vector<Vector<Slice> >& chansel,
00091                Vector<Vector<Slice> >& corrsel) const;
00092         
00093     // Applies this selection to a NewCaltable
00094     void apply(NewCalTable& ct, NewCalTable& selectedCT,
00095                Vector<Vector<Slice> >& chansel,
00096                Vector<Vector<Slice> >& corrsel) const;
00097         
00098     // Gets/Sets the value for the given selection field.
00099     // <group>
00100     const String& getValue(Field f) const;
00101     void getValue(Field f, String& value) const { value = getValue(f); }
00102     void setValue(Field f, const String& value);
00103     // </group>
00104     
00105     // Convenience methods for returning the standard selection fields.
00106     // <group>
00107     const String& field() const     { return getValue(FIELD);     }
00108     const String& spw() const       { return getValue(SPW);       }
00109     const String& timerange() const { return getValue(TIMERANGE); }
00110     const String& uvrange() const   { return getValue(UVRANGE);   }
00111     const String& antenna() const   { return getValue(ANTENNA);   }
00112     const String& scan() const      { return getValue(SCAN);      }
00113     const String& corr() const      { return getValue(CORR);      }
00114     const String& array() const     { return getValue(ARRAY);     }
00115     const String& observation() const {return getValue(OBSERVATION);}
00116     const String& msselect() const  { return getValue(MSSELECT);  }
00117     const Int& forceNew() const     { return forceNew_; }
00118     // </group>
00119     
00120     // Convenience methods for setting the standard selection fields.
00121     // <group>
00122     void setField(const String& v)     { setValue(FIELD, v);     }
00123     void setSpw(const String& v)       { setValue(SPW, v);       }
00124     void setTimerange(const String& v) { setValue(TIMERANGE, v); }
00125     void setUvrange(const String& v)   { setValue(UVRANGE, v);   }
00126     void setAntenna(const String& v)   { setValue(ANTENNA, v);   }
00127     void setScan(const String& v)      { setValue(SCAN, v);      }
00128     void setCorr(const String& v)      { setValue(CORR, v);      }
00129     void setArray(const String& v)     { setValue(ARRAY, v);     }
00130     void setObservation(const String& v) {setValue(OBSERVATION, v); }
00131     void setMsselect(const String& v)  { setValue(MSSELECT, v);  }
00132     void setForceNew(const Int& forcenew) { forceNew_ = forcenew; }
00133     // </group>
00134     
00135     // Equality operators.
00136     // <group>
00137     bool operator==(const PlotMSSelection& other) const;
00138     bool operator!=(const PlotMSSelection& other) const {
00139         return !(operator==(other)); }
00140 
00141     bool fieldsEqual(const PlotMSSelection& other) const;
00142     bool fieldsNotEqual(const PlotMSSelection& other) const {
00143         return !fieldsEqual(other); }
00144 
00145     // </group>
00146     
00147     // Copy operator.
00148     PlotMSSelection& operator=(const PlotMSSelection& copy);
00149     
00150 private:    
00151     // Selection field values.
00152     map<Field, String> itsValues_;
00153 
00154     // Force appearance of new selection (even when not new)
00155     Int forceNew_;
00156     
00157     // Initializes the values to their defaults.
00158     void initDefaults();
00159 };
00160 
00161 }
00162 
00163 #endif /* PLOTMSSELECTION_H_ */