MSTransformBufferImpl.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 #ifndef MSTransformBufferImpl_H_
00024 #define MSTransformBufferImpl_H_
00025
00026
00027 #include <msvis/MSVis/VisBufferImpl2.h>
00028
00029
00030 #include <mstransform/MSTransform/MSTransformManager.h>
00031
00032 namespace casa {
00033
00034 class DataCubeHolderBase
00035 {
00036
00037 public:
00038
00039 DataCubeHolderBase() {}
00040 virtual ~DataCubeHolderBase() {}
00041 virtual void setMatrixIndex(uInt matrixIndex) = 0;
00042 virtual void setVectorIndex(uInt vectorIndex) = 0;
00043 uInt getMatrixIndex() {return matrixIndex_p;}
00044 uInt getVectorIndex() {return vectorIndex_p;}
00045 IPosition & getMatrixShape() {return matrixShape_p;}
00046 IPosition & getVectorShape() {return vectorShape_p;}
00047
00048 protected:
00049
00050 uInt matrixIndex_p;
00051 uInt vectorIndex_p;
00052 IPosition matrixShape_p;
00053 IPosition vectorShape_p;
00054 };
00055
00056 template <class T> class DataCubeHolder : public DataCubeHolderBase
00057 {
00058
00059 public:
00060
00061 DataCubeHolder(Cube<T> &dataCube) {cube_p.reference(dataCube);}
00062 ~DataCubeHolder() {}
00063
00064 Matrix<T> & getMatrix() {return matrix_p;}
00065 Vector<T> & getVector() {return vector_p;}
00066
00067 void setMatrixIndex(uInt matrixIndex)
00068 {
00069 matrix_p.resize();
00070 matrixIndex_p = matrixIndex;
00071 matrix_p.reference(cube_p.xyPlane(matrixIndex));
00072 matrixShape_p = matrix_p.shape();
00073 }
00074
00075 void setVectorIndex(uInt vectorIndex)
00076 {
00077 vector_p.resize();
00078 vectorIndex_p = vectorIndex;
00079 vector_p.reference(matrix_p.row(vectorIndex));
00080 vectorShape_p = vector_p.shape();
00081 }
00082
00083 protected:
00084
00085 Cube<T> cube_p;
00086 Matrix<T> matrix_p;
00087 Vector<T> vector_p;
00088 };
00089
00090 class DataCubeMap
00091 {
00092
00093 public:
00094
00095 DataCubeMap() {dataCubeMap_p.clear();}
00096 ~DataCubeMap() {dataCubeMap_p.clear();}
00097
00098 void add(MS::PredefinedColumns key,DataCubeHolderBase* dataCubeHolder){dataCubeMap_p[key] = dataCubeHolder;}
00099
00100 void setWindowShape(IPosition windowShape) {windowShape_p = windowShape;}
00101 IPosition & getWindowShape() {return windowShape_p;}
00102
00103 template <class T> Vector<T> & getVector(MS::PredefinedColumns key)
00104 {
00105 DataCubeHolder<T> *flagCubeHolder = static_cast< DataCubeHolder<T>* >(dataCubeMap_p[key]);
00106 return flagCubeHolder->getVector();
00107 }
00108
00109 template <class T> Matrix<T> & getMatrix(MS::PredefinedColumns key)
00110 {
00111 DataCubeHolder<T> *flagCubeHolder = static_cast< DataCubeHolder<T>* >(dataCubeMap_p[key]);
00112 return flagCubeHolder->getVector();
00113 }
00114
00115 void setMatrixIndex(uInt rowIndex)
00116 {
00117 for (dataCubeMapIter_p = dataCubeMap_p.begin();dataCubeMapIter_p!= dataCubeMap_p.end();dataCubeMapIter_p++)
00118 {
00119 dataCubeMapIter_p->second->setMatrixIndex(rowIndex);
00120 }
00121 }
00122
00123 void setVectorIndex(uInt vectorIndex)
00124 {
00125 for (dataCubeMapIter_p = dataCubeMap_p.begin();dataCubeMapIter_p!= dataCubeMap_p.end();dataCubeMapIter_p++)
00126 {
00127 dataCubeMapIter_p->second->setVectorIndex(vectorIndex);
00128 }
00129 }
00130
00131 IPosition & getMatrixShape()
00132 {
00133 return dataCubeMap_p.begin()->second->getMatrixShape();
00134 }
00135
00136 IPosition & getVectorShape()
00137 {
00138 return dataCubeMap_p.begin()->second->getVectorShape();
00139 }
00140
00141
00142 protected:
00143
00144 IPosition windowShape_p;
00145 std::map<MS::PredefinedColumns, DataCubeHolderBase*> dataCubeMap_p;
00146 std::map<MS::PredefinedColumns, DataCubeHolderBase*>::iterator dataCubeMapIter_p;
00147 };
00148
00149 typedef void (casa::MSTransformBufferImpl::*TransformFunction)( vi::VisBuffer2 *vb,
00150 DataCubeMap &inputDataMap,
00151 DataCubeMap &outputDataMap) const;
00152
00153 typedef void (casa::MSTransformBufferImpl::*TransformKernel)( vi::VisBuffer2 *vb,
00154 DataCubeMap &inputDataMap,
00155 DataCubeMap &outputDataMap,
00156 IPosition &inputPos,
00157 IPosition &outputPos,
00158 IPosition &kernelShape) const;
00159
00160 typedef void (casa::MSTransformBufferImpl::*TransformKernel1D)( vi::VisBuffer2 *vb,
00161 DataCubeMap &inputDataMap,
00162 DataCubeMap &outputDataMap,
00163 uInt &inputPos,
00164 uInt &outputPos,
00165 uInt &kernelSize) const;
00166
00167 class MSTransformBufferImpl : public vi::VisBufferImpl2
00168 {
00169
00170 public:
00171
00172 MSTransformBufferImpl(MSTransformManager *manager);
00173 ~MSTransformBufferImpl() {};
00174
00175 void resetState();
00176 void setRowIdOffset(uInt rowOffset) {rowIdOffset_p = rowOffset;}
00177 void shiftRowIdOffset(Int nRows) {rowIdOffset_p += nRows;}
00178
00179 void generateWeights() const;
00180
00181
00182 const Vector<Int> & dataDescriptionIds () const;
00183 const Vector<Int> & spectralWindows () const;
00184 const Vector<Int> & observationId () const;
00185 const Vector<Int> & arrayId () const;
00186 const Vector<Int> & fieldId () const;
00187 const Vector<Int> & stateId () const;
00188 const Vector<Int> & antenna1 () const;
00189 const Vector<Int> & antenna2 () const;
00190
00191
00192 const Vector<Int> & scan () const;
00193 const Vector<Int> & processorId () const;
00194 const Vector<Int> & feed1 () const;
00195 const Vector<Int> & feed2 () const;
00196 const Vector<Double> & time () const;
00197 const Vector<Double> & timeCentroid () const;
00198 const Vector<Double> & timeInterval () const;
00199
00200
00201 const Vector<Double> & exposure () const;
00202 const Vector<Bool> & flagRow () const;
00203
00204 const Matrix<Double> & uvw () const;
00205 const Matrix<Float> & weight () const;
00206 const Matrix<Float> & sigma () const;
00207 const Cube<Bool> & flagCube () const;
00208 const Cube<Complex> & visCube () const;
00209 const Cube<Complex> & visCubeCorrected () const;
00210 const Cube<Complex> & visCubeModel () const;
00211 const Cube<Float> & visCubeFloat () const;
00212 const Cube<Float> & weightSpectrum () const;
00213 const Cube<Float> & sigmaSpectrum () const;
00214 const Array<Bool> & flagCategory () const;
00215
00216 IPosition getShape () const;
00217 Int nRows () const;
00218 Int nChannels () const;
00219 Int nCorrelations () const;
00220 Int nAntennas () const;
00221
00222
00223 const Vector<Float> & feedPa (Double time) const;
00224 Float parang0(Double time) const;
00225 const Vector<Float> & parang(Double time) const;
00226 MDirection azel0(Double time) const;
00227 const Vector<MDirection> & azel(Double time) const;
00228 Double hourang(Double time) const;
00229
00230 Vector<Int> getCorrelationTypes () const;
00231 const Vector<Int> & correlationTypes () const;
00232 Vector<Stokes::StokesTypes> getCorrelationTypesDefined () const;
00233 Vector<Stokes::StokesTypes> getCorrelationTypesSelected () const;
00234
00235 Double getFrequency (Int rowInBuffer, Int frequencyIndex, Int frame = FrameNotSpecified) const;
00236 const Vector<Double> & getFrequencies (Int rowInBuffer,Int frame = FrameNotSpecified) const;
00237 Int getChannelNumber (Int rowInBuffer, Int frequencyIndex) const;
00238 const Vector<Int> & getChannelNumbers (Int rowInBuffer) const;
00239 Vector<Int> getChannelNumbersSelected (Int outputChannelIndex) const;
00240
00241 const Vector<uInt> & rowIds () const;
00242
00243
00244 void phaseCenterShift(const Vector<Double>& phase);
00245
00246 void phaseCenterShift(Double dx, Double dy);
00247
00248 const MDirection& phaseCenter () const;
00249 const MFrequency::Types & freqRefFrameType () const;
00250
00251 protected:
00252
00253 MFrequency::Convert generateFreqRefTranEngine (Double time,Int outputRefFrame,Bool toObservedFrame) const;
00254
00255 void transformDataCube( vi::VisBuffer2 *vb,
00256 DataCubeMap &inputDataCubeMap,
00257 DataCubeMap &outputDataCubeMap,
00258 TransformFunction funcPointer) const;
00259
00260 void channelAverage( vi::VisBuffer2 *vb,
00261 DataCubeMap &inputDataCubeMap,
00262 DataCubeMap &outputDataCubeMap) const;
00263
00264 void decimationWindow( vi::VisBuffer2 *vb,
00265 DataCubeMap &inputDataCubeMap,
00266 DataCubeMap &outputDataCubeMap,
00267 TransformKernel1D kernelPointer) const;
00268
00269 void flagAverageKernel( vi::VisBuffer2 *vb,
00270 DataCubeMap &inputDataCubeMap,
00271 DataCubeMap &outputDataCubeMap,
00272 uInt &inputPos,
00273 uInt &outputPos,
00274 uInt &kernelSize) const;
00275
00276 private:
00277
00278 MSTransformManager *manager_p;
00279 ArrayColumn<Double> spwFrequencies_p;
00280 map<uInt,uInt> inputOutputSPWIndexMap_p;
00281 uInt rowIdOffset_p;
00282
00283
00284 MDirection phaseCenter_p;
00285 MPosition observatoryPosition_p;
00286 ArrayMeasColumn<MFrequency> spwRefRame_p;
00287
00288
00289 Bool applyPhaseShifting_p;
00290 Double dx_p, dy_p;
00291
00292
00293 Bool noneDataCol_p;
00294
00295 mutable Vector<Int> observationId_p;
00296 mutable Vector<Int> arrayId_p;
00297 mutable Vector<Int> scan_p;
00298 mutable Vector<Int> stateId_p;
00299 mutable Vector<Int> fieldId_p;
00300 mutable Vector<Int> dataDescriptionIds_p;
00301 mutable Vector<Int> spectralWindows_p;
00302 mutable Vector<Int> processorId_p;
00303 mutable Vector<Int> antenna1_p;
00304 mutable Vector<Int> antenna2_p;
00305 mutable Vector<Int> feed1_p;
00306 mutable Vector<Int> feed2_p;
00307 mutable Vector<Bool> flagRow_p;
00308 mutable Vector<Double> time_p;
00309 mutable Vector<Double> timeCentroid_p;
00310 mutable Vector<Double> timeInterval_p;
00311 mutable Vector<Double> exposure_p;
00312 mutable Matrix< Double> uvw_p;
00313 mutable Matrix<Float> weight_p;
00314 mutable Matrix<Float> sigma_p;
00315 mutable Cube<Bool> flagCube_p;
00316 mutable Cube<Complex> visCube_p;
00317 mutable Cube<Complex> visCubeCorrected_p;
00318 mutable Cube<Complex> visCubeModel_p;
00319 mutable Cube<Float> visCubeFloat_p;
00320 mutable Cube<Float> weightSpectrum_p;
00321 mutable Cube<Float> sigmaSpectrum_p;
00322 mutable Array<Bool> flagCategory_p;
00323 mutable Vector<Float> feedPa_p;
00324 mutable Vector<Float> parang_p;
00325 mutable Vector<MDirection> azel_p;
00326 mutable Vector<Double> frequencies_p;
00327 mutable Vector<Int> channelNumbers_p;
00328 mutable map< Int,Vector<Int> > outputInputChannelMap_p;
00329 mutable Vector<uInt> rowIds_p;
00330 mutable IPosition shape_p;
00331 mutable uInt nRows_p;
00332 mutable uInt nChannels_p;
00333 mutable uInt nCorrelations_p;
00334 mutable uInt nAntennas_p;
00335 mutable MFrequency::Types freqRefFrameType_p;
00336
00337 mutable Bool observationIdOk_p;
00338 mutable Bool arrayIdOk_p;
00339 mutable Bool scanOk_p;
00340 mutable Bool stateIdOk_p;
00341 mutable Bool fieldIdOk_p;
00342 mutable Bool dataDescIdOk_p;
00343 mutable Bool spectralWindowsOk_p;
00344 mutable Bool processorIdOk_p;
00345 mutable Bool antenna1Ok_p;
00346 mutable Bool antenna2Ok_p;
00347 mutable Bool feed1Ok_p;
00348 mutable Bool feed2Ok_p;
00349 mutable Bool flagRowOk_p;
00350 mutable Bool timeOk_p;
00351 mutable Bool timeCentroidOk_p;
00352 mutable Bool timeIntervalOk_p;
00353 mutable Bool exposureOk_p;
00354 mutable Bool uvwOk_p;
00355 mutable Bool weightOk_p;
00356 mutable Bool sigmaOk_p;
00357 mutable Bool flagCubeOk_p;
00358 mutable Bool visCubeOk_p;
00359 mutable Bool visCubeCorrectedOk_p;
00360 mutable Bool visCubeModelOk_p;
00361 mutable Bool visCubeFloatOk_p;
00362 mutable Bool weightSpectrumOk_p;
00363 mutable Bool sigmaSpectrumOk_p;
00364 mutable Bool flagCategoryOk_p;
00365 mutable Bool feedPaOk_p;
00366 mutable Bool parangOk_p;
00367 mutable Bool azelOk_p;
00368 mutable Bool frequenciesOk_p;
00369 mutable Bool channelNumbersOk_p;
00370 mutable Bool channelNumbersSelectedOk_p;
00371 mutable Bool rowIdsOk_p;
00372 mutable Bool shapeOk_p;
00373 mutable Bool nRowsOk_p;
00374 mutable Bool nChannelsOk_p;
00375 mutable Bool nCorrelationsOk_p;
00376 mutable Bool nAntennasOk_p;
00377 mutable Bool freqRefFrameTypeOk_p;
00378
00379 mutable Bool observationIdTransformed_p;
00380 mutable Bool arrayIdTransformed_p;
00381 mutable Bool scanTransformed_p;
00382 mutable Bool stateIdTransformed_p;
00383 mutable Bool fieldIdTransformed_p;
00384 mutable Bool dataDescIdTransformed_p;
00385 mutable Bool spectralWindowsTransformed_p;
00386 mutable Bool processorIdTransformed_p;
00387 mutable Bool antenna1Transformed_p;
00388 mutable Bool antenna2Transformed_p;
00389 mutable Bool feed1Transformed_p;
00390 mutable Bool feed2Transformed_p;
00391 mutable Bool flagRowTransformed_p;
00392 mutable Bool uvwTransformed_p;
00393 mutable Bool weightTransformed_p;
00394 mutable Bool sigmaTransformed_p;
00395 mutable Bool timeTransformed_p;
00396 mutable Bool timeCentroidTransformed_p;
00397 mutable Bool timeIntervalTransformed_p;
00398 mutable Bool exposureTransformed_p;
00399 mutable Bool feedPaTransformed_p;
00400 mutable Bool parangTransformed_p;
00401 mutable Bool azelTransformed_p;
00402 mutable Bool frequenciesTransformed_p;
00403 mutable Bool channelNumbersTransformed_p;
00404 mutable Bool rowIdsTransformed_p;
00405
00406 };
00407
00408 }
00409
00410
00411 #endif
00412