Line data Source code
1 : //# VisibilityIterator.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: VisibilityIterator.h,v 19.14 2006/02/28 04:48:58 mvoronko Exp $
27 :
28 : #ifndef MSVIS_VISIBILITYITERATOR_H
29 : #define MSVIS_VISIBILITYITERATOR_H
30 :
31 : #include <casacore/casa/Arrays/Cube.h>
32 : #include <casacore/casa/Arrays/Matrix.h>
33 : #include <casacore/casa/Arrays/Slicer.h>
34 : #include <casacore/casa/BasicSL/String.h>
35 : #include <casacore/casa/Containers/RecordInterface.h>
36 : #include <casacore/casa/Quanta/MVDoppler.h>
37 : #include <casacore/casa/aips.h>
38 : #include <casacore/measures/Measures/MCDoppler.h>
39 : #include <casacore/measures/Measures/MDoppler.h>
40 : #include <casacore/measures/Measures/MeasConvert.h>
41 : #include <casacore/measures/Measures/Stokes.h>
42 : #include <casacore/ms/MSOper/MSDerivedValues.h>
43 : #include <casacore/ms/MeasurementSets/MSIter.h>
44 : #include <casacore/ms/MeasurementSets/MeasurementSet.h>
45 : #include <casacore/scimath/Mathematics/RigidVector.h>
46 : #include <casacore/scimath/Mathematics/SquareMatrix.h>
47 : #include <msvis/MSVis/StokesVector.h>
48 : #include <msvis/MSVis/VisBufferComponents.h>
49 : #include <msvis/MSVis/VisImagingWeight.h>
50 : #include <casacore/tables/Tables/ArrayColumn.h>
51 : #include <casacore/tables/Tables/ScalarColumn.h>
52 :
53 : #include <map>
54 : #include <set>
55 : #include <vector>
56 :
57 : namespace casa { //# NAMESPACE CASA - BEGIN
58 :
59 : //# forward decl
60 :
61 : namespace asyncio {
62 :
63 : class VLAT;
64 :
65 : // <summary>
66 : // The PrefetchColumns class is used to specify a set of columns that
67 : // can be prefetched when the (RO)VisibilityIterator is using asynchronous
68 : // I/O.
69 : // </summary>
70 : //
71 : // <synopsis>
72 : // When creating an ROVisibilityIterator or VisibilityIterator that can
73 : // potentially operate using asynchronous I/O it is necessary to specify
74 : // which columns of the main table are to be prefetched by the lookahead
75 : // thread. This class provides the way to specify those columns. The
76 : // class is an STL set object of enum values defined in VisBufferComponents.h.
77 : // These roughly correspond to the different components that can be access
78 : // via a VisBuffer.
79 : //
80 : // </synopsis>
81 : //
82 : // <example>
83 : // This is a simple example showing the construction of a PrefetchColumns
84 : // and its use in a VisibilityIterator constructor. For more complex cases
85 : // (e.g., where the columns to be prefetched depend on other factors) the
86 : // class provides some additional utility methods.
87 : //
88 : // Usually the file that creates the VI will include VisBuffer which will
89 : // then include VisBufferComponents.h; if not then the user will also need
90 : // to add "#include <msvis/MSVis/VisBufferComponents.h>" to their file.
91 : //
92 : // <code>
93 : // asyncio::PrefetchColumns prefetchColumns =
94 : // PrefetchColumns::prefetchColumns (VisBufferComponents::Ant1,
95 : // VisBufferComponents::Ant2,
96 : // VisBufferComponents::ArrayId,
97 : // VisBufferComponents::Direction1,
98 : // VisBufferComponents::Direction2,
99 : // VisBufferComponents::Feed1,
100 : // VisBufferComponents::Feed1_pa,
101 : // VisBufferComponents::Feed2,
102 : // VisBufferComponents::Feed2_pa,
103 : // VisBufferComponents::FieldId,
104 : // VisBufferComponents::FlagCube,
105 : // VisBufferComponents::Flag,
106 : // VisBufferComponents::FlagRow,
107 : // VisBufferComponents::Freq,
108 : // VisBufferComponents::NChannel,
109 : // VisBufferComponents::NCorr,
110 : // VisBufferComponents::NRow,
111 : // VisBufferComponents::ObservedCube,
112 : // VisBufferComponents::PhaseCenter,
113 : // VisBufferComponents::PolFrame,
114 : // VisBufferComponents::SpW,
115 : // VisBufferComponents::Time,
116 : // VisBufferComponents::Uvw,
117 : // VisBufferComponents::UvwMat,
118 : // VisBufferComponents::Weight,
119 : // -1);
120 : //
121 : // wvi_p = new VisibilityIterator (& prefetchColumns, * wvi_p);
122 : //
123 : //
124 : // </code>
125 : //
126 : // </example
127 : class PrefetchColumns : public std::set<VisBufferComponents::EnumType>{
128 :
129 : public:
130 :
131 : PrefetchColumns operator+ (const PrefetchColumns & other);
132 :
133 : static casacore::String columnName (casacore::Int id);
134 : static PrefetchColumns prefetchColumnsAll ();
135 : static PrefetchColumns prefetchAllColumnsExcept (casacore::Int firstColumn, ...);
136 : static PrefetchColumns prefetchColumns (casacore::Int firstColumn, ...);
137 : };
138 :
139 : } // end namespace asyncio
140 :
141 : class VisBuffer;
142 : class VisibilityIteratorReadImpl;
143 : class VisibilityIteratorWriteImpl;
144 :
145 : class SubChunkPair : public std::pair<casacore::Int, casacore::Int>{
146 :
147 : public:
148 :
149 : // First component is Chunk and second is subchunk
150 :
151 1800 : SubChunkPair () { resetToOrigin ();}
152 0 : SubChunkPair (casacore::Int a , casacore::Int b) : pair<casacore::Int,casacore::Int> (a,b) {}
153 :
154 0 : casacore::Bool operator== (const SubChunkPair & other){
155 0 : return first == other.first && second == other.second;
156 : }
157 :
158 0 : casacore::Bool operator< (const SubChunkPair & other){
159 0 : return first < other.first ||
160 0 : (first == other.first && second < other.second);
161 : }
162 :
163 : casacore::Bool atOrigin () const { return * this == SubChunkPair ();}
164 0 : casacore::Int chunk () const { return first;}
165 28338 : void incrementSubChunk () { second ++;}
166 14788 : void incrementChunk () { first ++; second = 0; }
167 :
168 24257 : void resetSubChunk () { second = 0;} // position to start of chunk
169 :
170 9637 : void resetToOrigin () { first = 0; second = 0; }
171 : // Make a subchunk pair that is positioned to the first subchunk of the
172 : // first chunk (i.e., 0,0)
173 :
174 : casacore::Int subchunk () const { return second;}
175 : casacore::String toString () const;
176 :
177 : static SubChunkPair noMoreData ();
178 :
179 : private:
180 :
181 :
182 : };
183 :
184 :
185 : // <summary>
186 : // ROVisibilityIterator iterates through one or more readonly MeasurementSets
187 : // </summary>
188 : // <use visibility=export>
189 : // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
190 : // </reviewed>
191 : // <prerequisite>
192 : // <li> <linkto class="MSIter">MSIter</linkto>
193 : // <li> <linkto class="casacore::MeasurementSet">casacore::MeasurementSet</linkto>
194 : // <li> <linkto class="VisSet">VisSet</linkto>
195 : // <li> <linkto class="PrefetchColumns">PrefetchColumns</linkto>
196 : // </prerequisite>
197 : //
198 : // <etymology>
199 : // The ROVisibilityIterator is a readonly iterator returning visibilities
200 : // </etymology>
201 : //
202 : // <synopsis>
203 : // ROVisibilityIterator provides iteration with various sort orders
204 : // for one or more MSs. It has member functions to retrieve the fields
205 : // commonly needed in synthesis calibration and imaging.
206 : //
207 : // One should use <linkto class="VisBuffer">VisBuffer</linkto>
208 : // to access chunks of data.
209 : //
210 : // ROVisibilityIterators can be either synchronous or asynchronous, depending
211 : // on the constructor used to create them as well as the current value of
212 : // a CASARC file setting. A synchronous instance is works the same as
213 : // this class ever worked; an asynchronous instance uses a second thread
214 : // (the Visibility Lookahead Thread or VLAT) to fill the VisBuffers in
215 : // advance of their use by the original thread.
216 : //
217 : // To create an asynchronous instance of ROVI you must use one of the two
218 : // constructors which have a pointer to a PrefetchColumns object as the
219 : // first argument. This object specifies which table columns should be
220 : // prefetched by the VLAT; accessing columns not specified in the PrefetchColumns
221 : // object will result in an exception containing an error message indicating
222 : // that a the VisBuffer does not contain the requested column. In addition
223 : // to using the appropriate constructor, the CASARC file setting
224 : // VisibilityIterator.
225 : //
226 : // +-------------------+
227 : // | |
228 : // | *** Nota Bene *** |
229 : // | |
230 : // +-------------------+
231 : //
232 : // Because of the multithreaded nature of asynchronous I/O, the user
233 : // needs to be a bit more careful in the use of the VI and it's attached VisBuffer.
234 : // casacore::Data access operations need to be directed to the VisBuffer. Additionally
235 : // the user must not attempt to access the data using a separate VI since
236 : // the underlying casacore objects are not threadsafe and bizarre errors
237 : // will likely occur.
238 : //
239 : // CASARC Settings
240 : // ===============
241 : //
242 : // casacore::Normal settings
243 : // ---------------
244 : //
245 : // VisibilityIterator.async.enabled - Boolean value that enables or disables
246 : // async I/O. The default value is currently false (i.e., disabled).
247 : // VisibilityIterator.async.nBuffers - The number of lookahead buffers. This
248 : // defaults to 2.
249 : //
250 : //
251 : // Debug settings
252 : // --------------
253 : //
254 : // VisibilityIterator.async.doStats: true
255 : // VisibilityIterator.async.debug.logFile: stderr
256 : // VisibilityIterator.async.debug.logLevel: 1
257 : //
258 :
259 : // </synopsis>
260 : //
261 : // <example>
262 : // <code>
263 : // //
264 : // </code>
265 : // </example>
266 : //
267 : // <motivation>
268 : // For imaging and calibration you need to access an casacore::MS in some consistent
269 : // order (by field, spectralwindow, time interval etc.). This class provides
270 : // that access.
271 : // </motivation>
272 : //
273 : // <thrown>
274 : // <li>
275 : // <li>
276 : // </thrown>
277 : //
278 : // <todo asof="1997/05/30">
279 : // <li> cleanup the currently dual interface for visibilities and flags
280 : // <li> sort out what to do with weights when interpolating
281 : // </todo>
282 : class ROVisibilityIterator
283 : {
284 : friend class AsyncEnabler;
285 : friend class VisibilityIteratorReadImpl;
286 : friend class ViReadImplAsync;
287 : friend class asyncio::VLAT; // allow VI lookahead thread class to access protected functions
288 : // VLAT should not access private parts, especially variables
289 : public:
290 :
291 : class Factory {
292 :
293 : public:
294 :
295 1800 : virtual ~Factory () {}
296 :
297 : virtual VisibilityIteratorReadImpl *
298 1797 : operator() (const asyncio::PrefetchColumns * /*prefetchColumns*/,
299 : const casacore::Block<casacore::MeasurementSet>& /*mss*/,
300 : const casacore::Block<casacore::Int>& /*sortColumns*/,
301 : const casacore::Bool /*addDefaultSortCols*/,
302 : casacore::Double /*timeInterval*/) const
303 : {
304 1797 : return NULL;
305 : }
306 : };
307 :
308 : //# the following is a copy of the enum in MSIter
309 : //# can't think of a way to get one that known to the outside world from here
310 : enum PolFrame {
311 : // Circular polarization
312 : Circular=0,
313 : // Linear polarization
314 : Linear=1
315 : };
316 :
317 : typedef enum DataColumn {
318 : Observed=0, // Observed data
319 : Model, // Model data
320 : Corrected // Corrected data
321 : } DataColumn;
322 :
323 : class AsyncEnabler {
324 : public:
325 : AsyncEnabler (ROVisibilityIterator &);
326 : AsyncEnabler (ROVisibilityIterator *);
327 : ~AsyncEnabler ();
328 : void release ();
329 : private:
330 : casacore::Bool oldEnabledState_p;
331 : ROVisibilityIterator * roVisibilityIterator_p;
332 : };
333 :
334 : // Default constructor - useful only to assign another iterator later
335 : ROVisibilityIterator();
336 : // Construct from an casacore::MS and a casacore::Block of casacore::MS column enums specifying the
337 : // iteration order. If no order is specified, it uses the default sort
338 : // order of MSIter, which is not necessarily the raw order of ms!
339 : // The default ordering is ARRAY_ID, FIELD_ID, DATA_DESC_ID,
340 : // and TIME, but check MSIter.h to be sure.
341 : // These columns will be added first if they are not specified.
342 : //
343 : // An optional timeInterval (in seconds) can be given to iterate through
344 : // chunks of time. The default interval of 0 groups all times together.
345 : // Every 'chunk' of data contains all data within a certain time interval and
346 : // with identical values of the other iteration columns (e.g. DATA_DESC_ID
347 : // and FIELD_ID). Using selectChannel(), a number of groups of channels can
348 : // be requested. At present the channel group iteration will always occur
349 : // before the interval iteration.
350 : ROVisibilityIterator(const casacore::MeasurementSet& ms,
351 : const casacore::Block<casacore::Int>& sortColumns,
352 : casacore::Double timeInterval=0,
353 : const Factory & factory = Factory());
354 : // Same as above, but with the option of using the raw order of ms
355 : // (addDefaultSortCols=false).
356 : ROVisibilityIterator(const casacore::MeasurementSet& ms,
357 : const casacore::Block<casacore::Int>& sortColumns,
358 : const casacore::Bool addDefaultSortCols,
359 : casacore::Double timeInterval=0);
360 :
361 : // Same as previous constructors, but with multiple MSs to iterate over.
362 : ROVisibilityIterator(const casacore::Block<casacore::MeasurementSet>& mss,
363 : const casacore::Block<casacore::Int>& sortColumns,
364 : casacore::Double timeInterval=0);
365 :
366 : ROVisibilityIterator(const casacore::Block<casacore::MeasurementSet>& mss,
367 : const casacore::Block<casacore::Int>& sortColumns,
368 : const casacore::Bool addDefaultSortCols,
369 : casacore::Double timeInterval=0);
370 :
371 : ROVisibilityIterator(const asyncio::PrefetchColumns * prefetchColumns,
372 : const casacore::MeasurementSet& ms,
373 : const casacore::Block<casacore::Int>& sortColumns,
374 : const casacore::Bool addDefaultSortCols = true,
375 : casacore::Double timeInterval = 0);
376 :
377 : ROVisibilityIterator (const asyncio::PrefetchColumns * prefetchColumns,
378 : const casacore::Block<casacore::MeasurementSet>& mss,
379 : const casacore::Block<casacore::Int>& sortColumns,
380 : const casacore::Bool addDefaultSortCols = true,
381 : casacore::Double timeInterval = 0);
382 :
383 : // Copy construct. This calls the assigment operator.
384 : ROVisibilityIterator(const ROVisibilityIterator & other);
385 : ROVisibilityIterator(const asyncio::PrefetchColumns * prefetchColumns, const ROVisibilityIterator & other);
386 : // Assigment. Any attached VisBuffers are lost in the assign.
387 : ROVisibilityIterator & operator=(const ROVisibilityIterator &other);
388 : // Destructor
389 : virtual ~ROVisibilityIterator();
390 :
391 : // static ROVisibilityIterator * create (const casacore::MeasurementSet & ms,
392 : // const casacore::Block<casacore::Int>& sortColumns,
393 : // const asyncio::PrefetchColumns * prefetchColumns = NULL,
394 : // const casacore::Bool addDefaultSortCols = true,
395 : // casacore::Double timeInterval=0);
396 : //
397 : // static ROVisibilityIterator * create (const casacore::Block<casacore::MeasurementSet>& mss,
398 : // const casacore::Block<casacore::Int>& sortColumns,
399 : // const asyncio::PrefetchColumns * prefetchColumns = NULL,
400 : // const casacore::Bool addDefaultSortCols = true,
401 : // casacore::Double timeInterval=0);
402 : //
403 : // static ROVisibilityIterator * create (const ROVisibilityIterator & rovi,
404 : // const asyncio::PrefetchColumns * prefetchColumns,
405 : // casacore::Int nReadAheadBuffers = 2);
406 :
407 : // Members
408 :
409 : casacore::Bool isAsynchronous () const;
410 : static casacore::Bool isAsynchronousIoEnabled();
411 :
412 : casacore::Bool isAsyncEnabled () const;
413 : casacore::Bool isWritable () const;
414 : // Reset iterator to origin/start of data (of current chunk)
415 : void origin();
416 : // Reset iterator to true start of data (first chunk)
417 : void originChunks();
418 :
419 : // Return the time interval (in seconds) used for iteration.
420 : // This is not the same as the INTERVAL column.
421 : casacore::Double getInterval() const;
422 : // Set or reset the time interval (in seconds) to use for iteration.
423 : // You should call originChunks() to reset the iteration after
424 : // calling this.
425 : void setInterval(casacore::Double timeInterval);
426 :
427 : // Set the 'blocking' size for returning data.
428 : // With the default (0) only a single integration is returned at a time, this
429 : // is what is currently required for the calibration software. With blocking
430 : // set, up to nRows can be returned in one go. The chunk
431 : // size determines the actual maximum.
432 : void setRowBlocking(casacore::Int nRows=0);
433 : // Return false if no more data (in current chunk)
434 : casacore::Bool more() const;
435 : SubChunkPair getSubchunkId () const;
436 : // Advance iterator through data
437 : ROVisibilityIterator & operator++(int);
438 : ROVisibilityIterator & operator++();
439 : // Return false if no more 'Chunks' of data left
440 : casacore::Bool moreChunks() const;
441 : // Check if ms has change since last iteration
442 : casacore::Bool newMS() const;
443 : casacore::Int msId() const;
444 : VisBuffer * getVisBuffer ();
445 : //reference to actual ms in interator
446 : const casacore::MeasurementSet& ms() const;
447 : // Advance to the next Chunk of data
448 : ROVisibilityIterator& nextChunk();
449 : // Return antenna1
450 : casacore::Vector<casacore::Int>& antenna1(casacore::Vector<casacore::Int>& ant1) const;
451 : // Return antenna2
452 : casacore::Vector<casacore::Int>& antenna2(casacore::Vector<casacore::Int>& ant2) const;
453 : // Return feed1
454 : casacore::Vector<casacore::Int>& feed1(casacore::Vector<casacore::Int>& fd1) const;
455 : // Return feed2
456 : casacore::Vector<casacore::Int>& feed2(casacore::Vector<casacore::Int>& fd2) const;
457 : // Return channel numbers in selected VisSet spectrum
458 : // (i.e. disregarding possible selection on the iterator, but
459 : // including the selection set when creating the VisSet)
460 : virtual casacore::Vector<casacore::Int>& channel(casacore::Vector<casacore::Int>& chan) const;
461 : // Return feed configuration matrix for specified antenna
462 : casacore::Vector<casacore::SquareMatrix<casacore::Complex,2> >&
463 : CJones(casacore::Vector<casacore::SquareMatrix<casacore::Complex,2> >& cjones) const;
464 : // Return receptor angles for all antennae and feeds
465 : // First axis of the cube is a receptor number,
466 : // 2nd is antennaId, 3rd is feedId
467 : // Note: the method is intended to provide an access to MSIter::receptorAngles
468 : // for VisBuffer in the multi-feed case. It may be worth to change the
469 : // interface of feed_pa to return the information for all feeds.
470 : const casacore::Cube<casacore::Double>& receptorAngles() const;
471 : // return a string mount identifier for each antenna
472 : const casacore::Vector<casacore::String>& antennaMounts() const;
473 : // Return a cube containing pairs of coordinate offsets for each
474 : // receptor of each feed (values are in radians, coordinate system is fixed
475 : // with antenna and is the same one as used to define the BEAM_OFFSET
476 : // parameter in the feed table). The cube axes are receptor, antenna, feed.
477 : const casacore::Cube<casacore::RigidVector<casacore::Double, 2> >& getBeamOffsets() const;
478 : // true if all elements of the cube returned by getBeamOffsets are zero
479 : casacore::Bool allBeamOffsetsZero() const;
480 : // Return feed parallactic angles casacore::Vector(nant) (1 feed/ant)
481 : casacore::Vector<casacore::Float> feed_pa(casacore::Double time) const;
482 : static casacore::Vector<casacore::Float> feed_paCalculate(casacore::Double time, casacore::MSDerivedValues & msd,
483 : casacore::Int nAntennas, const casacore::MEpoch & mEpoch0,
484 : const casacore::Vector<casacore::Float> & receptor0Angle);
485 : // Return nominal parallactic angle at specified time
486 : // (does not include feed position angle offset--see feed_pa)
487 : // A global value for all antennas (e.g., small array)
488 : const casacore::Float& parang0(casacore::Double time) const;
489 : static casacore::Float parang0Calculate (casacore::Double time, casacore::MSDerivedValues & msd, const casacore::MEpoch & epoch0);
490 : // Per antenna:
491 : casacore::Vector<casacore::Float> parang(casacore::Double time) const;
492 : static casacore::Vector<casacore::Float> parangCalculate (casacore::Double time, casacore::MSDerivedValues & msd,
493 : int nAntennas, const casacore::MEpoch mEpoch0);
494 : // Return the antenna AZ/EL casacore::Vector(nant)
495 : casacore::MDirection azel0(casacore::Double time) const;
496 : static void azel0Calculate (casacore::Double time, casacore::MSDerivedValues & msd,
497 : casacore::MDirection & azel0, const casacore::MEpoch & mEpoch0);
498 : casacore::Vector<casacore::MDirection> azel(casacore::Double time) const;
499 : static void azelCalculate (casacore::Double time, casacore::MSDerivedValues & msd, casacore::Vector<casacore::MDirection> & azel,
500 : casacore::Int nAnt, const casacore::MEpoch & mEpoch0);
501 : // Return the hour angle for the specified time
502 : casacore::Double hourang(casacore::Double time) const;
503 : static casacore::Double hourangCalculate (casacore::Double time, casacore::MSDerivedValues & msd, const casacore::MEpoch & mEpoch0);
504 : // Return the current FieldId
505 : casacore::Int fieldId() const;
506 : // Return the current ArrayId
507 : casacore::Int arrayId() const;
508 : // Return the current Field Name
509 : casacore::String fieldName() const;
510 : // Return the current Source Name
511 : casacore::String sourceName() const;
512 : // Return flag for each polarization, channel and row
513 : virtual casacore::Cube<casacore::Bool>& flag(casacore::Cube<casacore::Bool>& flags) const;
514 : // Return flag for each channel & row
515 : casacore::Matrix<casacore::Bool>& flag(casacore::Matrix<casacore::Bool>& flags) const;
516 :
517 : // Determine whether FLAG_CATEGORY is valid.
518 : casacore::Bool existsFlagCategory() const;
519 :
520 : // Return flags for each polarization, channel, category, and row.
521 : casacore::Array<casacore::Bool>& flagCategory(casacore::Array<casacore::Bool>& flagCategories) const;
522 : // Return row flag
523 : casacore::Vector<casacore::Bool>& flagRow(casacore::Vector<casacore::Bool>& rowflags) const;
524 : // Return scan number
525 : casacore::Vector<casacore::Int>& scan(casacore::Vector<casacore::Int>& scans) const;
526 : // Return the OBSERVATION_IDs
527 : casacore::Vector<casacore::Int>& observationId(casacore::Vector<casacore::Int>& obsids) const;
528 : // Return the PROCESSOR_IDs
529 : casacore::Vector<casacore::Int>& processorId(casacore::Vector<casacore::Int>& procids) const;
530 : // Return the STATE_IDs
531 : casacore::Vector<casacore::Int>& stateId(casacore::Vector<casacore::Int>& stateids) const;
532 : // Return current frequencies (in Hz, acc. to the casacore::MS def'n v.2)
533 : virtual casacore::Vector<casacore::Double>& frequency(casacore::Vector<casacore::Double>& freq) const;
534 : // Return frequencies (in Hz, acc. to the casacore::MS def'n v.2) in selected velocity frame,
535 : // returns the same as frequency() if there is no vel selection active.
536 : casacore::Vector<casacore::Double>& lsrFrequency(casacore::Vector<casacore::Double>& freq) const;
537 : // Return the current phase center as an MDirection
538 : const casacore::MDirection& phaseCenter() const;
539 : const casacore::MDirection phaseCenter(const casacore::Int fieldid, const casacore::Double time=-1.0) const;
540 : // Return frame for polarization (returns PolFrame enum)
541 : casacore::Int polFrame() const;
542 : // Return the correlation type (returns casacore::Stokes enums)
543 : virtual casacore::Vector<casacore::Int>& corrType(casacore::Vector<casacore::Int>& corrTypes) const;
544 : // Return sigma
545 : casacore::Vector<casacore::Float>& sigma(casacore::Vector<casacore::Float>& sig) const;
546 : // Return sigma matrix (pol-dep)
547 : virtual casacore::Matrix<casacore::Float>& sigmaMat(casacore::Matrix<casacore::Float>& sigmat) const;
548 : // Return current SpectralWindow
549 : casacore::Int spectralWindow() const;
550 : // Return current Polarization Id
551 : casacore::Int polarizationId() const;
552 : // Return current DataDescription Id
553 : casacore::Int dataDescriptionId() const;
554 : // Return MJD midpoint of interval.
555 : casacore::Vector<casacore::Double>& time(casacore::Vector<casacore::Double>& t) const;
556 : // Return MJD centroid of interval.
557 : casacore::Vector<casacore::Double>& timeCentroid(casacore::Vector<casacore::Double>& t) const;
558 : // Return nominal time interval
559 : casacore::Vector<casacore::Double>& timeInterval(casacore::Vector<casacore::Double>& ti) const;
560 : // Return actual time interval
561 : casacore::Vector<casacore::Double>& exposure(casacore::Vector<casacore::Double>& expo) const;
562 : // Return the visibilities as found in the casacore::MS, casacore::Cube(npol,nchan,nrow).
563 : virtual casacore::Cube<casacore::Complex>& visibility(casacore::Cube<casacore::Complex>& vis,
564 : DataColumn whichOne) const;
565 : // Return FLOAT_DATA as a casacore::Cube(npol, nchan, nrow) if found in the MS.
566 : casacore::Cube<casacore::Float>& floatData(casacore::Cube<casacore::Float>& fcube) const;
567 : // Return the visibility 4-vector of polarizations for each channel.
568 : // If the casacore::MS doesn't contain all polarizations, it is assumed it
569 : // contains one or two parallel hand polarizations.
570 : casacore::Matrix<CStokesVector>& visibility(casacore::Matrix<CStokesVector>& vis,
571 : DataColumn whichOne) const;
572 : // Return the shape of the visibility Cube
573 : casacore::IPosition visibilityShape() const;
574 : // Return u,v and w (in meters)
575 : virtual casacore::Vector<casacore::RigidVector<casacore::Double,3> >& uvw(casacore::Vector<casacore::RigidVector<casacore::Double,3> >& uvwvec) const;
576 : casacore::Matrix<casacore::Double>& uvwMat(casacore::Matrix<casacore::Double>& uvwmat) const;
577 : // Return weight
578 : casacore::Vector<casacore::Float>& weight(casacore::Vector<casacore::Float>& wt) const;
579 : // Returns the nPol_p x curNumRow_p weight matrix
580 : virtual casacore::Matrix<casacore::Float>& weightMat(casacore::Matrix<casacore::Float>& wtmat) const;
581 : // Determine whether WEIGHT_SPECTRUM exists.
582 : casacore::Bool existsWeightSpectrum() const;
583 : // Return weightspectrum (a weight for each channel)
584 : casacore::Cube<casacore::Float>& weightSpectrum(casacore::Cube<casacore::Float>& wtsp) const;
585 : // Return imaging weight (a weight for each channel)
586 : //casacore::Matrix<casacore::Float>& imagingWeight(casacore::Matrix<casacore::Float>& wt) const;
587 : // Return true if FieldId/Source has changed since last iteration
588 : casacore::Bool newFieldId() const;
589 : // Return true if arrayID has changed since last iteration
590 : casacore::Bool newArrayId() const;
591 : // Return true if SpectralWindow has changed since last iteration
592 : casacore::Bool newSpectralWindow() const;
593 : // Return the index of the first channel of the current channel group
594 : // in the total (selected) spectrum.
595 : casacore::Int channelIndex() const;
596 : // Return the width of the current group of channels, i.e.,
597 : // the number of channels returned by visibility() and frequency().
598 : casacore::Int channelGroupSize() const;
599 :
600 : // Return the number of correlations in the current iteration
601 : casacore::Int nCorr() const;;
602 : // Return the number of rows in the current iteration
603 : casacore::Int nRow() const;
604 : // Return the row ids as from the original root table. This is useful
605 : // to find correspondance between a given row in this iteration to the
606 : // original ms row
607 : virtual casacore::Vector<casacore::rownr_t>& rowIds(casacore::Vector<casacore::rownr_t>& rowids) const;
608 : // Return the numbers of rows in the current chunk
609 : casacore::Int nRowChunk() const;
610 : // Return the number of sub-intervals in the current chunk
611 : casacore::Int nSubInterval() const;
612 : // Call to use the slurp i/o method for all scalar columns. This
613 : // will set the casacore::BucketCache cache size to the full column length
614 : // and cause the full column to be cached in memory, if
615 : // any value of the column is used. In case of out-of-memory,
616 : // it will automatically fall-back on the smaller cache size.
617 : // Slurping the column is to be considered as a work-around for the
618 : // casacore::Table i/o code, which uses casacore::BucketCache and performs extremely bad
619 : // for random access. Slurping is useful when iterating non-sequentially
620 : // an casacore::MS or parts of an casacore::MS, it is not tested with multiple MSs.
621 : void slurp() const;
622 : // Velocity selection - specify the output channels in velocity:
623 : // nChan - number of output channels, vStart - start velocity,
624 : // vInc - velocity increment. So channel i will have velocity
625 : // vStart + i*vInc (i=0,nChan-1).
626 : // Specify velocities as in e.g., casacore::MVRadialVelocity(casacore::Quantity(2001.,"km/s")).
627 : // The reference type and velocity definition are specified separately.
628 : // Note that no averaging is performed, the visibilities will be interpolated
629 : // and sampled at the specified velocities, it's up to you to choose a vInc
630 : // appropriate to the channel width.
631 : // The REST_FREQUENCY column in the SPECTRAL_WINDOW subtable is used to
632 : // determine the velocity-frequency conversion.
633 : // By default calculations are done for a single velocity with offsets
634 : // applied for the others (ok for non-rel velocities with RADIO defn),
635 : // set precise to true to do a full conversion for each output channel.(NYI)
636 : ROVisibilityIterator&
637 : selectVelocity(casacore::Int nChan,
638 : const casacore::MVRadialVelocity& vStart, const casacore::MVRadialVelocity& vInc,
639 : casacore::MRadialVelocity::Types rvType = casacore::MRadialVelocity::LSR,
640 : casacore::MDoppler::Types dType = casacore::MDoppler::RADIO, casacore::Bool precise=false);
641 : // Select the velocity interpolation scheme.
642 : // At present the choice is limited to : nearest and linear, linear
643 : // is the default.
644 : // TODO: add cubic, spline and possibly FFT
645 : ROVisibilityIterator& velInterpolation(const casacore::String& type);
646 : // Channel selection - only the selected channels will be returned by the
647 : // access functions. The default spectralWindow is the current one (or 0)
648 : // This allows selection of the input channels, producing
649 : // nGroup groups of width output channels. Default is to return all channels
650 : // in a single group.
651 : ROVisibilityIterator& selectChannel(casacore::Int nGroup=1, casacore::Int start=0, casacore::Int width=0,
652 : casacore::Int increment=1, casacore::Int spectralWindow=-1);
653 : //Same as above except when multiple ms's are to be accessed
654 : ROVisibilityIterator& selectChannel(casacore::Block< casacore::Vector<casacore::Int> >& blockNGroup,
655 : casacore::Block< casacore::Vector<casacore::Int> >& blockStart,
656 : casacore::Block< casacore::Vector<casacore::Int> >& blockWidth,
657 : casacore::Block< casacore::Vector<casacore::Int> >& blockIncr,
658 : casacore::Block< casacore::Vector<casacore::Int> >& blockSpw);
659 : //get the channel selection ...the block over the number of ms's associated
660 : // with this iterator
661 : void getChannelSelection(casacore::Block< casacore::Vector<casacore::Int> >& blockNGroup,
662 : casacore::Block< casacore::Vector<casacore::Int> >& blockStart,
663 : casacore::Block< casacore::Vector<casacore::Int> >& blockWidth,
664 : casacore::Block< casacore::Vector<casacore::Int> >& blockIncr,
665 : casacore::Block< casacore::Vector<casacore::Int> >& blockSpw);
666 : // Translate slicesv from the form returned by casacore::MSSelection::getChanSlices()
667 : // to matv as used by setChanAveBounds(). widthsv is the channel averaging
668 : // width for each _selected_ spw.
669 : void slicesToMatrices(casacore::Vector<casacore::Matrix<casacore::Int> >& matv,
670 : const casacore::Vector<casacore::Vector<casacore::Slice> >& slicesv,
671 : const casacore::Vector<casacore::Int>& widthsv) const;
672 : // Get the spw, start and nchan for all the ms's is this Visiter that
673 : // match the frequecy "freqstart-freqStep" and "freqEnd+freqStep" range
674 : // Can help in doing channel selection above..
675 : // freqFrame is the frame the caller frequency values are in (freqStart and freqEnd)
676 : // These will be converted to the frame of the selected spw to match
677 : void getSpwInFreqRange(casacore::Block<casacore::Vector<casacore::Int> >& spw,
678 : casacore::Block<casacore::Vector<casacore::Int> >& start,
679 : casacore::Block<casacore::Vector<casacore::Int> >& nchan,
680 : casacore::Double freqStart, casacore::Double freqEnd,
681 : casacore::Double freqStep, casacore::MFrequency::Types freqFrame=casacore::MFrequency::LSRK);
682 :
683 : //Get the frequency range of the data selection
684 : void getFreqInSpwRange(casacore::Double& freqStart, casacore::Double& freqEnd, casacore::MFrequency::Types freqframe = casacore::MFrequency::LSRK);
685 :
686 : // Attach a VisBuffer object.
687 : // Note that while more than one VisBuffer may be attached, only the
688 : // last one is actively updated. A casacore::Stack is kept internally, so after
689 : // a detach, the previous VisBuffer becomes active again.
690 : void attachVisBuffer(VisBuffer& vb);
691 : // Detach a VisBuffer object.
692 : // If the object detached is not the last one attached an exception
693 : // is thrown.
694 : void detachVisBuffer(VisBuffer& vb);
695 : // Access the current casacore::MSColumns object in MSIter
696 : const casacore::MSColumns& msColumns() const;
697 : // get back the selected spectral windows and spectral channels for
698 : // current ms
699 : void allSelectedSpectralWindows(casacore::Vector<casacore::Int>& spws, casacore::Vector<casacore::Int>& nvischan);
700 : // Convert the frequency from the observe frame to lsr frame.
701 : // Returns true in convert if given spw was not observed
702 : // in the LSRK frame
703 : //when ignoreconv=true...no conversion is done from data frame
704 : //frequency is served as is
705 : void lsrFrequency(const casacore::Int& spw, casacore::Vector<casacore::Double>& freq, casacore::Bool& convert, const casacore::Bool ignoreconv=false);
706 : //assign a VisImagingWeight object to this iterator
707 : void useImagingWeight(const VisImagingWeight& imWgt);
708 : const VisImagingWeight & getImagingWeightGenerator () const;
709 :
710 : //return number of Ant
711 : casacore::Int numberAnt();
712 : //Return number of rows in all selected ms's
713 : casacore::Int numberCoh();
714 : // Return number of spws, polids, ddids
715 : casacore::Int numberSpw();
716 : casacore::Int numberPol();
717 : casacore::Int numberDDId();
718 : // casacore::ArrayColumn <casacore::Double> & getChannelFrequency () const;
719 : // casacore::Block<casacore::Int> getChannelGroupNumber () const;
720 : // casacore::Block<casacore::Int> getChannelIncrement () const;
721 : // casacore::Block<casacore::Int> getChannelStart () const;
722 : // casacore::Block<casacore::Int> getChannelWidth () const;
723 : casacore::Int getDataDescriptionId () const;
724 : const casacore::MeasurementSet & getMeasurementSet() const;;
725 : casacore::Int getMeasurementSetId() const;
726 : casacore::Int getNAntennas () const;
727 : casacore::MEpoch getEpoch () const;
728 : ///////////////casacore::MFrequency::Types getObservatoryFrequencyType () const; //???
729 : ///////////////casacore::MPosition getObservatoryPosition () const;
730 : ///////////////casacore::MDirection getPhaseCenter () const;
731 : casacore::Vector<casacore::Float> getReceptor0Angle ();
732 : casacore::Vector<casacore::rownr_t> getRowIds () const;
733 :
734 : // Returns the columns that the VisibilityIterator is sorting by.
735 : const casacore::Block<casacore::Int>& getSortColumns() const;
736 :
737 : static void lsrFrequency (const casacore::Int& spw,
738 : casacore::Vector<casacore::Double>& freq,
739 : casacore::Bool & convert,
740 : const casacore::Block<casacore::Int> & chanStart,
741 : const casacore::Block<casacore::Int> & chanWidth,
742 : const casacore::Block<casacore::Int> & chanInc,
743 : const casacore::Block<casacore::Int> & numChanGroup,
744 : const casacore::ArrayColumn <casacore::Double> & chanFreqs,
745 : const casacore::ScalarColumn<casacore::Int> & obsMFreqTypes,
746 : const casacore::MEpoch & ep,
747 : const casacore::MPosition & obsPos,
748 : const casacore::MDirection & dir);
749 :
750 1800 : static casacore::String getAipsRcBase () { return "VisibilityIterator";}
751 0 : static casacore::String getAsyncRcBase () { return getAipsRcBase() + ".async";}
752 :
753 : protected:
754 :
755 : ROVisibilityIterator (const asyncio::PrefetchColumns * prefetchColumns,
756 : const casacore::Block<casacore::MeasurementSet>& mss,
757 : const casacore::Block<casacore::Int>& sortColumns,
758 : const casacore::Bool addDefaultSortCols,
759 : casacore::Double timeInterval,
760 : casacore::Bool writable);
761 :
762 : void construct (const asyncio::PrefetchColumns * prefetchColumns,
763 : const casacore::Block<casacore::MeasurementSet>& mss,
764 : const casacore::Block<casacore::Int>& sortColumns,
765 : const casacore::Bool addDefaultSortCols,
766 : casacore::Double timeInterval,
767 : casacore::Bool writable,
768 : const Factory & factory);
769 :
770 : VisibilityIteratorReadImpl * getReadImpl() const;
771 :
772 : bool existsColumn (VisBufferComponents::EnumType id) const;
773 : // advance the iteration
774 : virtual void advance();
775 : // set the currently selected table
776 : virtual void setSelTable();
777 : // set the iteration state
778 : void setState();
779 : // get the TOPO frequencies from the selected velocities and the obs. vel.
780 : void getTopoFreqs();
781 : void getTopoFreqs(casacore::Vector<casacore::Double> & lsrFreq, casacore::Vector<casacore::Double> & selFreq); // for async i/o
782 : void getLsrInfo (casacore::Block<casacore::Int> & channelGroupNumber,
783 : casacore::Block<casacore::Int> & channelIncrement,
784 : casacore::Block<casacore::Int> & channelStart,
785 : casacore::Block<casacore::Int> & channelWidth,
786 : casacore::MPosition & observatoryPositon,
787 : casacore::MDirection & phaseCenter,
788 : casacore::Bool & velocitySelection) const;
789 : std::vector<casacore::MeasurementSet> getMeasurementSets () const;
790 : const casacore::MSDerivedValues & getMSD () const; // for use by Async I/O *ONLY*
791 : // update the DATA slicer
792 : virtual void updateSlicer();
793 : // attach the column objects to the currently selected table
794 : virtual void attachColumns(const casacore::Table &t);
795 : // returns the table, to which columns are attached,
796 : // can be overridden in derived classes
797 : virtual const casacore::Table attachTable() const;
798 : // get the (velocity selected) interpolated visibilities, flags and weights.
799 : // It is not really const at all (it seems to use This-> trickery so callers
800 : // like flag() can be declared const).
801 : // void getInterpolatedVisFlagWeight(DataColumn whichOne) const;
802 : // get the (velocity selected) interpolated FLOAT_DATA (as real Floats),
803 : // flags and weights.
804 : // void getInterpolatedFloatDataFlagWeight() const;
805 : // get the visibility data (observed, corrected or model);
806 : // deals with casacore::Float and casacore::Complex observed data (DATA or FLOAT_DATA)
807 : void getDataColumn(DataColumn whichOne, const casacore::Slicer& slicer,
808 : casacore::Cube<casacore::Complex>& data) const;
809 : void getDataColumn(DataColumn whichOne, casacore::Cube<casacore::Complex>& data) const;
810 : // get FLOAT_DATA as real Floats.
811 : void getFloatDataColumn(const casacore::Slicer& slicer, casacore::Cube<casacore::Float>& data) const;
812 : void getFloatDataColumn(casacore::Cube<casacore::Float>& data) const;
813 :
814 : void originChunks(casacore::Bool forceRewind);
815 : //Re-Do the channel selection in multi ms case
816 : void doChannelSelection();
817 : //Set the tile cache size....when using slice access if tile cache size is
818 : // not set memory usage can go wild. Specifically, the caching scheme is
819 : // ephemeral and lives for that instance of setting the caching scheme.
820 : //
821 : // If you don't set any then the defaults come into play and caches a few
822 : // tiles along every axis at the tile you requested...which is a waste when
823 : // say you know you want to proceed along the row axis for example...and in
824 : // fact now VisIter just reads one tile (thus the commenting in setTileCache)
825 : // and lets the OS do the caching rather than than having the table system
826 : // cache extra tiles.
827 : virtual void setTileCache();
828 : //Check if spw is in selected SPW for actual ms
829 : casacore::Bool isInSelectedSPW(const casacore::Int& spw);
830 : // Updates, if necessary, rowIds_p member for the current chunk
831 : void update_rowIds() const;
832 : void setAsyncEnabled (casacore::Bool enable);
833 : template<class T>
834 : void getColScalar(const casacore::ScalarColumn<T> &column, casacore::Vector<T> &array, casacore::Bool resize) const;
835 : template<class T>
836 : void getColArray(const casacore::ArrayColumn<T> &column, casacore::Array<T> &array, casacore::Bool resize) const;
837 : // column access functions, can be overridden in derived classes
838 : virtual void getCol(const casacore::ScalarColumn<casacore::Bool> &column, casacore::Vector<casacore::Bool> &array, casacore::Bool resize = false) const;
839 : virtual void getCol(const casacore::ScalarColumn<casacore::Int> &column, casacore::Vector<casacore::Int> &array, casacore::Bool resize = false) const;
840 : virtual void getCol(const casacore::ScalarColumn<casacore::Double> &column, casacore::Vector<casacore::Double> &array, casacore::Bool resize = false) const;
841 : virtual void getCol(const casacore::ArrayColumn<casacore::Bool> &column, casacore::Array<casacore::Bool> &array, casacore::Bool resize = false) const;
842 : virtual void getCol(const casacore::ArrayColumn<casacore::Float> &column, casacore::Array<casacore::Float> &array, casacore::Bool resize = false) const;
843 : virtual void getCol(const casacore::ArrayColumn<casacore::Double> &column, casacore::Array<casacore::Double> &array, casacore::Bool resize = false) const;
844 : virtual void getCol(const casacore::ArrayColumn<casacore::Complex> &column, casacore::Array<casacore::Complex> &array, casacore::Bool resize = false) const;
845 : virtual void getCol(const casacore::ArrayColumn<casacore::Bool> &column, const casacore::Slicer &slicer, casacore::Array<casacore::Bool> &array, casacore::Bool resize = false) const;
846 : virtual void getCol(const casacore::ArrayColumn<casacore::Float> &column, const casacore::Slicer &slicer, casacore::Array<casacore::Float> &array, casacore::Bool resize = false) const;
847 : virtual void getCol(const casacore::ArrayColumn<casacore::Complex> &column, const casacore::Slicer &slicer, casacore::Array<casacore::Complex> &array, casacore::Bool resize = false) const;
848 : // void getCol(const casacore::String &colName, casacore::Array<casacore::Double> &array,
849 : // casacore::Array<casacore::Double> &all, casacore::Bool resize = false) const;
850 : // void getCol(const casacore::String &colName, casacore::Vector<casacore::Bool> &array,
851 : // casacore::Vector<casacore::Bool> &all, casacore::Bool resize = false) const;
852 : // void getCol(const casacore::String &colName, casacore::Vector<casacore::Int> &array,
853 : // casacore::Vector<casacore::Int> &all, casacore::Bool resize = false) const;
854 : // void getCol(const casacore::String &colName, casacore::Vector<casacore::Double> &array,
855 : // casacore::Vector<casacore::Double> &all, casacore::Bool resize = false) const;
856 : template<class T>
857 : void swapyz(casacore::Cube<T>& out, const casacore::Cube<T>& in) const;
858 :
859 : VisibilityIteratorReadImpl * readImpl_p;
860 : };
861 :
862 :
863 : // <summary>
864 : // VisibilityIterator iterates through one or more writable MeasurementSets
865 : // </summary>
866 : // <use visibility=export>
867 : // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
868 : // </reviewed>
869 : // <prerequisite>
870 : // <li> <linkto class="ROVisibilityIterator">ROVisibilityIterator</linkto>
871 : // </prerequisite>
872 : //
873 : // <etymology>
874 : // The VisibilityIterator is a read/write iterator returning visibilities
875 : // </etymology>
876 : //
877 : // <synopsis>
878 : // VisibilityIterator provides iteration with various sort orders
879 : // for one or more MSs. It has member functions to retrieve the fields
880 : // commonly needed in synthesis calibration and imaging. It is
881 : // derived from the read-only iterator
882 : // <linkto class="ROVisibilityIterator">ROVisibilityIterator</linkto>.
883 : //
884 : // One should use <linkto class="VisBuffer">VisBuffer</linkto>
885 : // to access chunks of data.
886 : //
887 : // As with an ROVI, a VI can be created to only utilize synchronous I/O
888 : // (the "normal" way) or it can potentially use asynchronous I/O. To create
889 : // an asynchronous instance of VI requires using an appropriate constructor
890 : // (i.e., one that has PrefetchColumns * as its first argument) and setting
891 : // the CASARC setting "VisibilityIterator.async.disabled: false".
892 : //
893 : // When a write operation is performed using the various setX methods of an
894 : // asynchronous instance of this class, the data is shipped over to the VLAT
895 : // which writes out when it is not in the middle of performing a read ahead
896 : // of a VisBuffer.
897 : //
898 : // </synopsis>
899 : //
900 : // <example>
901 : // <code>
902 : // //
903 : // </code>
904 : // </example>
905 : //
906 : // <motivation>
907 : // For imaging and calibration you need to access an casacore::MS in some consistent
908 : // order (by field, spectralwindow, time interval etc.). This class provides
909 : // that access.
910 : // </motivation>
911 : //
912 : // #<thrown>
913 : //
914 : // #</thrown>
915 : //
916 : // <todo asof="1997/05/30">
917 : // <li> cleanup the currently dual interface for visibilities and flags
918 : // <li> sort out what to do with weights when interpolating
919 : // </todo>
920 : class VisibilityIterator : public ROVisibilityIterator
921 : {
922 :
923 : friend class VisibilityIteratorWriteImpl;
924 :
925 : public:
926 : // Constructors.
927 : // Note: The VisibilityIterator is not initialized correctly by default, you
928 : // need to call origin() before using it to iterate.
929 : VisibilityIterator();
930 : VisibilityIterator(casacore::MeasurementSet & ms, const casacore::Block<casacore::Int>& sortColumns,
931 : casacore::Double timeInterval=0);
932 : VisibilityIterator(casacore::MeasurementSet & ms, const casacore::Block<casacore::Int>& sortColumns,
933 : const casacore::Bool addDefaultSortCols,
934 : casacore::Double timeInterval=0);
935 : // Same as previous constructor, but with multiple MSs to iterate over.
936 : VisibilityIterator(const casacore::Block<casacore::MeasurementSet>& mss,
937 : const casacore::Block<casacore::Int>& sortColumns,
938 : casacore::Double timeInterval=0);
939 : VisibilityIterator(const casacore::Block<casacore::MeasurementSet>& mss,
940 : const casacore::Block<casacore::Int>& sortColumns, const casacore::Bool addDefaultSortCols,
941 : casacore::Double timeInterval=0);
942 : VisibilityIterator (const asyncio::PrefetchColumns * prefetchColumns,
943 : const casacore::Block<casacore::MeasurementSet>& mss,
944 : const casacore::Block<casacore::Int>& sortColumns,
945 : const casacore::Bool addDefaultSortCols = true,
946 : casacore::Double timeInterval = 0);
947 : VisibilityIterator (const asyncio::PrefetchColumns * prefetchColumns,
948 : casacore::MeasurementSet & mss,
949 : const casacore::Block<casacore::Int>& sortColumns,
950 : const casacore::Bool addDefaultSortCols = true,
951 : casacore::Double timeInterval = 0);
952 : VisibilityIterator(const VisibilityIterator & MSI);
953 : VisibilityIterator(const asyncio::PrefetchColumns * prefetchColumns, const VisibilityIterator & other);
954 :
955 :
956 : virtual ~VisibilityIterator();
957 :
958 : VisibilityIterator & operator=(const VisibilityIterator &MSI);
959 :
960 :
961 : // Members
962 :
963 : casacore::Bool isWritable () const;
964 :
965 : // Advance iterator through data
966 : VisibilityIterator & operator++(int);
967 : VisibilityIterator & operator++();
968 : // Set/modify the flags in the data.
969 : // This will flag all channels in the original data that contributed to
970 : // the output channel in the case of channel averaging.
971 : // All polarizations have the same flag value.
972 : void setFlag(const casacore::Matrix<casacore::Bool>& flag);
973 : // Set/modify the flags in the data.
974 : // This sets the flags as found in the casacore::MS, casacore::Cube(npol,nchan,nrow),
975 : // where nrow is the number of rows in the current iteration (given by
976 : // nRow()).
977 : virtual void setFlag(const casacore::Cube<casacore::Bool>& flag);
978 : // Set/modify the flag row column; dimension casacore::Vector(nrow)
979 : virtual void setFlagRow(const casacore::Vector<casacore::Bool>& rowflags);
980 :
981 : void setFlagCategory(const casacore::Array<casacore::Bool>& fc);
982 :
983 : // Set/modify the visibilities.
984 : // This is possibly only for a 'reference' casacore::MS which has a new DATA column.
985 : // The first axis of the matrix should equal the selected number of channels
986 : // in the original MS.
987 : // If the casacore::MS does not contain all polarizations, only the parallel
988 : // hand polarizations are used.
989 : void setVis(const casacore::Matrix<CStokesVector>& vis, DataColumn whichOne);
990 : // Set/modify the visibilities
991 : // This sets the data as found in the casacore::MS, casacore::Cube(npol,nchan,nrow).
992 : virtual void setVis(const casacore::Cube<casacore::Complex>& vis, DataColumn whichOne);
993 : // Set the visibility and flags, and interpolate from velocities if needed
994 : virtual void setVisAndFlag(const casacore::Cube<casacore::Complex>& vis, const casacore::Cube<casacore::Bool>& flag,
995 : DataColumn whichOne);
996 : // Set/modify the weights
997 : void setWeight(const casacore::Vector<casacore::Float>& wt);
998 : // Set/modify the weightMat
999 : virtual void setWeightMat(const casacore::Matrix<casacore::Float>& wtmat);
1000 : // Set/modify the weightSpectrum
1001 : virtual void setWeightSpectrum(const casacore::Cube<casacore::Float>& wtsp);
1002 : // Set/modify the Sigma
1003 : void setSigma(const casacore::Vector<casacore::Float>& sig);
1004 : // Set/modify the ncorr x nrow SigmaMat.
1005 : void setSigmaMat(const casacore::Matrix<casacore::Float>& sigmat);
1006 :
1007 : //This puts a model into the descriptor of the current ms in the iterator
1008 : //Set iscomponentlist to true if the record represent a componentlist
1009 : //if false then it is a FTMachine casacore::Record that holds the model image
1010 : //note the spw and fields selected are going to be associated with this model
1011 : //incremetal =true implies add the model to previous any existant model
1012 : //in the ms for the spw and fields
1013 : //false means any existant model will be replaces.
1014 : void putModel(const casacore::RecordInterface& rec, casacore::Bool iscomponentlist=true, casacore::Bool incremental=false);
1015 :
1016 :
1017 : void writeBack (VisBuffer *);
1018 :
1019 : protected:
1020 :
1021 : virtual void attachColumns(const casacore::Table &t);
1022 :
1023 : void construct ();
1024 :
1025 :
1026 : VisibilityIteratorWriteImpl * getWriteImpl() const;
1027 :
1028 : void initializeBackWriters ();
1029 :
1030 : VisibilityIteratorWriteImpl * writeImpl_p;
1031 : };
1032 :
1033 : } //# NAMESPACE CASA - END
1034 :
1035 : #ifndef AIPS_NO_TEMPLATE_SRC
1036 : #include <msvis/MSVis/VisibilityIterator.tcc>
1037 : #endif //# AIPS_NO_TEMPLATE_SRC
1038 :
1039 : #endif
|