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 #ifndef SYNTHESIS_DECONVOLVER_H
00030 #define SYNTHESIS_DECONVOLVER_H
00031
00032 #include <casa/aips.h>
00033 #include <casa/Arrays/IPosition.h>
00034 #include <casa/Quanta/Quantum.h>
00035 #include <measures/Measures/MDirection.h>
00036 #include <measures/Measures/MPosition.h>
00037 #include <measures/Measures/MRadialVelocity.h>
00038 #include <lattices/LatticeMath/LatticeCleaner.h>
00039 #include <scimath/Mathematics/GaussianBeam.h>
00040
00041 #include <synthesis/MeasurementEquations/MultiTermMatrixCleaner.h>
00042
00043 #include <casa/namespace.h>
00044 namespace casa {
00045 template<class T> class Lattice;
00046 template<class T> class PagedImage;
00047 template<class T> class TempImage;
00048 template<class T> class ImageInterface;
00049 template<class T> class LatticeConvolver;
00050 template<class T> class ResidualEquation;
00051 template<class T> class SubImage;
00052
00053
00054 class File;
00055 class CEMemModel;
00056 class ClarkCleanLatModel;
00057 class LatConvEquation;
00058 class ImageMSCleaner;
00059 class ImageNACleaner;
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128 class Deconvolver
00129 {
00130 public:
00131
00132 Deconvolver();
00133
00134 Deconvolver(const String& dirty, const String& psf);
00135
00136 Deconvolver(const Deconvolver &other);
00137 Deconvolver &operator=(const Deconvolver &other);
00138 ~Deconvolver();
00139
00140
00141
00142
00143 Bool open(const String& dirty, const String& psf, Bool warn=True);
00144
00145
00146
00147
00148
00149 Bool reopen();
00150
00151
00152
00153 Bool close();
00154
00155 String dirtyname() const;
00156 String psfname() const;
00157
00158
00159 Bool summary() const;
00160
00161
00162 String state() const;
00163
00164
00165 IPosition imageshape() const;
00166
00167
00168 Bool restore(const String& model,
00169 const String& image, GaussianBeam& mbeam);
00170
00171
00172 Bool residual(const String& model,
00173 const String& image);
00174
00175
00176 Bool smooth(const String& model,
00177 const String& image,
00178 GaussianBeam& mbeam,
00179 Bool normalizeVolume);
00180
00181
00182
00183 Bool clean(const String& algorithm,
00184 const Int niter, const Float gain, const Quantity& threshold,
00185 const Bool displayProgress,
00186 const String& model, const String& mask, Float& maxResidual,
00187 Int& iterationsDone );
00188 Bool naclean(const Int niter,
00189 const Float gain, const Quantity& threshold,
00190 const String& model, const String& mask, const Int masksupp, const Int memoryType, const Float numSigma, Float& maxResidual, Int& iterationsDone) ;
00191
00192
00193
00194
00195 Bool clarkclean(const Int niter,
00196 const Float gain, const Quantity& threshold,
00197 const String& model, const String& maskName,
00198 Float& maxresid, Int& iterused,
00199 Float cycleFactor=1.5);
00200
00201
00202 Bool clarkclean(const Int niter,
00203 const Float gain, const Quantity& threshold,
00204 const Bool displayProgress,
00205 const String& model, const String& mask,
00206 const Int histBins,
00207 const Vector<Int>& psfPatchSize, const Float maxExtPsf,
00208 const Float speedUp, Int maxNumPix,
00209 const Int maxNumMajorCycles,
00210 const Int maxNumMinorIterations);
00211
00212
00213
00214 Bool mem(const String& algorithm,
00215 const Int niter, const Quantity& sigma,
00216 const Quantity& targetFlux,
00217 Bool constrainTargetFlux,
00218 Bool displayprogress,
00219 const String& model,
00220 const String& prior = "",
00221 const String& mask = "",
00222 const Bool imagePlane = False);
00223
00224
00225 Bool makeprior(const String& prior,
00226 const String& templateImage,
00227 const Quantity& lowClipfrom,
00228 const Quantity& lowClipto,
00229 const Quantity& highClipfrom,
00230 const Quantity& highClipto,
00231 const Vector<Int>& blc,
00232 const Vector<Int>& trc);
00233
00234
00235
00236
00237 Bool setscales(const String& scaleMethod, const Int nscales,
00238 const Vector<Float>& userScaleSizes);
00239
00240
00241 Bool nnls(const String& algorithm, const Int niter, const Float tolerance,
00242 const String& model,
00243 const String& fluxMask, const String& dataMask);
00244
00245
00246 Bool ft(const String& model, const String& transform);
00247
00248
00249 Bool make(const String& model);
00250
00251
00252 Bool make1(const String& imagename);
00253
00254
00255 Bool make(const String& model, ImageInterface<Float>& templateImage);
00256
00257
00258 Bool boxmask(const String& boxmask,
00259 const Vector<Int> blc,
00260 const Vector<Int> trc,
00261 const Quantity& fillValue=1.0,
00262 const Quantity& externalValue=0.0);
00263
00264
00265 Bool regionmask(const String& maskimage, Record* imageRegRec,
00266 Matrix<Quantity>& blctrcs, const Float& value=1.0);
00267
00268
00269 Bool clipimage(const String& clippedImage, const String& inputImage,
00270 const Quantity& threshold);
00271
00272
00273 Bool fitpsf(const String& psf, GaussianBeam& beam);
00274
00275
00276 Bool convolve(const String& convolvedmodel,
00277 const String& model);
00278
00279
00280 Bool makegaussian(const String& gaussianimage, GaussianBeam& mbeam, Bool normalizeVolume);
00281
00282
00283
00284 Bool mtopen(const Int nTaylor,
00285 const Vector<Float>& userScaleSizes,
00286 const Vector<String>& psfs);
00287
00288
00289 Bool mtclean(const Vector<String>& residuals,
00290 const Vector<String>& models,
00291 const Int niter,
00292 const Float gain,
00293 const Quantity& threshold,
00294 const Bool displayProgress,
00295 const String& mask,
00296 Float& maxResidual, Int& iterationsDone);
00297
00298
00299 Bool mtrestore(const Vector<String>& models,
00300 const Vector<String>& residuals,
00301 const Vector<String>& images,
00302 GaussianBeam& mbeam);
00303
00304
00305 Bool mtcalcpowerlaw(const Vector<String>& images,
00306 const Vector<String>& residuals,
00307 const String& alphaname,
00308 const String& betaname,
00309 const Quantity& threshold,
00310 const Bool calcerror);
00311
00312
00313
00314
00315
00316 private:
00317
00318
00319 SubImage<Float>* innerQuarter(PagedImage<Float>& in);
00320
00321
00322 SubImage<Float>* allQuarters(PagedImage<Float>& in);
00323
00324
00325 Bool clone(const String& imageName, const String& newImageName);
00326
00327
00328
00329 void findAxes();
00330
00331
00332
00333 void checkMask(ImageInterface<Float>& maskimage, Int& xbeg, Int& xend,
00334 Int& ybeg, Int& yend);
00335
00336
00337
00338 Bool setupLatCleaner(const String& algorithm,
00339 const Int niter, const Float gain, const Quantity& threshold,
00340 const Bool displayProgress);
00341
00342
00343 Bool createMask(LatticeExpr<Bool> &lemask, ImageInterface<Float> &outimage);
00344
00345 Bool putGaussian(ImageInterface<Float>& im, const GaussianBeam& beam);
00346 PagedImage<Float>* dirty_p;
00347 PagedImage<Float>* psf_p;
00348
00349 LatticeConvolver<Float>* convolver_p;
00350 ResidualEquation<Lattice<Float> >* residEqn_p;
00351 LatConvEquation* latConvEqn_p;
00352 CountedPtr <ImageMSCleaner> cleaner_p;
00353 std::shared_ptr <ImageNACleaner> naCleaner_p;
00354
00355 Bool scalesValid_p;
00356
00357 Int nx_p, ny_p, npol_p, nchan_p;
00358 Int chanAxis_p, polAxis_p;
00359 String mode_p;
00360 GaussianBeam beam_p;
00361
00362 Bool beamValid_p;
00363 String dirtyName_p;
00364 String psfName_p;
00365 Bool fullPlane_p;
00366
00367 Vector<Float> itsTotalFluxScale;
00368 Float itsTotalFlux;
00369 Vector<Float> scaleSizes_p;
00370
00371
00372 Int mt_nterms_p;
00373 MultiTermMatrixCleaner mt_cleaner_p;
00374 Bool mt_valid_p;
00375
00376
00377 void defaults();
00378
00379 Bool removeTable(const String& tablename);
00380
00381
00382 Bool detached() const;
00383
00384 String imageName() const;
00385
00386 Bool valid() const;
00387
00388 };
00389
00390 }
00391
00392 #endif