casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MultiTermMatrixCleaner.h
Go to the documentation of this file.
1 //# MultiTermMatrixCleaner.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 //# $Id: MultiTermMatrixCleaner Urvashi R.V. 2010-12-04 <rurvashi@aoc.nrao.edu$
27 
28 #ifndef SYNTHESIS_MULTITERMLATTICECLEANER_H
29 #define SYNTHESIS_MULTITERMLATTICECLEANER_H
30 
33 
34 namespace casa { //# NAMESPACE CASA - BEGIN
35 
37 {
38 public:
39  // Create a cleaner
41 
42  // The copy constructor uses reference semantics
43  // MultiTermMatrixCleaner(const MultiTermMatrixCleaner & other);
44 
45  // The assignment operator also uses reference semantics
46  // MultiTermMatrixCleaner & operator=(const MultiTermMatrixCleaner & other);
47 
48  // The destructor resizes arrays to empty before destruction.
50 
51  // casacore::Input : number of Taylor terms
52  // Reshapes PtrBlocks to hold the correct number of PSFs and Residual images
53  casacore::Bool setntaylorterms(const int & nterms);
54 
55  // casacore::Input : scales
57 
58  // Initialize all the memory being used.
60 
61  // Calculate Hessian elements and check for invertibility
62  // Does not have to be called externally, but can be. Either way, it executes only once.
64 
65  // casacore::Input : psfs and dirty images
67 
68  // casacore::Input : psfs and dirty images
70 
71  // casacore::Input : model images
73 
74  // casacore::Input : mask
76 
77  // Run the minor cycle
78  casacore::Int mtclean(casacore::Int maxniter, casacore::Float stopfraction, casacore::Float inputgain, casacore::Float userthreshold);
79 
80  // Output : Model images
82 
83  // Output : psfs and dirty images
85 
86  // Compute principal solution - in-place on the residual images in vecDirty.
88 
89  // Output : Hessian matrix
91 
92  // Output : Peak residual computed from matR_p (residual convolved with PSF).
94 
95 
96 private:
98 
105  // using MatrixCleaner::itsScaleMasks;
106  // using MatrixCleaner::itsScaleXfrs;
107  // using MatrixCleaner::itsNscales;
108  // using MatrixCleaner::itsScalesValid;
110 
114  // using MatrixCleaner::addTo;
117  //using MatrixCleaner::makeScaleMasks;
118 
119  casacore::Int ntaylor_p; // Number of terms in the Taylor expansion to use.
120  casacore::Int psfntaylor_p; // Number of terms in the Taylor expansion for PSF.
121  casacore::Int nscales_p; // Number of scales to use for the multiscale part.
124  casacore::Int totalIters_p; // Total number of minor-cycle iterations
128  casacore::Int itercount_p; // Number of minor cycle iterations
136 
140 
141  casacore::Vector<casacore::Float> scaleSizes_p; // casacore::Vector of scale sizes in pixels.
142  casacore::Vector<casacore::Float> scaleBias_p; // casacore::Vector of scale biases !!
143  casacore::Vector<casacore::Float> totalScaleFlux_p; // casacore::Vector of total scale fluxes.
144  casacore::Vector<casacore::Float> totalTaylorFlux_p; // casacore::Vector of total flux in each taylor term.
145  casacore::Vector<casacore::Float> maxScaleVal_p; // casacore::Vector for peaks at each scale size
146  casacore::Vector<casacore::IPosition> maxScalePos_p; // casacore::Vector of peak positions at each scale size.
147 
149  //casacore::Int nx,ny;
151 
154 
157 
158  // h(s) [nx,ny,nscales]
161 
162  // B_k [nx,ny,ntaylor]
163  // casacore::Block<casacore::Matrix<casacore::Float> > vecPsf_p;
165 
166  // I_D : Residual/Dirty Images [nx,ny,ntaylor]
168 
169  // I_M : Model Images [nx,ny,ntaylor]
171  // casacore::Block <casacore::Matrix<casacore::Float> > vecScaleModel_p;
172 
173  // A_{smn} = B_{sm} * B{sn} [nx,ny,ntaylor,ntaylor,nscales,nscales]
174  // A_{s1s2mn} = B_{s1m} * B{s2n} [nx,ny,ntaylor,ntaylor,nscales,nscales]
176 
177  // R_{sk} = I_D * B_{sk} [nx,ny,ntaylor,nscales]
179 
180  // a_{sk} = Solution vectors. [nx,ny,ntaylor,nscales]
182 
183  // casacore::Memory to be allocated per Matrix
185 
186  // Solve [A][Coeffs] = [I_D * B]
187  // Shape of A : [ntaylor,ntaylor]
190 
191  // FFTserver
193 
194  // Initial setup functions
198 
199  // Setup per major cycle
203 
204  // Solver functions : minor-cycle iterations. Need to be efficient.
209  casacore::Int checkConvergence(casacore::Int updatetype, casacore::Float &fluxlimit, casacore::Float &loopgain);
211 
212  // Helper functions
215  casacore::Int IND4(casacore::Int taylor1, casacore::Int taylor2, casacore::Int scale1, casacore::Int scale2);
216 
218 };
219 
220 } //# NAMESPACE CASA - END
221 
222 #endif
223 
casacore::Bool initialise(casacore::Int nx, casacore::Int ny)
Initialize all the memory being used.
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
casacore::Int verifyScaleSizes()
Initial setup functions.
casacore::Bool getmodel(int order, casacore::Matrix< casacore::Float > &model)
Output : Model images.
casacore::FFTServer< casacore::Float, casacore::Complex > fftcomplex
FFTserver.
int Int
Definition: aipstype.h:50
casacore::Int computeHessianPeak()
Calculate Hessian elements and check for invertibility Does not have to be called externally...
casacore::Int IND2(casacore::Int taylor, casacore::Int scale)
casacore::Matrix< casacore::Float > residual()
Look at what WE think the residuals look like Assumes the first scale is zero-sized.
casacore::Float threshold() const
Method to return threshold, including any speedup factors.
casacore::Quantum< casacore::Double > itsThreshold
casacore::Block< casacore::Matrix< casacore::Complex > > vecScalesFT_p
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
casacore::Int solveMatrixEqn(casacore::Int ntaylor, casacore::Int scale, casacore::IPosition blc, casacore::IPosition trc)
Solver functions : minor-cycle iterations.
casacore::Vector< casacore::Float > scaleSizes_p
casacore::Bool setmask(casacore::Matrix< casacore::Float > &mask)
casacore::Input : mask
casacore::Bool setmodel(int order, casacore::Matrix< casacore::Float > &model)
casacore::Input : model images
casacore::Matrix< casacore::Complex > dirtyFT_p
casacore::Float itsMaskThreshold
casacore::Bool setresidual(int order, casacore::Matrix< casacore::Float > &dirty)
casacore::Input : psfs and dirty images
casacore::Bool getresidual(int order, casacore::Matrix< casacore::Float > &residual)
Output : psfs and dirty images.
casacore::Int computeFluxLimit(casacore::Float &fluxlimit, casacore::Float threshold)
casacore::Int mtclean(casacore::Int maxniter, casacore::Float stopfraction, casacore::Float inputgain, casacore::Float userthreshold)
Run the minor cycle.
ostream-like interface to creating log messages.
Definition: LogIO.h:167
casacore::Vector< casacore::Float > totalTaylorFlux_p
casacore::Block< casacore::Matrix< casacore::Float > > vecDirty_p
I_D : Residual/Dirty Images [nx,ny,ntaylor].
casacore::Bool setscales(const casacore::Vector< casacore::Float > &scales)
casacore::Input : scales
casacore::Block< casacore::Matrix< casacore::Double > > matA_p
Solve [A][Coeffs] = [I_D * B] Shape of A : [ntaylor,ntaylor].
casacore::CountedPtr< casacore::Matrix< casacore::Float > > itsMask
casacore::IPosition itsPositionPeakPsf
casacore::Int setupUserMask()
Setup per major cycle.
casacore::Bool computeprincipalsolution()
Compute principal solution - in-place on the residual images in vecDirty.
casacore::Int ntaylor_p
using MatrixCleaner::makeScaleMasks;
casacore::Int checkConvergence(casacore::Int updatetype, casacore::Float &fluxlimit, casacore::Float &loopgain)
static casacore::Bool findMaxAbs(const casacore::Matrix< casacore::Float > &lattice, casacore::Float &maxAbs, casacore::IPosition &posMax)
Find the Peak of the matrix.
casacore::Block< casacore::Matrix< casacore::Double > > invMatA_p
double Double
Definition: aipstype.h:55
casacore::Block< casacore::Matrix< casacore::Float > > vecScaleMasks_p
casacore::Int setupScaleFunctions()
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
static void makeBoxesSameSize(casacore::IPosition &blc1, casacore::IPosition &trc1, casacore::IPosition &blc2, casacore::IPosition &trc2)
Helper function to reduce the box sizes until the have the same size keeping the centers intact...
casacore::Int writeMatrixToDisk(casacore::String imagename, casacore::Matrix< casacore::Float > &themat)
Helper functions.
casacore::Float getpeakresidual()
Output : Peak residual computed from matR_p (residual convolved with PSF).
casacore::Block< casacore::Matrix< casacore::Float > > vecScales_p
h(s) [nx,ny,nscales]
casacore::Bool validatePsf(const casacore::Matrix< casacore::Float > &psf)
Make sure that the peak of the Psf is within the image.
float Float
Definition: aipstype.h:54
MultiTermMatrixCleaner()
Create a cleaner.
casacore::Vector< casacore::IPosition > maxScalePos_p
casacore::Bool setntaylorterms(const int &nterms)
casacore::Input : number of Taylor terms Reshapes PtrBlocks to hold the correct number of PSFs and Re...
casacore::Int IND4(casacore::Int taylor1, casacore::Int taylor2, casacore::Int scale1, casacore::Int scale2)
simple 1-D array
casacore::Matrix< casacore::Complex > cWork_p
A copy of casacore::LatticeCleaner but just using 2-D matrices.
Definition: MatrixCleaner.h:93
casacore::Bool buildImagePatches()
casacore::Vector< casacore::Float > scaleBias_p
casacore::Vector< casacore::Float > totalScaleFlux_p
casacore::Vector< casacore::Float > maxScaleVal_p
casacore::Block< casacore::Matrix< casacore::Float > > cubeA_p
casacore::Block &lt;casacore::Matrix&lt;casacore::Float&gt; &gt; vecScaleModel_p;
casacore::Int itsMaxNiter
casacore::Int updateModelAndRHS(casacore::Float loopgain)
casacore::Block< casacore::Matrix< casacore::Float > > vecWork_p
casacore::Int chooseComponent(casacore::Int ntaylor, casacore::Int scale, casacore::Int criterion, casacore::IPosition blc, casacore::IPosition trc)
casacore::Int allocateMemory()
~MultiTermMatrixCleaner()
The copy constructor uses reference semantics MultiTermMatrixCleaner(const MultiTermMatrixCleaner &amp; o...
String: the storage and methods of handling collections of characters.
Definition: String.h:223
casacore::Block< casacore::Matrix< casacore::Float > > vecModel_p
I_M : Model Images [nx,ny,ntaylor].
casacore::Block< casacore::Matrix< casacore::Complex > > vecPsfFT_p
B_k [nx,ny,ntaylor] casacore::Block&lt;casacore::Matrix&lt;casacore::Float&gt; &gt; vecPsf_p;.
casacore::Bool setpsf(int order, casacore::Matrix< casacore::Float > &psf)
casacore::Input : psfs and dirty images
casacore::CleanEnums::CleanType itsCleanType
casacore::Int updateRHS(casacore::Int ntaylor, casacore::Int scale, casacore::Float loopgain, casacore::Vector< casacore::Float > coeffs, casacore::IPosition blc, casacore::IPosition trc, casacore::IPosition blcPsf, casacore::IPosition trcPsf)
casacore::Block< casacore::Matrix< casacore::Float > > matCoeffs_p
a_{sk} = Solution vectors.
casacore::Float itsGain
void makeScale(casacore::Matrix< casacore::Float > &scale, const casacore::Float &scaleSize)
Make an array of the specified scale.
casacore::Bool findMaxAbsMask(const casacore::Matrix< casacore::Float > &lattice, const casacore::Matrix< casacore::Float > &mask, casacore::Float &maxAbs, casacore::IPosition &posMax)
Find the Peak of the lattice, applying a mask.
casacore::Block< casacore::Matrix< casacore::Float > > matR_p
R_{sk} = I_D * B_{sk} [nx,ny,ntaylor,nscales].
casacore::Bool getinvhessian(casacore::Matrix< casacore::Double > &invhessian)
Output : Hessian matrix.
casacore::Bool donePSP_p
casacore::Int nx,ny;
casacore::Double memoryMB_p
casacore::Memory to be allocated per Matrix