LCOV - code coverage report
Current view: top level - synthesis/MeasurementEquations - ImageMSCleaner.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 2 0.0 %
Date: 2024-10-10 19:51:30 Functions: 0 1 0.0 %

          Line data    Source code
       1             : //# ImageMSCleaner.h: this defines Cleaner a class for doing convolution
       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             : //#
      27             : //# $Id: $
      28             : 
      29             : #ifndef SYNTHESIS_IMAGEMSCLEANER_H
      30             : #define SYNTHESIS_IMAGEMSCLEANER_H
      31             : 
      32             : //# Includes
      33             : #include <synthesis/MeasurementEquations/MatrixCleaner.h>
      34             : #include <casacore/casa/Arrays/ArrayFwd.h>
      35             : 
      36             : namespace casacore{
      37             : 
      38             : template <class T> class ImageInterface;
      39             : 
      40             : }
      41             : 
      42             : namespace casa { //# NAMESPACE CASA - BEGIN
      43             : 
      44             : //# Forward Declarations
      45             : 
      46             : 
      47             : 
      48             : // <summary>A class interfacing images to MatrixCleaner </summary>
      49             : 
      50             : // <use visibility=export>
      51             : 
      52             : // <reviewed reviewer="" date="yyyy/mm/dd" tests="tLatticeCleaner">
      53             : // </reviewed>
      54             : 
      55             : // <prerequisite>
      56             : //  <li> ImageInterface
      57             : //  <li> MatrixCleaner
      58             : // </prerequisite>
      59             : //
      60             : // <etymology>
      61             : 
      62             : // The ImageCleaner class will use MSClean on Images.
      63             : 
      64             : // </etymology>
      65             : //
      66             : // <synopsis>
      67             : // This class will perform various types of Clean deconvolution
      68             : // on Lattices.
      69             : //
      70             : // </synopsis>
      71             : //
      72             : // <example>
      73             : // <srcblock>
      74             : // </srcblock> 
      75             : // </example>
      76             : //
      77             : // <motivation>
      78             : // </motivation>
      79             : //
      80             : // <thrown>
      81             : // <li> casacore::AipsError: if psf has more dimensions than the model. 
      82             : // </thrown>
      83             : //
      84             : 
      85             : class ImageMSCleaner
      86             : 
      87             : {
      88             : 
      89             :  public:
      90             :   //Default
      91             :   ImageMSCleaner();
      92             :   // Create a cleaner with a psf and dirty image
      93             :   ImageMSCleaner(casacore::ImageInterface<casacore::Float>& psf, casacore::ImageInterface<casacore::Float>& dirty);
      94             :   //assignmemnt constructor
      95             :   ImageMSCleaner(const ImageMSCleaner& other);
      96             :   //assignment operator
      97             :   ImageMSCleaner & operator=(const ImageMSCleaner & other);
      98             : 
      99             :   //The destructor
     100             :   ~ImageMSCleaner();
     101             :   
     102             :   // Update the dirty image only
     103             :   void update(casacore::ImageInterface<casacore::Float> & dirty);
     104             :   // Change the psf image 
     105             :   void setPsf(casacore::ImageInterface<casacore::Float> & psf);
     106             : 
     107             :   //// Set a number of scale sizes. The units of the scale are pixels.
     108             :   void setscales(const casacore::Int nscales, const casacore::Float scaleInc=1.0);
     109             :   // Set a specific set of scales
     110             :   void  setscales(const casacore::Vector<casacore::Float> & scales);
     111             : 
     112             :   // Set up control parameters
     113             :   // cleanType - type of the cleaning algorithm to use (HOGBOM, MULTISCALE)
     114             :   // niter - number of iterations
     115             :   // gain - loop gain used in cleaning (a fraction of the maximum 
     116             :   //        subtracted at every iteration)
     117             :   // aThreshold - absolute threshold to stop iterations
     118             :   // fThreshold - fractional threshold (i.e. given w.r.t. maximum residual)
     119             :   //              to stop iterations. This parameter is specified as
     120             :   //              casacore::Quantity so it can be given in per cents. 
     121             :   casacore::Bool setcontrol(casacore::CleanEnums::CleanType cleanType, const casacore::Int niter,
     122             :                   const casacore::Float gain, const casacore::Quantity& aThreshold,
     123             :                   const casacore::Quantity& fThreshold);
     124             :   
     125             :   // This version of the method disables stopping on fractional threshold
     126             :   casacore::Bool setcontrol(casacore::CleanEnums::CleanType cleanType, const casacore::Int niter,
     127             :                   const casacore::Float gain, const casacore::Quantity& threshold);
     128             :   
     129             :   // return how many iterations we did do
     130             :   casacore::Int iteration() const ;
     131             :   casacore::Int numberIterations() const ;
     132             :   
     133             :   // what iteration number to start on
     134             :   void startingIteration(const casacore::Int starting = 0);
     135             : 
     136             :   // Clean an image. 
     137             :   //return value gives you a hint of what's happening
     138             :   //  1 = converged
     139             :   //  0 = not converged but behaving normally
     140             :   // -1 = not converged and stopped on cleaning consecutive smallest scale
     141             :   // -2 = not converged and either large scale hit negative or diverging 
     142             :   // -3 = clean is diverging rather than converging 
     143             :   casacore::Int clean(casacore::ImageInterface<casacore::Float> & model, const casacore::String& algorithm, 
     144             :             const casacore::Int niter, const casacore::Float gain, const casacore::Quantity& threshold, 
     145             :             const casacore::Quantity& fthresh=casacore::Quantity(0.0, "%"),
     146             :             casacore::Bool doPlotProgress=false);
     147             :   // Set the mask
     148             :   // mask - input mask lattice
     149             :   // maskThreshold - if positive, the value is treated as a threshold value to determine
     150             :   // whether a pixel is good (mask value is greater than the threshold) or has to be 
     151             :   // masked (mask value is below the threshold). Negative threshold switches mask clipping
     152             :   // off. The mask value is used to weight the flux during cleaning. This mode is used
     153             :   // to implement cleaning based on the signal-to-noise as opposed to the standard cleaning
     154             :   // based on the flux. The default threshold value is 0.9, which ensures the behavior of the
     155             :   // code is exactly the same as before this parameter has been introduced.
     156           0 :   void setMask(casacore::ImageInterface<casacore::Float> & mask, const casacore::Float& maskThreshold = 0.9);
     157             :   // Tell the algorithm to NOT clean just the inner quarter
     158             :   // (This is useful when multiscale clean is being used
     159             :   // inside a major cycle for MF or WF algorithms)
     160             :   // if true, the full image deconvolution will be attempted
     161             :   void ignoreCenterBox(casacore::Bool ign) ;
     162             :   // Consider the case of a point source: 
     163             :   // the flux on all scales is the same, and the first scale will be chosen.
     164             :   // Now, consider the case of a point source with a *little* bit of extended structure:
     165             :   // thats right, the largest scale will be chosen.  In this case, we should provide some
     166             :   // bias towards the small scales, or against the large scales.  We do this in
     167             :   // an ad hoc manner, multiplying the maxima found at each scale by
     168             :   // 1.0 - itsSmallScaleBias * itsScaleSizes(scale)/itsScaleSizes(nScalesToClean-1);
     169             :   // Typical bias values range from 0.2 to 1.0.
     170             :   void setSmallScaleBias(const casacore::Float x=0.5);
     171             :    // During early iterations of a cycled casacore::MS Clean in mosaicing, it common
     172             :   // to come across an ocsilatory pattern going between positive and
     173             :   // negative in the large scale.  If this is set, we stop at the first
     174             :   // negative in the largest scale.
     175             :   void stopAtLargeScaleNegative() ;
     176             :   // Some algorithms require that the cycles be terminated when the image
     177             :   // is dominated by point sources; if we get nStopPointMode of the
     178             :   // smallest scale components in a row, we terminate the cycles
     179             :   void stopPointMode(casacore::Int nStopPointMode) ;
     180             :    // After completion of cycle, querry this to find out if we stopped because
     181             :   // of stopPointMode
     182             :   casacore::Bool queryStopPointMode() const ;
     183             :   // speedup() will speed the clean iteration by raising the
     184             :   // threshold.  This may be required if the threshold is
     185             :   // accidentally set too low (ie, lower than can be achieved
     186             :   // given errors in the approximate PSF).
     187             :   //
     188             :   // threshold(iteration) = threshold(0) 
     189             :   //                        * ( exp( (iteration - startingiteration)/Ndouble )/ 2.718 )
     190             :   // If speedup() is NOT invoked, no effect on threshold
     191             :   void speedup(const casacore::Float Ndouble);
     192             : 
     193             :   //Max residual after last clean
     194           0 :   casacore::Float maxResidual() {return maxResidual_p;};
     195             : 
     196             :  private:
     197             :   //Helper function to setup some param
     198             :   casacore::Bool setupMatCleaner(const casacore::String& alg, const casacore::Int niter, const casacore::Float gain, 
     199             :                        const casacore::Quantity& threshold, const casacore::Quantity& fthresh=casacore::Quantity(0.0, "%"));
     200             :   MatrixCleaner matClean_p;
     201             :   casacore::ImageInterface<casacore::Float>* psf_p;
     202             :   casacore::ImageInterface<casacore::Float>* dirty_p;
     203             :   casacore::ImageInterface<casacore::Float>* mask_p;
     204             :   casacore::Int nPsfChan_p;
     205             :   casacore::Int nImChan_p;
     206             :   casacore::Int nPsfPol_p;
     207             :   casacore::Int nImPol_p;
     208             :   casacore::Int chanAxis_p;
     209             :   casacore::Int polAxis_p;
     210             :   casacore::Int nMaskChan_p;
     211             :   casacore::Int nMaskPol_p;
     212             :   casacore::Vector<casacore::Float> scales_p;
     213             :   casacore::Float maskThresh_p;
     214             :   casacore::Float maxResidual_p;
     215             : 
     216             : };
     217             : 
     218             : } //# NAMESPACE CASA - END
     219             : 
     220             : #endif

Generated by: LCOV version 1.16