casa
5.7.0-16
|
A copy of casacore::LatticeCleaner but just using 2-D matrices. More...
#include <MatrixCleaner.h>
Public Member Functions | |
MatrixCleaner () | |
Create a cleaner : default constructor. More... | |
MatrixCleaner (const casacore::Matrix< casacore::Float > &psf, const casacore::Matrix< casacore::Float > &dirty) | |
Create a cleaner for a specific dirty image and PSF. More... | |
MatrixCleaner (const MatrixCleaner &other) | |
The copy constructor uses reference semantics. More... | |
MatrixCleaner & | operator= (const MatrixCleaner &other) |
The assignment operator also uses reference semantics. More... | |
~MatrixCleaner () | |
The destructor does nothing special. More... | |
void | defineScales (const casacore::Vector< casacore::Float > &scales) |
just define the scales...nothing else is done the user will need to call setPsf+makePsfScales+setDirty+makeDirtyScales to be in a good state to clean. More... | |
void | setDirty (const casacore::Matrix< casacore::Float > &dirty) |
Set the dirty image without calculating convolutions. More... | |
void | makeDirtyScales () |
Calculate the convolutions for the dirt Obviously the. More... | |
void | update (const casacore::Matrix< casacore::Float > &dirty) |
Update the dirty image only (equiv of setDirty + makeDirtyScales) More... | |
void | setPsf (const casacore::Matrix< casacore::Float > &psf) |
change the psf don't forget to redo the setscales or run makePsfScales, followed by makeDirtyScales More... | |
void | makePsfScales () |
calculate the convolutions of the psf More... | |
casacore::Bool | setscales (const casacore::Int nscales, const casacore::Float scaleInc=1.0) |
Set a number of scale sizes. More... | |
casacore::Bool | setscales (const casacore::Vector< casacore::Float > &scales) |
Set a specific set of scales. More... | |
casacore::Bool | setcontrol (casacore::CleanEnums::CleanType cleanType, const casacore::Int niter, const casacore::Float gain, const casacore::Quantity &aThreshold, const casacore::Quantity &fThreshold) |
Set up control parameters cleanType - type of the cleaning algorithm to use (HOGBOM, MULTISCALE) niter - number of iterations gain - loop gain used in cleaning (a fraction of the maximum subtracted at every iteration) aThreshold - absolute threshold to stop iterations fThreshold - fractional threshold (i.e. More... | |
casacore::Bool | setcontrol (casacore::CleanEnums::CleanType cleanType, const casacore::Int niter, const casacore::Float gain, const casacore::Quantity &threshold) |
This version of the method disables stopping on fractional threshold. More... | |
casacore::Int | iteration () const |
return how many iterations we did do More... | |
casacore::Int | numberIterations () const |
void | startingIteration (const casacore::Int starting=0) |
what iteration number to start on More... | |
casacore::Float | totalFlux () const |
Total flux accumulated so far. More... | |
casacore::Int | clean (casacore::Matrix< casacore::Float > &model, casacore::Bool doPlotProgress=false) |
Clean an image. More... | |
void | setMask (casacore::Matrix< casacore::Float > &mask, const casacore::Float &maskThreshold=0.9) |
Set the mask mask - input mask lattice maskThreshold - if positive, the value is treated as a threshold value to determine whether a pixel is good (mask value is greater than the threshold) or has to be masked (mask value is below the threshold). More... | |
casacore::Bool | makeScaleMasks () |
Call the function below if the psf is changed..no need to setMask again. More... | |
void | unsetMask () |
remove the mask; useful when keeping object and sending a new dirty image to clean one can set another mask then More... | |
void | ignoreCenterBox (casacore::Bool huh) |
Tell the algorithm to NOT clean just the inner quarter (This is useful when multiscale clean is being used inside a major cycle for MF or WF algorithms) if true, the full image deconvolution will be attempted. More... | |
void | setSmallScaleBias (const casacore::Float x=0.5) |
Consider the case of a point source: the flux on all scales is the same, and the first scale will be chosen. More... | |
void | stopAtLargeScaleNegative () |
During early iterations of a cycled casacore::MS Clean in mosaicing, it common to come across an ocsilatory pattern going between positive and negative in the large scale. More... | |
void | stopPointMode (casacore::Int nStopPointMode) |
Some algorithms require that the cycles be terminated when the image is dominated by point sources; if we get nStopPointMode of the smallest scale components in a row, we terminate the cycles. More... | |
casacore::Bool | queryStopPointMode () const |
After completion of cycle, querry this to find out if we stopped because of stopPointMode. More... | |
void | speedup (const casacore::Float Ndouble) |
speedup() will speed the clean iteration by raising the threshold. More... | |
casacore::Matrix< casacore::Float > | residual () |
Look at what WE think the residuals look like Assumes the first scale is zero-sized. More... | |
casacore::Matrix< casacore::Float > | residual (const casacore::Matrix< casacore::Float > &model) |
slightly better approximation of the residual: it convolves the given model with the psf and remove it from the dirty image put in setdirty More... | |
casacore::Float | threshold () const |
Method to return threshold, including any speedup factors. More... | |
casacore::Float | strengthOptimum () const |
Method to return the strength optimum achieved at the last clean iteration The output of this method makes sense only if it is called after clean. More... | |
Protected Member Functions | |
casacore::Bool | validatePsf (const casacore::Matrix< casacore::Float > &psf) |
Make sure that the peak of the Psf is within the image. More... | |
void | makeScale (casacore::Matrix< casacore::Float > &scale, const casacore::Float &scaleSize) |
Make an array of the specified scale. More... | |
casacore::Float | spheroidal (casacore::Float nu) |
Make Spheroidal function for scale images. More... | |
casacore::Int | findBeamPatch (const casacore::Float maxScaleSize, const casacore::Int &nx, const casacore::Int &ny, const casacore::Float psfBeam=4.0, const casacore::Float nBeams=20.0) |
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. More... | |
Static Protected Member Functions | |
static casacore::Bool | findMaxAbs (const casacore::Matrix< casacore::Float > &lattice, casacore::Float &maxAbs, casacore::IPosition &posMax) |
Find the Peak of the matrix. More... | |
static casacore::Bool | findPSFMaxAbs (const casacore::Matrix< casacore::Float > &lattice, casacore::Float &maxAbs, casacore::IPosition &posMax, const casacore::Int &supportSize=100) |
This is made static since findMaxAbs is static(!). More... | |
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. More... | |
Private Member Functions | |
casacore::Int | index (const casacore::Int scale, const casacore::Int otherscale) |
Calculate index into PsfConvScales. More... | |
casacore::Bool | destroyScales () |
casacore::Bool | destroyMasks () |
Friends | |
class | MatrixNACleaner |
Helper function to optimize adding static void addTo(casacore::Matrix<casacore::Float>& to, const casacore::Matrix<casacore::Float> & add); More... | |
A copy of casacore::LatticeCleaner but just using 2-D matrices.
It is a mimic of the casacore::LatticeCleaner class but avoid a lot of of the lattice to array and back copies and uses openmp in the obvious places
A class for doing multi-dimensional cleaning
Public interface
The MatrixCleaner class will deconvolve 2-D arrays of floats.
This class will perform various types of Clean deconvolution on Lattices.
Definition at line 93 of file MatrixCleaner.h.
casa::MatrixCleaner::MatrixCleaner | ( | ) |
Create a cleaner : default constructor.
casa::MatrixCleaner::MatrixCleaner | ( | const casacore::Matrix< casacore::Float > & | psf, |
const casacore::Matrix< casacore::Float > & | dirty | ||
) |
Create a cleaner for a specific dirty image and PSF.
casa::MatrixCleaner::MatrixCleaner | ( | const MatrixCleaner & | other | ) |
The copy constructor uses reference semantics.
casa::MatrixCleaner::~MatrixCleaner | ( | ) |
The destructor does nothing special.
casacore::Int casa::MatrixCleaner::clean | ( | casacore::Matrix< casacore::Float > & | model, |
casacore::Bool | doPlotProgress = false |
||
) |
Clean an image.
return value gives you a hint of what's happening 1 = converged 0 = not converged but behaving normally -1 = not converged and stopped on cleaning consecutive smallest scale -2 = not converged and either large scale hit negative or diverging -3 = clean is diverging rather than converging
void casa::MatrixCleaner::defineScales | ( | const casacore::Vector< casacore::Float > & | scales | ) |
just define the scales...nothing else is done the user will need to call setPsf+makePsfScales+setDirty+makeDirtyScales to be in a good state to clean.
|
private |
|
private |
|
protected |
|
staticprotected |
Find the Peak of the matrix.
|
protected |
Find the Peak of the lattice, applying a mask.
|
staticprotected |
This is made static since findMaxAbs is static(!).
Why is findMaxAbs static??? –SB
|
inline |
Tell the algorithm to NOT clean just the inner quarter (This is useful when multiscale clean is being used inside a major cycle for MF or WF algorithms) if true, the full image deconvolution will be attempted.
Definition at line 207 of file MatrixCleaner.h.
References itsIgnoreCenterBox.
|
private |
Calculate index into PsfConvScales.
|
inline |
return how many iterations we did do
Definition at line 166 of file MatrixCleaner.h.
References itsIteration.
|
staticprotected |
Helper function to reduce the box sizes until the have the same size keeping the centers intact.
void casa::MatrixCleaner::makeDirtyScales | ( | ) |
Calculate the convolutions for the dirt Obviously the.
void casa::MatrixCleaner::makePsfScales | ( | ) |
calculate the convolutions of the psf
|
protected |
Make an array of the specified scale.
casacore::Bool casa::MatrixCleaner::makeScaleMasks | ( | ) |
Call the function below if the psf is changed..no need to setMask again.
|
inline |
Definition at line 167 of file MatrixCleaner.h.
References itsIteration.
MatrixCleaner& casa::MatrixCleaner::operator= | ( | const MatrixCleaner & | other | ) |
The assignment operator also uses reference semantics.
|
inline |
After completion of cycle, querry this to find out if we stopped because of stopPointMode.
Definition at line 232 of file MatrixCleaner.h.
References itsDidStopPointMode.
|
inline |
Look at what WE think the residuals look like Assumes the first scale is zero-sized.
Definition at line 246 of file MatrixCleaner.h.
References itsDirtyConvScales.
casacore::Matrix<casacore::Float> casa::MatrixCleaner::residual | ( | const casacore::Matrix< casacore::Float > & | model | ) |
slightly better approximation of the residual: it convolves the given model with the psf and remove it from the dirty image put in setdirty
casacore::Bool casa::MatrixCleaner::setcontrol | ( | casacore::CleanEnums::CleanType | cleanType, |
const casacore::Int | niter, | ||
const casacore::Float | gain, | ||
const casacore::Quantity & | aThreshold, | ||
const casacore::Quantity & | fThreshold | ||
) |
Set up control parameters cleanType - type of the cleaning algorithm to use (HOGBOM, MULTISCALE) niter - number of iterations gain - loop gain used in cleaning (a fraction of the maximum subtracted at every iteration) aThreshold - absolute threshold to stop iterations fThreshold - fractional threshold (i.e.
given w.r.t. maximum residual) to stop iterations. This parameter is specified as casacore::Quantity so it can be given in per cents. choose - unused at the moment, specify false. Original meaning is to allow interactive decision on whether to continue iterations. This method always returns true.
casacore::Bool casa::MatrixCleaner::setcontrol | ( | casacore::CleanEnums::CleanType | cleanType, |
const casacore::Int | niter, | ||
const casacore::Float | gain, | ||
const casacore::Quantity & | threshold | ||
) |
This version of the method disables stopping on fractional threshold.
void casa::MatrixCleaner::setDirty | ( | const casacore::Matrix< casacore::Float > & | dirty | ) |
Set the dirty image without calculating convolutions.
can be done by calling makeDirtyScales or setscales if one want to redo the psfscales too.
void casa::MatrixCleaner::setMask | ( | casacore::Matrix< casacore::Float > & | mask, |
const casacore::Float & | maskThreshold = 0.9 |
||
) |
Set the mask mask - input mask lattice maskThreshold - if positive, the value is treated as a threshold value to determine whether a pixel is good (mask value is greater than the threshold) or has to be masked (mask value is below the threshold).
Negative threshold switches mask clipping off. The mask value is used to weight the flux during cleaning. This mode is used to implement cleaning based on the signal-to-noise as opposed to the standard cleaning based on the flux. The default threshold value is 0.9, which ensures the behavior of the code is exactly the same as before this parameter has been introduced.
void casa::MatrixCleaner::setPsf | ( | const casacore::Matrix< casacore::Float > & | psf | ) |
change the psf don't forget to redo the setscales or run makePsfScales, followed by makeDirtyScales
casacore::Bool casa::MatrixCleaner::setscales | ( | const casacore::Int | nscales, |
const casacore::Float | scaleInc = 1.0 |
||
) |
Set a number of scale sizes.
The units of the scale are pixels. The 2 functions below assume you have the dirty image and the psf set the convolutions are calculated automatically and the masks ones too if it is set....kept so as to be compatible function wise with LatticeCleaner
casacore::Bool casa::MatrixCleaner::setscales | ( | const casacore::Vector< casacore::Float > & | scales | ) |
Set a specific set of scales.
|
inline |
Consider the case of a point source: the flux on all scales is the same, and the first scale will be chosen.
Now, consider the case of a point source with a little bit of extended structure: thats right, the largest scale will be chosen. In this case, we should provide some bias towards the small scales, or against the large scales. We do this in an ad hoc manner, multiplying the maxima found at each scale by 1.0 - itsSmallScaleBias * itsScaleSizes(scale)/itsScaleSizes(nScalesToClean-1); Typical bias values range from 0.2 to 1.0.
Definition at line 217 of file MatrixCleaner.h.
References itsSmallScaleBias.
void casa::MatrixCleaner::speedup | ( | const casacore::Float | Ndouble | ) |
speedup() will speed the clean iteration by raising the threshold.
This may be required if the threshold is accidentally set too low (ie, lower than can be achieved given errors in the approximate PSF).
threshold(iteration) = threshold(0) (exp((iteration - startingiteration)/Ndouble)/ 2.718) If speedup() is NOT invoked, no effect on threshold
|
protected |
Make Spheroidal function for scale images.
|
inline |
what iteration number to start on
Definition at line 170 of file MatrixCleaner.h.
References itsStartingIter.
|
inline |
During early iterations of a cycled casacore::MS Clean in mosaicing, it common to come across an ocsilatory pattern going between positive and negative in the large scale.
If this is set, we stop at the first negative in the largest scale.
Definition at line 223 of file MatrixCleaner.h.
References itsStopAtLargeScaleNegative.
|
inline |
Some algorithms require that the cycles be terminated when the image is dominated by point sources; if we get nStopPointMode of the smallest scale components in a row, we terminate the cycles.
Definition at line 228 of file MatrixCleaner.h.
References itsStopPointMode.
|
inline |
Method to return the strength optimum achieved at the last clean iteration The output of this method makes sense only if it is called after clean.
Definition at line 255 of file MatrixCleaner.h.
References itsStrengthOptimum.
casacore::Float casa::MatrixCleaner::threshold | ( | ) | const |
Method to return threshold, including any speedup factors.
|
inline |
Total flux accumulated so far.
Definition at line 173 of file MatrixCleaner.h.
References itsTotalFlux.
void casa::MatrixCleaner::unsetMask | ( | ) |
remove the mask; useful when keeping object and sending a new dirty image to clean one can set another mask then
void casa::MatrixCleaner::update | ( | const casacore::Matrix< casacore::Float > & | dirty | ) |
Update the dirty image only (equiv of setDirty + makeDirtyScales)
|
protected |
Make sure that the peak of the Psf is within the image.
|
friend |
Helper function to optimize adding
static void addTo(casacore::Matrix<casacore::Float>& to, const casacore::Matrix<casacore::Float> & add);
Definition at line 261 of file MatrixCleaner.h.
|
private |
Let the user choose whether to stop.
Definition at line 340 of file MatrixCleaner.h.
|
protected |
Definition at line 294 of file MatrixCleaner.h.
|
private |
Definition at line 360 of file MatrixCleaner.h.
Referenced by queryStopPointMode().
|
private |
Definition at line 315 of file MatrixCleaner.h.
|
private |
Definition at line 322 of file MatrixCleaner.h.
Referenced by residual().
|
private |
Threshold speedup factors:
Definition at line 343 of file MatrixCleaner.h.
|
private |
Definition at line 327 of file MatrixCleaner.h.
|
protected |
Definition at line 295 of file MatrixCleaner.h.
|
private |
Definition at line 357 of file MatrixCleaner.h.
Referenced by ignoreCenterBox().
|
private |
Definition at line 325 of file MatrixCleaner.h.
Referenced by iteration(), and numberIterations().
|
private |
Definition at line 361 of file MatrixCleaner.h.
|
protected |
Definition at line 298 of file MatrixCleaner.h.
|
protected |
Definition at line 305 of file MatrixCleaner.h.
|
private |
Definition at line 329 of file MatrixCleaner.h.
|
protected |
Definition at line 296 of file MatrixCleaner.h.
|
private |
casacore::Memory to be allocated per TempLattice
Definition at line 337 of file MatrixCleaner.h.
|
private |
Definition at line 344 of file MatrixCleaner.h.
|
protected |
Definition at line 304 of file MatrixCleaner.h.
|
protected |
Definition at line 299 of file MatrixCleaner.h.
|
private |
Definition at line 321 of file MatrixCleaner.h.
|
protected |
Definition at line 301 of file MatrixCleaner.h.
|
private |
Definition at line 320 of file MatrixCleaner.h.
|
private |
Definition at line 318 of file MatrixCleaner.h.
|
protected |
Definition at line 303 of file MatrixCleaner.h.
|
protected |
Definition at line 302 of file MatrixCleaner.h.
|
protected |
Definition at line 300 of file MatrixCleaner.h.
Referenced by setSmallScaleBias().
|
private |
Definition at line 326 of file MatrixCleaner.h.
Referenced by startingIteration().
|
private |
Definition at line 358 of file MatrixCleaner.h.
Referenced by stopAtLargeScaleNegative().
|
private |
Definition at line 359 of file MatrixCleaner.h.
Referenced by stopPointMode().
|
private |
Definition at line 330 of file MatrixCleaner.h.
Referenced by strengthOptimum().
|
protected |
Definition at line 297 of file MatrixCleaner.h.
|
private |
Definition at line 334 of file MatrixCleaner.h.
Referenced by totalFlux().
|
private |
Definition at line 333 of file MatrixCleaner.h.
|
private |
Definition at line 316 of file MatrixCleaner.h.
|
private |
Definition at line 367 of file MatrixCleaner.h.
|
private |
threshold for masks.
If negative, mask values are used as weights and no pixels are discarded (although effectively they would be discarded if the mask value is 0.)
Definition at line 366 of file MatrixCleaner.h.