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>
41 public:
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 Blocks to hold the correct number of PSFs and Residual images
56 Bool setntaylorterms(const int& nterms);
57
58 // Input : 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,
66 const Quantity& aThreshold, const Bool choose);
67 // # This function is defined in the base class LatticeCleaner, but was not
68 // # defined in the new MultiTermLatticeCleaner.
69 // # I (GvD) have added it for the time being.
70 Bool setcontrol(CleanEnums::CleanType cleanType, const Int niter, const Float gain,
71 const Quantity& aThreshold, const Quantity& /*fThreshold*/,
72 const Bool choose = True) {
73 return setcontrol(cleanType, niter, gain, aThreshold, choose);
74 }
75
76 // Input : psfs and dirty images
78
79 // Input : psfs and dirty images
81
82 // Input : model images
84
85 // Input : mask
87
88 // Run the minor cycle
90
91 // Output : Model images
93
94 // Ouput : psfs and dirty images
96
97 // Output : Hessian matrix
99
100 private:
102
109
113 using LatticeCleaner<T>::addTo;
116
117 Int ntaylor_p; // Number of terms in the Taylor expansion to use.
118 Int psfntaylor_p; // Number of terms in the Taylor expansion for PSF.
119 Int nscales_p; // Number of scales to use for the multiscale part.
123
124 // Image mask
129
130 Vector<Float> scaleSizes_p; // Vector of scale sizes in pixels.
131 Vector<Float> scaleBias_p; // Vector of scale biases !!
132 Vector<Float> totalScaleFlux_p; // Vector of total scale fluxes.
133 Vector<Float> totalTaylorFlux_p; // Vector of total flux in each taylor term.
136
140
141 // h(s) [nx,ny,nscales]
144
145 // B_k [nx,ny,ntaylor]
148
149 // I_D : Residual/Dirty Images [nx,ny,ntaylor]
151
152 // I_M : Model Images [nx,ny,ntaylor]
154
155 // A_{smn} = B_{sm} * B{sn} [nx,ny,ntaylor,ntaylor,nscales,nscales]
156 // A_{s1s2mn} = B_{s1m} * B{s2n} [nx,ny,ntaylor,ntaylor,nscales,nscales]
159
160 // R_{sk} = I_D * B_{sk} [nx,ny,ntaylor,nscales]
163
164 // a_{sk} = Solution vectors. [nx,ny,ntaylor,nscales]
167
168 // Memory to be allocated per TempLattice
170
171 // Solve [A][Coeffs] = [I_D * B]
172 // Shape of A : [ntaylor,ntaylor]
173 Block<Matrix<Double>*> matA_p; // 2D matrix to be inverted.
174 Block<Matrix<Double>*> invMatA_p; // Inverse of matA_p;
175
176 // Scratch Lattices and iterators.
180
182
184
185 Int numberOfTempLattices(Int nscales, Int ntaylor);
187
189 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
210
211#ifndef CASACORE_NO_AUTO_TEMPLATES
212#include <casacore/lattices/LatticeMath/MultiTermLatticeCleaner.tcc>
213#endif // # CASACORE_NO_AUTO_TEMPLATES
214#endif
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
LatticeCleaner()
Create a cleaner : default constructor.
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.
Block< TempLattice< Complex > * > vecScalesFT_p
Block< LatticeIterator< Float > * > itercubeA_p
~MultiTermLatticeCleaner()
The destructor does nothing special.
MultiTermLatticeCleaner(const MultiTermLatticeCleaner< T > &other)
The copy constructor uses reference semantics.
Block< TempLattice< Float > * > vecModel_p
I_M : Model Images [nx,ny,ntaylor].
Block< TempLattice< Float > * > vecScales_p
h(s) [nx,ny,nscales]
Block< LatticeIterator< Float > * > itermatCoeffs_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.
Int mtclean(LatticeCleanProgress *progress=0)
Run the minor cycle.
Block< TempLattice< Float > * > matCoeffs_p
a_{sk} = Solution vectors.
TempLattice< Complex > * cWork_p
Scratch Lattices and iterators.
Bool getmodel(int order, Lattice< T > &model)
Output : Model images.
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)
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)
Block< TempLattice< Float > * > vecDirty_p
I_D : Residual/Dirty Images [nx,ny,ntaylor].
Block< TempLattice< Float > * > matR_p
R_{sk} = I_D * B_{sk} [nx,ny,ntaylor,nscales].
Bool initialise(Int nx, Int ny)
Initialize all the memory being used.
Block< TempLattice< Complex > * > vecPsfFT_p
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 Blocks to hold the correct number of PSFs and Residual images...
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)
Block< TempLattice< Float > * > cubeA_p
A_{smn} = B_{sm} * B{sn} [nx,ny,ntaylor,ntaylor,nscales,nscales] A_{s1s2mn} = B_{s1m}...
Double memoryMB_p
Memory to be allocated per TempLattice.
Block< Matrix< Double > * > matA_p
Solve [A][Coeffs] = [I_D * B] Shape of A : [ntaylor,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)
Block< LatticeIterator< Float > * > itermatR_p
Block< TempLattice< Float > * > vecPsf_p
B_k [nx,ny,ntaylor].
Bool setmodel(int order, Lattice< T > &model)
Input : model images.
Int checkConvergence(Bool choosespec, Float thresh, Float fluxlimit)
For temporary backward namespace compatibility, use casa as alias for casacore.
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
uInt order() const
What is the order of the polynomial, i.e.
int Int
Definition aipstype.h:48
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
Quantum< Double > Quantity
Definition Quantum.h:40
const Bool True
Definition aipstype.h:41
double Double
Definition aipstype.h:53