casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Deconvolver.h
Go to the documentation of this file.
1 //# Deconvolver: defines classes for deconvolver.
2 //# Copyright (C) 1996-2007
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: DOdeconvolver.h,v 19.7 2005/03/18 01:43:31 kgolap Exp $
28 
29 #ifndef SYNTHESIS_DECONVOLVER_H
30 #define SYNTHESIS_DECONVOLVER_H
31 
32 #include <casa/aips.h>
33 #include <casa/Arrays/IPosition.h>
34 #include <casa/Quanta/Quantum.h>
40 
42 
43 #include <casa/namespace.h>
44 namespace casacore{
45 
46 template<class T> class Lattice;
47 template<class T> class PagedImage;
48 template<class T> class TempImage;
49 template<class T> class ImageInterface;
50 template<class T> class LatticeConvolver;
51 template<class T> class SubImage;
52 class File;
53 }
54 
55 namespace casa { //# NAMESPACE CASA - BEGIN
56 template<class T> class ResidualEquation;
57 
58 
59 class CEMemModel;
60 class ClarkCleanLatModel;
61 class LatConvEquation;
62 class ImageMSCleaner;
63 class ImageNACleaner;
64 // <summary> A simple deconvolver operating on images (no SkyEquation) </summary>
65 
66 // <use visibility=export>
67 
68 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
69 // </reviewed>
70 
71 // <prerequisite>
72 // <li> <linkto class="SkyEquation">SkyEquation</linkto>
73 // <li> <linkto class="SkyModel">SkyModel</linkto>
74 // </prerequisite>
75 //
76 // <etymology>
77 // Undo convolution or at least try to do it !
78 // </etymology>
79 //
80 // <synopsis>
81 // This class is a container that allows many SkyComponents to be grouped
82 // together and manipulated as a group. In this respect this class is identical
83 // to the <linkto class="ComponentList">ComponentList</linkto> class. The user
84 // is encouraged to read the synopsis of that class for a general description
85 // of the capabilities of this class.
86 //
87 // This class is differs from the ComponentList class in the following ways:
88 // <ul>
89 // <li> All components are indexed starting at one. This means the first
90 // component in this class is obtained by <src>component(1)</src> rather
91 // than <src>component(0)</src> in the ComponentList class.
92 // <li> Copies of the components, rather than references, are returned to the
93 // user. This means that this class needs a replace function whereas
94 // ComponentList does not.
95 // <li> Components that have been removed from the list are stored in a
96 // temporary place. In the ComponentList class once they are deleted they
97 // are gone.
98 // <li> This class is derived from ApplicationObject and follows the AIPS++
99 // conventions for "distributed objects". Hence the fuunctions in this
100 // class can be made accessible from glish.
101 // <li> This class can generate simulated components and add them to the list.
102 // </ul>
103 //
104 // There is a one-to-one correspondence between the functions in the glish
105 // componentlist object (see the AIPS++ User Reference manual) and functions in
106 // this class. This is make simplify the porting from glish to C++ of a glish
107 // script using the componentlist distributed object.
108 // </synopsis>
109 //
110 // <example>
111 // These examples are coded in the tDOcomponentlist.h file.
112 // <h4>Example 1:</h4>
113 // In this example a ComponentList object is created and used to calculate the
114 // ...
115 // <srcblock>
116 // </srcblock>
117 // </example>
118 //
119 // <motivation>
120 // This class was written to make the componentlist classes usable from glish
121 // </motivation>
122 //
123 // <thrown>
124 // <li> casacore::AipsError - If an internal inconsistancy is detected, when compiled in
125 // debug mode only.
126 // </thrown>
127 //
128 // <todo asof="1998/05/22">
129 // <li> Nothing I hope. But I expect users will disagree.
130 // </todo>
131 
133 {
134 public:
135  // "deconvolver" ctor
136  Deconvolver();
137 
138  Deconvolver(const casacore::String& dirty, const casacore::String& psf);
139 
140  Deconvolver(const Deconvolver &other);
141  Deconvolver &operator=(const Deconvolver &other);
142  ~Deconvolver();
143 
144  // Open the given dirty image and psf
145  // If warn is true, print warnings about there being
146  // no psf if one is not supplied.
147  casacore::Bool open(const casacore::String& dirty, const casacore::String& psf, casacore::Bool warn=true);
148 
149  // After some cleaning, the dirty image is replaced with the
150  // residual image in the deconvolver tool. reopen reinstates
151  // that dirty image; cannot be invoked before open has been
152  // invoked
154 
155  // Flush the ms to disk and detach from the ms file. All function
156  // calls after this will be a no-op.
158 
159  casacore::String dirtyname() const;
160  casacore::String psfname() const;
161 
162  // Output a summary of the state of the object
163  casacore::Bool summary() const;
164 
165  // Return the state of the object as a string
166  casacore::String state() const;
167 
168  // Return the image shape
170 
171  // Restore
173  const casacore::String& image, casacore::GaussianBeam& mbeam);
174 
175  // Residual
177  const casacore::String& image);
178 
179  // Smooth
180  casacore::Bool smooth(const casacore::String& model,
181  const casacore::String& image,
182  casacore::GaussianBeam& mbeam,
183  casacore::Bool normalizeVolume);
184 
185  // Clean algorithm
186  //maxResidual and iterationsDone are return values
187  casacore::Bool clean(const casacore::String& algorithm,
188  const casacore::Int niter, const casacore::Float gain, const casacore::Quantity& threshold,
189  const casacore::Bool displayProgress,
190  const casacore::String& model, const casacore::String& mask, casacore::Float& maxResidual,
191  casacore::Int& iterationsDone );
193  const casacore::Float gain, const casacore::Quantity& threshold,
194  const casacore::String& model, const casacore::String& mask, const casacore::Int masksupp, const casacore::Int memoryType, const casacore::Float numSigma, casacore::Float& maxResidual, casacore::Int& iterationsDone) ;
195 
196  //Clark Clean but image, psf, mask has to be 4-axes in the canonical casa order.
197  //Useful for cleaning dirty images made in CASA
198  //if mask is larger than a quarter of the image it will do a full image clean ...unlike the one below
200  const casacore::Float gain, const casacore::Quantity& threshold,
201  const casacore::String& model, const casacore::String& maskName,
202  casacore::Float& maxresid, casacore::Int& iterused,
203  casacore::Float cycleFactor=1.5);
204 
205  // Clark Clean algorithm
207  const casacore::Float gain, const casacore::Quantity& threshold,
208  const casacore::Bool displayProgress,
209  const casacore::String& model, const casacore::String& mask,
210  const casacore::Int histBins,
211  const casacore::Vector<casacore::Int>& psfPatchSize, const casacore::Float maxExtPsf,
212  const casacore::Float speedUp, casacore::Int maxNumPix,
213  const casacore::Int maxNumMajorCycles,
214  const casacore::Int maxNumMinorIterations);
215 
216 
217  // MEM algorithm add other inputs as required
218  casacore::Bool mem(const casacore::String& algorithm,
219  const casacore::Int niter, const casacore::Quantity& sigma,
220  const casacore::Quantity& targetFlux,
221  casacore::Bool constrainTargetFlux,
222  casacore::Bool displayprogress,
223  const casacore::String& model,
224  const casacore::String& prior = "",
225  const casacore::String& mask = "",
226  const casacore::Bool imagePlane = false);
227 
228  // make a prior image
230  const casacore::String& templateImage,
231  const casacore::Quantity& lowClipfrom,
232  const casacore::Quantity& lowClipto,
233  const casacore::Quantity& highClipfrom,
234  const casacore::Quantity& highClipto,
237 
238  // Set up scales: based on scaleMethod = "nscales" or "uservector",
239  // we will create the scale sizes in pixels via a power law or
240  // use the user specified scale sizes.
241  casacore::Bool setscales(const casacore::String& scaleMethod, const casacore::Int nscales,
242  const casacore::Vector<casacore::Float>& userScaleSizes);
243 
244  // NNLS algorithm
245  casacore::Bool nnls(const casacore::String& algorithm, const casacore::Int niter, const casacore::Float tolerance,
246  const casacore::String& model,
247  const casacore::String& fluxMask, const casacore::String& dataMask);
248 
249  // Fourier transform the model and componentlist
251 
252  // Make an empty image
253  casacore::Bool make(const casacore::String& model);
254 
255  // Make an empty image with just one casacore::Stokes pixel (ie, for a mask)
256  casacore::Bool make1(const casacore::String& imagename);
257 
258  // Make an empty image modeled after templateImage
260 
261  // Make a Box Mask
265  const casacore::Quantity& fillValue=1.0,
266  const casacore::Quantity& externalValue=0.0);
267 
268  //make a mask image from regions
269  casacore::Bool regionmask(const casacore::String& maskimage, casacore::Record* imageRegRec,
271 
272  // Clip an image below some casacore::Stokes I threshold
273  casacore::Bool clipimage(const casacore::String& clippedImage, const casacore::String& inputImage,
274  const casacore::Quantity& threshold);
275 
276  // Fit the psf
278 
279  // Convolve one image with another
280  casacore::Bool convolve(const casacore::String& convolvedmodel,
281  const casacore::String& model);
282 
283  // Make a Gaussian -- you might want to use it for convolution, etc
284  casacore::Bool makegaussian(const casacore::String& gaussianimage, casacore::GaussianBeam& mbeam, casacore::Bool normalizeVolume);
285 
286  // ------------------ Multi-Term Deconvolver functions - START ----------------------
287  // Initialize the Multi-Term casacore::Matrix Cleaners and compute Hessian elements.
288  casacore::Bool mtopen(const casacore::Int nTaylor,
289  const casacore::Vector<casacore::Float>& userScaleSizes,
291 
292  // Do component-finding iterations
295  const casacore::Int niter,
296  const casacore::Float gain,
297  const casacore::Quantity& threshold,
298  const casacore::Bool displayProgress,
299  const casacore::String& mask,
300  casacore::Float& maxResidual, casacore::Int& iterationsDone);
301 
302  // Restore the output images
304  const casacore::Vector<casacore::String>& residuals,
306  casacore::GaussianBeam& mbeam);
307 
308  // Calculate alpha and beta from restored images.
310  const casacore::Vector<casacore::String>& residuals,
311  const casacore::String& alphaname,
312  const casacore::String& betaname,
313  const casacore::Quantity& threshold,
314  const casacore::Bool calcerror);
315 
316 
317  // ------------------ Multi-Term Deconvolver functions - END ----------------------
318 
319 
320 private:
321 
322  // Cut the inner quarter out of an image
324 
325  // Return full image as a SubImage
327 
328  // Clone an image
329  casacore::Bool clone(const casacore::String& imageName, const casacore::String& newImageName);
330 
331 
332  //find which axes are the spectral and pol one
333  void findAxes();
334 
335  //check mask
336 
338  casacore::Int& ybeg, casacore::Int& yend);
339 
340 
341  // setup lattice cleaner
343  const casacore::Int niter, const casacore::Float gain, const casacore::Quantity& threshold,
344  const casacore::Bool displayProgress);
345 
346  // Embed a mask into an image. A convenience function.
348  //Put a unit peak gaussian at centre
352 
357  std::shared_ptr <ImageNACleaner> naCleaner_p;
358 
360 
365 // casacore::Quantity bmaj_p, bmin_p, bpa_p;
370 
374 
375  // Multi-Term private variables
379 
380  // Set the defaults
381  void defaults();
382 
383  casacore::Bool removeTable(const casacore::String& tablename);
384 
385  // Prints an error message if the deconvolver DO is detached and returns true.
386  casacore::Bool detached() const;
387 
388  casacore::String imageName() const;
389 
390  casacore::Bool valid() const;
391 
392 };
393 
394 } //# NAMESPACE CASA - END
395 
396 #endif
casacore::Int ny_p
Definition: Deconvolver.h:361
casacore::LatticeConvolver< casacore::Float > * convolver_p
Definition: Deconvolver.h:353
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
casacore::Bool nnls(const casacore::String &algorithm, const casacore::Int niter, const casacore::Float tolerance, const casacore::String &model, const casacore::String &fluxMask, const casacore::String &dataMask)
NNLS algorithm.
casacore::Bool close()
Flush the ms to disk and detach from the ms file.
casacore::Vector< casacore::Float > itsTotalFluxScale
Definition: Deconvolver.h:371
casacore::Bool setupLatCleaner(const casacore::String &algorithm, const casacore::Int niter, const casacore::Float gain, const casacore::Quantity &threshold, const casacore::Bool displayProgress)
setup lattice cleaner
A class interfacing images to MatrixNACleaner.
int Int
Definition: aipstype.h:50
casacore::GaussianBeam beam_p
Definition: Deconvolver.h:364
casacore::Float itsTotalFlux
Definition: Deconvolver.h:372
void checkMask(casacore::ImageInterface< casacore::Float > &maskimage, casacore::Int &xbeg, casacore::Int &xend, casacore::Int &ybeg, casacore::Int &yend)
check mask
Temporary astronomical images.
std::shared_ptr< ImageNACleaner > naCleaner_p
Definition: Deconvolver.h:357
casacore::String dirtyname() const
casacore::Bool make1(const casacore::String &imagename)
Make an empty image with just one casacore::Stokes pixel (ie, for a mask)
casacore::Bool mtcalcpowerlaw(const casacore::Vector< casacore::String > &images, const casacore::Vector< casacore::String > &residuals, const casacore::String &alphaname, const casacore::String &betaname, const casacore::Quantity &threshold, const casacore::Bool calcerror)
Calculate alpha and beta from restored images.
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
A class interfacing images to MatrixCleaner.
casacore::Bool fullPlane_p
Definition: Deconvolver.h:369
Implements the convolution equation.
casacore::String psfName_p
Definition: Deconvolver.h:368
casacore::Bool beamValid_p
casacore::Quantity bmaj_p, bmin_p, bpa_p;
Definition: Deconvolver.h:366
casacore::Bool clarkclean(const casacore::Int niter, const casacore::Float gain, const casacore::Quantity &threshold, const casacore::String &model, const casacore::String &maskName, casacore::Float &maxresid, casacore::Int &iterused, casacore::Float cycleFactor=1.5)
Clark Clean but image, psf, mask has to be 4-axes in the canonical casa order.
casacore::Bool mtopen(const casacore::Int nTaylor, const casacore::Vector< casacore::Float > &userScaleSizes, const casacore::Vector< casacore::String > &psfs)
---------------— Multi-Term Deconvolver functions - START -------------------— Initialize the Multi-T...
casacore::Bool boxmask(const casacore::String &boxmask, const casacore::Vector< casacore::Int > blc, const casacore::Vector< casacore::Int > trc, const casacore::Quantity &fillValue=1.0, const casacore::Quantity &externalValue=0.0)
Make a Box Mask.
casacore::String state() const
Return the state of the object as a string.
casacore::String dirtyName_p
Definition: Deconvolver.h:367
void defaults()
Set the defaults.
casacore::Bool convolve(const casacore::String &convolvedmodel, const casacore::String &model)
Convolve one image with another.
A Class for performing the Clark Clean Algorithm on Arrays.
casacore::Bool scalesValid_p
Definition: Deconvolver.h:359
A class for doing multi-dimensional convolution.
Definition: Deconvolver.h:50
casacore::Bool mtclean(const casacore::Vector< casacore::String > &residuals, const casacore::Vector< casacore::String > &models, const casacore::Int niter, const casacore::Float gain, const casacore::Quantity &threshold, const casacore::Bool displayProgress, const casacore::String &mask, casacore::Float &maxResidual, casacore::Int &iterationsDone)
Do component-finding iterations.
casacore::Bool setscales(const casacore::String &scaleMethod, const casacore::Int nscales, const casacore::Vector< casacore::Float > &userScaleSizes)
Set up scales: based on scaleMethod = &quot;nscales&quot; or &quot;uservector&quot;, we will create the scale sizes in pi...
Interface class containing functions returning &quot;Domain&quot; type.
Definition: Deconvolver.h:56
casacore::Bool mt_valid_p
Definition: Deconvolver.h:378
casacore::Bool open(const casacore::String &dirty, const casacore::String &psf, casacore::Bool warn=true)
Open the given dirty image and psf If warn is true, print warnings about there being no psf if one is...
A 2-D Specialization of the Array class.
casacore::Int polAxis_p
Definition: Deconvolver.h:362
casacore::Bool removeTable(const casacore::String &tablename)
casacore::Bool valid() const
Represents a Gaussian restoring beam associated with an image.
Definition: GaussianBeam.h:68
casacore::Bool ft(const casacore::String &model, const casacore::String &transform)
Fourier transform the model and componentlist.
casacore::Bool reopen()
After some cleaning, the dirty image is replaced with the residual image in the deconvolver tool...
casacore::Bool residual(const casacore::String &model, const casacore::String &image)
Residual.
casacore::Bool makegaussian(const casacore::String &gaussianimage, casacore::GaussianBeam &mbeam, casacore::Bool normalizeVolume)
Make a Gaussian – you might want to use it for convolution, etc.
ResidualEquation< casacore::Lattice< casacore::Float > > * residEqn_p
Definition: Deconvolver.h:354
A simple deconvolver operating on images (no SkyEquation)
Definition: Deconvolver.h:132
casacore::Bool createMask(casacore::LatticeExpr< casacore::Bool > &lemask, casacore::ImageInterface< casacore::Float > &outimage)
Embed a mask into an image.
A templated, abstract base class for array-like objects.
Referenced counted pointer for constant data.
Definition: VisModelData.h:42
A base class for astronomical images.
casacore::Bool clean(const casacore::String &algorithm, const casacore::Int niter, const casacore::Float gain, const casacore::Quantity &threshold, const casacore::Bool displayProgress, const casacore::String &model, const casacore::String &mask, casacore::Float &maxResidual, casacore::Int &iterationsDone)
Clean algorithm maxResidual and iterationsDone are return values
casacore::CountedPtr< ImageMSCleaner > cleaner_p
Definition: Deconvolver.h:356
casacore::PagedImage< casacore::Float > * psf_p
Definition: Deconvolver.h:351
Deconvolver & operator=(const Deconvolver &other)
casacore::Vector< casacore::Float > scaleSizes_p
Definition: Deconvolver.h:373
casacore::Bool restore(const casacore::String &model, const casacore::String &image, casacore::GaussianBeam &mbeam)
Restore.
casacore::Bool clone(const casacore::String &imageName, const casacore::String &newImageName)
Clone an image.
casacore::String imageName() const
Class to get file information and a base for other file classes.
Definition: File.h:101
casacore::Bool naclean(const casacore::Int niter, const casacore::Float gain, const casacore::Quantity &threshold, const casacore::String &model, const casacore::String &mask, const casacore::Int masksupp, const casacore::Int memoryType, const casacore::Float numSigma, casacore::Float &maxResidual, casacore::Int &iterationsDone)
casacore::Bool detached() const
Prints an error message if the deconvolver DO is detached and returns true.
A hierarchical collection of named fields of various types.
Definition: Record.h:180
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
casacore::Bool fitpsf(const casacore::String &psf, casacore::GaussianBeam &beam)
Fit the psf.
casacore::Bool summary() const
Output a summary of the state of the object.
void findAxes()
find which axes are the spectral and pol one
float Float
Definition: aipstype.h:54
A (masked) subset of an ImageInterface object.
casacore::Int nx_p
Definition: Deconvolver.h:361
Implements the Cornwell &amp; Evans MEM Algorithm on Lattices.
Definition: CEMemModel.h:146
casacore::Bool regionmask(const casacore::String &maskimage, casacore::Record *imageRegRec, casacore::Matrix< casacore::Quantity > &blctrcs, const casacore::Float &value=1.0)
make a mask image from regions
casacore::Bool mem(const casacore::String &algorithm, const casacore::Int niter, const casacore::Quantity &sigma, const casacore::Quantity &targetFlux, casacore::Bool constrainTargetFlux, casacore::Bool displayprogress, const casacore::String &model, const casacore::String &prior="", const casacore::String &mask="", const casacore::Bool imagePlane=false)
MEM algorithm add other inputs as required.
casacore::Int nchan_p
Definition: Deconvolver.h:361
Deconvolver()
&quot;deconvolver&quot; ctor
casacore::IPosition imageshape() const
Return the image shape.
casacore::Bool mtrestore(const casacore::Vector< casacore::String > &models, const casacore::Vector< casacore::String > &residuals, const casacore::Vector< casacore::String > &images, casacore::GaussianBeam &mbeam)
Restore the output images.
casacore::String psfname() const
casacore::Int mt_nterms_p
Multi-Term private variables.
Definition: Deconvolver.h:376
casacore::String mode_p
Definition: Deconvolver.h:363
String: the storage and methods of handling collections of characters.
Definition: String.h:223
casacore::SubImage< casacore::Float > * innerQuarter(casacore::PagedImage< casacore::Float > &in)
------------—— Multi-Term Deconvolver functions - END ----------------——
LatConvEquation * latConvEqn_p
Definition: Deconvolver.h:355
casacore::Bool make(const casacore::String &model)
Make an empty image.
casacore::PagedImage< casacore::Float > * dirty_p
Definition: Deconvolver.h:350
casacore::Int chanAxis_p
Definition: Deconvolver.h:362
casacore::SubImage< casacore::Float > * allQuarters(casacore::PagedImage< casacore::Float > &in)
Return full image as a SubImage.
Class to allow C++ expressions involving lattices.
Definition: LatticeExpr.h:142
Read, store, and manipulate astronomical images.
Definition: Simulator.h:46
casacore::Bool clipimage(const casacore::String &clippedImage, const casacore::String &inputImage, const casacore::Quantity &threshold)
Clip an image below some casacore::Stokes I threshold.
MultiTermMatrixCleaner mt_cleaner_p
Definition: Deconvolver.h:377
casacore::Bool putGaussian(casacore::ImageInterface< casacore::Float > &im, const casacore::GaussianBeam &beam)
Put a unit peak gaussian at centre.
casacore::Bool smooth(const casacore::String &model, const casacore::String &image, casacore::GaussianBeam &mbeam, casacore::Bool normalizeVolume)
Smooth.
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
casacore::Bool makeprior(const casacore::String &prior, const casacore::String &templateImage, const casacore::Quantity &lowClipfrom, const casacore::Quantity &lowClipto, const casacore::Quantity &highClipfrom, const casacore::Quantity &highClipto, const casacore::Vector< casacore::Int > &blc, const casacore::Vector< casacore::Int > &trc)
make a prior image
casacore::Int npol_p
Definition: Deconvolver.h:361
transform(a.begin(), a.end(), std::ostream_iterator< int >(cout,"\n"), compose(unary(h), compose(unary(f), unary(f))))
Global Functions.
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42