FreqAxisTVI.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 FreqAxisTVI_H_
00024 #define FreqAxisTVI_H_
00025
00026
00027 #include <msvis/MSVis/TransformingVi2.h>
00028
00029
00030 #include <msvis/MSVis/VisBuffer2.h>
00031 #include <msvis/MSVis/VisibilityIterator2.h>
00032
00033
00034 #include <mstransform/TVI/UtilsTVI.h>
00035
00036
00037 #include <casacore/ms/MSSel/MSSelection.h>
00038
00039
00040
00041
00042 namespace casa {
00043
00044 namespace vi {
00045
00047
00049
00050 template<class T> class FreqAxisTransformEngine;
00051 template<class T> class FreqAxisTransformEngine2;
00052
00053 class FreqAxisTVI : public TransformingVi2
00054 {
00055
00056 public:
00057
00058
00059 FreqAxisTVI(ViImplementation2 * inputVii,const Record &configuration);
00060 ~FreqAxisTVI();
00061
00062
00063 virtual void origin ();
00064 virtual void next ();
00065
00066
00067 Bool existsColumn (VisBufferComponent2 id) const;
00068 Bool flagCategoryExists () const {return False;}
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082 void writeFlagRow (const Vector<Bool> & flag);
00083 Vector<Int> getChannels ( Double time, Int frameOfReference,
00084 Int spectralWindowId, Int msId) const;
00085 void flagRow (Vector<Bool> & flagRow) const;
00086 void weight (Matrix<Float> & weight) const;
00087 void sigma (Matrix<Float> & sigma) const;
00088
00089 protected:
00090
00091
00092 template <class T> void transformFreqAxis( Cube<T> const &inputDataCube,
00093 Cube<T> &outputDataCube,
00094 FreqAxisTransformEngine<T> &transformer) const
00095 {
00096
00097 outputDataCube.resize(getVisBufferConst()->getShape(),False);
00098
00099
00100 const IPosition &inputShape = inputDataCube.shape();
00101 uInt nRows = inputShape(2);
00102 uInt nCorrs = inputShape(0);
00103
00104
00105 Matrix<T> inputDataPlane;
00106 Matrix<T> outputDataPlane;
00107
00108
00109 Vector<T> inputDataVector;
00110 Vector<T> outputDataVector;
00111
00112 for (uInt row=0; row < nRows; row++)
00113 {
00114
00115 transformer.setRowIndex(row);
00116 inputDataPlane.reference(inputDataCube.xyPlane(row));
00117 outputDataPlane.reference(outputDataCube.xyPlane(row));
00118
00119 for (uInt corr=0; corr < nCorrs; corr++)
00120 {
00121
00122 transformer.setCorrIndex(corr);
00123 inputDataVector.reference(inputDataPlane.row(corr));
00124 outputDataVector.reference(outputDataPlane.row(corr));
00125
00126
00127 transformer.transform(inputDataVector,outputDataVector);
00128 }
00129 }
00130
00131 return;
00132 }
00133
00134
00135 template <class T> void transformFreqAxis2( const IPosition &inputShape,
00136 FreqAxisTransformEngine2<T> &transformer,
00137 Int parallelCorrAxis=-1) const
00138 {
00139 uInt nRows = inputShape(2);
00140 if (parallelCorrAxis >= 0)
00141 {
00142 for (uInt row=0; row < nRows; row++)
00143 {
00144 transformer.setRowIndex(row);
00145 transformer.setCorrIndex(parallelCorrAxis);
00146 transformer.transform();
00147 }
00148 }
00149 else
00150 {
00151 uInt nCorrs = inputShape(0);
00152 for (uInt row=0; row < nRows; row++)
00153 {
00154 transformer.setRowIndex(row);
00155
00156 for (uInt corr=0; corr < nCorrs; corr++)
00157 {
00158 transformer.setCorrIndex(corr);
00159
00160
00161 VisBuffer2 *vb = getVii()->getVisBuffer();
00162 if (vb->rowIds()(row)==0 and corr==0)
00163 {
00164 transformer.setDebug(True);
00165 }
00166 else
00167 {
00168 transformer.setDebug(False);
00169 }
00170
00171 transformer.transform();
00172 }
00173 }
00174 }
00175
00176 return;
00177 }
00178
00179 Bool parseConfiguration(const Record &configuration);
00180 void initialize();
00181
00182
00183 void formSelectedChanMap();
00184
00185 String spwSelection_p;
00186 mutable LogIO logger_p;
00187 mutable map<Int,uInt > spwOutChanNumMap_p;
00188 mutable map<Int,vector<Int> > spwInpChanIdxMap_p;
00189 };
00190
00192
00194
00195 template<class T> class FreqAxisTransformEngine
00196 {
00197
00198 public:
00199
00200 virtual void transform( Vector<T> &,Vector<T> &) {};
00201 virtual void setRowIndex(uInt row) {row_p = row;}
00202 virtual void setCorrIndex(uInt corr) {corr_p = corr;}
00203
00204 protected:
00205
00206 uInt row_p;
00207 uInt corr_p;
00208
00209 };
00210
00212
00214
00215 template<class T> class FreqAxisTransformEngine2
00216 {
00217
00218 public:
00219
00220 FreqAxisTransformEngine2(DataCubeMap *inputData,DataCubeMap *outputData)
00221 {
00222 debug_p = False;
00223 inputData_p = inputData;
00224 outputData_p = outputData;
00225 }
00226
00227 void setRowIndex(uInt row)
00228 {
00229 rowIndex_p = row;
00230 inputData_p->setMatrixIndex(row);
00231 outputData_p->setMatrixIndex(row);
00232
00233 return;
00234 }
00235
00236 void setCorrIndex(uInt corr)
00237 {
00238 corrIndex_p = corr;
00239 inputData_p->setVectorIndex(corr);
00240 outputData_p->setVectorIndex(corr);
00241
00242 return;
00243 }
00244
00245 void setDebug(Bool debug) { debug_p = debug;}
00246
00247 virtual void transform() {}
00248
00249 protected:
00250
00251 Bool debug_p;
00252 uInt rowIndex_p;
00253 uInt corrIndex_p;
00254 DataCubeMap *inputData_p;
00255 DataCubeMap *outputData_p;
00256
00257 };
00258
00259 }
00260
00261 }
00262
00263 #endif
00264