casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
ClarkCleanProgress.h
Go to the documentation of this file.
00001 //# ClarkCleanProgress.h: Abstract base class to monitor progress in lattice operations
00002 //# Copyright (C) 1997,1998,1999,2000
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id$
00027 
00028 #ifndef SYNTHESIS_CLARKCLEANPROGRESS_H
00029 #define SYNTHESIS_CLARKCLEANPROGRESS_H
00030  
00031 //# Includes
00032 #include <casa/aips.h>
00033 #include <casa/Quanta/Quantum.h>
00034 #include <lattices/Lattices/Lattice.h>
00035 #include <lattices/Lattices/TempLattice.h>
00036 #include <casa/Arrays/IPosition.h>
00037 #include <casa/Arrays/Vector.h>
00038 
00039 namespace casa { //# NAMESPACE CASA - BEGIN
00040 
00041 //# Forward Declarations
00042 template <class T> class Vector;
00043 class PGPlotter;
00044 
00045 // <summary>
00046 // Abstract base class to monitor progress in lattice operations
00047 // </summary>
00048 
00049 // <use visibility=export>
00050 
00051 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
00052 // </reviewed>
00053 
00054 // <synopsis>
00055 // This is an abstract base class for classes to monitor the
00056 // progress of an operation on a Lattice. The default implementation
00057 // offered by this class does nothing.
00058 // However, a derived class could show the progress using for example
00059 // a <linkto class=ProgressMeter>ProgressMeter</linkto>. A derived
00060 // class should override the virtual functions from this class.
00061 //
00062 // The user of the ClarkCleanProgress object should first call
00063 // function <src>init</src> with the total number of steps
00064 // that are to be done.   Thereafter, after each step has been
00065 // executed, function <src>nstepsDone</src> should be called
00066 // after each step.  Finally, function <src>done</src> should
00067 // be called.
00068 // </synopsis>
00069 
00070 // <example>
00071 // <srcblock>
00072 // </srcblock>
00073 // </example>
00074 
00075 // <motivation>
00076 // Since operations on Lattices can take a while, it can be useful
00077 // to show the progress. However, making module Lattices dependent on
00078 // the class ProgressMeter sounded bad. This abstract class serves
00079 // as a bridge between the Lattice module and the ProgressMeter class
00080 // (or any other class showing the progress).
00081 // </motivation>
00082 //
00083 //# <todo asof="1997/08/01">   
00084 //#   <li> 
00085 //# </todo>
00086 
00087 
00088 class ClarkCleanProgress {
00089 public:
00090   ClarkCleanProgress(PGPlotter* pgplotter=0, Int plotterIncrement=10);
00091 
00092   // delete its PGPlotter
00093   virtual ~ClarkCleanProgress();
00094   
00095   // Plot the information if it has a PGPlotter
00096   Bool info(const Bool lastcall,
00097             const Int iteration,
00098             const Int numberIterations,
00099             const Float& maximum,
00100             const IPosition& posMaximum,
00101             const Float& totalFlux,
00102             const Bool majorIteration,
00103             const Bool resetBase=False);
00104   
00105   // Finish up any aspects of the plot which need to be finished
00106   Bool finalize();
00107 
00108   // returns true if we have a live pgplotter_pointer
00109   // Use: do a     try { progress_pointer->hasPGPlotter(); }
00110   Bool hasPGPlotter();
00111 
00112 protected:
00113 
00114 private:
00115 
00116   // draw the outline of the plot;
00117   // If doplot = True, redraw all the past data as well.
00118   // THIS ASSUMES WE HAVE A VALID PGPLOTTER
00119   void basicSetUp(Bool doPlot = False);
00120 
00121   // plot just the current points
00122   // THIS ASSUMES WE HAVE A VALID PGPLOTTER
00123   void plotOne(const Int iteration, 
00124                const Float resid, const Float flux);
00125 
00126   // replot all points, but don't redraw plotter
00127   // THIS ASSUMES WE HAVE A VALID PGPLOTTER
00128   void plotVectors();
00129 
00130   PGPlotter* itsPgplotter;
00131 
00132   Vector<Float> iterationNumber;        
00133   Vector<Float> maxResiduals;           
00134   Vector<Float> posResiduals;           
00135   Vector<Float> negResiduals;           
00136   Vector<Float> totalFluxes;
00137   uInt currentIndex;
00138   uInt currentTotalIterations;
00139   Float currentFluxScale;
00140   Float currentMinFluxScale;
00141   Float currentMaxResidual;
00142   Float currentMinResidual;
00143 
00144   // we are going to plot all points, but not all at once; every Increment iterations
00145   Int plottingIncrement;
00146 
00147   Float baseFlux;
00148 
00149 };
00150 
00151 
00152 
00153 } //# NAMESPACE CASA - END
00154 
00155 #endif