casa
$Rev:20696$
|
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_VISIBILITYITERATORIMPL_H 00029 #define MSVIS_VISIBILITYITERATORIMPL_H 00030 00031 #include <casa/aips.h> 00032 #include <casa/Arrays/Matrix.h> 00033 #include <casa/Arrays/Cube.h> 00034 #include <casa/Arrays/Slicer.h> 00035 #include <casa/Containers/Stack.h> 00036 #include <ms/MeasurementSets/MeasurementSet.h> 00037 #include <measures/Measures/Stokes.h> 00038 #include <measures/Measures/MeasConvert.h> 00039 #include <casa/Quanta/MVDoppler.h> 00040 #include <measures/Measures/MCDoppler.h> 00041 #include <measures/Measures/MDoppler.h> 00042 #include <tables/Tables/ArrayColumn.h> 00043 #include <tables/Tables/ScalarColumn.h> 00044 #include <casa/BasicSL/String.h> 00045 #include <scimath/Mathematics/SquareMatrix.h> 00046 #include <scimath/Mathematics/RigidVector.h> 00047 00048 #include <ms/MeasurementSets/MSDerivedValues.h> 00049 #include <synthesis/MSVis/StokesVector.h> 00050 #include <synthesis/MSVis/VisImagingWeight.h> 00051 #include <synthesis/MSVis/VisibilityIterator.h> 00052 #include <synthesis/MSVis/VisBufferComponents.h> 00053 #include <ms/MeasurementSets/MSIter.h> 00054 00055 #include <map> 00056 #include <vector> 00057 00058 namespace casa { //# NAMESPACE CASA - BEGIN 00059 00060 //# forward decl 00061 class VisBuffer; 00062 00063 00064 00065 // <summary> 00066 // ROVisibilityIterator iterates through one or more readonly MeasurementSets 00067 // </summary> 00068 00069 // <use visibility=export> 00070 00071 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos=""> 00072 // </reviewed> 00073 00074 // <prerequisite> 00075 // <li> <linkto class="MSIter">MSIter</linkto> 00076 // <li> <linkto class="MeasurementSet">MeasurementSet</linkto> 00077 // <li> <linkto class="VisSet">VisSet</linkto> 00078 // </prerequisite> 00079 // 00080 // <etymology> 00081 // The ROVisibilityIterator is a readonly iterator returning visibilities 00082 // </etymology> 00083 // 00084 // <synopsis> 00085 // ROVisibilityIterator provides iteration with various sort orders 00086 // for one or more MSs. It has member functions to retrieve the fields 00087 // commonly needed in synthesis calibration and imaging. 00088 // 00089 // One should use <linkto class="VisBuffer">VisBuffer</linkto> 00090 // to access chunks of data. 00091 // </synopsis> 00092 // 00093 // <example> 00094 // <code> 00095 // // 00096 // </code> 00097 // </example> 00098 // 00099 // <motivation> 00100 // For imaging and calibration you need to access an MS in some consistent 00101 // order (by field, spectralwindow, time interval etc.). This class provides 00102 // that access. 00103 // </motivation> 00104 // 00105 // <thrown> 00106 // <li> 00107 // <li> 00108 // </thrown> 00109 // 00110 // <todo asof="1997/05/30"> 00111 // <li> cleanup the currently dual interface for visibilities and flags 00112 // <li> sort out what to do with weights when interpolating 00113 // </todo> 00114 00115 class VisibilityIteratorReadImpl { 00116 00117 friend class AsyncEnabler; 00118 friend class ViReadImplAsync; 00119 friend class VisibilityIteratorWriteImpl; 00120 friend class ROVisibilityIterator; 00121 friend class ROVisIterator; 00122 friend class VisIterator; 00123 friend class VLAT; // allow VI lookahead thread class to access protected functions 00124 // VLAT should not access private parts, especially variables 00125 00126 public: 00127 00128 //# the following is a copy of the enum in MSIter 00129 //# can't think of a way to get one that known to the outside world from here 00130 // enum PolFrame { 00131 // // Circular polarization 00132 // Circular=0, 00133 // // Linear polarization 00134 // Linear=1 00135 // }; 00136 // 00137 // enum DataColumn { 00138 // // Observed data 00139 // Observed=0, 00140 // // Model data 00141 // Model, 00142 // // Corrected data 00143 // Corrected 00144 // }; 00145 00146 typedef ROVisibilityIterator::DataColumn DataColumn; 00147 00148 // class AsyncEnabler { 00149 // public: 00150 // AsyncEnabler (ROVisibilityIterator &); 00151 // AsyncEnabler (ROVisibilityIterator *); 00152 // ~AsyncEnabler (); 00153 // 00154 // void release (); 00155 // 00156 // private: 00157 // 00158 // Bool oldEnabledState_p; 00159 // ROVisibilityIterator * roVisibilityIterator_p; 00160 // }; 00161 00162 // Default constructor - useful only to assign another iterator later 00163 VisibilityIteratorReadImpl (); 00164 00165 // Construct from an MS and a Block of MS column enums specifying the 00166 // iteration order. If no order is specified, it uses the default sort 00167 // order of MSIter, which is not necessarily the raw order of ms! 00168 // The default ordering is ARRAY_ID, FIELD_ID, DATA_DESC_ID, 00169 // and TIME, but check MSIter.h to be sure. 00170 // These columns will be added first if they are not specified. 00171 // 00172 // An optional timeInterval (in seconds) can be given to iterate through 00173 // chunks of time. The default interval of 0 groups all times together. 00174 // Every 'chunk' of data contains all data within a certain time interval and 00175 // with identical values of the other iteration columns (e.g. DATA_DESC_ID 00176 // and FIELD_ID). Using selectChannel (), a number of groups of channels can 00177 // be requested. At present the channel group iteration will always occur 00178 // before the interval iteration. 00179 // VisibilityIteratorReadImpl (const MeasurementSet & ms, 00180 // const Block<Int> & sortColumns, 00181 // Double timeInterval = 0); 00182 00183 // Same as above, but with the option of using the raw order of ms 00184 // (addDefaultSortCols=false). 00185 // VisibilityIteratorReadImpl (const MeasurementSet & ms, 00186 // const Block<Int> & sortColumns, const Bool addDefaultSortCols, 00187 // Double timeInterval = 0); 00188 00189 // Same as previous constructors, but with multiple MSs to iterate over. 00190 // VisibilityIteratorReadImpl (const Block<MeasurementSet> & mss, 00191 // const Block<Int> & sortColumns, 00192 // Double timeInterval = 0); 00193 00194 VisibilityIteratorReadImpl (ROVisibilityIterator * rovi, 00195 const Block<MeasurementSet> & mss, 00196 const Block<Int> & sortColumns, 00197 const Bool addDefaultSortCols, 00198 Double timeInterval); 00199 00200 // Copy construct. This calls the assigment operator. 00201 VisibilityIteratorReadImpl (const VisibilityIteratorReadImpl & other, 00202 ROVisibilityIterator * rovi); 00203 00204 // Assigment. Any attached VisBuffers are lost in the assign. 00205 VisibilityIteratorReadImpl & operator= (const VisibilityIteratorReadImpl & other); 00206 00207 // Destructor 00208 virtual ~VisibilityIteratorReadImpl (); 00209 00210 virtual VisibilityIteratorReadImpl * clone (ROVisibilityIterator * rovi) const; 00211 00212 // Members 00213 00214 Bool isAsyncEnabled () const; 00215 00216 virtual Bool isWritable () const { 00217 return False; 00218 } 00219 00220 // Reset iterator to origin/start of data (of current chunk) 00221 virtual void origin (); 00222 // Reset iterator to true start of data (first chunk) 00223 virtual void originChunks (); 00224 00225 // Return the time interval (in seconds) used for iteration. 00226 // This is not the same as the INTERVAL column. 00227 virtual Double getInterval() const { return timeInterval_p; } 00228 00229 // Set or reset the time interval (in seconds) to use for iteration. 00230 // You should call originChunks () to reset the iteration after 00231 // calling this. 00232 virtual void setInterval (Double timeInterval) { 00233 msIter_p.setInterval (timeInterval); 00234 timeInterval_p = timeInterval; 00235 } 00236 00237 // Set the 'blocking' size for returning data. 00238 // With the default (0) only a single integration is returned at a time, this 00239 // is what is currently required for the calibration software. With blocking 00240 // set, up to nRows can be returned in one go. The chunk 00241 // size determines the actual maximum. 00242 virtual void setRowBlocking (Int nRows = 0); 00243 00244 virtual Bool existsColumn (VisBufferComponents::EnumType id) const; 00245 00246 // Return False if no more data (in current chunk) 00247 virtual Bool more () const; 00248 00249 virtual SubChunkPair getSubchunkId () const; 00250 00251 virtual const Block<Int>& getSortColumns() const; 00252 00253 // Return False if no more 'Chunks' of data left 00254 virtual Bool moreChunks () const { 00255 return msIter_p.more (); 00256 } 00257 00258 // Check if ms has change since last iteration 00259 virtual Bool newMS () const { 00260 return msIter_p.newMS (); 00261 } 00262 00263 virtual Int msId () const { 00264 return msIter_p.msId (); 00265 } 00266 00267 virtual VisBuffer * getVisBuffer (); 00268 00269 //reference to actual ms in interator 00270 virtual const MeasurementSet & ms () const { 00271 return msIter_p.ms (); 00272 } 00273 // Advance to the next Chunk of data 00274 virtual VisibilityIteratorReadImpl & nextChunk (); 00275 00276 // Return antenna1 00277 virtual Vector<Int> & antenna1 (Vector<Int> & ant1) const; 00278 00279 // Return antenna2 00280 virtual Vector<Int> & antenna2 (Vector<Int> & ant2) const; 00281 00282 // Return feed1 00283 virtual Vector<Int> & feed1 (Vector<Int> & fd1) const; 00284 00285 // Return feed2 00286 virtual Vector<Int> & feed2 (Vector<Int> & fd2) const; 00287 00288 // Return channel numbers in selected VisSet spectrum 00289 // (i.e. disregarding possible selection on the iterator, but 00290 // including the selection set when creating the VisSet) 00291 virtual Vector<Int> & channel (Vector<Int> & chan) const; 00292 00293 // Return feed configuration matrix for specified antenna 00294 virtual Vector<SquareMatrix<Complex, 2> > & 00295 CJones (Vector<SquareMatrix<Complex, 2> > & cjones) const; 00296 00297 // Return receptor angles for all antennae and feeds 00298 // First axis of the cube is a receptor number, 00299 // 2nd is antennaId, 3rd is feedId 00300 // Note: the method is intended to provide an access to MSIter::receptorAngles 00301 // for VisBuffer in the multi-feed case. It may be worth to change the 00302 // interface of feed_pa to return the information for all feeds. 00303 virtual const Cube<Double> & receptorAngles () const; 00304 00305 // return a string mount identifier for each antenna 00306 virtual const Vector<String> & antennaMounts () const; 00307 00308 // Return a cube containing pairs of coordinate offsets for each 00309 // receptor of each feed (values are in radians, coordinate system is fixed 00310 // with antenna and is the same one as used to define the BEAM_OFFSET 00311 // parameter in the feed table). The cube axes are receptor, antenna, feed. 00312 virtual const Cube<RigidVector<Double, 2> > & getBeamOffsets () const; 00313 00314 // True if all elements of the cube returned by getBeamOffsets are zero 00315 virtual Bool allBeamOffsetsZero () const; 00316 00317 // Return feed parallactic angles Vector (nant) (1 feed/ant) 00318 virtual Vector<Float> feed_pa (Double time) const; 00319 static Vector<Float> feed_paCalculate (Double time, MSDerivedValues & msd, 00320 Int nAntennas, const MEpoch & mEpoch0, 00321 const Vector<Float> & receptor0Angle); 00322 00323 // Return nominal parallactic angle at specified time 00324 // (does not include feed position angle offset--see feed_pa) 00325 // A global value for all antennas (e.g., small array) 00326 virtual const Float & parang0 (Double time) const; 00327 static Float parang0Calculate (Double time, MSDerivedValues & msd, const MEpoch & epoch0); 00328 00329 // Per antenna: 00330 virtual Vector<Float> parang (Double time) const; 00331 static Vector<Float> parangCalculate (Double time, MSDerivedValues & msd, 00332 int nAntennas, const MEpoch mEpoch0); 00333 00334 // Return the antenna AZ/EL Vector (nant) 00335 virtual MDirection azel0 (Double time) const; 00336 static void azel0Calculate (Double time, MSDerivedValues & msd, 00337 MDirection & azel0, const MEpoch & mEpoch0); 00338 00339 virtual Vector<MDirection> azel (Double time) const; 00340 static void azelCalculate (Double time, MSDerivedValues & msd, Vector<MDirection> & azel, 00341 Int nAnt, const MEpoch & mEpoch0); 00342 00343 00344 // Return the hour angle for the specified time 00345 virtual Double hourang (Double time) const; 00346 static Double hourangCalculate (Double time, MSDerivedValues & msd, const MEpoch & mEpoch0); 00347 00348 // Return the current FieldId 00349 virtual Int fieldId () const { 00350 return msIter_p.fieldId (); 00351 } 00352 00353 // Return the current ArrayId 00354 virtual Int arrayId () const { 00355 return msIter_p.arrayId (); 00356 } 00357 00358 // Return the current Field Name 00359 virtual String fieldName () const { 00360 return msIter_p.fieldName (); 00361 } 00362 00363 // Return the current Source Name 00364 virtual String sourceName () const { 00365 return msIter_p.sourceName (); 00366 } 00367 00368 // Return flag for each polarization, channel and row 00369 virtual Cube<Bool> & flag (Cube<Bool> & flags) const; 00370 00371 // Return flag for each channel & row 00372 virtual Matrix<Bool> & flag (Matrix<Bool> & flags) const; 00373 00374 // Determine whether FLAG_CATEGORY is valid. 00375 Bool existsFlagCategory() const; 00376 00377 // Return flags for each polarization, channel, category, and row. 00378 virtual Array<Bool> & flagCategory (Array<Bool> & flagCategories) const; 00379 00380 // Return row flag 00381 virtual Vector<Bool> & flagRow (Vector<Bool> & rowflags) const; 00382 00383 // Return scan number 00384 virtual Vector<Int> & scan (Vector<Int> & scans) const; 00385 00386 // Return the OBSERVATION_IDs 00387 virtual Vector<Int> & observationId (Vector<Int> & obsids) const; 00388 00389 // Return the PROCESSOR_IDs 00390 virtual Vector<Int> & processorId (Vector<Int> & procids) const; 00391 00392 // Return the STATE_IDs 00393 virtual Vector<Int> & stateId (Vector<Int> & stateids) const; 00394 00395 // Return current frequencies (in Hz, acc. to the MS def'n v.2) 00396 virtual Vector<Double> & frequency (Vector<Double> & freq) const; 00397 00398 // Return frequencies (in Hz, acc. to the MS def'n v.2) in selected velocity frame, 00399 // returns the same as frequency () if there is no vel selection active. 00400 virtual Vector<Double> & lsrFrequency (Vector<Double> & freq) const; 00401 00402 // Return the current phase center as an MDirection 00403 virtual const MDirection & phaseCenter () const { 00404 return msIter_p.phaseCenter (); 00405 } 00406 00407 // Return frame for polarization (returns PolFrame enum) 00408 virtual Int polFrame () const { 00409 return msIter_p.polFrame (); 00410 } 00411 00412 // Return the correlation type (returns Stokes enums) 00413 virtual Vector<Int> & corrType (Vector<Int> & corrTypes) const; 00414 00415 // Return sigma 00416 virtual Vector<Float> & sigma (Vector<Float> & sig) const; 00417 00418 // Return sigma matrix (pol-dep) 00419 virtual Matrix<Float> & sigmaMat (Matrix<Float> & sigmat) const; 00420 00421 // Return current SpectralWindow 00422 virtual Int spectralWindow () const { 00423 return msIter_p.spectralWindowId (); 00424 } 00425 00426 // Return current Polarization Id 00427 virtual Int polarizationId () const { 00428 return msIter_p.polarizationId (); 00429 } 00430 00431 // Return current DataDescription Id 00432 virtual Int dataDescriptionId () const { 00433 return msIter_p.dataDescriptionId (); 00434 } 00435 00436 // Return MJD midpoint of interval. 00437 virtual Vector<Double> & time (Vector<Double> & t) const; 00438 00439 // Return MJD centroid of interval. 00440 virtual Vector<Double> & timeCentroid (Vector<Double> & t) const; 00441 00442 // Return nominal time interval 00443 virtual Vector<Double> & timeInterval (Vector<Double> & ti) const; 00444 00445 // Return actual time interval 00446 virtual Vector<Double> & exposure (Vector<Double> & expo) const; 00447 00448 // Return the visibilities as found in the MS, Cube (npol,nchan,nrow). 00449 virtual Cube<Complex> & visibility (Cube<Complex> & vis, 00450 DataColumn whichOne) const; 00451 00452 // Return FLOAT_DATA as a Cube (npol, nchan, nrow) if found in the MS. 00453 virtual Cube<Float> & floatData (Cube<Float> & fcube) const; 00454 00455 // Return the visibility 4-vector of polarizations for each channel. 00456 // If the MS doesn't contain all polarizations, it is assumed it 00457 // contains one or two parallel hand polarizations. 00458 virtual Matrix<CStokesVector> & visibility (Matrix<CStokesVector> & vis, 00459 DataColumn whichOne) const; 00460 00461 // Return the shape of the visibility Cube 00462 virtual IPosition visibilityShape () const; 00463 00464 // Return u,v and w (in meters) 00465 virtual Vector<RigidVector<Double, 3> > & uvw (Vector<RigidVector<Double, 3> > & uvwvec) const; 00466 virtual Matrix<Double> & uvwMat (Matrix<Double> & uvwmat) const; 00467 00468 // Return weight 00469 virtual Vector<Float> & weight (Vector<Float> & wt) const; 00470 00471 // Returns the nPol_p x curNumRow_p weight matrix 00472 virtual Matrix<Float> & weightMat (Matrix<Float> & wtmat) const; 00473 00474 // Determine whether WEIGHT_SPECTRUM exists. 00475 Bool existsWeightSpectrum () const; 00476 00477 // Return weightspectrum (a weight for each channel) 00478 virtual Cube<Float> & weightSpectrum (Cube<Float> & wtsp) const; 00479 00480 // Return imaging weight (a weight for each channel) 00481 //virtual Matrix<Float> & imagingWeight (Matrix<Float> & wt) const; 00482 const VisImagingWeight & getImagingWeightGenerator () const; 00483 00484 // Return True if FieldId/Source has changed since last iteration 00485 virtual Bool newFieldId () const { 00486 return (curStartRow_p == 0 && msIter_p.newField ()); 00487 } 00488 00489 // Return True if arrayID has changed since last iteration 00490 virtual Bool newArrayId () const { 00491 return (curStartRow_p == 0 && msIter_p.newArray ()); 00492 } 00493 00494 // Return True if SpectralWindow has changed since last iteration 00495 virtual Bool newSpectralWindow () const { 00496 return (curStartRow_p == 0 && msIter_p.newSpectralWindow ()); 00497 } 00498 00499 // Return the index of the first channel of the current channel group 00500 // in the total (selected) spectrum. 00501 virtual Int channelIndex () const; 00502 00503 // Return the width of the current group of channels, i.e., 00504 // the number of channels returned by visibility () and frequency (). 00505 virtual Int channelGroupSize () const; 00506 00507 // Return the number of correlations in the current iteration 00508 virtual Int nCorr () const { 00509 return nPol_p; 00510 }; 00511 00512 // Return the number of rows in the current iteration 00513 virtual Int nRow () const; 00514 00515 // Return the row ids as from the original root table. This is useful 00516 // to find correspondance between a given row in this iteration to the 00517 // original ms row 00518 virtual Vector<uInt> & rowIds (Vector<uInt> & rowids) const; 00519 00520 // Return the numbers of rows in the current chunk 00521 virtual Int nRowChunk () const; 00522 00523 // Return the number of sub-intervals in the current chunk 00524 virtual Int nSubInterval () const; 00525 00526 // Call to use the slurp i/o method for all scalar columns. This 00527 // will set the BucketCache cache size to the full column length 00528 // and cause the full column to be cached in memory, if 00529 // any value of the column is used. In case of out-of-memory, 00530 // it will automatically fall-back on the smaller cache size. 00531 // Slurping the column is to be considered as a work-around for the 00532 // Table i/o code, which uses BucketCache and performs extremely bad 00533 // for random access. Slurping is useful when iterating non-sequentially 00534 // an MS or parts of an MS, it is not tested with multiple MSs. 00535 virtual void slurp () const; 00536 00537 // Velocity selection - specify the output channels in velocity: 00538 // nChan - number of output channels, vStart - start velocity, 00539 // vInc - velocity increment. So channel i will have velocity 00540 // vStart + i*vInc (i=0,nChan-1). 00541 // Specify velocities as in e.g., MVRadialVelocity (Quantity (2001.,"km/s")). 00542 // The reference type and velocity definition are specified separately. 00543 // Note that no averaging is performed, the visibilities will be interpolated 00544 // and sampled at the specified velocities, it's up to you to choose a vInc 00545 // appropriate to the channel width. 00546 // The REST_FREQUENCY column in the SPECTRAL_WINDOW subtable is used to 00547 // determine the velocity-frequency conversion. 00548 // By default calculations are done for a single velocity with offsets 00549 // applied for the others (ok for non-rel velocities with RADIO defn), 00550 // set precise to True to do a full conversion for each output channel. (NYI) 00551 virtual VisibilityIteratorReadImpl & 00552 selectVelocity (Int nChan, 00553 const MVRadialVelocity & vStart, const MVRadialVelocity & vInc, 00554 MRadialVelocity::Types rvType = MRadialVelocity::LSR, 00555 MDoppler::Types dType = MDoppler::RADIO, Bool precise = False); 00556 00557 // Select the velocity interpolation scheme. 00558 // At present the choice is limited to : nearest and linear, linear 00559 // is the default. 00560 // TODO: add cubic, spline and possibly FFT 00561 virtual VisibilityIteratorReadImpl & velInterpolation (const String & /*type*/) {return * this; } 00562 00563 // Channel selection - only the selected channels will be returned by the 00564 // access functions. The default spectralWindow is the current one (or 0) 00565 // This allows selection of the input channels, producing 00566 // nGroup groups of width output channels. Default is to return all channels 00567 // in a single group. 00568 virtual VisibilityIteratorReadImpl & selectChannel (Int nGroup = 1, Int start = 0, Int width = 0, 00569 Int increment = 1, Int spectralWindow = -1); 00570 00571 //Same as above except when multiple ms's are to be accessed 00572 00573 virtual VisibilityIteratorReadImpl & selectChannel (const Block< Vector<Int> > & blockNGroup, 00574 const Block< Vector<Int> > & blockStart, 00575 const Block< Vector<Int> > & blockWidth, 00576 const Block< Vector<Int> > & blockIncr, 00577 const Block< Vector<Int> > & blockSpw); 00578 00579 00580 //get the channel selection ...the block over the number of ms's associated 00581 // with this iterator 00582 virtual void getChannelSelection (Block< Vector<Int> > & blockNGroup, 00583 Block< Vector<Int> > & blockStart, 00584 Block< Vector<Int> > & blockWidth, 00585 Block< Vector<Int> > & blockIncr, 00586 Block< Vector<Int> > & blockSpw); 00587 00588 // Translate slicesv from the form returned by MSSelection::getChanSlices () 00589 // to matv as used by setChanAveBounds (). widthsv is the channel averaging 00590 // width for each _selected_ spw. 00591 void slicesToMatrices (Vector<Matrix<Int> > & matv, 00592 const Vector<Vector<Slice> > & slicesv, 00593 const Vector<Int> & widthsv) const; 00594 00595 // Get the spw, start and nchan for all the ms's is this Visiter that 00596 // match the frequecy "freqstart-freqStep" and "freqEnd+freqStep" range 00597 // Can help in doing channel selection above.. 00598 // freqFrame is the frame the caller frequency values are in (freqStart and freqEnd) 00599 // These will be converted to the frame of the selected spw to match 00600 00601 virtual void getSpwInFreqRange (Block<Vector<Int> > & spw, 00602 Block<Vector<Int> > & start, 00603 Block<Vector<Int> > & nchan, 00604 Double freqStart, Double freqEnd, 00605 Double freqStep, MFrequency::Types freqFrame = MFrequency::LSRK) const; 00606 00607 // Get the range of frequency convered by the selected data in the frame requested 00608 00609 virtual void getFreqInSpwRange(Double& freqStart, Double& freqEnd, MFrequency::Types freqframe = MFrequency::LSRK) const; 00610 00611 // Attach a VisBuffer object. 00612 // Note that while more than one VisBuffer may be attached, only the 00613 // last one is actively updated. A Stack is kept internally, so after 00614 // a detach, the previous VisBuffer becomes active again. 00615 virtual void attachVisBuffer (VisBuffer & vb); 00616 00617 // Detach a VisBuffer object. 00618 // If the object detached is not the last one attached an exception 00619 // is thrown. 00620 virtual void detachVisBuffer (VisBuffer & vb); 00621 00622 // Access the current ROMSColumns object in MSIter 00623 virtual const ROMSColumns & msColumns () const { 00624 return msIter_p.msColumns (); 00625 } 00626 00627 // get back the selected spectral windows and spectral channels for 00628 // current ms 00629 00630 virtual void allSelectedSpectralWindows (Vector<Int> & spws, Vector<Int> & nvischan); 00631 00632 // Convert the frequency from the observe frame to lsr frame. 00633 // Returns True in convert if given spw was not observed 00634 // in the LSRK frame 00635 // if ignoreconv=True then conversion from frame in data 00636 //is ignored by request 00637 virtual void lsrFrequency (const Int & spw, Vector<Double> & freq, Bool & convert, const Bool ignoreconv=False); 00638 //assign a VisImagingWeight object to this iterator 00639 virtual void useImagingWeight (const VisImagingWeight & imWgt); 00640 //return number of Ant 00641 virtual Int numberAnt (); 00642 //Return number of rows in all selected ms's 00643 virtual Int numberCoh (); 00644 00645 // Return number of spws, polids, ddids 00646 virtual Int numberSpw (); 00647 virtual Int numberPol (); 00648 virtual Int numberDDId (); 00649 00650 ROArrayColumn <Double> & getChannelFrequency () const; 00651 Block<Int> getChannelGroupNumber () const; 00652 Block<Int> getChannelIncrement () const; 00653 Block<Int> getChannelStart () const; 00654 Block<Int> getChannelWidth () const; 00655 Int getDataDescriptionId () const; 00656 const MeasurementSet & getMeasurementSet () const;; 00657 Int getMeasurementSetId () const; 00658 Int getNAntennas () const; 00659 virtual MEpoch getEpoch () const; 00660 MFrequency::Types getObservatoryFrequencyType () const; //??? 00661 MPosition getObservatoryPosition () const; 00662 MDirection getPhaseCenter () const; 00663 Vector<Float> getReceptor0Angle (); 00664 Vector<uInt> getRowIds () const; 00665 00666 static void lsrFrequency (const Int & spw, 00667 Vector<Double> & freq, 00668 Bool & convert, 00669 const Block<Int> & chanStart, 00670 const Block<Int> & chanWidth, 00671 const Block<Int> & chanInc, 00672 const Block<Int> & numChanGroup, 00673 const ROArrayColumn <Double> & chanFreqs, 00674 const ROScalarColumn<Int> & obsMFreqTypes, 00675 const MEpoch & ep, 00676 const MPosition & obsPos, 00677 const MDirection & dir, 00678 const Bool ignoreconv=False); 00679 00680 protected: 00681 00682 void attachColumnsSafe (const Table & t); 00683 00684 // advance the iteration 00685 virtual void advance (); 00686 // set the currently selected table 00687 virtual void setSelTable (); 00688 // set the iteration state 00689 virtual void setState (); 00690 // get the TOPO frequencies from the selected velocities and the obs. vel. 00691 virtual void getTopoFreqs (); 00692 virtual void getTopoFreqs (Vector<Double> & lsrFreq, Vector<Double> & selFreq); // for async i/o 00693 00694 virtual void getLsrInfo (Block<Int> & channelGroupNumber, 00695 Block<Int> & channelIncrement, 00696 Block<Int> & channelStart, 00697 Block<Int> & channelWidth, 00698 MPosition & observatoryPositon, 00699 MDirection & phaseCenter, 00700 Bool & velocitySelection) const; 00701 00702 vector<MeasurementSet> getMeasurementSets () const; 00703 00704 const MSDerivedValues & getMSD () const; // for use by Async I/O *ONLY* 00705 00706 // update the DATA slicer 00707 virtual void updateSlicer (); 00708 // attach the column objects to the currently selected table 00709 virtual void attachColumns (const Table & t); 00710 // returns the table, to which columns are attached, 00711 // can be overridden in derived classes 00712 virtual const Table attachTable () const; 00713 00714 // get the (velocity selected) interpolated visibilities, flags and weights. 00715 // It is not really const at all (it seems to use This-> trickery so callers 00716 // like flag () can be declared const). 00717 00718 // virtual void getInterpolatedVisFlagWeight (DataColumn whichOne) const; 00719 00720 // get the (velocity selected) interpolated FLOAT_DATA (as real Floats), 00721 // flags and weights. 00722 00723 // void getInterpolatedFloatDataFlagWeight () const; 00724 00725 Bool usesTiledDataManager (const String & columnName, const MeasurementSet & ms) const; 00726 00727 // get the visibility data (observed, corrected or model); 00728 // deals with Float and Complex observed data (DATA or FLOAT_DATA) 00729 virtual void getDataColumn (ROVisibilityIterator::DataColumn whichOne, const Slicer & slicer, 00730 Cube<Complex> & data) const; 00731 virtual void getDataColumn (DataColumn whichOne, Cube<Complex> & data) const; 00732 00733 // get FLOAT_DATA as real Floats. 00734 virtual void getFloatDataColumn (const Slicer & slicer, Cube<Float> & data) const; 00735 virtual void getFloatDataColumn (Cube<Float> & data) const; 00736 00737 //constructor helpers 00738 virtual void initialize (const Block<MeasurementSet> & mss); 00739 00740 virtual void originChunks (Bool forceRewind); 00741 00742 //Re-Do the channel selection in multi ms case 00743 virtual void doChannelSelection (); 00744 //Set the tile cache size....when using slice access if tile cache size is 00745 // not set memory usage can go wild. Specifically, the caching scheme is 00746 // ephemeral and lives for that instance of setting the caching scheme. 00747 // 00748 // If you don't set any then the defaults come into play and caches a few 00749 // tiles along every axis at the tile you requested...which is a waste when 00750 // say you know you want to proceed along the row axis for example...and in 00751 // fact now VisIter just reads one tile (thus the commenting in setTileCache) 00752 // and lets the OS do the caching rather than than having the table system 00753 // cache extra tiles. 00754 virtual void setTileCache (); 00755 //Check if spw is in selected SPW for actual ms 00756 virtual Bool isInSelectedSPW (const Int & spw); 00757 00758 // Updates, if necessary, rowIds_p member for the current chunk 00759 virtual void update_rowIds () const; 00760 00761 void setAsyncEnabled (Bool enable); 00762 00763 template<class T> 00764 void getColScalar (const ROScalarColumn<T> & column, Vector<T> & array, Bool resize) const; 00765 00766 template<class T> 00767 void getColArray (const ROArrayColumn<T> & column, Array<T> & array, Bool resize) const; 00768 00769 // column access functions, can be overridden in derived classes 00770 virtual void getCol (const ROScalarColumn<Bool> & column, Vector<Bool> & array, Bool resize = False) const; 00771 virtual void getCol (const ROScalarColumn<Int> & column, Vector<Int> & array, Bool resize = False) const; 00772 virtual void getCol (const ROScalarColumn<Double> & column, Vector<Double> & array, Bool resize = False) const; 00773 00774 virtual void getCol (const ROArrayColumn<Bool> & column, Array<Bool> & array, Bool resize = False) const; 00775 virtual void getCol (const ROArrayColumn<Float> & column, Array<Float> & array, Bool resize = False) const; 00776 virtual void getCol (const ROArrayColumn<Double> & column, Array<Double> & array, Bool resize = False) const; 00777 virtual void getCol (const ROArrayColumn<Complex> & column, Array<Complex> & array, Bool resize = False) const; 00778 00779 virtual void getCol (const ROArrayColumn<Bool> & column, const Slicer & slicer, Array<Bool> & array, Bool resize = False) const; 00780 virtual void getCol (const ROArrayColumn<Float> & column, const Slicer & slicer, Array<Float> & array, Bool resize = False) const; 00781 virtual void getCol (const ROArrayColumn<Complex> & column, const Slicer & slicer, Array<Complex> & array, Bool resize = False) const; 00782 00783 // virtual void getCol (const String & colName, Array<Double> & array, 00784 // Array<Double> & all, Bool resize = False) const; 00785 // virtual void getCol (const String & colName, Vector<Bool> & array, 00786 // Vector<Bool> & all, Bool resize = False) const; 00787 // virtual void getCol (const String & colName, Vector<Int> & array, 00788 // Vector<Int> & all, Bool resize = False) const; 00789 // virtual void getCol (const String & colName, Vector<Double> & array, 00790 // Vector<Double> & all, Bool resize = False) const; 00791 00792 template<class T> 00793 void swapyz (Cube<T> & out, const Cube<T> & in) const; 00794 00795 class Cache { 00796 00797 public: 00798 00799 Cache (); 00800 00801 Cache & operator= (const Cache & other); 00802 00803 MDirection azel0_p; 00804 Vector<MDirection> azel_p; 00805 Vector<Float> feedpa_p; 00806 Cube<Bool> flagCube_p; 00807 Bool flagOK_p; 00808 Bool floatDataCubeOK_p; 00809 Cube<Float> floatDataCube_p; 00810 Bool freqCacheOK_p; 00811 Vector<Double> frequency_p; 00812 Double hourang_p; 00813 Matrix<Float> imagingWeight_p; 00814 Double lastParang0UT_p; 00815 Double lastParangUT_p; 00816 Double lastazelUT_p; 00817 Double lastfeedpaUT_p; 00818 Bool msHasFC_p; // Does the current MS have a valid FLAG_CATEGORY? 00819 Bool msHasWtSp_p; // Does the current MS have a valid WEIGHT_SPECTRUM? 00820 Float parang0_p; 00821 Vector<Float> parang_p; 00822 Vector<uInt> rowIds_p; 00823 Matrix<Double> uvwMat_p; 00824 Cube<Complex> visCube_p; 00825 Block<Bool> visOK_p; 00826 Bool weightSpOK_p; 00827 Cube<Float> wtSp_p; 00828 }; 00829 00830 class Channels { // channel selection 00831 00832 public: 00833 00834 Block<Int> inc_p; 00835 Block<Int> start_p; 00836 Block<Int> width_p; 00837 Block<Int> nGroups_p; 00838 Block<Int> preselectedChanStart_p; 00839 Block<Int> preselectednChan_p; 00840 00841 }; 00842 00843 class Columns { 00844 00845 public: 00846 00847 Columns & operator= (const Columns & other); 00848 00849 ROScalarColumn<Int> antenna1_p; 00850 ROScalarColumn<Int> antenna2_p; 00851 ROArrayColumn<Complex> corrVis_p; 00852 ROScalarColumn<Double> exposure_p; 00853 ROScalarColumn<Int> feed1_p; 00854 ROScalarColumn<Int> feed2_p; 00855 ROArrayColumn<Bool> flagCategory_p; 00856 ROScalarColumn<Bool> flagRow_p; 00857 ROArrayColumn<Bool> flag_p; 00858 ROArrayColumn<Float> floatVis_p; 00859 ROArrayColumn<Complex> modelVis_p; 00860 ROScalarColumn<Int> observation_p; 00861 ROScalarColumn<Int> processor_p; 00862 ROScalarColumn<Int> scan_p; 00863 ROArrayColumn<Float> sigma_p; 00864 ROScalarColumn<Int> state_p; 00865 ROScalarColumn<Double> timeCentroid_p; 00866 ROScalarColumn<Double> timeInterval_p; 00867 ROScalarColumn<Double> time_p; 00868 ROArrayColumn<Double> uvw_p; 00869 ROArrayColumn<Complex> vis_p; 00870 ROArrayColumn<Float> weightSpectrum_p; 00871 ROArrayColumn<Float> weight_p; 00872 00873 }; 00874 00875 class MeasurementSetChannels { 00876 00877 public: 00878 00879 Block < Vector<Int> > inc_p; 00880 Block < Vector<Int> > nGroups_p; 00881 Block < Vector<Int> > start_p; 00882 Block < Vector<Int> > width_p; 00883 Block < Vector<Int> > spw_p; 00884 00885 }; 00886 00887 class Velocity { // for velocity selection and conversion 00888 00889 public: 00890 00891 Velocity (); 00892 Velocity & operator= (const Velocity & other); 00893 00894 MDoppler::Convert cFromBETA_p; 00895 Vector<Double> lsrFreq_p; 00896 Int nVelChan_p; 00897 Vector<Double> selFreq_p; 00898 MDoppler::Types vDef_p; 00899 MVRadialVelocity vInc_p; 00900 String vInterpolation_p; 00901 Bool velSelection_p; 00902 Bool vPrecise_p; 00903 MVRadialVelocity vStart_p; 00904 00905 }; 00906 00907 00908 typedef std::vector<MeasurementSet> MeasurementSets; 00909 00910 Bool addDefaultSort_p; 00911 Bool asyncEnabled_p; // Allows lower-level code to make an async "copy" of this VI. 00912 mutable Cache cache_p; 00913 Int channelGroupSize_p; 00914 Channels channels_p; 00915 Int chunkNumber_p; 00916 Columns columns_p; 00917 Int curChanGroup_p; 00918 Int curEndRow_p; 00919 Int curNGroups_p; 00920 uInt curNumRow_p; 00921 Int curStartRow_p; 00922 Int curTableNumRow_p; 00923 Bool floatDataFound_p; 00924 VisImagingWeight imwgt_p; // object to calculate imaging weight 00925 Bool initialized_p; 00926 Bool isMultiMS_p; 00927 MeasurementSets measurementSets_p; // [use] 00928 Bool more_p; 00929 MeasurementSetChannels msChannels_p; 00930 Int msCounter_p; 00931 Bool msIterAtOrigin_p; 00932 MSIter msIter_p; 00933 mutable MSDerivedValues msd_p; 00934 Int nAnt_p; 00935 Int nChan_p; 00936 Int nPol_p; 00937 Int nRowBlocking_p; 00938 Bool newChanGroup_p; 00939 ROVisibilityIterator * rovi_p; // [use] 00940 RefRows selRows_p; // currently selected rows from msIter_p.table () 00941 Slicer slicer_p; 00942 Block<Int> sortColumns_p; 00943 Bool stateOk_p; 00944 SubChunkPair subchunk_p; 00945 Vector<Bool> tileCacheIsSet_p; 00946 Double timeInterval_p; 00947 Vector<Double> time_p; 00948 Bool useSlicer_p; 00949 Stack<VisBuffer *> vbStack_p; // Stack of VisBuffer objects 00950 Velocity velocity_p; 00951 Slicer weightSlicer_p; 00952 00953 00954 }; 00955 00956 inline Bool VisibilityIteratorReadImpl::more () const 00957 { 00958 return more_p; 00959 } 00960 00961 inline Vector<SquareMatrix<Complex, 2> > & 00962 VisibilityIteratorReadImpl::CJones (Vector<SquareMatrix<Complex, 2> > & cjones) const 00963 { 00964 cjones.resize (msIter_p.CJones ().nelements ()); 00965 return cjones = msIter_p.CJones (); 00966 } 00967 00968 inline const Cube<Double> & VisibilityIteratorReadImpl::receptorAngles () const 00969 { 00970 return msIter_p.receptorAngles (); 00971 } 00972 00973 inline const Vector<String> & VisibilityIteratorReadImpl::antennaMounts () const 00974 { 00975 return msIter_p.antennaMounts (); 00976 } 00977 00978 inline const Cube<RigidVector<Double, 2> > & 00979 VisibilityIteratorReadImpl::getBeamOffsets () const 00980 { 00981 return msIter_p.getBeamOffsets (); 00982 } 00983 00984 inline Bool VisibilityIteratorReadImpl::allBeamOffsetsZero () const 00985 { 00986 return msIter_p.allBeamOffsetsZero (); 00987 } 00988 00989 inline Int VisibilityIteratorReadImpl::channelGroupSize () const 00990 { 00991 return channels_p.width_p[msIter_p.spectralWindowId ()]; 00992 } 00993 inline Int VisibilityIteratorReadImpl::channelIndex () const 00994 { 00995 return channels_p.inc_p[msIter_p.spectralWindowId ()] * curChanGroup_p; 00996 } 00997 inline Int VisibilityIteratorReadImpl::nRow () const 00998 { 00999 return curNumRow_p; 01000 } 01001 inline Int VisibilityIteratorReadImpl::nRowChunk () const 01002 { 01003 return msIter_p.table ().nrow (); 01004 } 01005 //inline VisibilityIteratorReadImpl & 01006 //VisibilityIteratorReadImpl::velInterpolation (const String & type) 01007 //{ 01008 // vInterpolation_p = type; 01009 // return *this; 01010 //} 01011 inline IPosition VisibilityIteratorReadImpl::visibilityShape () const 01012 { 01013 return IPosition (3, nPol_p, channelGroupSize (), curNumRow_p); 01014 } 01015 01016 // <summary> 01017 // VisibilityIterator iterates through one or more writable MeasurementSets 01018 // </summary> 01019 01020 // <use visibility=export> 01021 01022 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos=""> 01023 // </reviewed> 01024 01025 // <prerequisite> 01026 // <li> <linkto class="VisibilityIteratorReadImpl">VisibilityIteratorReadImpl</linkto> 01027 // </prerequisite> 01028 // 01029 // <etymology> 01030 // The VisibilityIterator is a read/write iterator returning visibilities 01031 // </etymology> 01032 // 01033 // <synopsis> 01034 // VisibilityIterator provides iteration with various sort orders 01035 // for one or more MSs. It has member functions to retrieve the fields 01036 // commonly needed in synthesis calibration and imaging. It is 01037 // derived from the read-only iterator 01038 // <linkto class="VisibilityIteratorReadImpl">VisibilityIteratorReadImpl</linkto>. 01039 // 01040 // One should use <linkto class="VisBuffer">VisBuffer</linkto> 01041 // to access chunks of data. 01042 // </synopsis> 01043 // 01044 // <example> 01045 // <code> 01046 // // 01047 // </code> 01048 // </example> 01049 // 01050 // <motivation> 01051 // For imaging and calibration you need to access an MS in some consistent 01052 // order (by field, spectralwindow, time interval etc.). This class provides 01053 // that access. 01054 // </motivation> 01055 // 01056 // #<thrown> 01057 // 01058 // #</thrown> 01059 // 01060 // <todo asof="1997/05/30"> 01061 // <li> cleanup the currently dual interface for visibilities and flags 01062 // <li> sort out what to do with weights when interpolating 01063 // </todo> 01064 01065 class VisibilityIteratorWriteImpl { 01066 01067 friend class VisibilityIterator; 01068 01069 public: 01070 01071 typedef ROVisibilityIterator::DataColumn DataColumn; 01072 01073 // Constructors. 01074 // Note: The VisibilityIterator is not initialized correctly by default, you 01075 // need to call origin () before using it to iterate. 01076 01077 VisibilityIteratorWriteImpl (VisibilityIterator * vi); 01078 01079 //VisibilityIteratorWriteImpl (VisibilityIterator * vi); 01080 01081 VisibilityIteratorWriteImpl (const VisibilityIteratorWriteImpl & other); 01082 01083 // Destructor 01084 01085 virtual ~VisibilityIteratorWriteImpl (); 01086 01087 // Members 01088 01089 virtual VisibilityIteratorWriteImpl * clone (VisibilityIterator * vi) const; 01090 01091 virtual Bool isWritable () const { 01092 return True; 01093 } 01094 01095 // Set/modify the flags in the data. 01096 // This will flag all channels in the original data that contributed to 01097 // the output channel in the case of channel averaging. 01098 // All polarizations have the same flag value. 01099 virtual void setFlag (const Matrix<Bool> & flag); 01100 01101 // Set/modify the flags in the data. 01102 // This sets the flags as found in the MS, Cube (npol,nchan,nrow), 01103 // where nrow is the number of rows in the current iteration (given by 01104 // nRow ()). 01105 virtual void setFlag (const Cube<Bool> & flag); 01106 01107 // Set/modify the flag row column; dimension Vector (nrow) 01108 virtual void setFlagRow (const Vector<Bool> & rowflags); 01109 01110 void setFlagCategory(const Array<Bool>& fc); 01111 01112 // Set/modify the visibilities. 01113 // This is possibly only for a 'reference' MS which has a new DATA column. 01114 // The first axis of the matrix should equal the selected number of channels 01115 // in the original MS. 01116 // If the MS does not contain all polarizations, only the parallel 01117 // hand polarizations are used. 01118 virtual void setVis (const Matrix<CStokesVector> & vis, DataColumn whichOne); 01119 01120 // Set/modify the visibilities 01121 // This sets the data as found in the MS, Cube (npol,nchan,nrow). 01122 virtual void setVis (const Cube<Complex> & vis, DataColumn whichOne); 01123 01124 // Set the visibility and flags, and interpolate from velocities if needed 01125 virtual void setVisAndFlag (const Cube<Complex> & vis, const Cube<Bool> & flag, 01126 DataColumn whichOne); 01127 01128 // Set/modify the weights 01129 virtual void setWeight (const Vector<Float> & wt); 01130 01131 // Set/modify the weightMat 01132 virtual void setWeightMat (const Matrix<Float> & wtmat); 01133 01134 // Set/modify the weightSpectrum 01135 virtual void setWeightSpectrum (const Cube<Float> & wtsp); 01136 01137 // Set/modify the Sigma 01138 virtual void setSigma (const Vector<Float> & sig); 01139 01140 // Set/modify the ncorr x nrow SigmaMat. 01141 virtual void setSigmaMat (const Matrix<Float> & sigmat); 01142 01143 virtual void writeBack (VisBuffer *); 01144 01145 protected: 01146 01147 // A BackWriter is a functor that will extract a piece of information out of its VisBuffer 01148 // argument and write it out using a "set" method on the supplied VisibilityIterator. 01149 class BackWriter { 01150 01151 public: 01152 01153 virtual ~BackWriter () {} 01154 01155 virtual void operator () (VisibilityIteratorWriteImpl * vi, VisBuffer * vb) = 0; 01156 01157 }; 01158 01159 // A simple BackWriterImpl uses a nullary accessor on a VisBuffer. 01160 template <typename Setter, typename Getter> 01161 class BackWriterImpl : public BackWriter { 01162 public: 01163 01164 BackWriterImpl (Setter setter, Getter getter) : getter_p (getter), setter_p (setter) {} 01165 void operator () (VisibilityIteratorWriteImpl * vi, VisBuffer * vb) { 01166 (vi ->* setter_p) ((vb ->* getter_p) ()); 01167 } 01168 01169 private: 01170 01171 Getter getter_p; 01172 Setter setter_p; 01173 }; 01174 01175 // BackWriterImpl2 is slightly more complicated in that it uses a unary accessor. The argument 01176 // to the unary accessor is a member of the ROVisibilityIterator DataColumn enumeration which 01177 // specifies which visibilty or visCube type is wanted (e.g., observed, model or corrected). 01178 template <typename Setter, typename Getter> 01179 class BackWriterImpl2 : public BackWriter { 01180 public: 01181 01182 typedef VisibilityIteratorReadImpl::DataColumn DataColumn; 01183 01184 BackWriterImpl2 (Setter setter, Getter getter, DataColumn dc) 01185 : dataColumn_p (dc), getter_p (getter), setter_p (setter) 01186 {} 01187 void operator () (VisibilityIteratorWriteImpl * vi, VisBuffer * vb) { 01188 (vi ->* setter_p) ((vb ->* getter_p) (), dataColumn_p); 01189 } 01190 01191 private: 01192 01193 DataColumn dataColumn_p; 01194 Getter getter_p; 01195 Setter setter_p; 01196 }; 01197 01198 // Backwriter(2) creation methods. These methods make it fairly straightforward to create 01199 // a BackWriter object. 01200 01201 template <typename Ret> 01202 static 01203 BackWriter * 01204 makeBackWriter (void (VisibilityIteratorWriteImpl::* setter) (Ret), Ret (VisBuffer::* getter) () const) { 01205 return new BackWriterImpl <void (VisibilityIteratorWriteImpl:: *) (Ret), 01206 Ret (VisBuffer:: *) () const > 01207 (setter, getter); 01208 } 01209 01210 template <typename Ret> 01211 static 01212 BackWriter * 01213 makeBackWriter2 (void (VisibilityIteratorWriteImpl::* setter) (Ret, VisibilityIteratorReadImpl::DataColumn), 01214 Ret (VisBuffer::* getter) () const, 01215 ROVisibilityIterator::DataColumn dc) { 01216 01217 // Define the Getter and Setter types 01218 01219 typedef void (VisibilityIteratorWriteImpl::* Setter) (Ret, VisibilityIteratorReadImpl::DataColumn); 01220 typedef Ret (VisBuffer::* Getter) () const; 01221 01222 return new BackWriterImpl2 < Setter, Getter> (setter, getter, dc); 01223 } 01224 01225 VisibilityIteratorReadImpl * getReadImpl (); 01226 01227 void initializeBackWriters (); 01228 01229 virtual void attachColumns (const Table & t); 01230 01231 // void setInterpolatedVisFlag (const Cube<Complex> & vis, 01232 // const Cube<Bool> & flag); 01233 // void setInterpolatedWeight (const Matrix<Float> & wt); 01234 01235 // Write the data column (observed, model or corrected); 01236 // deals with Float or Complex observed data (DATA and FLOAT_DATA). 01237 01238 void putDataColumn (DataColumn whichOne, const Slicer & slicer, 01239 const Cube<Complex> & data); 01240 void putDataColumn (DataColumn whichOne, const Cube<Complex> & data); 01241 01242 // column access functions, can be overridden in derived classes 01243 virtual void putCol (ScalarColumn<Bool> & column, const Vector<Bool> & array); 01244 virtual void putCol (ArrayColumn<Bool> & column, const Array<Bool> & array); 01245 virtual void putCol (ArrayColumn<Float> & column, const Array<Float> & array); 01246 virtual void putCol (ArrayColumn<Complex> & column, const Array<Complex> & array); 01247 01248 virtual void putCol (ArrayColumn<Bool> & column, const Slicer & slicer, const Array<Bool> & array); 01249 virtual void putCol (ArrayColumn<Float> & column, const Slicer & slicer, const Array<Float> & array); 01250 virtual void putCol (ArrayColumn<Complex> & column, const Slicer & slicer, const Array<Complex> & array); 01251 01252 // non-virtual, no reason to template this function because Bool is the only type needed 01253 void putColScalar (ScalarColumn<Bool> & column, const Vector<Bool> & array); 01254 01255 //This puts a model into the descriptor of the actual ms 01256 //Set iscomponentlist to True if the record represent a componentlist 01257 //if False then it is a FTMachine Record that holds the model image 01258 // a [-1] vector in validfields mean the model applies to all fields of the active ms 01259 virtual void putModel(const RecordInterface& rec, Bool iscomponentlist=True, Bool incremental=False); 01260 01261 01262 01263 01264 01265 private: 01266 01267 class Columns { 01268 01269 public: 01270 01271 Columns & operator= (const Columns & other); 01272 01273 ArrayColumn<Complex> corrVis_p; 01274 ScalarColumn<Bool> flagRow_p; 01275 ArrayColumn<Bool> flag_p; 01276 ArrayColumn<Bool> flagCategory_p; 01277 ArrayColumn<Float> floatVis_p; 01278 ArrayColumn<Complex> modelVis_p; 01279 ArrayColumn<Float> sigma_p; 01280 ArrayColumn<Complex> vis_p; 01281 ArrayColumn<Float> weightSpectrum_p; 01282 ArrayColumn<Float> weight_p; 01283 01284 }; 01285 01286 std::map <VisBufferComponents::EnumType, BackWriter *> backWriters_p; 01287 Columns columns_p; 01288 VisibilityIterator * vi_p; // [use] 01289 }; 01290 01291 } //# NAMESPACE CASA - END 01292 01293 #endif 01294