casacore
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>
34#include <casacore/lattices/LatticeMath/LatticeCleaner.h>
35#include <casacore/lattices/Lattices/LatticeIterator.h>
36#include <casacore/lattices/LEL/LatticeExpr.h>
37#include <casacore/lattices/LEL/LatticeExprNode.h>
38
39namespace casacore { //# NAMESPACE CASACORE - BEGIN
40
41template<class T> class MultiTermLatticeCleaner : public LatticeCleaner<T>
42{
43public:
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
91
92 // Output : Model images
93 Bool getmodel(int order, Lattice<T> & model);
94
95 // Ouput : psfs and dirty images
97
98 // Output : Hessian matrix
100
101private:
103
110
114 using LatticeCleaner<T>::addTo;
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);
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
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
A class for doing multi-dimensional cleaning.
Bool findMaxAbsMaskLattice(const Lattice< T > &lattice, const Lattice< T > &mask, T &maxAbs, IPosition &posMax)
Find the Peak of the lattice, applying a mask.
void makeScale(Lattice< T > &scale, const Float &scaleSize)
Make an lattice of the specified scale.
Bool validatePsf(const Lattice< T > &psf)
Make sure that the peak of the Psf is within the image.
Float threshold() const
Method to return threshold, including any speedup factors.
TempLattice< T > * itsMask
CleanEnums::CleanType itsCleanType
Lattice< T > * residual()
Look at what WE think the residuals look like Assumes the first scale is zero-sized.
static void makeBoxesSameSize(IPosition &blc1, IPosition &trc1, IPosition &blc2, IPosition &trc2)
Helper function to reduce the box sizes until the have the same size keeping the centers intact
Quantum< Double > itsThreshold
~MultiTermLatticeCleaner()
The destructor does nothing special.
MultiTermLatticeCleaner(const MultiTermLatticeCleaner< T > &other)
The copy constructor uses reference semantics.
PtrBlock< TempLattice< Complex > * > vecPsfFT_p
Int IND2(Int taylor, Int scale)
MultiTermLatticeCleaner()
Create a cleaner for a specific dirty image and PSF.
Bool findMaxAbsLattice(const TempLattice< Float > &masklat, const Lattice< Float > &lattice, Float &maxAbs, IPosition &posMaxAbs, Bool flip=False)
TempLattice< Float > * dirty_p
Image mask.
Bool setscales(const Vector< Float > &scales)
Input : scales.
PtrBlock< Matrix< Double > * > matA_p
Solve [A][Coeffs] = [I_D * B] Shape of A : [ntaylor,ntaylor].
Int mtclean(LatticeCleanProgress *progress=0)
Run the minor cycle.
PtrBlock< TempLattice< Float > * > vecModel_p
I_M : Model Images [nx,ny,ntaylor].
PtrBlock< LatticeIterator< Float > * > itercubeA_p
TempLattice< Complex > * cWork_p
Scratch Lattices and iterators.
Bool getmodel(int order, Lattice< T > &model)
Output : Model images.
PtrBlock< TempLattice< Float > * > vecScales_p
h(s) [nx,ny,nscales]
Int addTo(Lattice< Float > &to, const Lattice< Float > &add, Float multiplier)
Bool setcontrol(CleanEnums::CleanType cleanType, const Int niter, const Float gain, const Quantity &aThreshold, const Quantity &, const Bool choose=True)
PtrBlock< TempLattice< Float > * > cubeA_p
A_{smn} = B_{sm} * B{sn} [nx,ny,ntaylor,ntaylor,nscales,nscales] A_{s1s2mn} = B_{s1m} * B{s2n} [nx,...
PtrBlock< TempLattice< Float > * > matR_p
R_{sk} = I_D * B_{sk} [nx,ny,ntaylor,nscales].
Bool setmask(Lattice< T > &mask)
Input : mask.
Bool setpsf(int order, Lattice< T > &psf)
Input : psfs and dirty images.
Int numberOfTempLattices(Int nscales, Int ntaylor)
PtrBlock< TempLattice< Float > * > vecDirty_p
I_D : Residual/Dirty Images [nx,ny,ntaylor].
LatticeIterator< Float > * itertWork_p
PtrBlock< TempLattice< Complex > * > vecScalesFT_p
Bool initialise(Int nx, Int ny)
Initialize all the memory being used.
Bool setcontrol(CleanEnums::CleanType cleanType, const Int niter, const Float gain, const Quantity &aThreshold, const Bool choose)
Set control parameters.
Bool setntaylorterms(const int &nterms)
Input : number of Taylor terms Reshapes PtrBlocks to hold the correct number of PSFs and Residual ima...
Bool setresidual(int order, Lattice< T > &dirty)
Input : psfs and dirty images.
Bool getresidual(int order, Lattice< T > &residual)
Ouput : psfs and dirty images.
MultiTermLatticeCleaner< T > & operator=(const MultiTermLatticeCleaner< T > &other)
The assignment operator also uses reference semantics.
Int computePenaltyFunction(Int scale, Float &loopgain, Bool choosespec)
Double memoryMB_p
Memory to be allocated per TempLattice.
PtrBlock< LatticeIterator< Float > * > itermatCoeffs_p
PtrBlock< TempLattice< Float > * > vecPsf_p
B_k [nx,ny,ntaylor].
Int IND4(Int taylor1, Int taylor2, Int scale1, Int scale2)
Int updateSolution(IPosition globalmaxpos, Int maxscaleindex, Float loopgain)
Bool getinvhessian(Matrix< Double > &invhessian)
Output : Hessian matrix.
Int computeFluxLimit(Float &fluxlimit, Float threshold)
PtrBlock< TempLattice< Float > * > matCoeffs_p
a_{sk} = Solution vectors.
PtrBlock< LatticeIterator< Float > * > itermatR_p
Bool setmodel(int order, Lattice< T > &model)
Input : model images.
Int checkConvergence(Bool choosespec, Float thresh, Float fluxlimit)
PtrBlock< Matrix< Double > * > invMatA_p
A drop-in replacement for Block<T*>.
Definition: Block.h:814
this file contains all the compiler specific defines
Definition: mainpage.dox:28
const Bool False
Definition: aipstype.h:44
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
float Float
Definition: aipstype.h:54
int Int
Definition: aipstype.h:50
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
const Bool True
Definition: aipstype.h:43
double Double
Definition: aipstype.h:55