MultiTermMatrixCleaner.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 #ifndef SYNTHESIS_MULTITERMLATTICECLEANER_H
00029 #define SYNTHESIS_MULTITERMLATTICECLEANER_H
00030
00031 #include <scimath/Mathematics/FFTServer.h>
00032 #include <synthesis/MeasurementEquations/MatrixCleaner.h>
00033
00034 namespace casa {
00035
00036 class MultiTermMatrixCleaner : public MatrixCleaner
00037 {
00038 public:
00039
00040 MultiTermMatrixCleaner();
00041
00042
00043
00044
00045
00046
00047
00048
00049 ~MultiTermMatrixCleaner();
00050
00051
00052
00053 Bool setntaylorterms(const int & nterms);
00054
00055
00056 Bool setscales(const Vector<Float> & scales);
00057
00058
00059 Bool initialise(Int nx,Int ny);
00060
00061
00062
00063 Int computeHessianPeak();
00064
00065
00066 Bool setpsf(int order, Matrix<Float> & psf);
00067
00068
00069 Bool setresidual(int order, Matrix<Float> & dirty);
00070
00071
00072 Bool setmodel(int order, Matrix<Float> & model);
00073
00074
00075 Bool setmask(Matrix<Float> & mask);
00076
00077
00078 Int mtclean(Int maxniter, Float stopfraction, Float inputgain, Float userthreshold);
00079
00080
00081 Bool getmodel(int order, Matrix<Float> & model);
00082
00083
00084 Bool getresidual(int order, Matrix<Float> & residual);
00085
00086
00087 Bool computeprincipalsolution();
00088
00089
00090 Bool getinvhessian(Matrix<Double> & invhessian);
00091
00092
00093 Float getpeakresidual(){return rmaxval_p;}
00094
00095
00096 private:
00097 LogIO os;
00098
00099 using MatrixCleaner::itsCleanType;
00100 using MatrixCleaner::itsMaxNiter;
00101 using MatrixCleaner::itsGain;
00102 using MatrixCleaner::itsThreshold;
00103 using MatrixCleaner::itsMask;
00104 using MatrixCleaner::itsPositionPeakPsf;
00105
00106
00107
00108
00109 using MatrixCleaner::itsMaskThreshold;
00110
00111 using MatrixCleaner::findMaxAbs;
00112 using MatrixCleaner::findMaxAbsMask;
00113 using MatrixCleaner::makeScale;
00114
00115 using MatrixCleaner::makeBoxesSameSize;
00116 using MatrixCleaner::validatePsf;
00117
00118
00119 Int ntaylor_p;
00120 Int psfntaylor_p;
00121 Int nscales_p;
00122 Int nx_p;
00123 Int ny_p;
00124 Int totalIters_p;
00125 Float globalmaxval_p;
00126 Int maxscaleindex_p;
00127 IPosition globalmaxpos_p;
00128 Int itercount_p;
00129 Int maxniter_p;
00130 Float stopfraction_p;
00131 Float inputgain_p;
00132 Float userthreshold_p;
00133 Float prev_max_p;
00134 Float min_max_p;
00135 Float rmaxval_p;
00136
00137 IPosition psfsupport_p;
00138 IPosition psfpeak_p;
00139 IPosition blc_p, trc_p, blcPsf_p, trcPsf_p;
00140
00141 Vector<Float> scaleSizes_p;
00142 Vector<Float> scaleBias_p;
00143 Vector<Float> totalScaleFlux_p;
00144 Vector<Float> totalTaylorFlux_p;
00145 Vector<Float> maxScaleVal_p;
00146 Vector<IPosition> maxScalePos_p;
00147
00148 IPosition gip;
00149 Int nx,ny;
00150 Bool donePSF_p,donePSP_p,doneCONV_p;
00151
00152 Matrix<Complex> dirtyFT_p;
00153 Block<Matrix<Float> > vecScaleMasks_p;
00154
00155 Matrix<Complex> cWork_p;
00156 Block<Matrix<Float> > vecWork_p;
00157
00158
00159 Block<Matrix<Float> > vecScales_p;
00160 Block<Matrix<Complex> > vecScalesFT_p;
00161
00162
00163
00164 Block<Matrix<Complex> > vecPsfFT_p;
00165
00166
00167 Block<Matrix<Float> > vecDirty_p;
00168
00169
00170 Block<Matrix<Float> > vecModel_p;
00171
00172
00173
00174
00175 Block<Matrix<Float> > cubeA_p;
00176
00177
00178 Block<Matrix<Float> > matR_p;
00179
00180
00181 Block<Matrix<Float> > matCoeffs_p;
00182
00183
00184 Double memoryMB_p;
00185
00186
00187
00188 Block<Matrix<Double> > matA_p;
00189 Block<Matrix<Double> > invMatA_p;
00190
00191
00192 FFTServer<Float,Complex> fftcomplex;
00193
00194
00195 Int verifyScaleSizes();
00196 Int allocateMemory();
00197 Int setupScaleFunctions();
00198
00199
00200 Int setupUserMask();
00201 Int computeFluxLimit(Float &fluxlimit, Float threshold);
00202 Int computeRHS();
00203
00204
00205 Int solveMatrixEqn(Int ntaylor,Int scale, IPosition blc, IPosition trc);
00206 Int chooseComponent(Int ntaylor,Int scale, Int criterion, IPosition blc, IPosition trc);
00207 Int updateModelAndRHS(Float loopgain);
00208 Int updateRHS(Int ntaylor, Int scale, Float loopgain,Vector<Float> coeffs, IPosition blc, IPosition trc, IPosition blcPsf, IPosition trcPsf);
00209 Int checkConvergence(Int updatetype, Float &fluxlimit, Float &loopgain);
00210 Bool buildImagePatches();
00211
00212
00213 Int writeMatrixToDisk(String imagename, Matrix<Float> &themat);
00214 Int IND2(Int taylor,Int scale);
00215 Int IND4(Int taylor1, Int taylor2, Int scale1, Int scale2);
00216
00217 Bool adbg;
00218 };
00219
00220 }
00221
00222 #endif
00223