00001 //# VisibilityIterator.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: VisibilityIterator.h,v 19.14 2006/02/28 04:48:58 mvoronko Exp $ 00027 00028 #ifndef MSVIS_VISIBILITYITERATOR2_H 00029 #define MSVIS_VISIBILITYITERATOR2_H 00030 00031 #include <casa/aips.h> 00032 00033 #include <ms/MeasurementSets/MSIter.h> 00034 #include <ms/MeasurementSets/MeasurementSet.h> 00035 #include <msvis/MSVis/VisBuffer2.h> 00036 #include <msvis/MSVis/VisBufferComponents2.h> 00037 #include <msvis/MSVis/ViiLayerFactory.h> 00038 00039 #include <map> 00040 #include <set> 00041 #include <utility> 00042 #include <vector> 00043 00044 namespace casa { //# NAMESPACE CASA - BEGIN 00045 00046 //# forward decl 00047 00048 //class CStokesVector; 00049 class MDirection; 00050 class MSDerivedValues; 00051 class MSIter; 00052 class RecordInterface; 00053 class ROMSAntennaColumns; 00054 class ROMSDataDescColumns; 00055 class ROMSFeedColumns; 00056 class ROMSFieldColumns; 00057 class ROMSFlagCmdColumns; 00058 class ROMSHistoryColumns; 00059 class ROMSObservationColumns; 00060 class ROMSPointingColumns; 00061 class ROMSPolarizationColumns; 00062 class ROMSProcessorColumns; 00063 class ROMSSpWindowColumns; 00064 class ROMSStateColumns; 00065 class ROMSDopplerColumns; 00066 class ROMSFreqOffsetColumns; 00067 class ROMSSourceColumns; 00068 class ROMSSysCalColumns; 00069 class ROMSWeatherColumns; 00070 template <typename T, Int N> class RigidVector; 00071 template <typename T, Int N> class SquareMatrix; 00072 class VisBufferType; 00073 class VisBufferOptions; 00074 class VisImagingWeight; 00075 00076 namespace asyncio { 00077 00078 class VLAT; 00079 00080 } // end namespace asyncio 00081 00082 // Forward declarations outside namespace vi 00083 class MSTransformIteratorFactory; 00084 00085 namespace vi { 00086 00087 class FrequencySelection; 00088 class FrequencySelections; 00089 class VisBuffer2; 00090 class VisBufferComponents2; 00091 class VisBufferImpl2; 00092 class ViImplementation2; 00093 00094 class SubtableColumns { 00095 00096 public: 00097 00098 // Simple wrapper class to limit access to only the columns associated with the 00099 // current MS's subtables. This prevents misuse of the main table data columns 00100 // which are provided as part of the MSColumns object returned by 00101 // MSIter::msColumns. 00102 00103 SubtableColumns (CountedPtr <MSIter> msIter); 00104 00105 const ROMSAntennaColumns& antenna() const; 00106 const ROMSDataDescColumns& dataDescription() const; 00107 const ROMSFeedColumns& feed() const; 00108 const ROMSFieldColumns& field() const; 00109 const ROMSFlagCmdColumns& flagCmd() const; 00110 const ROMSHistoryColumns& history() const; 00111 const ROMSObservationColumns& observation() const; 00112 const ROMSPointingColumns& pointing() const; 00113 const ROMSPolarizationColumns& polarization() const; 00114 const ROMSProcessorColumns& processor() const; 00115 const ROMSSpWindowColumns& spectralWindow() const; 00116 const ROMSStateColumns& state() const; 00117 const ROMSDopplerColumns& doppler() const; 00118 const ROMSFreqOffsetColumns& freqOffset() const; 00119 const ROMSSourceColumns& source() const; 00120 const ROMSSysCalColumns& sysCal() const; 00121 const ROMSWeatherColumns& weather() const; 00122 00123 private: 00124 00125 CountedPtr <MSIter> msIter_p; 00126 }; 00127 00129 // 00130 // Subchunk class 00131 // 00132 // Provides the ordered pair identifying the current subchunk. The first 00133 // component is the chunk (goes from 0 to nChunks-1 during the outer loop 00134 // iteration). The second component is the subchunk number which is 00135 // zero after VisibilityIterator::origin is called and is increment 00136 // until ROVI::more returns False. 00137 00138 class Subchunk : public std::pair<Int, Int>{ 00139 00140 public: 00141 00142 // First component is Chunk and second is Subchunk 00143 00144 Subchunk () { resetToOrigin ();} 00145 Subchunk (Int a , Int b) : std::pair<Int,Int> (a,b) {} 00146 00147 Bool operator== (const Subchunk & other){ 00148 return first == other.first && second == other.second; 00149 } 00150 00151 Bool operator< (const Subchunk & other){ 00152 return first < other.first || 00153 (first == other.first && second < other.second); 00154 } 00155 00156 Bool atOrigin () const { return * this == Subchunk ();} 00157 Int chunk () const { return first;} 00158 void incrementSubChunk () { second ++;} 00159 void incrementChunk () { first ++; second = 0; } 00160 00161 void resetSubChunk () { second = 0;} // position to start of chunk 00162 00163 void resetToOrigin () { first = 0; second = 0; } 00164 // Make a subchunk pair that is positioned to the first subchunk of the 00165 // first chunk (i.e., 0,0) 00166 00167 Int subchunk () const { return second;} 00168 String toString () const; 00169 00170 static Subchunk noMoreData (); 00171 00172 private: 00173 00174 }; 00175 00176 00177 00179 // 00180 // Code to provide interface to weight function 00181 // 00182 // WeightScaling is essentially the interface to the function 00183 // used for weight scaling while WeightScalingImpl is the class 00184 // to actually use to create WeightScaling functors. The use of 00185 // a templated implementation allows the wrapping of both functors 00186 // and functions while the base class allows polymorphic storage. 00187 00188 class WeightScaling { 00189 public: 00190 00191 virtual ~WeightScaling () {} 00192 Float operator() (Float x) { return apply (x);} 00193 00194 static CountedPtr<WeightScaling> generateUnityWeightScaling (); 00195 static CountedPtr<WeightScaling> generateIdentityWeightScaling (); 00196 static CountedPtr<WeightScaling> generateSquareWeightScaling (); 00197 00198 protected: 00199 00200 virtual Float apply (Float) = 0; 00201 static Float unity (Float); 00202 static Float identity (Float x); 00203 static Float square (Float x); 00204 }; 00205 00206 template<typename F> 00207 class WeightScalingImpl : public WeightScaling { 00208 public: 00209 00210 // Provide either a unary function, Float (*) (Float), or 00211 // a functor class having a Float operator() (Float) method. 00212 00213 WeightScalingImpl (F f) : function_p (f) {} 00214 00215 Float apply (Float f) { return function_p (f);} 00216 00217 private: 00218 00219 F function_p; 00220 }; 00221 00222 00223 template<typename F> 00224 CountedPtr <WeightScaling> generateWeightScaling (F f) { return new WeightScalingImpl<F> (f);} 00225 00226 class SortColumns { 00227 public: 00228 00229 explicit SortColumns (const Block<Int> & columnIds = Block<Int> (), Bool addDefaultColumns = True); 00230 00231 Bool shouldAddDefaultColumns () const; 00232 const Block<Int> & getColumnIds () const; 00233 00234 private: 00235 00236 Bool addDefaultColumns_p; 00237 Block<Int> columnIds_p; 00238 }; 00239 00240 class VisibilityIterator2; 00241 00243 // 00244 // Class ViFactory 00245 // 00246 // The ViFactory is a class that can be used to initialize the implementation of 00247 // a VisibilityIterator2. It is passed into VI2's constructor where it creates 00248 // the needed ViImplementation object used by the VI2. The first example of this 00249 // factory is the AveragingVi2Factory which is used to create a VI2 which will 00250 // return time-averaged data. 00251 00252 class ViFactory { 00253 00254 public: 00255 00256 virtual ~ViFactory () {} 00257 00258 protected: 00259 00260 friend class VisibilityIterator2; 00261 00262 virtual ViImplementation2 * createVi () const = 0; 00263 }; 00264 00265 // <summary> 00266 // VisibilityIterator2 iterates through one or more readonly MeasurementSets 00267 // </summary> 00268 // <use visibility=export> 00269 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos=""> 00270 // </reviewed> 00271 // <prerequisite> 00272 // <li> <linkto class="MSIter">MSIter</linkto> 00273 // <li> <linkto class="MeasurementSet">MeasurementSet</linkto> 00274 // <li> <linkto class="VisSet">VisSet</linkto> 00275 // <li> <linkto class="PrefetchColumns">PrefetchColumns</linkto> 00276 // </prerequisite> 00277 // 00278 // <etymology> 00279 // The VisibilityIterator2 is a readonly iterator returning visibilities 00280 // </etymology> 00281 // 00282 // <synopsis> 00283 // VisibilityIterator2 provides iteration with various sort orders 00284 // for one or more MSs. It has member functions to retrieve the fields 00285 // commonly needed in synthesis calibration and imaging. 00286 // 00287 // One should use <linkto class="VisBuffer">VisBuffer</linkto> 00288 // to access chunks of data. 00289 // 00290 // VisibilityIterator2s can be either synchronous or asynchronous, depending 00291 // on the constructor used to create them as well as the current value of 00292 // a CASARC file setting. A synchronous instance is works the same as 00293 // this class ever worked; an asynchronous instance uses a second thread 00294 // (the Visibility Lookahead Thread or VLAT) to fill the VisBuffers in 00295 // advance of their use by the original thread. 00296 // 00297 // To create an asynchronous instance of ROVI you must use one of the two 00298 // constructors which have a pointer to a PrefetchColumns object as the 00299 // first argument. This object specifies which VisBuffer components should be 00300 // prefetched by the VLAT; accessing components not specified in the PrefetchColumns 00301 // object will result in an exception containing an error message indicating 00302 // that the VisBuffer does not contain the requested column. In addition 00303 // to using the appropriate constructor, the CASARC file setting 00304 // VisibilityIterator2.async.enabled can be used to turn asynchronous I/O 00305 // off globally; if it's globally enabled then it is still possible for the 00306 // user to choose to enable/disable it on a VI by VI basis. 00307 // 00308 // +-------------------+ 00309 // | | 00310 // | *** Nota Bene *** | 00311 // | | 00312 // +-------------------+ 00313 // 00314 // Because of the multithreaded nature of asynchronous I/O, the user 00315 // needs to be a bit more careful in the use of the VI and it's attached VisBuffer. 00316 // Data access operations need to be directed to the VisBuffer. Additionally 00317 // the user must not attempt to access the data using a separate VI since 00318 // the underlying casacore objects are not threadsafe and bizarre errors 00319 // will likely occur. 00320 // 00321 // CASARC Settings 00322 // =============== 00323 // 00324 // Normal settings 00325 // --------------- 00326 // 00327 // VisibilityIterator2.async.enabled - Boolean value that enables or disables 00328 // async I/O. The default value is currently False (i.e., disabled). 00329 // VisibilityIterator2.async.nBuffers - The number of lookahead buffers. This 00330 // defaults to 2. 00331 // 00332 // 00333 // Debug settings 00334 // -------------- 00335 // 00336 // VisibilityIterator2.async.doStats: true 00337 // VisibilityIterator2.async.debug.logFile: stderr 00338 // VisibilityIterator2.async.debug.logLevel: 1 00339 // 00340 00341 // </synopsis> 00342 // 00343 // <example> 00344 // <code> 00345 // // 00346 // </code> 00347 // </example> 00348 // 00349 // <motivation> 00350 // For imaging and calibration you need to access an MS in some consistent 00351 // order (by field, spectralwindow, time interval etc.). This class provides 00352 // that access. 00353 // </motivation> 00354 // 00355 // <thrown> 00356 // <li> 00357 // <li> 00358 // </thrown> 00359 // 00360 // <todo asof="1997/05/30"> 00361 // <li> cleanup the currently dual interface for visibilities and flags 00362 // <li> sort out what to do with weights when interpolating 00363 // </todo> 00364 class VisibilityIterator2 00365 { 00366 // These classes are members of the VI/VB framework and need extra 00367 // access to the non-public methods of this class. Any additions of 00368 // classes not in this framework is strongly discouraged. 00369 // 00370 // Friends of the class should limit themselves to accessing the protected 00371 // area of this class so that items in the private area can remeain de 00372 // facto private. 00373 00374 //friend class VisibilityIteratorImpl2; 00375 // friend VisBuffer2 * VisBuffer2::factory (VisibilityIterator2 * vi, VisBufferType t, 00376 // VisBufferOptions options); 00377 friend class VisBuffer2Adapter; 00378 //friend class VisBufferImpl2; 00379 //friend class VisBufferState; 00380 friend class asyncio::VLAT; // allow VI lookahead thread class to access protected 00381 // functions VLAT should not access private parts, 00382 // especially variables 00383 friend class casa::MSTransformIteratorFactory; 00384 00385 public: 00386 00387 VisibilityIterator2( const VisibilityIterator2& ) = delete; 00388 VisibilityIterator2& operator=( const VisibilityIterator2& ) = delete; 00389 class Factory { // Interface for implementation creation factory 00390 00391 public: 00392 00393 virtual ~Factory () {} 00394 00395 virtual ViImplementation2 * 00396 operator() (const VisBufferComponents2 * /*prefetchColumns*/, 00397 const Block<MeasurementSet>& /*mss*/, 00398 const Block<Int>& /*sortColumns*/, 00399 const Bool /*addDefaultSortCols*/, 00400 Double /*timeInterval*/) const 00401 { 00402 return NULL; 00403 } 00404 }; 00405 00406 typedef enum MSIter::PolFrame PolFrame; 00407 00408 typedef enum DataColumn { 00409 Observed=0, // Observed data 00410 Model, // Model data 00411 Corrected // Corrected data 00412 } DataColumn; 00413 00414 // Construct from an MS and a Block of MS column enums specifying the 00415 // iteration order. These can be specified as MS::ANTENNA1, MS::ARRAY_ID, 00416 // etc.; they are defined in MSMainEnums.h. 00417 // If no order is specified, it uses the default sort 00418 // order of MSIter, which is not necessarily the raw order of ms! 00419 // The default ordering is ARRAY_ID, FIELD_ID, DATA_DESC_ID, 00420 // and TIME, but check MSIter.h to be sure. 00421 // These columns will be added first if they are not specified. 00422 // 00423 // An optional timeInterval (in seconds) can be given to iterate through 00424 // chunks of time. The default interval of 0 groups all times together. 00425 // Every 'chunk' of data contains all data within a certain time interval and 00426 // with identical values of the other iteration columns (e.g. DATA_DESC_ID 00427 // and FIELD_ID). 00428 // 00429 // A set of prefetch columns can be specified for asynchronous I/O use. These 00430 // roughly correspond to the fields accessible from the VisBuffer. Specifying 00431 // prefetch columns will cause an asynchronous VI to be created if asynchronous 00432 // I/O is globally enabled. If the user wishes to have application-specific 00433 // enable/disable of asynchronous I/O then they must implement logic that 00434 // either either provides prefetch columns (enables) or a null pointer (disables). 00435 00436 VisibilityIterator2 (const MeasurementSet& ms, 00437 const SortColumns & sortColumns = SortColumns (), 00438 Bool isWritable = False, 00439 const VisBufferComponents2 * prefetchColumns = 0, 00440 Double timeInterval = 0); 00441 00442 VisibilityIterator2 (const Block<const MeasurementSet *>& mss, 00443 const SortColumns & sortColumns = SortColumns (), 00444 Bool isWritable = False, 00445 const VisBufferComponents2 * prefetchColumns = 0, 00446 Double timeInterval = 0); 00447 00448 VisibilityIterator2 (const ViFactory & factory); 00449 VisibilityIterator2 (const Vector<ViiLayerFactory*> & factories); 00450 00451 // Destructor 00452 00453 virtual ~VisibilityIterator2(); 00454 00455 // Report the the ViImplementation type 00456 String ViiType() const; 00457 00459 // 00460 // BEGIN Experimental Section 00461 // 00462 00463 static VisibilityIterator2 * copyingViFactory (const MeasurementSet & srcMs, 00464 MeasurementSet & dstMs); 00465 00466 template <typename KlugeIn, typename KlugeOut> 00467 static KlugeOut KlugeForTesting (KlugeIn); 00468 00469 // 00470 // END Experimental Section 00471 // 00473 00475 // 00476 // Iteration movement methods 00477 // 00478 // The typical use case for VisibilityIteration looks like 00479 // 00480 // for (vi.originChunks(); vi.moreChunks(); nextChunk()){ 00481 // for (vi.origin (); vi.more(); vi++){ 00482 // } 00483 // } 00484 // 00485 // The outer loop is the "chunk" loop and the inner loop is the "subchunk" 00486 // loop. A chunk contains all the rows having identical values for the 00487 // sort columns values except time; time can have an optional interval 00488 // value specified either in the constructor or via the setInterval 00489 // method. If an interval is specified the set of rows will all have 00490 // timestamps that are within that interval of the first row in the 00491 // chunk; if no interval is specified then the chunk will contain only 00492 // rows having the identical timestamp. If multiple MSs are specified 00493 // in the constructor then changing from one MS to the next will occur 00494 // on a chunk boundary (i.e., a chunk will never contain data from more 00495 // than one MS). 00496 // 00497 // A subchunk typically contains all the rows in the chunk having identical 00498 // timestamps. The only exception is when the user calls setRowBlocking(N) 00499 // with a positive value. In this case, the subchunk *may* contain up to 00500 // N rows; however, this is only a suggestion to the VI. If there are 00501 // less than N rows remaining in the chunk then fewer than N rows will be 00502 // contained in the chunk. The number of rows in a subchunk will also be 00503 // less than N if a larger set of rows would create an inconsistently 00504 // shaped visibility cube; this could happen if the number of channels 00505 // changes from one timestamp to another or the framed frequency 00506 // selection selects a different number of channels from one timestamp to 00507 // the next. 00508 // 00509 // origin () - positions VI to the start of the current chunk 00510 // operator++ - advance VI to next subchunk if it exists 00511 // more - returns True if the VI is pointing to a valid subchunk 00512 // 00513 // originChunks - Move to the first chunk of data. 00514 // operator++ - advance VI to the next chunk if it exists 00515 // moreChunks - returns True if the VI is pointing to a valid chunk. 00516 00517 void origin(); // Reset to start of the chunk 00518 void next (); 00519 Bool more() const; 00520 00521 void originChunks(); 00522 void nextChunk(); 00523 Bool moreChunks() const; 00524 00525 // Returns the pair (chunk,subchunk) for the current position of the VI. Only 00526 // valid after origin has been called. 00527 00528 Subchunk getSubchunkId () const; 00529 00531 // 00532 // Iterator operation methods 00533 // 00534 // These methods alter the way that the VI operates. After applying any of these 00535 // (except slurp which should be called after originChunks) originChunks must be 00536 // called before the VI is advanced again; otherwise an exception will be thrown 00537 // (changing these values in the middle of a sweep can lead to unexpected behavior). 00538 // 00539 // Selecting ranges of frequencies involves initializing a 00540 // FrequencySelection(s) object and providing it to the VI. Once 00541 // properly applied the VI will only return data for the selected 00542 // frequencies. No interpolation is performed; the data returned is 00543 // simply the channels that currently map to the selected frequencies for 00544 // the specified frame of reference. 00545 00546 void setFrequencySelection (const FrequencySelection &); // for single MS 00547 void setFrequencySelection (const FrequencySelections &); // when using multiple MSs 00548 00549 // RowBlocking is a suggestion to the iterator that it try to use subchunks 00550 // having the suggested number of rows. The VI will attempt to honor the 00551 // suggestion except when there are not enough rows remaining in the chunk 00552 // or when putting the suggested number of rows in the subchunk cannot 00553 // be contained in a cube (e.g., there are sets of row with different 00554 // numbers of frequencies, etc.). The latter case will mainly occur 00555 // when the row visibility shape changes from one row to the next. 00556 00557 Int getRowBlocking() const; 00558 void setRowBlocking(Int nRows=0); 00559 00560 // In this context the interval determines what rows will be contained 00561 // in a chunk. A chunk is all the rows in an MS that have the same values 00562 // in the sort columns, except for time; all rows that otherwise have the 00563 // same values for the sort columns will be in the chunk if they are no 00564 // later than "interval" seconds after the first row in the chunk. 00565 // 00566 // *** This value is unrelated to the interval field of the MS main table. 00567 00568 Double getInterval() const; 00569 void setInterval(Double timeInterval); 00570 00571 // Call to use the slurp i/o method for all scalar columns. This 00572 // will set the BucketCache cache size to the full column length 00573 // and cause the full column to be cached in memory, if 00574 // any value of the column is used. In case of out-of-memory, 00575 // it will automatically fall-back on the smaller cache size. 00576 // Slurping the column is to be considered as a work-around for the 00577 // Table i/o code, which uses BucketCache and performs extremely bad 00578 // for random access. Slurping is useful when iterating non-sequentially 00579 // an MS or parts of an MS, it is not tested with multiple MSs. 00580 00581 void slurp() const; 00582 00584 // 00585 // Other methods 00586 // 00587 00588 // Returns True if this is an asynchronous VI 00589 00590 Bool isAsynchronous () const; 00591 00592 // Returns True if async I/O is globally enabled. 00593 00594 static Bool isAsynchronousIoEnabled(); 00595 00596 // Returns True if this VI is writable (always False for ROVI and 00597 // True for VI; see VisibilityIterator class). 00598 00599 Bool isWritable () const; 00600 00601 // Returns the columns that the VisibilityIterator2 is sorting by. These are 00602 // defined in MSMainEnums.h. These can be specified as MS::ANTENNA1, 00603 // MS::ARRAY_ID, etc. 00604 00605 const SortColumns & getSortColumns() const; 00606 00607 // Returns true if the specified column exists. 00608 00609 bool existsColumn (VisBufferComponent2 id) const; 00610 00611 // Returns the VisBuffer permanently attached to this VisibilityIterator. 00612 00613 VisBuffer2 * getVisBuffer (); 00614 00615 // Manages the weight function that can be used to process the weights 00616 // produced by the "scaled" variants of the weight accessors. Use 00617 // generateWeightscaling to create a WeightScaling object. This allow you 00618 // to use either a function (FLoat (Float)) or a functor (object having 00619 // method Float operator () (Float)). 00620 // 00621 // To revert to having no scaling function, call setWeightScaling with 00622 // 0 as the argument. Any call to setWeightScaling needs to be followed 00623 // by an originChunks call before any further data access is performed 00624 // using the VI. 00625 // 00626 // The method hasWeightScaling will return false if either no weightScaling 00627 // object has installed or setWeightScaling (0) was called. There is not 00628 // way for VI to know if the user has passed in the identity function; 00629 // doing so will still cause hasWeightScaling to return true. 00630 00631 virtual void setWeightScaling (CountedPtr<WeightScaling> weightscaling); 00632 virtual Bool hasWeightScaling () const; 00633 00634 // Return number of spws, polids, ddids for the current MS 00635 00636 Int nSpectralWindows () const; 00637 Int nPolarizationIds () const; // number of different polarization configurations 00638 // (i.e., length of polarization subtable) 00639 Int nDataDescriptionIds () const; 00640 00641 // Determine whether WEIGHT_SPECTRUM exists. 00642 00643 Bool weightSpectrumExists() const; 00644 00645 // Determine whether WEIGHT_SPECTRUM exists. 00646 00647 Bool sigmaSpectrumExists() const; 00648 00649 //reference to actual ms in interator 00650 00651 const MeasurementSet& ms() const /*__attribute__((deprecated))*/; 00652 00653 const vi::SubtableColumns & subtableColumns () const /*__attribute__((deprecated))*/; 00654 00655 static String getAipsRcBase () { return "VisibilityIterator2";} 00656 00657 // The reporting frame of reference is the default frame of reference to be 00658 // used when the user requests the frequencies of the current data selection 00659 // in a VisBuffer. This is useful when the user wishes to select the data 00660 // using one frame of reference but use the frequencies from another frame 00661 // of reference. If not specified then the default will be to use the 00662 // frame of reference used to select the data. 00663 // 00664 // These *do not* change the selection in any way. 00665 00666 Int getReportingFrameOfReference () const; 00667 void setReportingFrameOfReference (Int); 00668 00669 // Return the numbers of rows in the current chunk 00670 00671 Int nRowsInChunk() const; 00672 00673 // Assign a VisImagingWeight object to this iterator. This object is used 00674 // to generate imaging weights. 00675 00676 void useImagingWeight(const VisImagingWeight& imWgt); 00677 const VisImagingWeight & getImagingWeightGenerator () const; 00678 00679 // Write/modify the flags in the data. 00680 // This will flag all channels in the original data that contributed to 00681 // the output channel in the case of channel averaging. 00682 // All polarizations have the same flag value. 00683 00684 // Write/modify the flags in the data. 00685 // This writes the flags as found in the MS, Cube(npol,nchan,nrow), 00686 // where nrow is the number of rows in the current iteration (given by 00687 // nRow()). 00688 00689 virtual void writeFlag(const Cube<Bool>& flag); 00690 00691 // Write/modify the flag row column; dimension Vector(nrow) 00692 00693 virtual void writeFlagRow(const Vector<Bool>& rowflags); 00694 00695 void writeFlagCategory(const Array<Bool>& fc); 00696 00697 // Write/modify the visibilities. 00698 // This is possibly only for a 'reference' MS which has a new DATA column. 00699 // The first axis of the matrix should equal the selected number of channels 00700 // in the original MS. 00701 // If the MS does not contain all polarizations, only the parallel 00702 // hand polarizations are used. 00703 00704 // void writeVisCorrected (const Matrix<CStokesVector>& vis); 00705 // void writeVisModel (const Matrix<CStokesVector>& vis); 00706 // void writeVisObserved (const Matrix<CStokesVector>& vis); 00707 00708 // Write/modify the visibilities 00709 // This writes the data as found in the MS, Cube(npol,nchan,nrow). 00710 00711 void writeVisCorrected (const Cube <Complex> & vis); 00712 void writeVisModel (const Cube <Complex> & vis); 00713 void writeVisObserved (const Cube <Complex> & vis); 00714 00715 // Write/modify the weights 00716 00717 void writeWeight(const Matrix<Float>& wt); 00718 00719 // Write/modify the weightMat 00720 00721 //virtual void writeWeightMat(const Matrix<Float>& wtmat); 00722 00723 // Write/modify the weightSpectrum 00724 00725 virtual void writeWeightSpectrum(const Cube<Float>& wtsp); 00726 00727 00728 // Initialize the weightSpectrum 00729 virtual void initWeightSpectrum(const Cube<Float>& wtsp); 00730 00731 // Write/modify the Sigma 00732 00733 void writeSigma(const Matrix<Float>& sig); 00734 00735 // Write/modify the ncorr x nrow SigmaMat. 00736 00737 //void writeSigmaMat(const Matrix<Float>& sigmat); 00738 00739 // This puts a model into the descriptor of the current ms in the iterator 00740 // Set iscomponentlist to True if the record represent a componentlist 00741 // if False then it is a FTMachine Record that holds the model image 00742 // note the spw and fields selected are going to be associated with this model 00743 // incremetal =True implies add the model to previous any existant model 00744 // in the ms for the spw and fields 00745 // false means any existant model will be replaces. 00746 00747 void writeModel(const RecordInterface& rec, Bool iscomponentlist=True, 00748 Bool incremental=False); 00749 00750 // Requests that the modified VisBuffer2 be written back to the visibility 00751 // at the same spot that it came from. The dirtyComponents feature of 00752 // VisBuffer is used to mark which portions of the VisBuffer actually need 00753 // to be written back out. 00754 00755 void writeBackChanges (VisBuffer2 *); 00756 00757 //********************************************************************** 00758 // Internal methods below this line 00759 //********************************************************************** 00760 00761 ViImplementation2 * getImpl() const; 00762 00763 protected: 00764 00765 00766 VisibilityIterator2(); 00767 00768 void construct (const VisBufferComponents2 * prefetchColumns, 00769 const Block<const MeasurementSet *>& mss, 00770 const SortColumns & sortColumns, 00771 Double timeInterval, 00772 Bool writable); 00773 00774 // advance the iteration 00775 00776 void originChunks(Bool forceRewind); 00777 00778 00779 private: 00780 00781 ViImplementation2 * impl_p; 00782 }; 00783 00784 } // end namespace vi 00785 00786 } //# NAMESPACE CASA - END 00787 00788 #endif