00001
00002
00003
00004
00005
00006
00007
00008 #if ! defined (VisibilityIteratorAsync_H_)
00009 #define VisibilityIteratorAsync_H_
00010
00011 #include <set>
00012 using std::set;
00013
00014 #include <msvis/MSVis/VisibilityIteratorImpl.h>
00015 #include <msvis/MSVis/AsynchronousInterface.h>
00016 #include "UtilJ.h"
00017
00018 #define NotImplementedROVIA throw utilj::AipsErrorTrace (String ("Method not legal in ROVIA: ") + __PRETTY_FUNCTION__, __FILE__, __LINE__)
00019 #define NotPrefetched throw utilj::AipsErrorTrace (String ("Column not prefetched for async I/O: ") + __PRETTY_FUNCTION__, __FILE__, __LINE__)
00020
00021 namespace casa {
00022
00023
00024 class VisBufferAsync;
00025 class VisBufferAsyncWrapper;
00026
00027 namespace asyncio {
00028
00029 class AsynchronousInterface;
00030 class VlaDatum;
00031 class VlaData;
00032 class VLAT;
00033
00034 }
00035
00036 class ViReadImplAsync : public VisibilityIteratorReadImpl {
00037
00038
00039
00040 friend class Rovia_Test;
00041 friend class ROVisIterator;
00042 friend class VisIterator;
00043 friend class ViWriteImplAsync;
00044
00045 public:
00046
00047 typedef casa::asyncio::PrefetchColumns PrefetchColumns;
00048
00049
00050
00051
00052
00053
00054 ViReadImplAsync (const Block<MeasurementSet> & mss,
00055 const PrefetchColumns & prefetchColumns,
00056 const Block<Int> & sortColumns,
00057 const Bool addDefaultSortCols,
00058 Double timeInterval,
00059 Bool writable);
00060
00061 ViReadImplAsync (const PrefetchColumns & prefetchColumns,
00062 const VisibilityIteratorReadImpl & other,
00063 Bool writable);
00064
00065
00066 ~ViReadImplAsync ();
00067
00068 VisibilityIteratorReadImpl * clone () const;
00069
00070 void attachVisBuffer (VisBuffer & vb);
00071 void detachVisBuffer (VisBuffer & vb);
00072 void getChannelSelection(Block< Vector<Int> >& ,
00073 Block< Vector<Int> >& ,
00074 Block< Vector<Int> >& ,
00075 Block< Vector<Int> >& ,
00076 Block< Vector<Int> >& );
00077 PrefetchColumns getPrefetchColumns () const;
00078 VisBuffer * getVisBuffer ();
00079
00080
00081
00082
00083
00084
00085 MEpoch getEpoch () const;
00086
00087
00089
00090 bool more () const;
00091 bool moreChunks () const;
00092 ViReadImplAsync & nextChunk ();
00093 void origin ();
00094 void originChunks ();
00095 virtual void advance ();
00096
00097 void setPrefetchColumns (const PrefetchColumns & prefetchColumns);
00098
00099 VisibilityIteratorReadImpl& selectChannel(Int nGroup=1,
00100 Int start=0,
00101 Int width=0,
00102 Int increment=1,
00103 Int spectralWindow=-1);
00104
00105 VisibilityIteratorReadImpl& selectChannel(const Block< Vector<Int> >& blockNGroup,
00106 const Block< Vector<Int> >& blockStart,
00107 const Block< Vector<Int> >& blockWidth,
00108 const Block< Vector<Int> >& blockIncr,
00109 const Block< Vector<Int> >& blockSpw);
00110
00111
00112 VisibilityIteratorReadImpl&
00113 selectVelocity(Int ,
00114 const MVRadialVelocity& ,
00115 const MVRadialVelocity& ,
00116 MRadialVelocity::Types ,
00117 MDoppler::Types , Bool );
00118 void setInterval(Double timeInterval);
00119 void setRowBlocking(Int nRow);
00120
00121
00122
00123
00124
00125 static int getDefaultNBuffers ();
00126
00127
00128
00129
00130
00131
00132
00133
00134 Bool allBeamOffsetsZero() const;
00135 void allSelectedSpectralWindows(Vector<Int>& , Vector<Int>& ) { NotPrefetched; }
00136 Vector<Int>& antenna1(Vector<Int>& ) const { NotPrefetched; }
00137 Vector<Int>& antenna2(Vector<Int>& ) const { NotPrefetched; }
00138 const Vector<String>& antennaMounts() const;
00139 Vector<MDirection> azel(Double ) const { NotImplementedROVIA; }
00140 MDirection azel0(Double ) const { NotImplementedROVIA; }
00141 Vector<Int>& channel(Vector<Int>& ) const { NotPrefetched; }
00142 Int channelGroupSize() const { NotImplementedROVIA; }
00143 Int channelIndex() const { NotImplementedROVIA; }
00144 Vector<SquareMatrix<Complex,2> >& CJones(Vector<SquareMatrix<Complex,2> >& ) const { NotPrefetched; }
00145 Vector<Int>& corrType(Vector<Int>& ) const { NotPrefetched; }
00146 Int dataDescriptionId() const { NotPrefetched; }
00147 Bool existsWeightSpectrum() const { NotImplementedROVIA; }
00148 Vector<Double>& exposure(Vector<Double>& ) const { NotPrefetched; }
00149 Vector<Int>& feed1(Vector<Int>& ) const { NotPrefetched; }
00150 Vector<Int>& feed2(Vector<Int>& ) const { NotPrefetched; }
00151
00152 Int fieldId() const { NotPrefetched; }
00153 Array<Bool>& flagCategory(Array<Bool>& ) const { NotPrefetched; }
00154 Cube<Float>& floatData(Cube<Float>& ) const { NotPrefetched; }
00155 void getFloatDataColumn (Cube<Float>& ) const { NotImplementedROVIA; }
00156 void getFloatDataColumn(const Slicer& , Cube<Float>& ) const { NotImplementedROVIA; }
00157 void getInterpolatedFloatDataFlagWeight() const { NotImplementedROVIA; }
00158 void getInterpolatedVisFlagWeight(DataColumn ) const { NotImplementedROVIA; }
00159 Int arrayId() const { NotPrefetched; }
00160 String fieldName() const { NotImplementedROVIA; }
00161 String sourceName() const { NotImplementedROVIA; }
00162 Cube<Bool>& flag(Cube<Bool>& ) const { NotPrefetched; }
00163 Matrix<Bool>& flag(Matrix<Bool>& ) const { NotPrefetched; }
00164 Vector<Bool>& flagRow(Vector<Bool>& ) const { NotPrefetched; }
00165 Vector<Double>& frequency(Vector<Double>& ) const { NotPrefetched; }
00166 const Cube<RigidVector<Double, 2> >& getBeamOffsets() const;
00167 Int getDataDescriptionId () const { NotPrefetched; }
00168 MEpoch getMEpoch () const { NotImplementedROVIA; }
00169 const MeasurementSet & getMeasurementSet() const { NotImplementedROVIA; }
00170 Int getMeasurementSetId() const { NotImplementedROVIA; }
00171 Int getNAntennas () const { NotImplementedROVIA; }
00172 Vector<Float> getReceptor0Angle () { NotImplementedROVIA; }
00173 Vector<uInt> getRowIds () const { NotImplementedROVIA; }
00174 Double hourang(Double ) const { NotImplementedROVIA; }
00175 Vector<Double>& lsrFrequency(Vector<Double>& ) const { NotImplementedROVIA; }
00176 void lsrFrequency(const Int& , Vector<Double>& , Bool& ) { NotImplementedROVIA; }
00177 const MeasurementSet& ms() const { NotImplementedROVIA; }
00178 const ROMSColumns& msColumns() const;
00179 Int msId() const;
00180 Int nCorr() const { NotPrefetched; }
00181 Int nRow() const { NotPrefetched; }
00182 Int nRowChunk() const;
00183 Int nSubInterval() const { NotImplementedROVIA; }
00184 Bool newArrayId() const { NotImplementedROVIA; }
00185 Bool newFieldId() const { NotImplementedROVIA; }
00186 Bool newMS() const { return msIter_p.more();}
00187 Bool newSpectralWindow() const { NotImplementedROVIA; }
00188 Int numberCoh() { NotPrefetched; }
00189 Int numberDDId() { NotPrefetched; }
00190 Int numberPol() { NotPrefetched; }
00191 Int numberSpw();
00192 Vector<Int>& observationId(Vector<Int>& ) const { NotPrefetched; }
00193 Vector<Float> parang(Double ) const { NotImplementedROVIA; }
00194 const Float& parang0(Double ) const { NotImplementedROVIA; }
00195 const MDirection& phaseCenter() const { NotPrefetched; }
00196 Int polFrame() const { NotPrefetched; }
00197 Vector<Int>& processorId(Vector<Int>& ) const { NotPrefetched; }
00198 Int polarizationId() const { NotPrefetched; }
00199 const Cube<Double>& receptorAngles() const;
00200 Vector<uInt>& rowIds(Vector<uInt>& ) const { NotImplementedROVIA; }
00201 Vector<Int>& scan(Vector<Int>& ) const { NotPrefetched; }
00202 Vector<Float>& sigma(Vector<Float>& ) const { NotPrefetched; }
00203 Matrix<Float>& sigmaMat(Matrix<Float>& ) const { NotPrefetched; }
00204 void slurp() const { NotImplementedROVIA; }
00205 Int spectralWindow() const { NotPrefetched; }
00206 Vector<Int>& stateId(Vector<Int>& ) const { NotPrefetched; }
00207 Vector<Double>& time(Vector<Double>& ) const { NotPrefetched; }
00208 Vector<Double>& timeCentroid(Vector<Double>& ) const { NotPrefetched; }
00209 Vector<Double>& timeInterval(Vector<Double>& ) const { NotPrefetched; }
00210 Vector<RigidVector<Double,3> >& uvw(Vector<RigidVector<Double,3> >& ) const { NotPrefetched; }
00211 Matrix<Double>& uvwMat(Matrix<Double>& ) const { NotPrefetched; }
00212 VisibilityIteratorReadImpl& velInterpolation(const String& ) { NotImplementedROVIA; }
00213 Cube<Complex>& visibility(Cube<Complex>& , DataColumn ) const { NotPrefetched; }
00214 Matrix<CStokesVector>& visibility(Matrix<CStokesVector>& , DataColumn ) const { NotPrefetched; }
00215 IPosition visibilityShape() const { NotImplementedROVIA; }
00216 Vector<Float>& weight(Vector<Float>& ) const { NotPrefetched; }
00217 Matrix<Float>& weightMat(Matrix<Float>& ) const { NotPrefetched; }
00218 Cube<Float>& weightSpectrum(Cube<Float>& ) const { NotPrefetched; }
00219
00220 static String prefetchColumnName (Int id);
00221
00222 protected:
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248 ViReadImplAsync (const ROVisibilityIterator & rovi,
00249 const PrefetchColumns & prefetchColumns,
00250 Int nReadAheadBuffers = -1);
00251
00252 PrefetchColumns augmentPrefetchColumns (const PrefetchColumns & prefetchColumnsBase);
00253 void construct(const Block<MeasurementSet> & mss,
00254 const PrefetchColumns & prefetchColumns,
00255 const Block<Int> & sortColumns,
00256 const Bool addDefaultSortCols,
00257 Double timeInterval,
00258 Bool writable);
00259
00260
00261 void fillVisBuffer();
00262 const MeasurementSet & getMs() const;
00263 void readComplete ();
00264 void saveMss (const Block<MeasurementSet> & mss);
00265 void saveMss (const MeasurementSet & ms);
00266
00267
00268 private:
00269
00270 asyncio::AsynchronousInterface * interface_p;
00271 Int msId_p;
00272 PrefetchColumns prefetchColumns_p;
00273 Stack<VisBufferAsyncWrapper *> vbaWrapperStack_p;
00274 VisBufferAsync * visBufferAsync_p;
00275 asyncio::VlaData * vlaData_p;
00276 asyncio::VLAT * vlat_p;
00277
00278 void dumpPrefetchColumns () const;
00279 void updateMsd ();
00280
00281 ViReadImplAsync (const ViReadImplAsync & MSI);
00282 ViReadImplAsync & operator=(const ViReadImplAsync &MSI);
00283
00284 };
00285
00286 namespace asyncio {
00287 class WriteData;
00288 }
00289
00290 class ViWriteImplAsync : public VisibilityIteratorWriteImpl {
00291
00292 public:
00293
00294 typedef casa::asyncio::PrefetchColumns PrefetchColumns;
00295
00296 ViWriteImplAsync (VisibilityIterator * vi);
00297 ViWriteImplAsync (const PrefetchColumns & prefetchColumns,
00298 const VisibilityIteratorWriteImpl & other,
00299 VisibilityIterator * vi);
00300
00301 ~ViWriteImplAsync ();
00302
00303 VisibilityIteratorWriteImpl * clone () const;
00304
00305 void putModel(const RecordInterface& rec, Bool iscomponentlist=True, Bool incremental=False);
00306
00307
00308
00309
00310
00311
00312 void setFlag(const Matrix<Bool>& flag);
00313
00314
00315
00316
00317 void setFlag(const Cube<Bool>& flag);
00318
00319 void setFlagCategory (const Array<Bool> & flagCategory);
00320
00321
00322 void setFlagRow(const Vector<Bool>& rowflags);
00323
00324
00325
00326
00327
00328
00329 void setVis(const Matrix<CStokesVector>& vis, DataColumn whichOne);
00330
00331
00332 void setVis(const Cube<Complex>& vis, DataColumn whichOne);
00333
00334 void setVisAndFlag(const Cube<Complex>& vis, const Cube<Bool>& flag,
00335 DataColumn whichOne);
00336
00337 void setWeight(const Vector<Float>& wt);
00338
00339 void setWeightMat(const Matrix<Float>& wtmat);
00340
00341 void setWeightSpectrum(const Cube<Float>& wtsp);
00342
00343 void setSigma(const Vector<Float>& sig);
00344
00345 void setSigmaMat(const Matrix<Float>& sigmat);
00346
00347 protected:
00348
00349 ViReadImplAsync * getReadImpl();
00350 void queueWriteData (const asyncio::WriteData & data);
00351
00352 private:
00353
00354
00355 };
00356
00357
00358 typedef ViReadImplAsync ROVIA;
00359
00360 }
00361
00362 #endif // ViReadImplAsync