casacore
Loading...
Searching...
No Matches
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: casa-feedback@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#ifndef LATTICES_MULTITERMLATTICECLEANER_H
29#define LATTICES_MULTITERMLATTICECLEANER_H
30
31#include <casacore/casa/aips.h>
32#include <casacore/lattices/LatticeMath/LatticeCleaner.h>
33#include <casacore/lattices/Lattices/LatticeIterator.h>
34#include <casacore/lattices/LEL/LatticeExpr.h>
35#include <casacore/lattices/LEL/LatticeExprNode.h>
36
37namespace casacore { //# NAMESPACE CASACORE - BEGIN
38
39template<class T> class MultiTermLatticeCleaner : public LatticeCleaner<T>
40{
41public:
42 // Create a cleaner for a specific dirty image and PSF
44
45 // The copy constructor uses reference semantics
47
48 // The assignment operator also uses reference semantics
50
51 // The destructor does nothing special.
53
54 // Input : number of Taylor terms
55 // Reshapes PtrBlocks to hold the correct number of PSFs and Residual images
56 Bool setntaylorterms(const int & nterms);
57
58 // Input : scales
59 Bool setscales(const Vector<Float> & scales);
60
61 // Initialize all the memory being used.
63
64 // Set control parameters.
65 Bool setcontrol(CleanEnums::CleanType cleanType,const Int niter,const Float gain,const Quantity& aThreshold,const Bool choose);
66 //# This function is defined in the base class LatticeCleaner, but was not
67 //# defined in the new MultiTermLatticeCleaner.
68 //# I (GvD) have added it for the time being.
69 Bool setcontrol(CleanEnums::CleanType cleanType, const Int niter,
70 const Float gain, const Quantity& aThreshold,
71 const Quantity& /*fThreshold*/,
72 const Bool choose=True)
73 { return setcontrol (cleanType, niter, gain, aThreshold, choose); }
74
75 // Input : psfs and dirty images
76 Bool setpsf(int order, Lattice<T> & psf);
77
78 // Input : psfs and dirty images
79 Bool setresidual(int order, Lattice<T> & dirty);
80
81 // Input : model images
82 Bool setmodel(int order, Lattice<T> & model);
83
84 // Input : mask
86
87 // Run the minor cycle
89
90 // Output : Model images
91 Bool getmodel(int order, Lattice<T> & model);
92
93 // Ouput : psfs and dirty images
95
96 // Output : Hessian matrix
98
99private:
101
108
112 using LatticeCleaner<T>::addTo;
115
116 Int ntaylor_p; // Number of terms in the Taylor expansion to use.
117 Int psfntaylor_p; // Number of terms in the Taylor expansion for PSF.
118 Int nscales_p; // Number of scales to use for the multiscale part.
122
123 // Image mask
128
129 Vector<Float> scaleSizes_p; // Vector of scale sizes in pixels.
130 Vector<Float> scaleBias_p; // Vector of scale biases !!
131 Vector<Float> totalScaleFlux_p; // Vector of total scale fluxes.
132 Vector<Float> totalTaylorFlux_p; // Vector of total flux in each taylor term.
135
139
140 // h(s) [nx,ny,nscales]
143
144 // B_k [nx,ny,ntaylor]
147
148 // I_D : Residual/Dirty Images [nx,ny,ntaylor]
150
151 // I_M : Model Images [nx,ny,ntaylor]
153
154 // A_{smn} = B_{sm} * B{sn} [nx,ny,ntaylor,ntaylor,nscales,nscales]
155 // A_{s1s2mn} = B_{s1m} * B{s2n} [nx,ny,ntaylor,ntaylor,nscales,nscales]
158
159 // R_{sk} = I_D * B_{sk} [nx,ny,ntaylor,nscales]
162
163 // a_{sk} = Solution vectors. [nx,ny,ntaylor,nscales]
166
167 // Memory to be allocated per TempLattice
169
170 // Solve [A][Coeffs] = [I_D * B]
171 // Shape of A : [ntaylor,ntaylor]
172 PtrBlock<Matrix<Double>*> matA_p; // 2D matrix to be inverted.
173 PtrBlock<Matrix<Double>*> invMatA_p; // Inverse of matA_p;
174
175 // Scratch Lattices and iterators.
179
181
183
184 Int numberOfTempLattices(Int nscales,Int ntaylor);
186
187 Bool findMaxAbsLattice(const TempLattice<Float>& masklat,const Lattice<Float>& lattice,Float& maxAbs,IPosition& posMaxAbs, Bool flip=False);
188 Int addTo(Lattice<Float>& to, const Lattice<Float>& add, Float multiplier);
189
197 Int computePenaltyFunction(Int scale, Float &loopgain, Bool choosespec);
198 Int updateSolution(IPosition globalmaxpos, Int maxscaleindex, Float loopgain);
199 Int checkConvergence(Bool choosespec, Float thresh, Float fluxlimit);
200
201 Int IND2(Int taylor,Int scale);
202 Int IND4(Int taylor1, Int taylor2, Int scale1, Int scale2);
203
205};
206
207} //# NAMESPACE CASACORE - END
208
209#ifndef CASACORE_NO_AUTO_TEMPLATES
210#include <casacore/lattices/LatticeMath/MultiTermLatticeCleaner.tcc>
211#endif //# CASACORE_NO_AUTO_TEMPLATES
212#endif
213
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
A read/write lattice iterator.
~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].
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:812
this file contains all the compiler specific defines
Definition mainpage.dox:28
const Bool False
Definition aipstype.h:42
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
float Float
Definition aipstype.h:52
int Int
Definition aipstype.h:48
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
const Bool True
Definition aipstype.h:41
double Double
Definition aipstype.h:53