Loading...
Searching...
No Matches
MultiTermLatticeCleaner.h
Go to the documentation of this file.
//# MultiTermLatticeCleaner.h: Minor Cycle for MSMFS deconvolution
//# Copyright (C) 1996,1997,1998,1999,2000,2001,2002,2003
//# Associated Universities, Inc. Washington DC, USA.
//#
//# This library is free software; you can redistribute it and/or modify it
//# under the terms of the GNU Library General Public License as published by
//# the Free Software Foundation; either version 2 of the License, or (at your
//# option) any later version.
//#
//# This library is distributed in the hope that it will be useful, but WITHOUT
//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
//# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
//# License for more details.
//#
//# You should have received a copy of the GNU Library General Public License
//# along with this library; if not, write to the Free Software Foundation,
//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
//#
//# Correspondence concerning AIPS++ should be addressed as follows:
//# Internet email: casa-feedback@nrao.edu.
//# Postal address: AIPS++ Project Office
//# National Radio Astronomy Observatory
//# 520 Edgemont Road
//# Charlottesville, VA 22903-2475 USA
//#
//# Urvashi Rau <rurvashi@aoc.nrao.edu>
#ifndef LATTICES_MULTITERMLATTICECLEANER_H
#define LATTICES_MULTITERMLATTICECLEANER_H
#include <casacore/casa/aips.h>
#include <casacore/lattices/LatticeMath/LatticeCleaner.h>
#include <casacore/lattices/Lattices/LatticeIterator.h>
#include <casacore/lattices/LEL/LatticeExpr.h>
#include <casacore/lattices/LEL/LatticeExprNode.h>
namespace casacore { //# NAMESPACE CASACORE - BEGIN
template<class T> class MultiTermLatticeCleaner : public LatticeCleaner<T>
{
public:
// Create a cleaner for a specific dirty image and PSF
MultiTermLatticeCleaner();
// The copy constructor uses reference semantics
MultiTermLatticeCleaner(const MultiTermLatticeCleaner<T> & other);
// The assignment operator also uses reference semantics
MultiTermLatticeCleaner<T> & operator=(const MultiTermLatticeCleaner<T> & other);
// The destructor does nothing special.
~MultiTermLatticeCleaner();
// Input : number of Taylor terms
// Reshapes Blocks to hold the correct number of PSFs and Residual images
Bool setntaylorterms(const int & nterms);
// Input : scales
Bool setscales(const Vector<Float> & scales);
// Initialize all the memory being used.
Bool initialise(Int nx,Int ny);
// Set control parameters.
Bool setcontrol(CleanEnums::CleanType cleanType,const Int niter,const Float gain,const Quantity& aThreshold,const Bool choose);
//# This function is defined in the base class LatticeCleaner, but was not
//# defined in the new MultiTermLatticeCleaner.
//# I (GvD) have added it for the time being.
Bool setcontrol(CleanEnums::CleanType cleanType, const Int niter,
const Float gain, const Quantity& aThreshold,
const Quantity& /*fThreshold*/,
const Bool choose=True)
{ return setcontrol (cleanType, niter, gain, aThreshold, choose); }
// Input : psfs and dirty images
Bool setpsf(int order, Lattice<T> & psf);
// Input : psfs and dirty images
Bool setresidual(int order, Lattice<T> & dirty);
// Input : model images
Bool setmodel(int order, Lattice<T> & model);
// Input : mask
Bool setmask(Lattice<T> & mask);
// Run the minor cycle
Int mtclean(LatticeCleanProgress* progress=0);
// Output : Model images
Bool getmodel(int order, Lattice<T> & model);
// Ouput : psfs and dirty images
Bool getresidual(int order, Lattice<T> & residual);
// Output : Hessian matrix
Bool getinvhessian(Matrix<Double> & invhessian);
private:
LogIO os;
using LatticeCleaner<T>::itsCleanType;
using LatticeCleaner<T>::itsMaxNiter;
using LatticeCleaner<T>::itsGain;
using LatticeCleaner<T>::itsThreshold;
using LatticeCleaner<T>::itsMask;
using LatticeCleaner<T>::itsPositionPeakPsf;
using LatticeCleaner<T>::findMaxAbsLattice;
using LatticeCleaner<T>::findMaxAbsMaskLattice;
using LatticeCleaner<T>::makeScale;
using LatticeCleaner<T>::addTo;
using LatticeCleaner<T>::makeBoxesSameSize;
using LatticeCleaner<T>::validatePsf;
Int ntaylor_p; // Number of terms in the Taylor expansion to use.
Int psfntaylor_p; // Number of terms in the Taylor expansion for PSF.
Int nscales_p; // Number of scales to use for the multiscale part.
Int nx_p;
Int ny_p;
Int totalIters_p;
// Image mask
TempLattice<Float>* dirty_p;
TempLattice<Complex>* dirtyFT_p;
TempLattice<Float>* mask_p;
TempLattice<Float>* fftmask_p;
Vector<Float> scaleSizes_p; // Vector of scale sizes in pixels.
Vector<Float> scaleBias_p; // Vector of scale biases !!
Vector<Float> totalScaleFlux_p; // Vector of total scale fluxes.
Vector<Float> totalTaylorFlux_p; // Vector of total flux in each taylor term.
Float weightScaleFactor_p;
Float maxPsf_p;
IPosition gip,imshape;
Int nx,ny,npol_p,nchan;
Bool donePSF_p,donePSP_p,doneCONV_p;
// h(s) [nx,ny,nscales]
Block<TempLattice<Float>* > vecScales_p;
Block<TempLattice<Complex>* > vecScalesFT_p;
// B_k [nx,ny,ntaylor]
Block<TempLattice<Float>* > vecPsf_p;
Block<TempLattice<Complex>* > vecPsfFT_p;
// I_D : Residual/Dirty Images [nx,ny,ntaylor]
Block<TempLattice<Float>* > vecDirty_p;
// I_M : Model Images [nx,ny,ntaylor]
Block<TempLattice<Float>* > vecModel_p;
// A_{smn} = B_{sm} * B{sn} [nx,ny,ntaylor,ntaylor,nscales,nscales]
// A_{s1s2mn} = B_{s1m} * B{s2n} [nx,ny,ntaylor,ntaylor,nscales,nscales]
Block<TempLattice<Float>* > cubeA_p;
Block<LatticeIterator<Float>* > itercubeA_p;
// R_{sk} = I_D * B_{sk} [nx,ny,ntaylor,nscales]
Block<TempLattice<Float>* > matR_p;
Block<LatticeIterator<Float>* > itermatR_p;
// a_{sk} = Solution vectors. [nx,ny,ntaylor,nscales]
Block<TempLattice<Float>* > matCoeffs_p;
Block<LatticeIterator<Float>* > itermatCoeffs_p;
// Memory to be allocated per TempLattice
Double memoryMB_p;
// Solve [A][Coeffs] = [I_D * B]
// Shape of A : [ntaylor,ntaylor]
Block<Matrix<Double>*> matA_p; // 2D matrix to be inverted.
Block<Matrix<Double>*> invMatA_p; // Inverse of matA_p;
// Scratch Lattices and iterators.
TempLattice<Complex>* cWork_p;
TempLattice<Float>* tWork_p;
LatticeIterator<Float>* itertWork_p;
LatticeExprNode len_p;
Float lambda_p;
Int numberOfTempLattices(Int nscales,Int ntaylor);
Int manageMemory(Bool allocate);
Bool findMaxAbsLattice(const TempLattice<Float>& masklat,const Lattice<Float>& lattice,Float& maxAbs,IPosition& posMaxAbs, Bool flip=False);
Int addTo(Lattice<Float>& to, const Lattice<Float>& add, Float multiplier);
Int setupFFTMask();
Int setupUserMask();
Int setupBlobs();
Int computeFluxLimit(Float &fluxlimit, Float threshold);
Int computeMatrixA();
Int computeRHS();
Int solveMatrixEqn(Int scale);
Int computePenaltyFunction(Int scale, Float &loopgain, Bool choosespec);
Int updateSolution(IPosition globalmaxpos, Int maxscaleindex, Float loopgain);
Int checkConvergence(Bool choosespec, Float thresh, Float fluxlimit);
Int IND2(Int taylor,Int scale);
Int IND4(Int taylor1, Int taylor2, Int scale1, Int scale2);
Bool adbg;
};
} //# NAMESPACE CASACORE - END
#ifndef CASACORE_NO_AUTO_TEMPLATES
#include <casacore/lattices/LatticeMath/MultiTermLatticeCleaner.tcc>
#endif //# CASACORE_NO_AUTO_TEMPLATES
#endif
casacore::Block
Definition Block.h:140
casacore::CleanEnums::CleanType
CleanType
Definition LatticeCleaner.h:51
casacore::IPosition
Definition IPosition.h:117
casacore::LatticeCleanProgress
Definition LatticeCleanProgress.h:87
casacore::LatticeCleaner::findMaxAbsMaskLattice
Bool findMaxAbsMaskLattice(const Lattice< T > &lattice, const Lattice< T > &mask, T &maxAbs, IPosition &posMax)
Find the Peak of the lattice, applying a mask.
casacore::LatticeCleaner::itsGain
Float itsGain
Definition LatticeCleaner.h:257
casacore::LatticeCleaner::itsPositionPeakPsf
IPosition itsPositionPeakPsf
Definition LatticeCleaner.h:261
casacore::LatticeCleaner::makeScale
void makeScale(Lattice< T > &scale, const Float &scaleSize)
Make an lattice of the specified scale.
casacore::LatticeCleaner::itsMaxNiter
Int itsMaxNiter
Definition LatticeCleaner.h:258
casacore::LatticeCleaner::validatePsf
Bool validatePsf(const Lattice< T > &psf)
Make sure that the peak of the Psf is within the image.
casacore::LatticeCleaner::threshold
Float threshold() const
Method to return threshold, including any speedup factors.
casacore::LatticeCleaner::itsMask
TempLattice< T > * itsMask
Definition LatticeCleaner.h:260
casacore::LatticeCleaner::LatticeCleaner
LatticeCleaner()
Create a cleaner : default constructor.
casacore::LatticeCleaner::itsCleanType
CleanEnums::CleanType itsCleanType
Definition LatticeCleaner.h:256
casacore::LatticeCleaner::residual
Lattice< T > * residual()
Look at what WE think the residuals look like Assumes the first scale is zero-sized.
Definition LatticeCleaner.h:220
casacore::LatticeCleaner::makeBoxesSameSize
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.
casacore::LatticeCleaner::itsThreshold
Quantum< Double > itsThreshold
Definition LatticeCleaner.h:259
casacore::LatticeExprNode
Definition LatticeExprNode.h:439
casacore::LatticeIterator
A read/write lattice iterator.
Definition LatticeIterator.h:423
casacore::Lattice
Definition Lattice.h:230
casacore::LogIO
Definition LogIO.h:165
casacore::Matrix
Definition Matrix.h:87
casacore::MultiTermLatticeCleaner::os
LogIO os
Definition MultiTermLatticeCleaner.h:100
casacore::MultiTermLatticeCleaner::totalTaylorFlux_p
Vector< Float > totalTaylorFlux_p
Definition MultiTermLatticeCleaner.h:132
casacore::MultiTermLatticeCleaner::npol_p
Int npol_p
Definition MultiTermLatticeCleaner.h:137
casacore::MultiTermLatticeCleaner::matR_p
Block< TempLattice< Float > * > matR_p
R_{sk} = I_D * B_{sk} [nx,ny,ntaylor,nscales].
Definition MultiTermLatticeCleaner.h:160
casacore::MultiTermLatticeCleaner::~MultiTermLatticeCleaner
~MultiTermLatticeCleaner()
The destructor does nothing special.
casacore::MultiTermLatticeCleaner::MultiTermLatticeCleaner
MultiTermLatticeCleaner(const MultiTermLatticeCleaner< T > &other)
The copy constructor uses reference semantics.
casacore::MultiTermLatticeCleaner::scaleBias_p
Vector< Float > scaleBias_p
Definition MultiTermLatticeCleaner.h:130
casacore::MultiTermLatticeCleaner::adbg
Bool adbg
Definition MultiTermLatticeCleaner.h:204
casacore::MultiTermLatticeCleaner::psfntaylor_p
Int psfntaylor_p
Definition MultiTermLatticeCleaner.h:117
casacore::MultiTermLatticeCleaner::IND2
Int IND2(Int taylor, Int scale)
casacore::MultiTermLatticeCleaner::gip
IPosition gip
Definition MultiTermLatticeCleaner.h:136
casacore::MultiTermLatticeCleaner::donePSP_p
Bool donePSP_p
Definition MultiTermLatticeCleaner.h:138
casacore::MultiTermLatticeCleaner::MultiTermLatticeCleaner
MultiTermLatticeCleaner()
Create a cleaner for a specific dirty image and PSF.
casacore::MultiTermLatticeCleaner::tWork_p
TempLattice< Float > * tWork_p
Definition MultiTermLatticeCleaner.h:177
casacore::MultiTermLatticeCleaner::vecDirty_p
Block< TempLattice< Float > * > vecDirty_p
I_D : Residual/Dirty Images [nx,ny,ntaylor].
Definition MultiTermLatticeCleaner.h:149
casacore::MultiTermLatticeCleaner::nscales_p
Int nscales_p
Definition MultiTermLatticeCleaner.h:118
casacore::MultiTermLatticeCleaner::findMaxAbsLattice
Bool findMaxAbsLattice(const TempLattice< Float > &masklat, const Lattice< Float > &lattice, Float &maxAbs, IPosition &posMaxAbs, Bool flip=False)
casacore::MultiTermLatticeCleaner::vecScalesFT_p
Block< TempLattice< Complex > * > vecScalesFT_p
Definition MultiTermLatticeCleaner.h:142
casacore::MultiTermLatticeCleaner::dirty_p
TempLattice< Float > * dirty_p
Image mask.
Definition MultiTermLatticeCleaner.h:124
casacore::MultiTermLatticeCleaner::setscales
Bool setscales(const Vector< Float > &scales)
Input : scales.
casacore::MultiTermLatticeCleaner::setupFFTMask
Int setupFFTMask()
casacore::MultiTermLatticeCleaner::nchan
Int nchan
Definition MultiTermLatticeCleaner.h:137
casacore::MultiTermLatticeCleaner::setupUserMask
Int setupUserMask()
casacore::MultiTermLatticeCleaner::mtclean
Int mtclean(LatticeCleanProgress *progress=0)
Run the minor cycle.
casacore::MultiTermLatticeCleaner::donePSF_p
Bool donePSF_p
Definition MultiTermLatticeCleaner.h:138
casacore::MultiTermLatticeCleaner::nx_p
Int nx_p
Definition MultiTermLatticeCleaner.h:119
casacore::MultiTermLatticeCleaner::cWork_p
TempLattice< Complex > * cWork_p
Scratch Lattices and iterators.
Definition MultiTermLatticeCleaner.h:176
casacore::MultiTermLatticeCleaner::getmodel
Bool getmodel(int order, Lattice< T > &model)
Output : Model images.
casacore::MultiTermLatticeCleaner::dirtyFT_p
TempLattice< Complex > * dirtyFT_p
Definition MultiTermLatticeCleaner.h:125
casacore::MultiTermLatticeCleaner::addTo
Int addTo(Lattice< Float > &to, const Lattice< Float > &add, Float multiplier)
casacore::MultiTermLatticeCleaner::setcontrol
Bool setcontrol(CleanEnums::CleanType cleanType, const Int niter, const Float gain, const Quantity &aThreshold, const Quantity &, const Bool choose=True)
Definition MultiTermLatticeCleaner.h:69
casacore::MultiTermLatticeCleaner::matCoeffs_p
Block< TempLattice< Float > * > matCoeffs_p
a_{sk} = Solution vectors.
Definition MultiTermLatticeCleaner.h:164
casacore::MultiTermLatticeCleaner::lambda_p
Float lambda_p
Definition MultiTermLatticeCleaner.h:182
casacore::MultiTermLatticeCleaner::len_p
LatticeExprNode len_p
Definition MultiTermLatticeCleaner.h:180
casacore::MultiTermLatticeCleaner::computeRHS
Int computeRHS()
casacore::MultiTermLatticeCleaner::setmask
Bool setmask(Lattice< T > &mask)
Input : mask.
casacore::MultiTermLatticeCleaner::setpsf
Bool setpsf(int order, Lattice< T > &psf)
Input : psfs and dirty images.
casacore::MultiTermLatticeCleaner::totalScaleFlux_p
Vector< Float > totalScaleFlux_p
Definition MultiTermLatticeCleaner.h:131
casacore::MultiTermLatticeCleaner::maxPsf_p
Float maxPsf_p
Definition MultiTermLatticeCleaner.h:134
casacore::MultiTermLatticeCleaner::vecPsf_p
Block< TempLattice< Float > * > vecPsf_p
B_k [nx,ny,ntaylor].
Definition MultiTermLatticeCleaner.h:145
casacore::MultiTermLatticeCleaner::numberOfTempLattices
Int numberOfTempLattices(Int nscales, Int ntaylor)
casacore::MultiTermLatticeCleaner::cubeA_p
Block< TempLattice< Float > * > cubeA_p
A_{smn} = B_{sm} * B{sn} [nx,ny,ntaylor,ntaylor,nscales,nscales] A_{s1s2mn} = B_{s1m}...
Definition MultiTermLatticeCleaner.h:156
casacore::MultiTermLatticeCleaner::doneCONV_p
Bool doneCONV_p
Definition MultiTermLatticeCleaner.h:138
casacore::MultiTermLatticeCleaner::itertWork_p
LatticeIterator< Float > * itertWork_p
Definition MultiTermLatticeCleaner.h:178
casacore::MultiTermLatticeCleaner::vecScales_p
Block< TempLattice< Float > * > vecScales_p
h(s) [nx,ny,nscales]
Definition MultiTermLatticeCleaner.h:141
casacore::MultiTermLatticeCleaner::itermatCoeffs_p
Block< LatticeIterator< Float > * > itermatCoeffs_p
Definition MultiTermLatticeCleaner.h:165
casacore::MultiTermLatticeCleaner::initialise
Bool initialise(Int nx, Int ny)
Initialize all the memory being used.
casacore::MultiTermLatticeCleaner::itermatR_p
Block< LatticeIterator< Float > * > itermatR_p
Definition MultiTermLatticeCleaner.h:161
casacore::MultiTermLatticeCleaner::ny
Int ny
Definition MultiTermLatticeCleaner.h:137
casacore::MultiTermLatticeCleaner::invMatA_p
Block< Matrix< Double > * > invMatA_p
Definition MultiTermLatticeCleaner.h:173
casacore::MultiTermLatticeCleaner::setcontrol
Bool setcontrol(CleanEnums::CleanType cleanType, const Int niter, const Float gain, const Quantity &aThreshold, const Bool choose)
Set control parameters.
casacore::MultiTermLatticeCleaner::setntaylorterms
Bool setntaylorterms(const int &nterms)
Input : number of Taylor terms Reshapes Blocks to hold the correct number of PSFs and Residual images...
casacore::MultiTermLatticeCleaner::setresidual
Bool setresidual(int order, Lattice< T > &dirty)
Input : psfs and dirty images.
casacore::MultiTermLatticeCleaner::getresidual
Bool getresidual(int order, Lattice< T > &residual)
Ouput : psfs and dirty images.
casacore::MultiTermLatticeCleaner::operator=
MultiTermLatticeCleaner< T > & operator=(const MultiTermLatticeCleaner< T > &other)
The assignment operator also uses reference semantics.
casacore::MultiTermLatticeCleaner::computePenaltyFunction
Int computePenaltyFunction(Int scale, Float &loopgain, Bool choosespec)
casacore::MultiTermLatticeCleaner::memoryMB_p
Double memoryMB_p
Memory to be allocated per TempLattice.
Definition MultiTermLatticeCleaner.h:168
casacore::MultiTermLatticeCleaner::vecPsfFT_p
Block< TempLattice< Complex > * > vecPsfFT_p
Definition MultiTermLatticeCleaner.h:146
casacore::MultiTermLatticeCleaner::setupBlobs
Int setupBlobs()
casacore::MultiTermLatticeCleaner::matA_p
Block< Matrix< Double > * > matA_p
Solve [A][Coeffs] = [I_D * B] Shape of A : [ntaylor,ntaylor].
Definition MultiTermLatticeCleaner.h:172
casacore::MultiTermLatticeCleaner::totalIters_p
Int totalIters_p
Definition MultiTermLatticeCleaner.h:121
casacore::MultiTermLatticeCleaner::mask_p
TempLattice< Float > * mask_p
Definition MultiTermLatticeCleaner.h:126
casacore::MultiTermLatticeCleaner::ny_p
Int ny_p
Definition MultiTermLatticeCleaner.h:120
casacore::MultiTermLatticeCleaner::IND4
Int IND4(Int taylor1, Int taylor2, Int scale1, Int scale2)
casacore::MultiTermLatticeCleaner::scaleSizes_p
Vector< Float > scaleSizes_p
Definition MultiTermLatticeCleaner.h:129
casacore::MultiTermLatticeCleaner::nx
Int nx
Definition MultiTermLatticeCleaner.h:137
casacore::MultiTermLatticeCleaner::updateSolution
Int updateSolution(IPosition globalmaxpos, Int maxscaleindex, Float loopgain)
casacore::MultiTermLatticeCleaner::getinvhessian
Bool getinvhessian(Matrix< Double > &invhessian)
Output : Hessian matrix.
casacore::MultiTermLatticeCleaner::manageMemory
Int manageMemory(Bool allocate)
casacore::MultiTermLatticeCleaner::solveMatrixEqn
Int solveMatrixEqn(Int scale)
casacore::MultiTermLatticeCleaner::computeFluxLimit
Int computeFluxLimit(Float &fluxlimit, Float threshold)
casacore::MultiTermLatticeCleaner::weightScaleFactor_p
Float weightScaleFactor_p
Definition MultiTermLatticeCleaner.h:133
casacore::MultiTermLatticeCleaner::ntaylor_p
Int ntaylor_p
Definition MultiTermLatticeCleaner.h:116
casacore::MultiTermLatticeCleaner::vecModel_p
Block< TempLattice< Float > * > vecModel_p
I_M : Model Images [nx,ny,ntaylor].
Definition MultiTermLatticeCleaner.h:152
casacore::MultiTermLatticeCleaner::setmodel
Bool setmodel(int order, Lattice< T > &model)
Input : model images.
casacore::MultiTermLatticeCleaner::checkConvergence
Int checkConvergence(Bool choosespec, Float thresh, Float fluxlimit)
casacore::MultiTermLatticeCleaner::fftmask_p
TempLattice< Float > * fftmask_p
Definition MultiTermLatticeCleaner.h:127
casacore::MultiTermLatticeCleaner::imshape
IPosition imshape
Definition MultiTermLatticeCleaner.h:136
casacore::MultiTermLatticeCleaner::computeMatrixA
Int computeMatrixA()
casacore::MultiTermLatticeCleaner::itercubeA_p
Block< LatticeIterator< Float > * > itercubeA_p
Definition MultiTermLatticeCleaner.h:157
casacore::TempLattice
Definition TempLattice.h:130
casacore::Vector
Definition Vector.h:82
casacore
this file contains all the compiler specific defines
Definition mainpage.dox:28
casacore::False
const Bool False
Definition aipstype.h:42
casacore::mask
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
casacore::Float
float Float
Definition aipstype.h:52
casacore::order
uInt order() const
What is the order of the polynomial, i.e.
Definition PolynomialParam.h:134
casacore::Int
int Int
Definition aipstype.h:48
casacore::Bool
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
casacore::Quantity
Quantum< Double > Quantity
Definition Quantum.h:39
casacore::True
const Bool True
Definition aipstype.h:41
casacore::Double
double Double
Definition aipstype.h:53