casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
IPLatConvEquation.h
Go to the documentation of this file.
00001 //# IPLatConvEquation.h: this defines IPLatConvEquation
00002 //# Copyright (C) 1996,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 //#
00027 //# $Id$
00028 
00029 #ifndef SYNTHESIS_IPLATCONVEQUATION_H
00030 #define SYNTHESIS_IPLATCONVEQUATION_H
00031 
00032 
00033 #include <casa/aips.h>
00034 #include <synthesis/MeasurementEquations/LatConvEquation.h>
00035 #include <lattices/Lattices/LatticeConvolver.h>
00036 #include <lattices/Lattices/Lattice.h>
00037 #include <casa/Arrays/IPosition.h>
00038 #include <casa/Arrays/Array.h>
00039 
00040 namespace casa { //# NAMESPACE CASA - BEGIN
00041 
00042 template <class Domain> class LinearModel;
00043 
00044 
00045 // <summary> Implements the image plane lattice convolution equation </summary>
00046 
00047 // <use visibility=local>
00048 
00049 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
00050 // </reviewed>
00051 
00052 // <prerequisite> 
00053 // <li> <linkto class="LatConvEquation">LatConvEquation</linkto> 
00054 //       (or similar classes) 
00055 // </prerequisite>
00056 //
00057 // <etymology>
00058 // This class implements image plane (ie, single dish) convolution equation
00059 // within the LinearEquation framework, using Lattices.
00060 // </etymology>
00061 //
00062 // <synopsis>
00063 // This class is used in conjunction with classes like HogbomCleanModel to
00064 // implement deconvolution algorithms. This class contains the point spread
00065 // function (psf) and the convolved data (dirty image), and is able to
00066 // convolve a supplied model with the psf to produce a predicted output
00067 // (using the evaluate() function), or to subtract the convolved data and
00068 // produce a residual (using the residual() function).
00069 //
00070 // See the documentation for 
00071 // <linkto class=HogbomCleanModel>HogbomCleanModel</linkto> 
00072 // for an example of how this class can be used to perform deconvolution.
00073 //
00074 // This class also contains specialised functions (like the version of
00075 // evaluate() for a point source model) that speed up the calculation of the
00076 // convolution. This specialised version of evaluate() does not need to
00077 // actually perform the convolution and instead returns a suitable part of
00078 // the psf (zero padded if necessary). When this function is called this
00079 // class will get the psf from the convolver and cache it, on the assumption
00080 // that many evaluations of this function will be requested (as occurs in
00081 // Clean algorithms). 
00082 // 
00083 // The size and shape of the psf and the supplied model may be different. The
00084 // only restriction is that the dimension of the psf must be less than or
00085 // equal to the dimension of the model. If the dimension of the
00086 // model is larger than the dimension of the psf then the convolution
00087 // will be repeated along the slowest moving (last) axis. The dirty image
00088 // and the supplied model must be the same size and shape. 
00089 //
00090 //
00091 // </synopsis>
00092 //
00093 // <example>
00094 // <srcblock>
00095 // PagedArray<Float> psf(2,4,4), dirty(2,20,20), model(2,20,20);
00096 // .... put some meaningful values into these Lattices....
00097 // // create a convolution equation, and a PagedArray model
00098 // LatConvEquation convEqn(psf, dirty);
00099 // LinearModel< Lattice<Float> > myModel(model);
00100 // // now calculate the convolution of the model and the psf
00101 // PagedArray<Float> prediction;
00102 // convEqn.evaluate(myModel, prediction);
00103 // // and calculate the difference between the predicted and actual convolution
00104 // PagedArray<Float> residual;
00105 // convEqn.residual(mymodel, residual)
00106 // </srcblock>
00107 // </example>
00108 //
00109 // <motivation>
00110 // This class was designed with deconvolution in mind. 
00111 // </motivation>
00112 //
00113 // <todo asof="1990/05/03">
00114 //   <li> Reinstate the  evaluate() method with position argument.
00115 //   <li> Fix up copies and references with Ralph Marson's help
00116 //   <li> This class is not templated. If necessary I would use templating
00117 //        to produce a Double Precision Version.
00118 // </todo>
00119 
00120 class IPLatConvEquation: 
00121   public LatConvEquation
00122 {
00123 public:
00124 
00125   // Construct the LatConvEquation setting the psf and measured data
00126   IPLatConvEquation(Lattice<Float> & psf, 
00127                   Lattice<Float> & dirtyImage);
00128 
00129   // Somewhere I read that a destructor should alway be defined even if it
00130   // does nothing (as this one does).
00131   virtual ~IPLatConvEquation();
00132 
00133   // Calculate the convolution of the model (supplied by the LinearModel
00134   // class) and the psf and the difference between this and the supplied
00135   // (presumably measured) convolution.  
00136   virtual Bool residual(Lattice<Float> & result, 
00137                         const LinearModel< Lattice<Float> > & model);
00138 
00139   // Calculate the convolution of the model (supplied by the LinearModel
00140   // class) and the psf and the difference between this and the supplied
00141   // (presumably measured) convolution.   Also return chisq.
00142   virtual Bool residual(Lattice<Float> & result, Float & chisq, 
00143                         const LinearModel< Lattice<Float> > & model);
00144 
00145 private:
00146 
00147   // Don't use this one, due to the Lattice<Float> &
00148   IPLatConvEquation();
00149 
00150   // Factor by which we normalize the PSF for the second convolution
00151   Float itsQ;
00152 
00153 };
00154 
00155 
00156 } //# NAMESPACE CASA - END
00157 
00158 #endif