casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ViFrequencySelection.h
Go to the documentation of this file.
1 //# ViFrequencySelection.h: Step through the MeasurementEquation by visibility
2 //# Copyright (C) 1996,1997,1998,1999,2000,2001,2002,2003
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id: ViFrequencySelection.h,v 19.14 2006/02/28 04:48:58 mvoronko Exp $
27 
28 #if ! defined (MSVIS_ViFrequencySelection_H_121116_1101)
29 #define MSVIS_ViFrequencySelection_H_121116_1101
30 
31 #include <casa/aips.h>
32 #include <casa/BasicSL.h>
33 #include <casa/Arrays/Slicer.h>
35 
36 #include <memory>
37 #include <set>
38 #include <vector>
39 
40 using std::set;
41 using std::vector;
42 
43 namespace casacore{
44 
45 class MeasurementSet;
46 class MSSelection;
47 }
48 
49 namespace casa { //# NAMESPACE CASA - BEGIN
50 
51 
52 namespace vi {
53 
55 //
56 // FrequencySelection class
57 //
58 // A frequency selection is a way to select the channels of interest from the
59 // data in a single MeasurementSet. The user will provide one or more selections
60 // for the casacore::MS; each selection effectively specify the desired channel data in a
61 // specified spectral window. If the user uses the FrequencySelectionChannel
62 // class then the selection simply selects a range of channels. The other derived
63 // class is FrequencySelectionReferential which specifies a range of frequencies
64 // in a specified frame of reference (e.g., LSRK). Unlike the other first method,
65 // the frame-related selection will not necessarily select the same channels across
66 // the entire MS.
67 //
68 // The frame of reference will either be one defined in the casacore::MFrequency::Types enum
69 // or one of the special "frames" defined in this class.
70 
72 
73 public:
74 
75  typedef enum {Unknown = -11, ByChannel = -10} SpecialFrames;
76 
77  virtual ~FrequencySelection (){}
78 
80  virtual FrequencySelection * clone () const = 0;
81  virtual casacore::Bool empty () const = 0;
82  void filterByWindow (casacore::Int windowId = -1) const;
85  virtual set<int> getSelectedWindows () const = 0;
86  virtual casacore::String toString () const = 0;
87 
88  static casacore::String frameName (casacore::Int referenceFrame);
89 
90 //**********************************************************************
91 // Internal methods below this line
92 //**********************************************************************
93 
94 protected:
95 
97  : filterWindowId_p (-1),
98  referenceFrame_p (referenceFrame) {}
100 
101 private:
102 
106 };
107 
109 //
110 // FrequencySelectionUsingFrame class
111 //
112 // Selects sets of channels from a single MS. The selection is created
113 // by specifying a sequence of frame-related frequencies in a single MS.
114 // By adding multiple selections, the user can select any arbitrary collecton
115 // of channels. The frequencies are related to the specified frame of reference
116 // and the actual selected can be a function of time as the telescope moves through
117 // space.
118 
120 
121 public:
122 
123  class Element {
124  public:
125 
126  Element (casacore::Int spectralWindow = -1, double beginFrequency = 0,
127  double endFrequency = 0, double increment = 0)
128  : beginFrequency_p (beginFrequency),
129  endFrequency_p (endFrequency),
130  increment_p (increment),
131  spectralWindow_p (spectralWindow)
132  {}
133 
134  double getBeginFrequency () const;
135  double getEndFrequency () const;
136  std::pair<int, int> getChannelRange (const casacore::MeasurementSet * ms) const;
137  int getSpectralWindow () const;
138 
139  private:
140 
142 
145  double increment_p;
147  };
148 
149  typedef std::vector<Element> Elements;
151 
153 
154  void add (casacore::Int spectralWindow, double bottomFrequency, double topFrequency);
155  //void add (casacore::Int spectralWindow, double bottomFrequency, double topFrequency, double increment);
156  const_iterator begin () const;
157  FrequencySelection * clone () const;
158  casacore::Bool empty () const;
159  const_iterator end () const;
160  set<int> getSelectedWindows () const;
161  casacore::String toString () const;
163  std::map<int, std::pair<int, int> > getChannelRange (const casacore::MeasurementSet& ms) const;
164 
165 private:
166 
169 };
170 
171 class SpectralWindowChannels;
172 
174 //
175 // FrequencySelectionUsingChannels class
176 //
177 // Selects sets of channels from a single MS. The selection is created
178 // by specifying a sequence of channels in a single MS. By adding multiple
179 // selections, the user can select any arbitrary collecton of channels.
180 //
181 // The order of the "add" operations are unimportant.
182 //
183 // Imaging finds it convenient to double specify the frequency ranges, first
184 // using an MSSelection object and later with a series of frequency ranges.
185 // The intent is that only channels which match up with both criteria should
186 // be a part of the VisBuffer. To accomplish this, first create a selection
187 // using a FrequencySelectionUsingChannels object (using method "add" with
188 // either an MSSelection or a channel range). When that is complete build
189 // up a FrequencySelectionUsingFrequency object to represent the various
190 // frequency ranges desired. Then use FrequencySelectionUsingChannels::refine
191 // passing in the FrequencySelectionUsingFrame object created before. The
192 // refinement process will remove any of the originalchannels which are not
193 // within the specified frequency bands. The refinement operation is delayed
194 // until the first time selection is actually used (usually after a call to
195 // VisibilityIterator2::origin.
196 
198 
199 public:
200 
201  class Element {
202  public:
203 
204  Element (casacore::Int spectralWindow = -1, casacore::Int firstChannel = -1, casacore::Int nChannels = -1, casacore::Int increment = 1)
205  : firstChannel_p (firstChannel),
206  increment_p (increment),
207  nChannels_p (nChannels),
208  spectralWindow_p (spectralWindow)
209  {}
210 
212 
217  };
218 
219  typedef std::vector<Element> Elements;
221 
224 
225  void add (casacore::Int spectralWindow, casacore::Int firstChannel, casacore::Int nChannels,
226  casacore::Int increment = 1);
227  void add (const casacore::MSSelection & msSelection, const casacore::MeasurementSet * ms);
228  void applyRefinement (std::function <casacore::Slice (int, double, double)>) const;
229  const_iterator begin () const;
230  FrequencySelection * clone () const;
231  casacore::Bool empty () const;
232  const_iterator end () const;
233  casacore::Int getNChannels (casacore::Int spectralWindowId) const;
234  set<int> getSelectedWindows () const;
235  void refine (const FrequencySelectionUsingFrame & frequencySelection);
236  bool refinementNeeded () const;
237  size_t size () const;
238  casacore::String toString () const;
239 
240 //**********************************************************************
241 // Internal methods below this line
242 //**********************************************************************
243 
244 private:
245 
248  mutable std::unique_ptr<FrequencySelectionUsingFrame> refinements_p;
249 
250 // std::pair<int, int> getChannelRange (const SpectralWindowChannels & spwChannels,
251 // double beginFrequency, double endFrequency);
252 
253  void refineSelection (FrequencySelectionUsingChannels::Element & originalElement,
254  int firstRefiningChannel, int lastRefiningChannel) const;
255 
256 
257 };
258 
259 
261 //
262 // FrequencySelections class
263 //
264 // A FrequenceSelections object is a collection of FrequencySelection objects.
265 // It is intended to allow the user to provide a frequency selection per
266 // casacore::MS when the VisibilityIterator is sweeping multiple MSs. All selections
267 // included in the collection must have the same frame of reference; an
268 // exception will be thrown when attempting to add a frame with a different
269 // frame of reference.
270 
272 public:
273 
274 
278 
279  void add (const FrequencySelection & selection);
280  FrequencySelections * clone () const;
281  void filterToSpectralWindow (casacore::Int spectralWindowId);
282  const FrequencySelection & get (casacore::Int msIndex) const;
284  casacore::Bool isSpectralWindowSelected (casacore::Int msIndex, casacore::Int spectralWindowId) const;
285  casacore::Int size () const;
286 
287 //**********************************************************************
288 // Internal methods below this line
289 //**********************************************************************
290 
291 
292 private:
293 
294  typedef std::set<std::pair<casacore::Int, casacore::Int> > SelectedWindows; // pair=(msIndex,spwId)
295 
299 
300  typedef std::vector<FrequencySelection *> Selections;
302 };
303 
304 
305 
306 } // end namespace vi
307 
308 } //# NAMESPACE CASA - END
309 
310 #endif // ! defined (MSVIS_ViFrequencySelection_H_121116_1101)
311 
void refine(const FrequencySelectionUsingFrame &frequencySelection)
std::set< std::pair< casacore::Int, casacore::Int > > SelectedWindows
casacore::Int spectralWindow_p
virtual FrequencySelection * clone() const =0
A 1-D Specialization of the Array class.
void filterToSpectralWindow(casacore::Int spectralWindowId)
int Int
Definition: aipstype.h:50
casacore::Int nChannels_p
Elements::const_iterator const_iterator
FrequencySelectionUsingFrame(casacore::MFrequency::Types frameOfReference)
casacore::Bool isSpectralWindowSelected(casacore::Int msIndex, casacore::Int spectralWindowId) const
void addCorrelationSlices(const casacore::Vector< casacore::Vector< casacore::Slice > > &slices)
casacore::Vector< casacore::Vector< casacore::Slice > > correlationSlices_p
casacore::String toString() const
casacore::Slice getSlice() const
void add(const FrequencySelection &selection)
FrequencySelections * clone() const
FrequencySelectionUsingChannels()
set< int > getSelectedWindows() const
const_iterator begin() const
void add (casacore::Int spectralWindow, double bottomFrequency, double topFrequency, double increment);
casacore::String toString() const
virtual set< int > getSelectedWindows() const =0
Element(casacore::Int spectralWindow=-1, double beginFrequency=0, double endFrequency=0, double increment=0)
bool refinementNeeded() const
casacore::Vector< casacore::Slice > getCorrelationSlices(casacore::Int polarizationId) const
std::vector< FrequencySelection * > Selections
const_iterator end() const
size_t size() const
casacore::Int getFrameOfReference() const
void filterByWindow(casacore::Int windowId=-1) const
FrequencySelection * clone() const
virtual casacore::Bool empty() const =0
const_iterator begin() const
static casacore::String frameName(casacore::Int referenceFrame)
define a (start,length,increment) along an axis
Definition: Slice.h:93
void refineSelection(FrequencySelectionUsingChannels::Element &originalElement, int firstRefiningChannel, int lastRefiningChannel) const
std::pair&lt;int, int&gt; getChannelRange (const SpectralWindowChannels &amp; spwChannels, double beginFrequenc...
std::unique_ptr< FrequencySelectionUsingFrame > refinements_p
Elements filtered_p
MSSelection: Class to represent a selection on an MS.
Definition: MSSelection.h:118
const FrequencySelectionUsingChannels defaultSelection_p
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
casacore::Int filterWindow() const
FrequencySelection(casacore::Int referenceFrame)
casacore::Bool empty() const
std::pair< int, int > getChannelRange(const casacore::MeasurementSet *ms) const
void add(casacore::Int spectralWindow, casacore::Int firstChannel, casacore::Int nChannels, casacore::Int increment=1)
A Table intended to hold astronomical data (a set of Measurements).
virtual casacore::String toString() const =0
FrequencySelection * clone() const
casacore::Int getNChannels(casacore::Int spectralWindowId) const
void applyRefinement(std::function< casacore::Slice(int, double, double)>) const
void add(casacore::Int spectralWindow, double bottomFrequency, double topFrequency)
Elements elements_p
String: the storage and methods of handling collections of characters.
Definition: String.h:223
casacore::Int increment_p
casacore::Int firstChannel_p
Types
Types of known MFrequencies Warning: The order defines the order in the translation matrix FromTo in...
Definition: MFrequency.h:176
casacore::Int size() const
std::map< int, std::pair< int, int > > getChannelRange(const casacore::MeasurementSet &ms) const
This will return a map where the key is the spw and the pair is the pair (nchan, start) for that spw...
std::vector< Element > Elements
casacore::Int getFrameOfReference() const
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42