casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MultiTermLatticeCleaner.h
Go to the documentation of this file.
1 //# MultiTermLatticeCleaner.h: Minor Cycle for MSMFS deconvolution
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 //# Urvashi Rau <rurvashi@aoc.nrao.edu>
27 //#
28 //# $Id: HostInfoDarwin.h 21521 2014-12-10 08:06:42Z gervandiepen $
29 
30 #ifndef LATTICES_MULTITERMLATTICECLEANER_H
31 #define LATTICES_MULTITERMLATTICECLEANER_H
32 
33 #include <casacore/casa/aips.h>
38 
39 namespace casacore { //# NAMESPACE CASACORE - BEGIN
40 
41 template<class T> class MultiTermLatticeCleaner : public LatticeCleaner<T>
42 {
43 public:
44  // Create a cleaner for a specific dirty image and PSF
46 
47  // The copy constructor uses reference semantics
49 
50  // The assignment operator also uses reference semantics
52 
53  // The destructor does nothing special.
55 
56  // Input : number of Taylor terms
57  // Reshapes PtrBlocks to hold the correct number of PSFs and Residual images
58  Bool setntaylorterms(const int & nterms);
59 
60  // Input : scales
61  Bool setscales(const Vector<Float> & scales);
62 
63  // Initialize all the memory being used.
65 
66  // Set control parameters.
67  Bool setcontrol(CleanEnums::CleanType cleanType,const Int niter,const Float gain,const Quantity& aThreshold,const Bool choose);
68  //# This function is defined in the base class LatticeCleaner, but was not
69  //# defined in the new MultiTermLatticeCleaner.
70  //# I (GvD) have added it for the time being.
71  Bool setcontrol(CleanEnums::CleanType cleanType, const Int niter,
72  const Float gain, const Quantity& aThreshold,
73  const Quantity& /*fThreshold*/,
74  const Bool choose=True)
75  { return setcontrol (cleanType, niter, gain, aThreshold, choose); }
76 
77  // Input : psfs and dirty images
78  Bool setpsf(int order, Lattice<T> & psf);
79 
80  // Input : psfs and dirty images
81  Bool setresidual(int order, Lattice<T> & dirty);
82 
83  // Input : model images
84  Bool setmodel(int order, Lattice<T> & model);
85 
86  // Input : mask
88 
89  // Run the minor cycle
90  Int mtclean(LatticeCleanProgress* progress=0);
91 
92  // Output : Model images
93  Bool getmodel(int order, Lattice<T> & model);
94 
95  // Ouput : psfs and dirty images
96  Bool getresidual(int order, Lattice<T> & residual);
97 
98  // Output : Hessian matrix
99  Bool getinvhessian(Matrix<Double> & invhessian);
100 
101 private:
103 
110 
117 
118  Int ntaylor_p; // Number of terms in the Taylor expansion to use.
119  Int psfntaylor_p; // Number of terms in the Taylor expansion for PSF.
120  Int nscales_p; // Number of scales to use for the multiscale part.
124 
125  // Image mask
130 
131  Vector<Float> scaleSizes_p; // Vector of scale sizes in pixels.
132  Vector<Float> scaleBias_p; // Vector of scale biases !!
133  Vector<Float> totalScaleFlux_p; // Vector of total scale fluxes.
134  Vector<Float> totalTaylorFlux_p; // Vector of total flux in each taylor term.
137 
141 
142  // h(s) [nx,ny,nscales]
145 
146  // B_k [nx,ny,ntaylor]
149 
150  // I_D : Residual/Dirty Images [nx,ny,ntaylor]
152 
153  // I_M : Model Images [nx,ny,ntaylor]
155 
156  // A_{smn} = B_{sm} * B{sn} [nx,ny,ntaylor,ntaylor,nscales,nscales]
157  // A_{s1s2mn} = B_{s1m} * B{s2n} [nx,ny,ntaylor,ntaylor,nscales,nscales]
160 
161  // R_{sk} = I_D * B_{sk} [nx,ny,ntaylor,nscales]
164 
165  // a_{sk} = Solution vectors. [nx,ny,ntaylor,nscales]
168 
169  // Memory to be allocated per TempLattice
171 
172  // Solve [A][Coeffs] = [I_D * B]
173  // Shape of A : [ntaylor,ntaylor]
174  PtrBlock<Matrix<Double>*> matA_p; // 2D matrix to be inverted.
175  PtrBlock<Matrix<Double>*> invMatA_p; // Inverse of matA_p;
176 
177  // Scratch Lattices and iterators.
181 
183 
185 
186  Int numberOfTempLattices(Int nscales,Int ntaylor);
187  Int manageMemory(Bool allocate);
188 
189  Bool findMaxAbsLattice(const TempLattice<Float>& masklat,const Lattice<Float>& lattice,Float& maxAbs,IPosition& posMaxAbs, Bool flip=False);
190  Int addTo(Lattice<Float>& to, const Lattice<Float>& add, Float multiplier);
191 
192  Int setupFFTMask();
193  Int setupUserMask();
194  Int setupBlobs();
197  Int computeRHS();
198  Int solveMatrixEqn(Int scale);
199  Int computePenaltyFunction(Int scale, Float &loopgain, Bool choosespec);
200  Int updateSolution(IPosition globalmaxpos, Int maxscaleindex, Float loopgain);
201  Int checkConvergence(Bool choosespec, Float thresh, Float fluxlimit);
202 
203  Int IND2(Int taylor,Int scale);
204  Int IND4(Int taylor1, Int taylor2, Int scale1, Int scale2);
205 
207 };
208 
209 } //# NAMESPACE CASACORE - END
210 
211 #ifndef CASACORE_NO_AUTO_TEMPLATES
212 #include <casacore/lattices/LatticeMath/MultiTermLatticeCleaner.tcc>
213 #endif //# CASACORE_NO_AUTO_TEMPLATES
214 #endif
215 
TempLattice< Float > * dirty_p
Image mask.
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
PtrBlock< Matrix< Double > * > invMatA_p
LatticeIterator< Float > * itertWork_p
int Int
Definition: aipstype.h:50
TempLattice< Complex > * cWork_p
Scratch Lattices and iterators.
Bool findMaxAbsLattice(const TempLattice< Float > &masklat, const Lattice< Float > &lattice, Float &maxAbs, IPosition &posMaxAbs, Bool flip=False)
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
Float threshold() const
Method to return threshold, including any speedup factors.
Bool setmask(Lattice< T > &mask)
Input : mask.
Bool setpsf(int order, Lattice< T > &psf)
Input : psfs and dirty images.
PtrBlock< LatticeIterator< Float > * > itermatCoeffs_p
Bool setntaylorterms(const int &nterms)
Input : number of Taylor terms Reshapes PtrBlocks to hold the correct number of PSFs and Residual ima...
Bool getinvhessian(Matrix< Double > &invhessian)
Output : Hessian matrix.
PtrBlock< TempLattice< Complex > * > vecPsfFT_p
PtrBlock< TempLattice< Float > * > vecDirty_p
I_D : Residual/Dirty Images [nx,ny,ntaylor].
Lattice< T > * residual()
Look at what WE think the residuals look like Assumes the first scale is zero-sized.
Int mtclean(LatticeCleanProgress *progress=0)
Run the minor cycle.
ostream-like interface to creating log messages.
Definition: LogIO.h:167
PtrBlock< LatticeIterator< Float > * > itermatR_p
A class for doing multi-dimensional cleaning.
PtrBlock< TempLattice< Float > * > vecScales_p
h(s) [nx,ny,nscales]
Int IND2(Int taylor, Int scale)
~MultiTermLatticeCleaner()
The destructor does nothing special.
Int IND4(Int taylor1, Int taylor2, Int scale1, Int scale2)
Double memoryMB_p
Memory to be allocated per TempLattice.
A templated, abstract base class for array-like objects.
PtrBlock< TempLattice< Float > * > matCoeffs_p
a_{sk} = Solution vectors.
PtrBlock< TempLattice< Complex > * > vecScalesFT_p
Bool setmodel(int order, Lattice< T > &model)
Input : model images.
double Double
Definition: aipstype.h:55
Bool initialise(Int nx, Int ny)
Initialize all the memory being used.
Bool setresidual(int order, Lattice< T > &dirty)
Input : psfs and dirty images.
Bool setcontrol(CleanEnums::CleanType cleanType, const Int niter, const Float gain, const Quantity &aThreshold, const Bool choose)
Set control parameters.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
Int addTo(Lattice< Float > &to, const Lattice< Float > &add, Float multiplier)
float Float
Definition: aipstype.h:54
Abstract base class to monitor progress in lattice operations.
MultiTermLatticeCleaner()
Create a cleaner for a specific dirty image and PSF.
Bool getmodel(int order, Lattice< T > &model)
Output : Model images.
const Bool False
Definition: aipstype.h:44
Int computePenaltyFunction(Int scale, Float &loopgain, Bool choosespec)
PtrBlock< TempLattice< Float > * > matR_p
R_{sk} = I_D * B_{sk} [nx,ny,ntaylor,nscales].
PtrBlock< TempLattice< Float > * > vecModel_p
I_M : Model Images [nx,ny,ntaylor].
A drop-in replacement for Block&lt;T*&gt;.
Definition: WProjectFT.h:54
void add(casacore::Int spectralWindow, casacore::Int firstChannel, casacore::Int nChannels, casacore::Int increment=1)
PtrBlock< TempLattice< Float > * > cubeA_p
A_{smn} = B_{sm} * B{sn} [nx,ny,ntaylor,ntaylor,nscales,nscales] A_{s1s2mn} = B_{s1m} * B{s2n} [nx...
Bridging class to allow C++ expressions involving lattices.
Int computeFluxLimit(Float &fluxlimit, Float threshold)
Int numberOfTempLattices(Int nscales, Int ntaylor)
Bool setcontrol(CleanEnums::CleanType cleanType, const Int niter, const Float gain, const Quantity &aThreshold, const Quantity &, const Bool choose=True)
MultiTermLatticeCleaner< T > & operator=(const MultiTermLatticeCleaner< T > &other)
The assignment operator also uses reference semantics.
Int updateSolution(IPosition globalmaxpos, Int maxscaleindex, Float loopgain)
PtrBlock< Matrix< Double > * > matA_p
Solve [A][Coeffs] = [I_D * B] Shape of A : [ntaylor,ntaylor].
Bool getresidual(int order, Lattice< T > &residual)
Ouput : psfs and dirty images.
const Bool True
Definition: aipstype.h:43
PtrBlock< LatticeIterator< Float > * > itercubeA_p
Int checkConvergence(Bool choosespec, Float thresh, Float fluxlimit)
PtrBlock< TempLattice< Float > * > vecPsf_p
B_k [nx,ny,ntaylor].
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42
Bool setscales(const Vector< Float > &scales)
Input : scales.