00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef UVContSubTVI_H_
00024 #define UVContSubTVI_H_
00025
00026
00027 #include <mstransform/TVI/FreqAxisTVI.h>
00028
00029
00030 #include <scimath/Fitting/LinearFitSVD.h>
00031 #include <scimath/Functionals/Polynomial.h>
00032 #include <mstransform/TVI/DenoisingLib.h>
00033
00034
00035 #ifdef _OPENMP
00036 #include <omp.h>
00037 #endif
00038
00039
00040 namespace casa {
00041
00042 namespace vi {
00043
00045
00047
00048 class UVContSubTVI : public FreqAxisTVI
00049 {
00050
00051 public:
00052
00053 UVContSubTVI( ViImplementation2 * inputVii,
00054 const Record &configuration);
00055
00056 ~UVContSubTVI();
00057
00058
00059 virtual String ViiType() const { return String("UVContSub( ")+getVii()->ViiType()+" )"; };
00060
00061 virtual void floatData (Cube<Float> & vis) const;
00062 virtual void visibilityObserved (Cube<Complex> & vis) const;
00063 virtual void visibilityCorrected (Cube<Complex> & vis) const;
00064 virtual void visibilityModel (Cube<Complex> & vis) const;
00065
00066 protected:
00067
00068 Bool parseConfiguration(const Record &configuration);
00069 void initialize();
00070
00071 template<class T> void transformDataCube( const Cube<T> &inputVis,
00072 const Cube<Float> &inputWeight,
00073 Cube<T> &outputVis) const;
00074
00075 template<class T> void transformDataCore( denoising::GslPolynomialModel<Double>* model,
00076 Vector<Bool> *lineFreeChannelMask,
00077 const Cube<T> &inputVis,
00078 const Cube<Bool> &inputFlags,
00079 const Cube<Float> &inputWeight,
00080 Cube<T> &outputVis,
00081 Int parallelCorrAxis=-1) const;
00082
00083 mutable uInt fitOrder_p;
00084 mutable Bool want_cont_p;
00085 mutable Bool gsl_p;
00086 mutable String fitspw_p;
00087 mutable map<Int,Vector<Bool> > lineFreeChannelMaskMap_p;
00088 mutable map<Int, denoising::GslPolynomialModel<Double>* > inputFrequencyMap_p;
00089 };
00090
00092
00094
00095 class UVContSubTVIFactory : public ViFactory
00096 {
00097
00098 public:
00099
00100 UVContSubTVIFactory(Record &configuration,ViImplementation2 *inputVII);
00101
00102 protected:
00103
00104 vi::ViImplementation2 * createVi (VisibilityIterator2 *) const;
00105 vi::ViImplementation2 * createVi () const;
00106
00107 Record configuration_p;
00108 ViImplementation2 *inputVii_p;
00109 };
00110
00112
00114
00115 class UVContSubTVILayerFactory : public ViiLayerFactory
00116 {
00117
00118 public:
00119
00120 UVContSubTVILayerFactory(Record &configuration);
00121 virtual ~UVContSubTVILayerFactory() {};
00122
00123 protected:
00124
00125 ViImplementation2 * createInstance(ViImplementation2* vii0) const;
00126
00127 Record configuration_p;
00128
00129 };
00130
00132
00134
00135 template<class T> class UVContSubKernel;
00136
00137 template<class T> class UVContSubTransformEngine : public FreqAxisTransformEngine2<T>
00138 {
00139 using FreqAxisTransformEngine2<T>::inputData_p;
00140 using FreqAxisTransformEngine2<T>::outputData_p;
00141 using FreqAxisTransformEngine2<T>::debug_p;
00142
00143 public:
00144
00145 UVContSubTransformEngine( UVContSubKernel<T> *kernel,
00146 DataCubeMap *inputData,
00147 DataCubeMap *outputData );
00148
00149 void transform();
00150
00151 void transformCore(DataCubeMap *inputData,DataCubeMap *outputData);
00152
00153 protected:
00154
00155
00156
00157
00158 UVContSubKernel<T> *uvContSubKernel_p;
00159 };
00160
00162
00164
00165 template<class T> class UVContSubKernel
00166 {
00167
00168 public:
00169
00170 UVContSubKernel( denoising::GslPolynomialModel<Double>* model,
00171 Vector<Bool> *lineFreeChannelMask);
00172
00173 virtual void kernel(DataCubeMap *inputData,
00174 DataCubeMap *outputData);
00175
00176 virtual void changeFitOrder(size_t order) = 0;
00177
00178 virtual void defaultKernel( Vector<T> &inputVector,
00179 Vector<T> &outputVector) = 0;
00180
00181 virtual void kernelCore(Vector<T> &inputVector,
00182 Vector<Bool> &inputFlags,
00183 Vector<Float> &inputWeights,
00184 Vector<T> &outputVector) = 0;
00185
00186 void setDebug(Bool debug) { debug_p = debug;}
00187
00188 protected:
00189
00190 Bool debug_p;
00191 size_t fitOrder_p;
00192 denoising::GslPolynomialModel<Double> *model_p;
00193 Matrix<Double> freqPows_p;
00194 Vector<Float> frequencies_p;
00195 Vector<Bool> *lineFreeChannelMask_p;
00196 };
00197
00199
00201
00202 template<class T> class UVContSubtractionKernel : public UVContSubKernel<T>
00203 {
00204 using UVContSubKernel<T>::fitOrder_p;
00205 using UVContSubKernel<T>::model_p;
00206 using UVContSubKernel<T>::freqPows_p;
00207 using UVContSubKernel<T>::frequencies_p;
00208 using UVContSubKernel<T>::lineFreeChannelMask_p;
00209 using UVContSubKernel<T>::debug_p;
00210
00211
00212 public:
00213
00214 UVContSubtractionKernel( denoising::GslPolynomialModel<Double>* model,
00215 Vector<Bool> *lineFreeChannelMask=NULL);
00216
00217 void changeFitOrder(size_t order);
00218
00219 void defaultKernel( Vector<Complex> &inputVector,
00220 Vector<Complex> &outputVector);
00221
00222 void defaultKernel( Vector<Float> &inputVector,
00223 Vector<Float> &outputVector);
00224
00225 void kernelCore( Vector<Complex> &inputVector,
00226 Vector<Bool> &inputFlags,
00227 Vector<Float> &inputWeights,
00228 Vector<Complex> &outputVector);
00229
00230 void kernelCore( Vector<Float> &inputVector,
00231 Vector<Bool> &inputFlags,
00232 Vector<Float> &inputWeights,
00233 Vector<Float> &outputVector);
00234
00235 private:
00236
00237 LinearFitSVD<Float> fitter_p;
00238 };
00239
00241
00243
00244 template<class T> class UVContEstimationKernel : public UVContSubKernel<T>
00245 {
00246
00247 using UVContSubKernel<T>::fitOrder_p;
00248 using UVContSubKernel<T>::model_p;
00249 using UVContSubKernel<T>::freqPows_p;
00250 using UVContSubKernel<T>::frequencies_p;
00251 using UVContSubKernel<T>::lineFreeChannelMask_p;
00252 using UVContSubKernel<T>::debug_p;
00253
00254 public:
00255
00256 UVContEstimationKernel( denoising::GslPolynomialModel<Double>* model,
00257 Vector<Bool> *lineFreeChannelMask=NULL);
00258
00259 void changeFitOrder(size_t order);
00260
00261 void defaultKernel( Vector<Complex> &inputVector,
00262 Vector<Complex> &outputVector);
00263
00264 void defaultKernel( Vector<Float> &inputVector,
00265 Vector<Float> &outputVector);
00266
00267 void kernelCore( Vector<Complex> &inputVector,
00268 Vector<Bool> &inputFlags,
00269 Vector<Float> &inputWeights,
00270 Vector<Complex> &outputVector);
00271
00272 void kernelCore( Vector<Float> &inputVector,
00273 Vector<Bool> &inputFlags,
00274 Vector<Float> &inputWeights,
00275 Vector<Float> &outputVector);
00276 private:
00277
00278 LinearFitSVD<Float> fitter_p;
00279 };
00280
00282
00284
00285 template<class T> class UVContSubtractionGSLKernel : public UVContSubKernel<T>
00286 {
00287 using UVContSubKernel<T>::fitOrder_p;
00288 using UVContSubKernel<T>::model_p;
00289 using UVContSubKernel<T>::freqPows_p;
00290 using UVContSubKernel<T>::frequencies_p;
00291 using UVContSubKernel<T>::lineFreeChannelMask_p;
00292 using UVContSubKernel<T>::debug_p;
00293
00294
00295 public:
00296
00297 UVContSubtractionGSLKernel( denoising::GslPolynomialModel<Double>* model,
00298 Vector<Bool> *lineFreeChannelMask=NULL);
00299
00300 void changeFitOrder(size_t order);
00301
00302 void defaultKernel( Vector<T> &inputVector,
00303 Vector<T> &outputVector);
00304
00305 void kernelCore( Vector<T> &inputVector,
00306 Vector<Bool> &inputFlags,
00307 Vector<Float> &inputWeights,
00308 Vector<T> &outputVector);
00309
00310 private:
00311
00312 denoising::GslMultifitWeightedLinear fitter_p;
00313 };
00314
00316
00318
00319 template<class T> class UVContEstimationGSLKernel : public UVContSubKernel<T>
00320 {
00321
00322 using UVContSubKernel<T>::fitOrder_p;
00323 using UVContSubKernel<T>::model_p;
00324 using UVContSubKernel<T>::freqPows_p;
00325 using UVContSubKernel<T>::frequencies_p;
00326 using UVContSubKernel<T>::lineFreeChannelMask_p;
00327 using UVContSubKernel<T>::debug_p;
00328
00329 public:
00330
00331 UVContEstimationGSLKernel( denoising::GslPolynomialModel<Double>* model,
00332 Vector<Bool> *lineFreeChannelMask=NULL);
00333
00334 void changeFitOrder(size_t order);
00335
00336 void defaultKernel( Vector<T> &inputVector,
00337 Vector<T> &outputVector);
00338
00339 void kernelCore( Vector<T> &inputVector,
00340 Vector<Bool> &inputFlags,
00341 Vector<Float> &inputWeights,
00342 Vector<T> &outputVector);
00343
00344 private:
00345
00346 denoising::GslMultifitWeightedLinear fitter_p;
00347 };
00348
00349
00350
00351 }
00352
00353 }
00354
00355 #endif
00356