VisBufferAsyncWrapper.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef VISBUFFER_ASYNC_WRAPPER_H
00029 #define VISBUFFER_ASYNC_WRAPPER_H
00030
00031 #include <casa/aips.h>
00032 #include <casa/Arrays/Cube.h>
00033 #include <casa/Arrays/Vector.h>
00034 #include <casa/Arrays/Matrix.h>
00035 #include <casa/BasicSL/Complex.h>
00036 #include <measures/Measures/MDirection.h>
00037 #include <measures/Measures/MEpoch.h>
00038 #include <msvis/MSVis/StokesVector.h>
00039 #include <msvis/MSVis/VisBuffer.h>
00040 #include <msvis/MSVis/VisBufferAsync.h>
00041 #include <msvis/MSVis/VisibilityIterator.h>
00042 #include <msvis/MSVis/MSCalEnums.h>
00043
00044 namespace casa {
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081 class VisBufferAsyncWrapper : public VisBufferAsync {
00082
00083 friend class ViReadImplAsync;
00084
00085 public:
00086
00087 VisBufferAsyncWrapper();
00088
00089
00090 VisBufferAsyncWrapper (ROVisibilityIterator & iter);
00091
00092
00093
00094 VisBufferAsyncWrapper (const VisBufferAsync & vb);
00095
00096
00097 virtual ~VisBufferAsyncWrapper();
00098
00099
00100
00101
00102 virtual VisBufferAsyncWrapper & operator=(const VisBufferAsyncWrapper & vb);
00103
00104
00105
00106
00107 virtual VisBufferAsyncWrapper & assign(const VisBuffer & vb, Bool copy = True);
00108
00109
00110
00111
00112 VisBufferAsyncWrapper & operator-=(const VisBuffer & vb);
00113
00114
00115
00116 virtual void attachToVisIter(ROVisibilityIterator & iter);
00117 void attachToVisIterAsync (ROVisibilityIterator & iter);
00118 virtual VisBuffer * clone ();
00119 virtual void detachFromVisIter ();
00120
00121
00122 virtual void invalidate();
00123
00124
00125
00126
00127 virtual Int & nCorr();
00128 Int nCorr() const;
00129
00130 Int & nChannel();
00131 Int nChannel() const;
00132
00133 Vector<Int>& channel();
00134 const Vector<Int>& channel() const;
00135
00136 Bool newArrayId () const;
00137 Bool newFieldId () const;
00138 Bool newSpectralWindow () const;
00139
00140 Int & nRow();
00141 Int nRow() const;
00142
00143 Vector<Int>& antenna1();
00144 const Vector<Int>& antenna1() const;
00145
00146 Vector<Int>& antenna2();
00147 const Vector<Int>& antenna2() const;
00148
00149 Vector<Int>& feed1();
00150 const Vector<Int>& feed1() const;
00151
00152 Vector<Int>& feed2();
00153 const Vector<Int>& feed2() const;
00154
00155
00156
00157
00158
00159
00160 Vector<Float>& feed1_pa();
00161 const Vector<Float>& feed1_pa() const;
00162
00163 Vector<Float>& feed2_pa();
00164 const Vector<Float>& feed2_pa() const;
00165
00166 Vector<SquareMatrix<Complex, 2> >& CJones();
00167 const Vector<SquareMatrix<Complex, 2> >& CJones() const;
00168
00169
00170 virtual Vector<Float> feed_pa(Double time) const;
00171
00172
00173
00174
00175 Vector<MDirection>& direction1();
00176 const Vector<MDirection>& direction1() const;
00177
00178 Vector<MDirection>& direction2();
00179 const Vector<MDirection>& direction2() const;
00180
00181
00182
00183 virtual Float parang0(Double time) const;
00184 virtual Vector<Float> parang(Double time) const;
00185
00186
00187 virtual MDirection azel0(Double time) const;
00188 Vector<Double>& azel0Vec(Double time, Vector<Double>& azelVec) const;
00189 virtual Vector<MDirection> azel(Double time) const;
00190 Matrix<Double>& azelMat(Double time, Matrix<Double>& azelMat) const;
00191
00192
00193 virtual Double hourang(Double time) const;
00194
00195 Int fieldId() const;
00196
00197 Int arrayId() const;
00198
00199 Int polarizationId() const;
00200
00201
00202 Matrix<Bool>& flag();
00203 const Matrix<Bool>& flag() const;
00204
00205
00206 Cube<Bool>& flagCube();
00207 const Cube<Bool>& flagCube() const;
00208
00209 Vector<Bool>& flagRow();
00210 const Vector<Bool>& flagRow() const;
00211
00212
00213 Array<Bool>& flagCategory();
00214 const Array<Bool>& flagCategory() const;
00215
00216 Vector<Int>& scan();
00217 const Vector<Int>& scan() const;
00218
00219
00220
00221 Int scan0();
00222
00223 Vector<Int>& processorId();
00224 const Vector<Int>& processorId() const;
00225
00226 Vector<Int>& observationId();
00227 const Vector<Int>& observationId() const;
00228
00229 Vector<Int>& stateId();
00230 const Vector<Int>& stateId() const;
00231
00232
00233 Vector<Double>& frequency();
00234 const Vector<Double>& frequency() const;
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244 virtual void lsrFrequency(const Int & spw, Vector<Double>& freq, Bool & convert) const;
00245
00246 virtual Int numberCoh () const;
00247
00248 MDirection & phaseCenter();
00249 MDirection phaseCenter() const;
00250
00251 Int polFrame() const;
00252
00253 Vector<Int>& corrType();
00254 const Vector<Int>& corrType() const;
00255
00256 Vector<Float>& sigma();
00257 const Vector<Float>& sigma() const;
00258
00259 Matrix<Float>& sigmaMat();
00260 const Matrix<Float>& sigmaMat() const;
00261
00262 Int & spectralWindow();
00263 Int spectralWindow() const;
00264 virtual Int dataDescriptionId() const;
00265 Vector<Double>& time();
00266 const Vector<Double>& time() const;
00267
00268 Vector<Double>& timeCentroid();
00269 const Vector<Double>& timeCentroid() const;
00270
00271 Vector<Double>& timeInterval();
00272 const Vector<Double>& timeInterval() const;
00273
00274 Vector<Double>& exposure();
00275 const Vector<Double>& exposure() const;
00276
00277 Vector<RigidVector<Double, 3> >& uvw();
00278 const Vector<RigidVector<Double, 3> >& uvw() const;
00279
00280 Matrix<Double>& uvwMat();
00281 const Matrix<Double>& uvwMat() const;
00282
00283 Matrix<CStokesVector>& visibility();
00284 const Matrix<CStokesVector>& visibility() const;
00285
00286 Matrix<CStokesVector>& modelVisibility();
00287 const Matrix<CStokesVector>& modelVisibility() const;
00288
00289 Matrix<CStokesVector>& correctedVisibility();
00290 const Matrix<CStokesVector>& correctedVisibility() const;
00291
00292 Cube<Complex>& visCube();
00293 const Cube<Complex>& visCube() const;
00294
00295 Cube<Complex>& modelVisCube();
00296
00297 Cube<Complex>& modelVisCube(const Bool & matchVisCubeShape);
00298
00299 const Cube<Complex>& modelVisCube() const;
00300
00301 Cube<Complex>& correctedVisCube();
00302 const Cube<Complex>& correctedVisCube() const;
00303
00304
00305
00306
00307
00308 Cube<Complex>& dataCube(const MS::PredefinedColumns whichcol=MS::DATA);
00309 const Cube<Complex>& dataCube(const MS::PredefinedColumns
00310 whichcol=MS::DATA) const;
00311
00312 Cube<Float>& floatDataCube();
00313 const Cube<Float>& floatDataCube() const;
00314
00315
00316 Vector<Float>& weight();
00317 const Vector<Float>& weight() const;
00318
00319
00320 Matrix<Float>& weightMat();
00321 const Matrix<Float>& weightMat() const;
00322
00323
00324 Bool existsWeightSpectrum() const;
00325
00326 Cube<Float>& weightSpectrum();
00327 const Cube<Float>& weightSpectrum() const;
00328
00329 const Matrix<Float>& imagingWeight() const;
00330 Matrix<Float> & imagingWeight ();
00331
00332 Cube<Float>& weightCube();
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342 Vector<Int> vecIntRange(const MSCalEnums::colDef & calEnum) const;
00343
00344
00345 Vector<Int> antIdRange() const;
00346
00347
00348 Bool timeRange(MEpoch & rTime, MVEpoch & rTimeEP, MVEpoch & rInterval) const;
00349
00350
00351
00352 virtual Vector<uInt>& rowIds();
00353
00354 virtual const Vector<uInt>& rowIds() const;;
00355
00356
00357
00358
00359 void freqAverage();
00360
00361
00362 void freqAveCubes();
00363
00364
00365
00366
00367
00368 void channelAve(const Matrix<Int>& chanavebounds);
00369
00370
00371 template<class T> void chanAveVisCube(Cube<T>& data, Int nChanOut);
00372
00373
00374
00375
00376 template<class T> void chanAccCube(Cube<T>& data, Int nChanOut);
00377
00378
00379
00380
00381 void chanAveFlagCube(Cube<Bool>& flagcube, const Int nChanOut,
00382 const Bool restoreWeightSpectrum = True);
00383
00384
00385
00386 void formStokes();
00387 void formStokesWeightandFlag();
00388 void formStokes(Cube<Complex>& vis);
00389 void formStokes(Cube<Float>& fcube);
00390
00391
00392
00393 void sortCorr();
00394 void unSortCorr();
00395
00396
00397
00398 void normalize(const Bool & phaseOnly = False);
00399
00400
00401 void resetWeightMat();
00402
00403
00404 void phaseCenterShift(Double dx, Double dy);
00405
00406
00407
00408
00409
00410 virtual void updateCoordInfo(const VisBuffer * vb = NULL);
00411
00412
00413
00414 virtual void setVisCube(Complex c);
00415 virtual void setModelVisCube(Complex c);
00416 virtual void setCorrectedVisCube(Complex c);
00417
00418
00419
00420 void setVisCube(const Cube<Complex>& vis);
00421 void setModelVisCube(const Cube<Complex>& vis);
00422 void setCorrectedVisCube(const Cube<Complex>& vis);
00423
00424
00425 void setFloatDataCube(const Cube<Float>& fcube);
00426
00427
00428 void setModelVisCube(const Vector<Float>& stokes);
00429
00430
00431 void refModelVis(const Matrix<CStokesVector>& mvis);
00432
00433
00434 void removeScratchCols();
00435
00436
00437 virtual const ROMSColumns & msColumns() const;
00438
00439 virtual Int numberAnt () const;
00440
00441
00442
00443
00444 virtual void allSelectedSpectralWindows(Vector<Int>& spws, Vector<Int>& nvischan);
00445
00446 void allSelectedSpectralWindows(Vector<Int>& spws, Vector<Int>& nvischan) const;
00447
00448
00449
00450 virtual Int msId() const;
00451
00452
00453 virtual Bool newMS() const;
00454
00455 void wrap (VisBufferAsync * vba);
00456
00457 protected:
00458
00459 virtual Bool checkMSId();
00460 virtual void checkVisIter (const char * func, const char * file, int line) const;
00461 void copyCache (const VisBuffer & other, Bool force);
00462 const VisImagingWeight & getImagingWeightGenerator () const;
00463 Int getOldMsId () const;
00464 ROVisibilityIterator * getVisibilityIterator () const;
00465 VisBufferAsync * releaseVba ();
00466
00467
00468
00469
00470 #undef CacheStatus
00471 #define CacheStatus(item)\
00472 Bool item ## OK () const\
00473 {\
00474 if (wrappedVba_p == NULL){\
00475 throw AipsError ("VisBufferAsyncWrapper: No attached VBA", __FILE__, __LINE__);\
00476 }\
00477 return wrappedVba_p->item ## OK_p;\
00478 }
00479
00480 CacheStatus (antenna1);
00481 CacheStatus (antenna2);
00482 CacheStatus (arrayId);
00483 CacheStatus (channel);
00484 CacheStatus (cjones);
00485 CacheStatus (correctedVisCube);
00486 CacheStatus (correctedVisibility);
00487 CacheStatus (corrType);
00488 CacheStatus (dataDescriptionId);
00489 CacheStatus (direction1);
00490 CacheStatus (direction2);
00491 CacheStatus (exposure);
00492 CacheStatus (feed1_pa);
00493 CacheStatus (feed1);
00494 CacheStatus (feed2_pa);
00495 CacheStatus (feed2);
00496 CacheStatus (fieldId);
00497 CacheStatus (flagCategory);
00498 CacheStatus (flagCube);
00499 CacheStatus (flag);
00500 CacheStatus (flagRow);
00501 CacheStatus (floatDataCube);
00502 CacheStatus (frequency);
00503 CacheStatus (imagingWeight);
00504 CacheStatus (modelVisCube);
00505 CacheStatus (modelVisibility);
00506 CacheStatus (ms);
00507 CacheStatus (nChannel);
00508 CacheStatus (nCorr);
00509 CacheStatus (nRow);
00510 CacheStatus (observationId);
00511 CacheStatus (phaseCenter);
00512 CacheStatus (polFrame);
00513 CacheStatus (processorId);
00514 CacheStatus (rowIds);
00515 CacheStatus (scan);
00516 CacheStatus (sigmaMat);
00517 CacheStatus (sigma);
00518 CacheStatus (spectralWindow);
00519 CacheStatus (stateId);
00520 CacheStatus (timeCentroid);
00521 CacheStatus (timeInterval);
00522 CacheStatus (time);
00523 CacheStatus (uvwMat);
00524 CacheStatus (uvw);
00525 CacheStatus (visCube);
00526 CacheStatus (visibility);
00527 CacheStatus (weightMat);
00528 CacheStatus (weight);
00529 CacheStatus (weightSpectrum);
00530
00531 private:
00532
00533 VisBufferAsync * wrappedVba_p;
00534 ROVisibilityIterator * wrappedVisIterAsync_p;
00535
00536
00537 void validate();
00538 void attachWrappedVb (ROVisibilityIterator * iter);
00539
00540 void setAllCacheStatuses (bool status);
00541
00542
00543 Bool nonCanonCorr();
00544
00545
00546 Vector<Int> unique(const Vector<Int>& indices) const;
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572 Vector<Int>& fillAnt1();
00573 Vector<Int>& fillAnt2();
00574 Int & fillArrayId();
00575
00576 Vector<Int>& fillChannel();
00577 Vector<SquareMatrix<Complex, 2> >& fillCjones();
00578 Vector<Int>& fillCorrType();
00579 virtual Vector<MDirection>& fillDirection1();
00580 virtual Vector<MDirection>& fillDirection2();
00581 Vector<Double>& fillExposure();
00582 Vector<Int>& fillFeed1();
00583 Vector<Float>& fillFeed1_pa();
00584 Vector<Int>& fillFeed2();
00585 Vector<Float>& fillFeed2_pa();
00586 Int & fillFieldId();
00587 Matrix<Bool>& fillFlag();
00588 Array<Bool>& fillFlagCategory();
00589 Cube<Bool>& fillFlagCube();
00590 Vector<Bool> & fillFlagRow();
00591 Cube<Float>& fillFloatDataCube();
00592 Vector<Double>& fillFreq();
00593
00594
00595 Int & fillnChannel();
00596 Int & fillnCorr();
00597 Int & fillnRow();
00598 Vector<Int> & fillObservationId();
00599 virtual MDirection & fillPhaseCenter();
00600 Int & fillPolFrame();
00601 Vector<Int> & fillProcessorId();
00602 Vector<Int> & fillScan();
00603 Vector<Float>& fillSigma();
00604 Matrix<Float>& fillSigmaMat();
00605 Int & fillSpW();
00606 Vector<Int> & fillStateId();
00607 Vector<Double>& fillTime();
00608 Vector<Double>& fillTimeCentroid();
00609 Vector<Double>& fillTimeInterval();
00610 Vector<RigidVector<Double, 3> >& filluvw();
00611 Matrix<Double>& filluvwMat();
00612 Matrix<CStokesVector>& fillVis(VisibilityIterator::DataColumn whichOne);
00613 Cube<Complex>& fillVisCube(VisibilityIterator::DataColumn whichOne);
00614 Vector<Float>& fillWeight();
00615 Matrix<Float>& fillWeightMat();
00616 Cube<Float>& fillWeightSpectrum();
00617
00618 };
00619
00620 }
00621
00622 #endif