casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ImageMSCleaner.h
Go to the documentation of this file.
1 //# ImageMSCleaner.h: this defines Cleaner a class for doing convolution
2 //# Copyright (C) 1996,1997,1998,1999,2000,2001,2002,2003
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //#
27 //# $Id: $
28 
29 #ifndef SYNTHESIS_IMAGEMSCLEANER_H
30 #define SYNTHESIS_IMAGEMSCLEANER_H
31 
32 //# Includes
34 
35 namespace casacore{
36 
37 template <class T> class Matrix;
38 template <class T> class ImageInterface;
39 }
40 
41 namespace casa { //# NAMESPACE CASA - BEGIN
42 
43 //# Forward Declarations
44 
45 
46 
47 // <summary>A class interfacing images to MatrixCleaner </summary>
48 
49 // <use visibility=export>
50 
51 // <reviewed reviewer="" date="yyyy/mm/dd" tests="tLatticeCleaner">
52 // </reviewed>
53 
54 // <prerequisite>
55 // <li> ImageInterface
56 // <li> MatrixCleaner
57 // </prerequisite>
58 //
59 // <etymology>
60 
61 // The ImageCleaner class will use MSClean on Images.
62 
63 // </etymology>
64 //
65 // <synopsis>
66 // This class will perform various types of Clean deconvolution
67 // on Lattices.
68 //
69 // </synopsis>
70 //
71 // <example>
72 // <srcblock>
73 // </srcblock>
74 // </example>
75 //
76 // <motivation>
77 // </motivation>
78 //
79 // <thrown>
80 // <li> casacore::AipsError: if psf has more dimensions than the model.
81 // </thrown>
82 //
83 
85 
86 {
87 
88  public:
89  //Default
91  // Create a cleaner with a psf and dirty image
93  //assignmemnt constructor
94  ImageMSCleaner(const ImageMSCleaner& other);
95  //assignment operator
96  ImageMSCleaner & operator=(const ImageMSCleaner & other);
97 
98  //The destructor
100 
101  // Update the dirty image only
103  // Change the psf image
105 
107  void setscales(const casacore::Int nscales, const casacore::Float scaleInc=1.0);
108  // Set a specific set of scales
109  void setscales(const casacore::Vector<casacore::Float> & scales);
110 
111  // Set up control parameters
112  // cleanType - type of the cleaning algorithm to use (HOGBOM, MULTISCALE)
113  // niter - number of iterations
114  // gain - loop gain used in cleaning (a fraction of the maximum
115  // subtracted at every iteration)
116  // aThreshold - absolute threshold to stop iterations
117  // fThreshold - fractional threshold (i.e. given w.r.t. maximum residual)
118  // to stop iterations. This parameter is specified as
119  // casacore::Quantity so it can be given in per cents.
121  const casacore::Float gain, const casacore::Quantity& aThreshold,
122  const casacore::Quantity& fThreshold);
123 
124  // This version of the method disables stopping on fractional threshold
126  const casacore::Float gain, const casacore::Quantity& threshold);
127 
128  // return how many iterations we did do
129  casacore::Int iteration() const ;
131 
132  // what iteration number to start on
133  void startingIteration(const casacore::Int starting = 0);
134 
135  // Clean an image.
136  //return value gives you a hint of what's happening
137  // 1 = converged
138  // 0 = not converged but behaving normally
139  // -1 = not converged and stopped on cleaning consecutive smallest scale
140  // -2 = not converged and either large scale hit negative or diverging
141  // -3 = clean is diverging rather than converging
143  const casacore::Int niter, const casacore::Float gain, const casacore::Quantity& threshold,
144  const casacore::Quantity& fthresh=casacore::Quantity(0.0, "%"),
145  casacore::Bool doPlotProgress=false);
146  // Set the mask
147  // mask - input mask lattice
148  // maskThreshold - if positive, the value is treated as a threshold value to determine
149  // whether a pixel is good (mask value is greater than the threshold) or has to be
150  // masked (mask value is below the threshold). Negative threshold switches mask clipping
151  // off. The mask value is used to weight the flux during cleaning. This mode is used
152  // to implement cleaning based on the signal-to-noise as opposed to the standard cleaning
153  // based on the flux. The default threshold value is 0.9, which ensures the behavior of the
154  // code is exactly the same as before this parameter has been introduced.
155  void setMask(casacore::ImageInterface<casacore::Float> & mask, const casacore::Float& maskThreshold = 0.9);
156  // Tell the algorithm to NOT clean just the inner quarter
157  // (This is useful when multiscale clean is being used
158  // inside a major cycle for MF or WF algorithms)
159  // if true, the full image deconvolution will be attempted
160  void ignoreCenterBox(casacore::Bool ign) ;
161  // Consider the case of a point source:
162  // the flux on all scales is the same, and the first scale will be chosen.
163  // Now, consider the case of a point source with a *little* bit of extended structure:
164  // thats right, the largest scale will be chosen. In this case, we should provide some
165  // bias towards the small scales, or against the large scales. We do this in
166  // an ad hoc manner, multiplying the maxima found at each scale by
167  // 1.0 - itsSmallScaleBias * itsScaleSizes(scale)/itsScaleSizes(nScalesToClean-1);
168  // Typical bias values range from 0.2 to 1.0.
169  void setSmallScaleBias(const casacore::Float x=0.5);
170  // During early iterations of a cycled casacore::MS Clean in mosaicing, it common
171  // to come across an ocsilatory pattern going between positive and
172  // negative in the large scale. If this is set, we stop at the first
173  // negative in the largest scale.
174  void stopAtLargeScaleNegative() ;
175  // Some algorithms require that the cycles be terminated when the image
176  // is dominated by point sources; if we get nStopPointMode of the
177  // smallest scale components in a row, we terminate the cycles
178  void stopPointMode(casacore::Int nStopPointMode) ;
179  // After completion of cycle, querry this to find out if we stopped because
180  // of stopPointMode
182  // speedup() will speed the clean iteration by raising the
183  // threshold. This may be required if the threshold is
184  // accidentally set too low (ie, lower than can be achieved
185  // given errors in the approximate PSF).
186  //
187  // threshold(iteration) = threshold(0)
188  // * ( exp( (iteration - startingiteration)/Ndouble )/ 2.718 )
189  // If speedup() is NOT invoked, no effect on threshold
190  void speedup(const casacore::Float Ndouble);
191 
192  //Max residual after last clean
194 
195  private:
196  //Helper function to setup some param
197  casacore::Bool setupMatCleaner(const casacore::String& alg, const casacore::Int niter, const casacore::Float gain,
198  const casacore::Quantity& threshold, const casacore::Quantity& fthresh=casacore::Quantity(0.0, "%"));
214 
215 };
216 
217 } //# NAMESPACE CASA - END
218 
219 #endif
int Int
Definition: aipstype.h:50
casacore::Bool queryStopPointMode() const
After completion of cycle, querry this to find out if we stopped because of stopPointMode.
ImageMSCleaner & operator=(const ImageMSCleaner &other)
assignment operator
void stopAtLargeScaleNegative()
During early iterations of a cycled casacore::MS Clean in mosaicing, it common to come across an ocsi...
casacore::ImageInterface< casacore::Float > * psf_p
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
A class interfacing images to MatrixCleaner.
MatrixCleaner matClean_p
casacore::Float maxResidual()
Max residual after last clean.
casacore::Int iteration() const
return how many iterations we did do
void ignoreCenterBox(casacore::Bool ign)
Tell the algorithm to NOT clean just the inner quarter (This is useful when multiscale clean is being...
casacore::Float maskThresh_p
ImageMSCleaner()
Default.
casacore::Int nMaskChan_p
~ImageMSCleaner()
The destructor.
casacore::Int polAxis_p
casacore::ImageInterface< casacore::Float > * mask_p
casacore::Int nImPol_p
casacore::Int nMaskPol_p
void setPsf(casacore::ImageInterface< casacore::Float > &psf)
Change the psf image.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
void startingIteration(const casacore::Int starting=0)
what iteration number to start on
float Float
Definition: aipstype.h:54
void setMask(casacore::ImageInterface< casacore::Float > &mask, const casacore::Float &maskThreshold=0.9)
Set the mask mask - input mask lattice maskThreshold - if positive, the value is treated as a thresho...
casacore::Vector< casacore::Float > scales_p
casacore::Int nPsfChan_p
casacore::ImageInterface< casacore::Float > * dirty_p
Set a number of scale sizes The units of the scale are pixels *void setscales(const casacore::Int nscales, const casacore::Float scaleInc=1.0)
A copy of casacore::LatticeCleaner but just using 2-D matrices.
Definition: MatrixCleaner.h:93
casacore::Float maxResidual_p
casacore::Bool setcontrol(casacore::CleanEnums::CleanType cleanType, const casacore::Int niter, const casacore::Float gain, const casacore::Quantity &aThreshold, const casacore::Quantity &fThreshold)
Set up control parameters cleanType - type of the cleaning algorithm to use (HOGBOM, MULTISCALE) niter - number of iterations gain - loop gain used in cleaning (a fraction of the maximum subtracted at every iteration) aThreshold - absolute threshold to stop iterations fThreshold - fractional threshold (i.e.
casacore::Int clean(casacore::ImageInterface< casacore::Float > &model, const casacore::String &algorithm, const casacore::Int niter, const casacore::Float gain, const casacore::Quantity &threshold, const casacore::Quantity &fthresh=casacore::Quantity(0.0,"%"), casacore::Bool doPlotProgress=false)
Clean an image.
void update(casacore::ImageInterface< casacore::Float > &dirty)
Update the dirty image only.
casacore::Int nPsfPol_p
String: the storage and methods of handling collections of characters.
Definition: String.h:223
void stopPointMode(casacore::Int nStopPointMode)
Some algorithms require that the cycles be terminated when the image is dominated by point sources; i...
casacore::Int chanAxis_p
casacore::Int nImChan_p
casacore::Int numberIterations() const
void speedup(const casacore::Float Ndouble)
speedup() will speed the clean iteration by raising the threshold.
void setSmallScaleBias(const casacore::Float x=0.5)
Consider the case of a point source: the flux on all scales is the same, and the first scale will be ...
casacore::Bool setupMatCleaner(const casacore::String &alg, const casacore::Int niter, const casacore::Float gain, const casacore::Quantity &threshold, const casacore::Quantity &fthresh=casacore::Quantity(0.0,"%"))
Helper function to setup some param.
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42