casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VisIterator.h
Go to the documentation of this file.
1 //# VisIterator.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: VisIterator.h,v 19.14 2006/02/28 04:48:58 mvoronko Exp $
27 
28 #ifndef MSVIS_VISITERATOR_H
29 #define MSVIS_VISITERATOR_H
30 
31 #include <casa/aips.h>
32 #include <casa/Arrays/Matrix.h>
33 #include <casa/Arrays/Cube.h>
34 #include <casa/Arrays/Slicer.h>
38 #include <casa/Quanta/MVDoppler.h>
43 #include <casa/BasicSL/String.h>
46 
52 
53 namespace casa { //# NAMESPACE CASA - BEGIN
54 
55 //# forward decl
56 class VisBuffer;
57 
58 // <summary>
59 // ROVisIterator iterates through one or more readonly MeasurementSets
60 // </summary>
61 
62 // <use visibility=export>
63 
64 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
65 // </reviewed>
66 
67 // <prerequisite>
68 // <li> <linkto class="MSIter">MSIter</linkto>
69 // <li> <linkto class="casacore::MeasurementSet">casacore::MeasurementSet</linkto>
70 // <li> <linkto class="VisSet">VisSet</linkto>
71 // </prerequisite>
72 //
73 // <etymology>
74 // The ROVisIterator is a readonly iterator returning visibilities
75 // </etymology>
76 //
77 // <synopsis>
78 // ROVisIterator provides iteration with various sort orders
79 // for one or more MSs. It has member functions to retrieve the fields
80 // commonly needed in synthesis calibration and imaging.
81 //
82 // One should use <linkto class="VisBuffer">VisBuffer</linkto>
83 // to access chunks of data.
84 // </synopsis>
85 //
86 // <example>
87 // <code>
88 // //
89 // </code>
90 // </example>
91 //
92 // <motivation>
93 // For imaging and calibration you need to access an casacore::MS in some consistent
94 // order (by field, spectralwindow, time interval etc.). This class provides
95 // that access.
96 //
97 // Unlike ROVisibilityIterator, this supports non-strided in-row selection
98 // (e.g., of channels and correlations).
99 // </motivation>
100 //
101 // <thrown>
102 // <li>
103 // <li>
104 // </thrown>
105 //
106 // <todo asof="1997/05/30">
107 // <li> cleanup the currently dual interface for visibilities and flags
108 // <li> sort out what to do with weights when interpolating
109 // <li> Handle the multi-casacore::MS case like ROVisibilityIterator does.
110 // </todo>
111 
112 class ROVisIteratorImpl;
113 
115 {
116  public:
117 
118  // Default constructor - useful only to assign another iterator later
119  ROVisIterator();
120 
121  // Construct from casacore::MS and a casacore::Block of casacore::MS column enums specifying the iteration
122  // order, if none are specified, time iteration is implicit. An optional
123  // timeInterval can be given to iterate through chunks of time. The default
124  // interval of 0 groups all times together. Every 'chunk' of data contains
125  // all data within a certain time interval (in seconds) and with identical
126  // values of the other iteration columns (e.g. DATA_DESC_ID and FIELD_ID).
127  // Using selectChannel(), a number of groups of channels can be requested.
128  // At present the channel group iteration will always occur before the
129  // interval iteration.
131  const casacore::Block<casacore::Int>& sortColumns,
133 
136 
137 
138  // Copy construct. This calls the assignment operator.
139  ROVisIterator(const ROVisIterator & other);
140 
141  // Destructor
142  ~ROVisIterator();
143 
144  // Assignment. Any attached VisBuffers are lost in the assign.
145  ROVisIterator & operator=(const ROVisIterator &other);
146 
147  // Members
148 
149  // Advance iterator through data
150  ROVisIterator & operator++(int);
152 
153  // Return channel numbers in selected VisSet spectrum
154  // (i.e. disregarding possible selection on the iterator, but
155  // including the selection set when creating the VisSet)
156 
159 
160  // Return selected correlation indices
162 
163  // Return the correlation type (returns casacore::Stokes enums)
165 
166  // Set up new chan/corr selection via casacore::Vector<casacore::Slice>
169 
170  // Set up/return channel averaging bounds
172 
173  // Get selected spws and channel counts
175  void lsrFrequency(const casacore::Int& spw, casacore::Vector<casacore::Double>& freq, casacore::Bool& convert, const casacore::Bool ignoreconv=false);
176 
177  // The following throws an exception, because this isn't the
178  // language of channel selection in VisIterator
184  { throw(casacore::AipsError("VisIterator::getChannelSelection: you can't do that!")); };
185 
186 
187  // Return number of chans/corrs per spw/pol
190 
191 protected:
192 
194  public:
195 
196  Factory (ROVisIterator * vi) : vi_p (vi) {}
198  operator() (const asyncio::PrefetchColumns * prefetchColumns,
200  const casacore::Block<casacore::Int>& sortColumns,
201  const casacore::Bool addDefaultSortCols,
202  casacore::Double timeInterval) const;
203  private:
204 
206 
207  };
208 
210  virtual ROVisIteratorImpl * getReadImpl () const;
211 };
212 
213 // <summary>
214 // VisIterator iterates through one or more writable MeasurementSets
215 // </summary>
216 
217 // <use visibility=export>
218 
219 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
220 // </reviewed>
221 
222 // <prerequisite>
223 // <li> <linkto class="ROVisIterator">ROVisIterator</linkto>
224 // </prerequisite>
225 //
226 // <etymology>
227 // The VisIterator is a read/write iterator returning visibilities
228 // </etymology>
229 //
230 // <synopsis>
231 // VisIterator provides iteration with various sort orders
232 // for one or more MSs. It has member functions to retrieve the fields
233 // commonly needed in synthesis calibration and imaging. It is
234 // derived from the read-only iterator
235 // <linkto class="ROVisIterator">ROVisIterator</linkto>.
236 //
237 // One should use <linkto class="VisBuffer">VisBuffer</linkto>
238 // to access chunks of data.
239 // </synopsis>
240 //
241 // <example>
242 // <code>
243 // //
244 // </code>
245 // </example>
246 //
247 // <motivation>
248 // For imaging and calibration you need to access an casacore::MS in some consistent
249 // order (by field, spectralwindow, time interval etc.). This class provides
250 // that access.
251 //
252 // Unlike ROVisibilityIterator, this supports non-strided in-row selection
253 // (e.g., of channels).
254 // </motivation>
255 //
256 // #<thrown>
257 //
258 // #</thrown>
259 //
260 // <todo asof="1997/05/30">
261 // <li> cleanup the currently dual interface for visibilities and flags
262 // <li> sort out what to do with weights when interpolating
263 // <li> Handle the multi-casacore::MS case like VisibilityIterator does.
264 // </todo>
265 
266 class VisIteratorImpl;
267 
269 {
270 public:
271 
272  // Constructors.
273  // Note: The VisIterator is not initialized correctly by default, you
274  // need to call origin() before using it to iterate.
275  VisIterator();
278 
279  VisIterator(const VisIterator & MSI);
280 
281  // Destructor
282  virtual ~VisIterator();
283 
284  VisIterator & operator=(const VisIterator &MSI);
285 
286  // Members
287 
288  // Advance iterator through data
289  VisIterator & operator++(int);
291 
292  // Set/modify the flag row column; dimension casacore::Vector(nrow)
293  void setFlagRow(const casacore::Vector<casacore::Bool>& rowflags);
294 
295  // Set/modify the flags in the data.
296  // This sets the flags as found in the casacore::MS, casacore::Cube(npol,nchan,nrow),
297  // where nrow is the number of rows in the current iteration (given by
298  // nRow()).
300 
301  // Set/modify the visibilities
302  // This sets the data as found in the casacore::MS, casacore::Cube(npol,nchan,nrow).
303  void setVis(const casacore::Cube<casacore::Complex>& vis, DataColumn whichOne);
304 
305  // Set the visibility and flags, and interpolate from velocities if needed
307  DataColumn whichOne);
308 
309  // Set/modify the weightMat
311 
312  // Set/modify the weightSpectrum
314 
315 protected:
316 
318  public:
319 
320  Factory (VisIterator * vi) : vi_p (vi) {}
322  operator() (const asyncio::PrefetchColumns * prefetchColumns,
324  const casacore::Block<casacore::Int>& sortColumns,
325  const casacore::Bool addDefaultSortCols,
327  private:
328 
330 
331  };
332 
333  virtual void attachColumns(const casacore::Table &t);
334 
335  // deals with casacore::Float or casacore::Complex observed data (DATA and FLOAT_DATA).
339 
340  // column access functions
342 
346 
350 
351  VisIteratorImpl * getImpl () const;
352 };
353 
354 
355 
356 
357 } //# NAMESPACE CASA - END
358 
359 #endif
casacore::Vector< casacore::Double > & timeInterval(casacore::Vector< casacore::Double > &ti) const
Return nominal time interval.
casacore::Vector< casacore::Int > & chanIds(casacore::Vector< casacore::Int > &chanids) const
Return channel numbers in selected VisSet spectrum (i.e.
void selectChannel(const casacore::Vector< casacore::Vector< casacore::Slice > > &chansel)
Set up new chan/corr selection via casacore::Vector&lt;casacore::Slice&gt;
int Int
Definition: aipstype.h:50
virtual ROVisIteratorImpl * getReadImpl() const
void setWeightMat(const casacore::Matrix< casacore::Float > &wtmat)
Set/modify the weightMat.
Main interface class to a read/write table.
Definition: Table.h:153
Factory(VisIterator *vi)
Definition: VisIterator.h:320
void putDataColumn(DataColumn whichOne, const casacore::Vector< casacore::Vector< casacore::Slice > > &slices, const casacore::Cube< casacore::Complex > &data)
deals with casacore::Float or casacore::Complex observed data (DATA and FLOAT_DATA).
virtual void attachColumns(const casacore::Table &t)
attach the column objects to the currently selected table
void setVis(const casacore::Cube< casacore::Complex > &vis, DataColumn whichOne)
Set/modify the visibilities This sets the data as found in the casacore::MS, casacore::Cube(npol,nchan,nrow).
const casacore::MeasurementSet & ms() const
reference to actual ms in interator
TableExprNode array(const TableExprNode &values, const TableExprNodeSet &shape)
Create an array of the given shape and fill it with the values.
Definition: ExprNode.h:1886
void setVisAndFlag(const casacore::Cube< casacore::Complex > &vis, const casacore::Cube< casacore::Bool > &flag, DataColumn whichOne)
Set the visibility and flags, and interpolate from velocities if needed.
VisIterator & operator++()
void setFlagRow(const casacore::Vector< casacore::Bool > &rowflags)
Set/modify the flag row column; dimension casacore::Vector(nrow)
VisibilityIteratorReadImpl * operator()(const asyncio::PrefetchColumns *prefetchColumns, const casacore::Block< casacore::MeasurementSet > &mss, const casacore::Block< casacore::Int > &sortColumns, const casacore::Bool addDefaultSortCols, casacore::Double timeInterval) const
VisIterator & operator=(const VisIterator &MSI)
void getChannelSelection(casacore::Block< casacore::Vector< casacore::Int > > &, casacore::Block< casacore::Vector< casacore::Int > > &, casacore::Block< casacore::Vector< casacore::Int > > &, casacore::Block< casacore::Vector< casacore::Int > > &, casacore::Block< casacore::Vector< casacore::Int > > &)
The following throws an exception, because this isn&#39;t the language of channel selection in VisIterato...
Definition: VisIterator.h:179
VisibilityIteratorReadImpl * operator()(const asyncio::PrefetchColumns *prefetchColumns, const casacore::Block< casacore::MeasurementSet > &mss, const casacore::Block< casacore::Int > &sortColumns, const casacore::Bool addDefaultSortCols, casacore::Double timeInterval) const
ABSTRACT CLASSES Deliberately vague to be general enough to allow for many different types of data
Definition: PlotData.h:48
void selectCorrelation(const casacore::Vector< casacore::Vector< casacore::Slice > > &corrsel)
casacore::Int numberChan(casacore::Int spw) const
Return number of chans/corrs per spw/pol.
virtual void putCol(casacore::ScalarColumn< casacore::Bool > &column, const casacore::Vector< casacore::Bool > &array)
column access functions
ROVisIterator()
Default constructor - useful only to assign another iterator later.
casacore::Vector< casacore::Int > & corrIds(casacore::Vector< casacore::Int > &corrids) const
Return selected correlation indices.
void lsrFrequency(const casacore::Int &spw, casacore::Vector< casacore::Double > &freq, casacore::Bool &convert, const casacore::Bool ignoreconv=false)
The PrefetchColumns class is used to specify a set of columns that can be prefetched when the (RO)Vis...
casacore::Vector< casacore::Int > & corrType(casacore::Vector< casacore::Int > &corrTypes) const
Return the correlation type (returns casacore::Stokes enums)
double Double
Definition: aipstype.h:55
Factory(ROVisIterator *vi)
Definition: VisIterator.h:196
void setWeightSpectrum(const casacore::Cube< casacore::Float > &wtsp)
Set/modify the weightSpectrum.
ROVisibilityIterator iterates through one or more readonly MeasurementSets.
VLAT should not access private parts, especially variables.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
void allSelectedSpectralWindows(casacore::Vector< casacore::Int > &spws, casacore::Vector< casacore::Int > &nvischan)
Get selected spws and channel counts.
float Float
Definition: aipstype.h:54
~ROVisIterator()
Destructor.
VisIteratorImpl * getImpl() const
A Table intended to hold astronomical data (a set of Measurements).
Specify which elements to extract from an n-dimensional array.
Definition: Slicer.h:289
virtual ~VisIterator()
Destructor.
Base class for all Casacore library errors.
Definition: Error.h:134
void setFlag(const casacore::Cube< casacore::Bool > &flag)
Set/modify the flags in the data.
VisIterator()
Constructors.
ROVisibilityIterator iterates through one or more readonly MeasurementSets.
ROVisIterator & operator=(const ROVisIterator &other)
Assignment.
ROVisIterator & operator++()
casacore::Vector< casacore::Matrix< casacore::Int > > & setChanAveBounds(casacore::Float factor, casacore::Vector< casacore::Matrix< casacore::Int > > &bounds)
Set up/return channel averaging bounds.
virtual casacore::Cube< casacore::Bool > & flag(casacore::Cube< casacore::Bool > &flags) const
Return flag for each polarization, channel and row.
void getDataColumn(DataColumn whichOne, const casacore::Vector< casacore::Vector< casacore::Slice > > &slices, casacore::Cube< casacore::Complex > &data) const
casacore::Int numberCorr(casacore::Int pol) const