casa
$Rev:20696$
|
00001 //# WBCleanImageSkyModel.h: Definition for WBCleanImageSkyModel 00002 //# Copyright (C) 1996,1997,1998,1999,2000 00003 //# Associated Universities, Inc. Washington DC, USA. 00004 //# 00005 //# This library is free software; you can redistribute it and/or modify it 00006 //# under the terms of the GNU Library General Public License as published by 00007 //# the Free Software Foundation; either version 2 of the License, or (at your 00008 //# option) any later version. 00009 //# 00010 //# This library is distributed in the hope that it will be useful, but WITHOUT 00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00013 //# License for more details. 00014 //# 00015 //# You should have received a copy of the GNU Library General Public License 00016 //# along with this library; if not, write to the Free Software Foundation, 00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00018 //# 00019 //# Correspondence concerning AIPS++ should be adressed as follows: 00020 //# Internet email: aips2-request@nrao.edu. 00021 //# Postal address: AIPS++ Project Office 00022 //# National Radio Astronomy Observatory 00023 //# 520 Edgemont Road 00024 //# Charlottesville, VA 22903-2475 USA 00025 //# 00026 //# 00027 //# $Id$ 00028 00029 #ifndef SYNTHESIS_WBCLEANIMAGESKYMODEL_H 00030 #define SYNTHESIS_WBCLEANIMAGESKYMODEL_H 00031 00032 #include <synthesis/MeasurementComponents/CleanImageSkyModel.h> 00033 #include <lattices/Lattices/LatticeCleanProgress.h> 00034 #include <lattices/Lattices/LatticeExprNode.h> 00035 #include <lattices/Lattices/LatticeIterator.h> 00036 #include <synthesis/MeasurementEquations/MultiTermMatrixCleaner.h> 00037 #include <casa/OS/Timer.h> 00038 00039 namespace casa { //# NAMESPACE CASA - BEGIN 00040 00041 //forward 00042 class SkyEquation; 00043 00044 // <summary> 00045 // WB Clean Image Sky Model: Image Sky Model implementing a Wide-Band 00046 // multi frequency synthesis algorithm 00047 // </summary> 00048 00049 // <use visibility=export> 00050 00051 // <reviewed reviewer="" date="" tests="" demos=""> 00052 00053 // <prerequisite> 00054 // <li> <linkto class=LatticeCleaner>LatticeCleaner</linkto> module 00055 // <li> <linkto class=ImageSkyModel>ImageSkyModel</linkto> module 00056 // <li> <linkto class=LinearModel>LinearModel</linkto> module 00057 // </prerequisite> 00058 // 00059 // <etymology> 00060 // WBCleanImageSkyModel implements the Wide Band Clean algorithm. 00061 // It is derived from <linkto class=SkyModel>SkyModel</linkto>. 00062 // </etymology> 00063 // 00064 // <synopsis> 00065 // The WB Clean is the multi-frequency synthesis deconvolution 00066 // algorithm. It decomposes an image into a linear compbination 00067 // of models convolved with spectral dirty beams of various 00068 // order. A multiscale variant can be invoked by supplying a 00069 // user vector of scale sizes. Default is 1, corresponding to a 00070 // scale insensitive mfs deconvolution. 00071 // 00072 // Masking is optionally performed using a mask image: only points 00073 // where the mask is non-zero are searched for Gaussian components. 00074 // This can cause some difficulty, as the different Gaussian scale 00075 // sizes will extend beyond the mask by different amounts. 00076 // If no mask is specified 00077 // all points in the inner quarter of the image are cleaned. 00078 // </synopsis> 00079 // 00080 // <example> 00081 // See the example for <linkto class=SkyModel>SkyModel</linkto>. 00082 // </example> 00083 // 00084 // <motivation> 00085 // </motivation> 00086 // 00087 // <todo asof="99/04/07"> 00088 // <ul> Improve the masking. 00089 // </todo> 00090 00091 class WBCleanImageSkyModel : public CleanImageSkyModel { 00092 public: 00093 00094 // Create a WBCleanImageSkyModel - default scale size = 1 pixel 00095 WBCleanImageSkyModel(); 00096 WBCleanImageSkyModel(const Int ntaylor,const Int nscales,const Double reffreq); 00097 WBCleanImageSkyModel(const Int ntaylor,const Vector<Float>& userScaleSizes, const Double reffreq); 00098 00099 // destructor 00100 ~WBCleanImageSkyModel(); 00101 00102 // Solve for this SkyModel 00103 Bool solve (SkyEquation& se); 00104 // Bool copyLatToImInt(TempLattice<Float>& lat, ImageInterface<Float>& im); 00105 // Bool copyImIntToLat(TempLattice<Float>& lat, ImageInterface<Float>& im); 00106 00107 // Int nmodels_p; // Number of image models = nfields * ntaylor 00108 Int ntaylor_p; // Number of terms in the Taylor expansion to use. 00109 // Int nfields_p; // Number of image fields/pointings. 00110 Int nscales_p; // Number of scales to use for the multiscale part. 00111 00112 Double refFrequency_p; 00113 00114 // Int add(ImageInterface<Float>& iimage, const Int maxNumXfr=100); 00115 // Bool addResidual(Int thismodel, ImageInterface<Float>& iresidual); 00116 // void initializeGradients(); 00117 Bool solveResiduals(SkyEquation& se, Bool modelToMS=False); 00118 Bool makeNewtonRaphsonStep(SkyEquation& se, Bool incremental=False, Bool modelToMS=False); 00119 00120 Int numberOfTaylorTerms(){return ntaylor_p;}; 00121 Double getReferenceFrequency(){return refFrequency_p;}; 00122 00123 // Major axis for ordering : Taylor 00124 Int getModelIndex(uInt model, uInt taylor){return taylor * (nfields_p) + (model);}; 00125 Int getTaylorIndex(uInt index){return Int(index/nfields_p);}; 00126 Int getFieldIndex(uInt index){return index%nfields_p;}; 00127 00128 Bool calculateCoeffResiduals(); 00129 Bool calculateAlphaBeta(const Vector<String> &restoredNames, 00130 const Vector<String> &residualNames); 00131 00132 // Major axis for ordering : Models 00133 //inline Int getModelIndex(uInt model, uInt taylor){return model * (ntaylor_p) + (taylor);}; 00134 //inline Int getPSFModelIndex(uInt model, uInt taylor){return model * (2*ntaylor_p-1) + (taylor);}; 00135 //inline Int getTaylorIndex(uInt index){return index%ntaylor_p;}; 00136 //inline Int getFieldIndex(uInt index){return index/ntaylor_p;}; 00137 00138 Vector<String> imageNames; 00139 00140 private: 00141 00142 // PtrBlock<MultiTermLatticeCleaner<Float>* > lc_p; 00143 Block<MultiTermMatrixCleaner> lc_p; 00144 00145 Vector<Float> scaleSizes_p; // Vector of scale sizes in pixels. 00146 Vector<Float> scaleBias_p; // Vector of scale biases !! 00147 Float maxPsf_p; 00148 00149 IPosition gip,imshape; 00150 Bool donePSF_p; 00151 Bool doneMTMCinit_p; 00152 Int nx,ny; 00153 00154 Int numbermajorcycles_p; 00155 Float previous_maxresidual_p; 00156 00157 // Memory to be allocated per TempLattice 00158 Double memoryMB_p; 00159 00160 LogIO os; 00161 00162 void initVars(); 00163 Bool checkParameters(); 00164 00165 Int storeAsImg(String fileName, ImageInterface<Float>& theImg); 00166 //Int storeTLAsImg(String fileName, TempLattice<Float> &TL, ImageInterface<Float>& theImg); 00167 //Int storeTLAsImg(String fileName, TempLattice<Complex> &TL, ImageInterface<Float>& theImg); 00168 00169 Bool mergeDataError(ImageInterface<Float> &data, ImageInterface<Float> &error, const String &outImg); 00170 00171 Bool createMask(LatticeExpr<Bool> &lemask, ImageInterface<Float> &outimage); 00172 00173 Bool resizeWorkArrays(Int length); 00174 00175 Int makeSpectralPSFs(SkyEquation& se, Bool writeToDisk); 00176 //Int addTo(Lattice<Float>& to, const Lattice<Float>& add, Float multiplier); 00177 Int writeResultsToDisk(); 00178 Float computeFluxLimit(Float &fractionOfPsf); 00179 00180 void blankOverlappingModels(); 00181 void restoreOverlappingModels(); 00182 00183 Float saveCurrentModels(); 00184 00185 Timer tmr1,tmr2; 00186 Int adbg; 00187 Int tdbg; 00188 Int ddbg; 00189 // Put in some progress metre here... 00190 00191 00192 }; 00193 00194 00195 } //# NAMESPACE CASA - END 00196 00197 #endif 00198 00199