casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
MaskedArrayModel.h
Go to the documentation of this file.
00001 //# MaskedArrayModel.h: this defines MaskedArrayModel
00002 //# Copyright (C) 1996,1997,1999
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_MASKEDARRAYMODEL_H
00030 #define SYNTHESIS_MASKEDARRAYMODEL_H
00031 
00032 
00033 #include <casa/aips.h>
00034 #include <synthesis/MeasurementEquations/LinearModel.h>
00035 #include <casa/Arrays/Array.h>
00036 #include <casa/Arrays/MaskedArray.h>
00037 
00038 namespace casa { //# NAMESPACE CASA - BEGIN
00039 
00040 // <summary>
00041 // base class for models with an internal & external representation 
00042 // as a MaskedArray 
00043 // </summary>
00044 
00045 // <use visibility=export>
00046 
00047 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
00048 // </reviewed>
00049 
00050 // <prerequisite>
00051 //   <li> MaskedArrays
00052 //   <li> LinearModel
00053 //   <li> LinearModel/LinearEquation paradigm
00054 // </prerequisite>
00055 //
00056 // <synopsis>
00057 // An MaskedArrayModel is a base class for Models that can be
00058 // represented by arrays with a mask (used to denote which values
00059 // are valid) . It is expected that this class will be mainly used
00060 // by inheritence from other classes which will then provide the solve()
00061 // functions necessary to update the model given an equation.
00062 // 
00063 // However this class does not contain any pure virtual functions and hence
00064 // can be used "as is". An example of this is given below. For an example of
00065 // how this class can be used by derived classes see the 
00066 // <linkto class=MaskedHogbomCleanModel>MaskedHogbomCleanModel</linkto> 
00067 // class.
00068 //
00069 // This class makes an internal copy of the Array supplied to it (either
00070 // when constructed or when using the setModel function). If this is found
00071 // to significantly affect performance (execution speed or memory
00072 // requirements) this may be changed to a reference, perhaps using a smart
00073 // pointer like the <linkto class=COWPtr>COWPtr</linkto>
00074 // </synopsis>
00075 //
00076 // <example>
00077 // <srcblock>
00078 // MaskedArrayModel<Float> currentModel(); // Cannot use the model yet!
00079 // {
00080 //   Matrix<Float> bestGuess(32,32);
00081 //    ... put your best guess into the Matrix ...
00082 //   currentModel.setModel(bestGuess); // This does a real copy
00083 // }
00084 // ConvolutionEquation eqn(psf, dirty); // psf, and dirty are arrays defined
00085 //                                      // elsewhere.
00086 // eqn.evaluate(result, currentModel); // Here result is the convolution of
00087 //                                     // of the model with the psf.
00088 // </srcblock>
00089 // </example>
00090 //
00091 // <motivation>
00092 // All the different image plane based clean algorithms have a common
00093 // implementation in that they can use an array to store the current
00094 // model. This class provides a way to abstract this functionality, as well
00095 // as provide a mechanism to implement "clean boxes"  
00096 // </motivation>
00097 //
00098 // <templating arg=T>
00099 // While the template arguement for this class can be just about anything,
00100 // the use of this class with an equation class will significantly restrict
00101 // the possible templates. I have used this class (or derivations of it)
00102 // with the following data types.
00103 //    <li> Float
00104 // </templating>
00105 //
00106 // <thrown>
00107 // This class does not explicitly throw exceptions however the objects used
00108 // by this class may
00109 // </thrown>
00110 //
00111 // <todo asof="1996/05/14">
00112 //   <li> Decide whether to copy the input array by reference or stay with
00113 //   the current scheme.
00114 //   <li> Test the class with STokesVectors
00115 // </todo>
00116 
00117 template<class T> class MaskedArrayModel: 
00118   public LinearModel< MaskedArray<T> > {
00119 public:
00120     // Default constructor sets the internal arrays to zero size
00121     MaskedArrayModel();
00122     // Construct the model from a masked array. The data is copied.
00123     MaskedArrayModel(const MaskedArray<T> & model);
00124     // Construct the model from an array. The mask is set to be fully
00125     // transparent. 
00126     MaskedArrayModel(const Array<T> & model);
00127 
00128     // These functions return the model, either as a masked array or just
00129     // the data array itself with the mask removed. 
00130     // <group>
00131     void getModel(Array<T>& model) const;
00132     virtual void getModel(MaskedArray<T>& model) const;
00133     MaskedArray<T> getModel() const;
00134     // </group>
00135     // These functions are analogous to the constructors above and must be
00136     // called when the default constructor is used. If no mask is specified
00137     // then it is by default set to totally transparent.  
00138     // <group>
00139     void setModel(const Array<T>& model);
00140     virtual void setModel(const MaskedArray<T>& model);
00141     // </group>
00142     
00143 protected:
00144     MaskedArray<T> theModel;
00145 };
00146 
00147 
00148 } //# NAMESPACE CASA - END
00149 
00150 #ifndef AIPS_NO_TEMPLATE_SRC
00151 #include <synthesis/MeasurementEquations/MaskedArrayModel.tcc>
00152 #endif //# AIPS_NO_TEMPLATE_SRC
00153 #endif