casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ConvolutionEquation.h
Go to the documentation of this file.
1 //# ConvolutionEquation.h: this defines ConvolutionEquation
2 //# Copyright (C) 1996,1997,1999,2000,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: aips2-request@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_CONVOLUTIONEQUATION_H
30 #define SYNTHESIS_CONVOLUTIONEQUATION_H
31 
32 
33 #include <casa/aips.h>
38 #include <casa/Arrays/Array.h>
39 #include <casa/Arrays/IPosition.h>
40 
41 namespace casa { //# NAMESPACE CASA - BEGIN
42 
43 // <summary> Implements the convolution equation </summary>
44 
45 // <use visibility=local>
46 
47 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
48 // </reviewed>
49 
50 // <prerequisite>
51 // <li> <linkto class="HogbomCleanModel">HogbomCleanModel</linkto>
52 // (or similar classes)
53 // <li> LinearModel/LinearEquation Paradigm
54 // </prerequisite>
55 //
56 // <etymology>
57 // This class implements convolution within the LinearEquation framework.
58 // </etymology>
59 //
60 // <synopsis>
61 // This class is used in conjunction with classes like HogbomCleanModel to
62 // implement deconvolution algorithms. This class contains the point spread
63 // function (psf) and the convolved data (dirty image), and is able to
64 // convolve a supplied model with the psf to produce a predicted output
65 // (using the evaluate() function), or to subtract the convolved data and
66 // produce a residual (using the residual() function).
67 //
68 // See the documentation for
69 // <linkto class=HogbomCleanModel>HogbomCleanModel</linkto>
70 // for an example of how this class can be used to perform deconvolution.
71 //
72 // This class also contains specialised functions (like the version of
73 // evaluate() for a point source model) that speed up the calculation of the
74 // convolution. This specialised version of evaluate() does not need to
75 // actually perform the convolution and instead returns a suitable part of
76 // the psf (zero padded if necessary). When this function is called this
77 // class will get the psf from the convolver and cache it, on the assumption
78 // that many evaluations of this function will be requested (as occurs in
79 // Clean algorithms).
80 //
81 // The size and shape of the psf and the supplied model may be different. The
82 // only restriction is that the dimension of the psf must be less than or
83 // equal to the dimension of the model. If the dimension of the
84 // model is larger than the dimension of the psf then the convolution
85 // will be repeated along the slowest moving (last) axis. The dirty image
86 // and the supplied model must be the same size and shape.
87 //
88 // This class can also operate on MaskedArrays (and models representable by
89 // MaskedArrays). But the mask is currently discarded and the convolution
90 // performed on the entire supplied model. This may change in the future.
91 //
92 // </synopsis>
93 //
94 // <example>
95 // <srcblock>
96 // casacore::Matrix<casacore::Float> psf(4,4), dirty(20,20), model(20,20);
97 // .... put some meaningful values into these Arrays....
98 // // create a convolution equation, and an array model
99 // ConvolutionEquation convEqn(psf, dirty);
100 // ArrayModel<casacore::Float> myModel(model);
101 // // now calculate the convolution of the model and the psf
102 // casacore::Matrix<casacore::Float> prediction;
103 // convEqn.evaluate(myModel, prediction);
104 // // and calculate the difference between the predicted and actual convolution
105 // casacore::Matrix<casacore::Float> residual;
106 // convEqn.residual(mymodel, residual)
107 // </srcblock>
108 // </example>
109 //
110 // <motivation>
111 // This class was designed with deconvolution in mind.
112 // </motivation>
113 //
114 // <todo asof="1990/05/03">
115 // <li> Fix up the way this class works for other data types.
116 // It currently can handle Arrays of Floats only.
117 // I do not intend to extend it to handle casacore::Double, casacore::Complex, & DComplex
118 // until there is a demand.
119 // <li> This class is not templated. If necessary I would use templating
120 // to produce a casacore::Double Precision Version.
121 // </todo>
122 
124  public LinearEquation< casacore::Array<casacore::Float>, casacore::Array<casacore::Float> >
125 {
126 public:
127  // Construct the ConvolutionEquation. Until I write some functions for
128  // setting the private data the default constructor is essentially useless
130 
131  // Construct the ConvolutionEquation setting the psf and measured data
133  const casacore::Array<casacore::Float> & dirtyImage);
134 
135  // Construct the ConvolutionEquation setting the psf and measured data
136  // Even though a casacore::MaskedArray is used as an arguement the mask is discarded
137  // internally and hence not used by residual().
139  const casacore::MaskedArray<casacore::Float> & dirtyImage);
140 
141  // Somewhere I read that a destructor should alway be defined even if it
142  // does nothing (as this one does).
144 
145  // Do the convolution of the model supplied by the LinearModel class with
146  // the internal psf. Return the answer in result .
149 
150  // Do the convolution of the model supplied by the LinearModel class with
151  // the internal psf. Return the answer in result. This version
152  // uses Masked arrays. but the mask is currently discarded internally.
155 
156  // Do the convolution of the model supplied by the LinearModel class with
157  // the internal psf. Return the answer in result. This version
158  // uses MaskedArrays, but the mask is not currently used. However
159  // the model mask is transfered to the result unchanged.
162 
163  // Do the convolution of the a point source model at position 'position'
164  // with amplitude 'amplitude' and the internal psf. Return the answer in
165  // result.
167  const casacore::Float amplitude,
168  const casacore::IPosition & modelShape);
169 
170  // Calculate the convolution of the model (supplied by the LinearModel
171  // class) and the psf and the difference between this and the supplied
172  // (presumably measured) convolution.
175 
176 
177  // Calculate the convolution of the model (supplied by the LinearModel
178  // class) and the psf and the difference between this and the supplied
179  // (presumably measured) convolution. Also return chisq.
182 
183  // Calculate the convolution of the model (supplied by the LinearModel
184  // class) and the psf and the difference between this and the supplied
185  // (presumably measured) convolution. Also return chisq,
186  // considering a mask image
190 
191  // Calculate the convolution of the model (supplied by the LinearModel
192  // class) and the psf and the difference between this and the supplied
193  // (presumably measured) convolution. This version
194  // uses Masked arrays. but the mask is currently discarded internally.
197 
198  // Calculate the convolution of the model (supplied by the LinearModel
199  // class) and the psf and the difference between this and the supplied
200  // (presumably measured) convolution. This version
201  // uses Masked arrays. but the mask is currently discarded in the
202  // calculations and transfered unchanged from the model to the result.
205 
206  // return the psf size used in the convolution. The returned size does not
207  // include any zero padding
209  // release the storage associated with the cached psf. The psf can
210  // however still be recovered from the casacore::Convolver object
211  void flushPsf();
212 
213 private:
219 };
220 
221 
222 } //# NAMESPACE CASA - END
223 
224 #endif
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
virtual casacore::Bool residual(casacore::Array< casacore::Float > &result, const LinearModel< casacore::Array< casacore::Float > > &model)
Calculate the convolution of the model (supplied by the LinearModel class) and the psf and the differ...
casacore::Array< casacore::Float > theMeas
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
Implements the convolution equation.
Class for masking an Array for operations on that Array.
~ConvolutionEquation()
Somewhere I read that a destructor should alway be defined even if it does nothing (as this one does)...
ConvolutionEquation()
Construct the ConvolutionEquation.
casacore::IPosition theRealPsfSize
virtual casacore::Bool evaluate(casacore::Array< casacore::Float > &result, const LinearModel< casacore::Array< casacore::Float > > &model)
Do the convolution of the model supplied by the LinearModel class with the internal psf...
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
float Float
Definition: aipstype.h:54
casacore::Array< casacore::Float > thePsf
casacore::IPosition psfSize()
return the psf size used in the convolution.
casacore::IPosition thePsfOrigin
void flushPsf()
release the storage associated with the cached psf.
defines a relationship between Domain and Range objects
casacore::Convolver< casacore::Float > theConv
Provides a model for use in model fitting applications.
TableExprNode amplitude(const TableExprNode &node)
The amplitude (i.e.
Definition: ExprNode.h:1397