MultiTermLatticeCleaner.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
00029
00030 #ifndef LATTICES_MULTITERMLATTICECLEANER_H
00031 #define LATTICES_MULTITERMLATTICECLEANER_H
00032
00033 #include <casacore/casa/aips.h>
00034 #include <casacore/lattices/LatticeMath/LatticeCleaner.h>
00035 #include <casacore/lattices/Lattices/LatticeIterator.h>
00036 #include <casacore/lattices/LEL/LatticeExpr.h>
00037 #include <casacore/lattices/LEL/LatticeExprNode.h>
00038
00039 namespace casacore {
00040
00041 template<class T> class MultiTermLatticeCleaner : public LatticeCleaner<T>
00042 {
00043 public:
00044
00045 MultiTermLatticeCleaner();
00046
00047
00048 MultiTermLatticeCleaner(const MultiTermLatticeCleaner<T> & other);
00049
00050
00051 MultiTermLatticeCleaner<T> & operator=(const MultiTermLatticeCleaner<T> & other);
00052
00053
00054 ~MultiTermLatticeCleaner();
00055
00056
00057
00058 Bool setntaylorterms(const int & nterms);
00059
00060
00061 Bool setscales(const Vector<Float> & scales);
00062
00063
00064 Bool initialise(Int nx,Int ny);
00065
00066
00067 Bool setcontrol(CleanEnums::CleanType cleanType,const Int niter,const Float gain,const Quantity& aThreshold,const Bool choose);
00068
00069
00070
00071 Bool setcontrol(CleanEnums::CleanType cleanType, const Int niter,
00072 const Float gain, const Quantity& aThreshold,
00073 const Quantity& ,
00074 const Bool choose=True)
00075 { return setcontrol (cleanType, niter, gain, aThreshold, choose); }
00076
00077
00078 Bool setpsf(int order, Lattice<T> & psf);
00079
00080
00081 Bool setresidual(int order, Lattice<T> & dirty);
00082
00083
00084 Bool setmodel(int order, Lattice<T> & model);
00085
00086
00087 Bool setmask(Lattice<T> & mask);
00088
00089
00090 Int mtclean(LatticeCleanProgress* progress=0);
00091
00092
00093 Bool getmodel(int order, Lattice<T> & model);
00094
00095
00096 Bool getresidual(int order, Lattice<T> & residual);
00097
00098
00099 Bool getinvhessian(Matrix<Double> & invhessian);
00100
00101 private:
00102 LogIO os;
00103
00104 using LatticeCleaner<T>::itsCleanType;
00105 using LatticeCleaner<T>::itsMaxNiter;
00106 using LatticeCleaner<T>::itsGain;
00107 using LatticeCleaner<T>::itsThreshold;
00108 using LatticeCleaner<T>::itsMask;
00109 using LatticeCleaner<T>::itsPositionPeakPsf;
00110
00111 using LatticeCleaner<T>::findMaxAbsLattice;
00112 using LatticeCleaner<T>::findMaxAbsMaskLattice;
00113 using LatticeCleaner<T>::makeScale;
00114 using LatticeCleaner<T>::addTo;
00115 using LatticeCleaner<T>::makeBoxesSameSize;
00116 using LatticeCleaner<T>::validatePsf;
00117
00118 Int ntaylor_p;
00119 Int psfntaylor_p;
00120 Int nscales_p;
00121 Int nx_p;
00122 Int ny_p;
00123 Int totalIters_p;
00124
00125
00126 TempLattice<Float>* dirty_p;
00127 TempLattice<Complex>* dirtyFT_p;
00128 TempLattice<Float>* mask_p;
00129 TempLattice<Float>* fftmask_p;
00130
00131 Vector<Float> scaleSizes_p;
00132 Vector<Float> scaleBias_p;
00133 Vector<Float> totalScaleFlux_p;
00134 Vector<Float> totalTaylorFlux_p;
00135 Float weightScaleFactor_p;
00136 Float maxPsf_p;
00137
00138 IPosition gip,imshape;
00139 Int nx,ny,npol_p,nchan;
00140 Bool donePSF_p,donePSP_p,doneCONV_p;
00141
00142
00143 PtrBlock<TempLattice<Float>* > vecScales_p;
00144 PtrBlock<TempLattice<Complex>* > vecScalesFT_p;
00145
00146
00147 PtrBlock<TempLattice<Float>* > vecPsf_p;
00148 PtrBlock<TempLattice<Complex>* > vecPsfFT_p;
00149
00150
00151 PtrBlock<TempLattice<Float>* > vecDirty_p;
00152
00153
00154 PtrBlock<TempLattice<Float>* > vecModel_p;
00155
00156
00157
00158 PtrBlock<TempLattice<Float>* > cubeA_p;
00159 PtrBlock<LatticeIterator<Float>* > itercubeA_p;
00160
00161
00162 PtrBlock<TempLattice<Float>* > matR_p;
00163 PtrBlock<LatticeIterator<Float>* > itermatR_p;
00164
00165
00166 PtrBlock<TempLattice<Float>* > matCoeffs_p;
00167 PtrBlock<LatticeIterator<Float>* > itermatCoeffs_p;
00168
00169
00170 Double memoryMB_p;
00171
00172
00173
00174 PtrBlock<Matrix<Double>*> matA_p;
00175 PtrBlock<Matrix<Double>*> invMatA_p;
00176
00177
00178 TempLattice<Complex>* cWork_p;
00179 TempLattice<Float>* tWork_p;
00180 LatticeIterator<Float>* itertWork_p;
00181
00182 LatticeExprNode len_p;
00183
00184 Float lambda_p;
00185
00186 Int numberOfTempLattices(Int nscales,Int ntaylor);
00187 Int manageMemory(Bool allocate);
00188
00189 Bool findMaxAbsLattice(const TempLattice<Float>& masklat,const Lattice<Float>& lattice,Float& maxAbs,IPosition& posMaxAbs, Bool flip=False);
00190 Int addTo(Lattice<Float>& to, const Lattice<Float>& add, Float multiplier);
00191
00192 Int setupFFTMask();
00193 Int setupUserMask();
00194 Int setupBlobs();
00195 Int computeFluxLimit(Float &fluxlimit, Float threshold);
00196 Int computeMatrixA();
00197 Int computeRHS();
00198 Int solveMatrixEqn(Int scale);
00199 Int computePenaltyFunction(Int scale, Float &loopgain, Bool choosespec);
00200 Int updateSolution(IPosition globalmaxpos, Int maxscaleindex, Float loopgain);
00201 Int checkConvergence(Bool choosespec, Float thresh, Float fluxlimit);
00202
00203 Int IND2(Int taylor,Int scale);
00204 Int IND4(Int taylor1, Int taylor2, Int scale1, Int scale2);
00205
00206 Bool adbg;
00207 };
00208
00209 }
00210
00211 #ifndef CASACORE_NO_AUTO_TEMPLATES
00212 #include <casacore/lattices/LatticeMath/MultiTermLatticeCleaner.tcc>
00213 #endif //# CASACORE_NO_AUTO_TEMPLATES
00214 #endif
00215