ViFrequencySelection.h

Go to the documentation of this file.
00001 //# ViFrequencySelection.h: Step through the MeasurementEquation by visibility
00002 //# Copyright (C) 1996,1997,1998,1999,2000,2001,2002,2003
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: ViFrequencySelection.h,v 19.14 2006/02/28 04:48:58 mvoronko Exp $
00027 
00028 #if ! defined (MSVIS_ViFrequencySelection_H_121116_1101)
00029 #define MSVIS_ViFrequencySelection_H_121116_1101
00030 
00031 #include <casa/aips.h>
00032 #include <casa/BasicSL.h>
00033 #include <casa/Arrays/Slicer.h>
00034 #include <measures/Measures/MFrequency.h>
00035 
00036 
00037 #include <set>
00038 #include <vector>
00039 
00040 using std::set;
00041 using std::vector;
00042 
00043 namespace casa { //# NAMESPACE CASA - BEGIN
00044 
00045 class MeasurementSet;
00046 class MSSelection;
00047 
00048 namespace vi {
00049 
00051 //
00052 //  FrequencySelection class
00053 //
00054 // A frequency selection is a way to select the channels of interest from the
00055 // data in a single MeasurementSet.  The user will provide one or more selections
00056 // for the MS; each selection effectively specify the desired channel data in a
00057 // specified spectral window.  If the user uses the FrequencySelectionChannel
00058 // class then the selection simply selects a range of channels.  The other derived
00059 // class is FrequencySelectionReferential which specifies a range of frequencies
00060 // in a specified frame of reference (e.g., LSRK).  Unlike the other first method,
00061 // the frame-related selection will not necessarily select the same channels across
00062 // the entire MS.
00063 //
00064 // The frame of reference will either be one defined in the MFrequency::Types enum
00065 // or one of the special "frames" defined in this class.
00066 
00067 class FrequencySelection {
00068 
00069 public:
00070 
00071     typedef enum {Unknown = -11, ByChannel = -10} SpecialFrames;
00072 
00073     virtual ~FrequencySelection (){}
00074 
00075     void addCorrelationSlices (const Vector <Vector <Slice> > & slices);
00076     virtual FrequencySelection * clone () const = 0;
00077     virtual Bool empty () const = 0;
00078     void filterByWindow (Int windowId = -1) const;
00079     Vector <Slice> getCorrelationSlices (Int polarizationId) const;
00080     Int getFrameOfReference () const;
00081     virtual set<int> getSelectedWindows () const = 0;
00082     virtual String toString () const = 0;
00083 
00084     static String frameName (Int referenceFrame);
00085 
00086 //**********************************************************************
00087 // Internal methods below this line
00088 //**********************************************************************
00089 
00090 protected:
00091 
00092     FrequencySelection (Int referenceFrame)
00093     : filterWindowId_p (-1),
00094       referenceFrame_p (referenceFrame) {}
00095     Int filterWindow() const;
00096 
00097 private:
00098 
00099     Vector <Vector <Slice> > correlationSlices_p; // outer index is polarization id
00100     mutable Int filterWindowId_p;
00101     Int referenceFrame_p;
00102 };
00103 
00105 //
00106 // FrequencySelectionUsingChannels class
00107 //
00108 // Selects sets of channels from a single MS.  The selection is created
00109 // by specifying a sequence of channels in a single MS.  By adding multiple
00110 // selections, the user can select any arbitrary collecton of channels.
00111 //
00112 // The order of the "add" operations are unimportant.
00113 
00114 class FrequencySelectionUsingChannels : public FrequencySelection {
00115 
00116 public:
00117 
00118     class Element {
00119     public:
00120 
00121         Element (Int spectralWindow = -1, Int firstChannel = -1, Int nChannels = -1, Int increment = 1)
00122         : firstChannel_p (firstChannel),
00123           increment_p (increment),
00124           nChannels_p (nChannels),
00125           spectralWindow_p (spectralWindow)
00126         {}
00127 
00128         Slice getSlice () const { return Slice (firstChannel_p, nChannels_p, increment_p);}
00129 
00130         Int firstChannel_p;
00131         Int increment_p;
00132         Int nChannels_p;
00133         Int spectralWindow_p;
00134     };
00135 
00136     typedef std::vector<Element> Elements;
00137     typedef Elements::const_iterator const_iterator;
00138 
00139     FrequencySelectionUsingChannels () : FrequencySelection (ByChannel) {}
00140 
00141     void add (Int spectralWindow, Int firstChannel, Int nChannels, Int increment = 1);
00142     void add (const MSSelection & msSelection, const MeasurementSet * ms);
00143     const_iterator begin () const;
00144     FrequencySelection * clone () const;
00145     Bool empty () const;
00146     const_iterator end () const;
00147     Int getNChannels (Int spectralWindowId) const;
00148     set<int> getSelectedWindows () const;
00149     size_t size () const;
00150     String toString () const;
00151 
00152 //**********************************************************************
00153 // Internal methods below this line
00154 //**********************************************************************
00155 
00156 private:
00157 
00158     Elements elements_p;
00159     mutable Elements filtered_p;
00160 
00161 };
00162 
00164 //
00165 // FrequencySelectionUsingFrame class
00166 //
00167 // Selects sets of channels from a single MS.  The selection is created
00168 // by specifying a sequence of frame-related frequencies in a single MS.
00169 // By adding multiple selections, the user can select any arbitrary collecton
00170 // of channels.  The frequencies are related to the specified frame of reference
00171 // and the actual selected can be a function of time as the telescope moves through
00172 // space.
00173 
00174 class FrequencySelectionUsingFrame : public FrequencySelection {
00175 
00176 public:
00177 
00178     class Element {
00179     public:
00180 
00181         Element (Int spectralWindow = -1, Double beginFrequency = 0,
00182                  Double endFrequency = 0, Double increment = 0)
00183         : beginFrequency_p (beginFrequency),
00184           endFrequency_p (endFrequency),
00185           increment_p (increment),
00186           spectralWindow_p (spectralWindow)
00187           {}
00188 
00189         Double getBeginFrequency () const;
00190         Double getEndFrequency () const;
00191 
00192     private:
00193 
00194         friend class FrequencySelectionUsingFrame;
00195 
00196         Double beginFrequency_p;
00197         Double endFrequency_p;
00198         Double increment_p;
00199         Int spectralWindow_p;
00200     };
00201 
00202     typedef std::vector<Element> Elements;
00203     typedef Elements::const_iterator const_iterator;
00204 
00205     FrequencySelectionUsingFrame (MFrequency::Types frameOfReference);
00206 
00207     void add (Int spectralWindow, Double bottomFrequency, Double topFrequency);
00208     //void add (Int spectralWindow, Double bottomFrequency, Double topFrequency, Double increment);
00209     const_iterator begin () const;
00210     FrequencySelection * clone () const;
00211     Bool empty () const;
00212     const_iterator end () const;
00213     set<int> getSelectedWindows () const;
00214     String toString () const;
00215 
00216 private:
00217 
00218     Elements elements_p;
00219     mutable Elements filtered_p;
00220 };
00221 
00222 
00224 //
00225 //    FrequencySelections class
00226 //
00227 //    A FrequenceSelections object is a collection of FrequencySelection objects.
00228 //    It is intended to allow the user to provide a frequency selection per
00229 //    MS when the VisibilityIterator is sweeping multiple MSs.  All selections
00230 //    included in the collection must have the same frame of reference; an
00231 //    exception will be thrown when attempting to add a frame with a different
00232 //    frame of reference.
00233 
00234 class FrequencySelections {
00235 public:
00236 
00237 
00238     FrequencySelections ();
00239     FrequencySelections (const FrequencySelections & other);
00240     ~FrequencySelections ();
00241 
00242     void add (const FrequencySelection & selection);
00243     FrequencySelections * clone () const;
00244     void filterToSpectralWindow (Int spectralWindowId);
00245     const FrequencySelection & get (Int msIndex) const;
00246     Int getFrameOfReference () const;
00247     Bool isSpectralWindowSelected (Int msIndex, Int spectralWindowId) const;
00248     Int size () const;
00249 
00250 //**********************************************************************
00251 // Internal methods below this line
00252 //**********************************************************************
00253 
00254 
00255 private:
00256 
00257     typedef std::set<pair<Int, Int> > SelectedWindows; // pair=(msIndex,spwId)
00258 
00259     const FrequencySelectionUsingChannels defaultSelection_p;
00260     mutable Int filterWindow_p;
00261     SelectedWindows selectedWindows_p;
00262 
00263     typedef std::vector<FrequencySelection *> Selections;
00264     Selections selections_p;
00265 };
00266 
00267 
00268 
00269 } // end namespace vi
00270 
00271 } //# NAMESPACE CASA - END
00272 
00273 #endif // ! defined (MSVIS_ViFrequencySelection_H_121116_1101)
00274 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1