casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ImageSkyModel.h
Go to the documentation of this file.
1 //# ImageSkyModel.h: Definition for ImageSkyModel
2 //# Copyright (C) 1996,1997,1998,1999,2000,2002
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 adressed 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_IMAGESKYMODEL_H
30 #define SYNTHESIS_IMAGESKYMODEL_H
31 
34 #include <casa/Arrays/Matrix.h>
39 #include <casa/Logging/LogSink.h>
40 #include <casa/System/PGPlotter.h>
41 
42 namespace casa { //# NAMESPACE CASA - BEGIN
43 
44 // <summary>
45 // Image Sky Model: Image-based Model for the Sky Brightness
46 // </summary>
47 
48 // <use visibility=export>
49 
50 // <reviewed reviewer="" date="" tests="" demos="">
51 
52 // <prerequisite>
53 // <li> <linkto class=SkyModel>SkyModel</linkto> class
54 // <li> <linkto class=SkyEquation>SkyEquation</linkto> class
55 // <li> <linkto class=casacore::ImageInterface>ImageInterface</linkto> class
56 // <li> <linkto class=casacore::PagedImage>PagedImage</linkto> class
57 // <li> <linkto module=MeasurementComponents>MeasurementComponents</linkto> module
58 // <li> <linkto class=VisSet>VisSet</linkto> class
59 // </prerequisite>
60 //
61 // <etymology>
62 // ImageSkyModel describes an interface for Models to be used in
63 // the SkyEquation. It is derived from <linkto class=SkyModel>SkyModel</linkto>.
64 // </etymology>
65 //
66 // <synopsis>
67 // A ImageSkyModel contains a number of separate models. The interface to
68 // SkyEquation is via an image per model. <linkto class=SkyEquation>SkyEquation</linkto> uses this image to
69 // calculate Fourier transforms, etc. Some (most) SkyModels are
70 // solvable: the SkyEquation can be used by the SkyModel to return
71 // gradients with respect to itself (via the image interface). Thus
72 // for a SkyModel to solve for itself, it calls the SkyEquation
73 // methods to get gradients of chi-squared with respect to the
74 // image pixel values (thus returning an image: basically a residual
75 // image). The SkyModel then uses these gradients as appropriate to
76 // update itself.
77 // </synopsis>
78 //
79 // <example>
80 // See the example for <linkto class=SkyModel>SkyModel</linkto>.
81 // </example>
82 //
83 // <motivation>
84 // The properties of a model of the sky must be described
85 // for the <linkto class=SkyEquation>SkyEquation</linkto>.
86 // </motivation>
87 //
88 // <todo asof="97/10/01">
89 // <li> Multiple images in SkyModel
90 // <li> ComponentModel
91 // </todo>
92 
93 class ImageSkyModel : public SkyModel {
94 public:
95 
96  // Empty constructor
97  ImageSkyModel(const casacore::Int maxNumModels=1);
98 
99  void setMaxNumberModels(const casacore::Int maxNumModels);
100 
101  // Copy constructor
102  ImageSkyModel(const ImageSkyModel& sm);
103 
104  // Add a componentlist
105  virtual casacore::Bool add(ComponentList& compList);
106  //update componentlist
107  virtual casacore::Bool updatemodel(ComponentList& compList);
108 
109 
110  // Add an image. maxNumXfr is the maximum Number of transfer functions
111  // that we might want to associate with this image.
113  //update model image...you have to have added it before...nmodels_p held has to be bigger that image here
114  //its left to the caller to make sure the image is conformant...otherwise you are in trouble.
116  // Add a residual image
118 
119  // Destructor
120  virtual ~ImageSkyModel();
121 
122  // Assignment operator
123  ImageSkyModel& operator=(const ImageSkyModel& other);
124 
125  // Number of models contained
127 
128  // MFS : Number of taylor terms per model
129  virtual casacore::Int numberOfTaylorTerms() {return 1;};
130 
131  // MFS : In-place coefficient residual calculations
132  virtual casacore::Bool calculateCoeffResiduals(){return false;};
133 
134  // MFS : Calculate restored alpha and beta.
135  virtual casacore::Bool calculateAlphaBeta(const casacore::Vector<casacore::String>& /*restoredNames*/, const casacore::Vector<casacore::String>& /*residualNames*/){return false;};
136 
137  // MFS : Reference Frequency
139 
140  // MFS : Index of Taylor term in array of nmodels x ntaylorterms
141  //virtual casacore::Int getTaylorIndex(casacore::Int index){return 0;}
143 
144  // Is this model solveable?
146 
147  // Free and fix the model (returns previous status). Free means that
148  // it will be solved for in any solution.
151 
152  // Initialize for gradient search
153  virtual void initializeGradients();
154 
155  // Finalize for gradient search
156  virtual void finalizeGradients() {};
157 
158  // Does this have a component list?
160 
162 
163  // Return the component list
164  virtual ComponentList& componentList();
165 
166  // Return actual images to be used by SkyEquation.
167  // <group>
175  // if (doFluxScale(mod)) image(mod) * fluxScale(mod)
176  // gives actual brightness distribution
180  // </group>
181 
182  // tells if this model needs to be multiplied by a flux scale image
184  // require use of flux scale image
185  void mandateFluxScale(casacore::Int model=0);
186 
188 
189  // Add to Sum weights, Chi-Squared
190  void addStatistics(casacore::Float sumwt, casacore::Float chisq) {sumwt_p+=sumwt;chisq_p+=chisq;}
191 
192  // Weight per model (channels, polarizations)
194 
195  // Solve for this SkyModel: This replaces the image with
196  // the residual image
197  virtual casacore::Bool solve (SkyEquation& me);
198 
199  // Solve explicitly for the residuals: same as solve for
200  // this class
201  // modelToMs determines if predicted vis is put in the MODEL_DATA column
203 
204  // Make the approximate PSFs needed for each model
205  virtual void makeApproxPSFs(SkyEquation& se);
206 
207  // Get current residual image: this is either that image specified via
208  // addResidual, or a scratch image.
209  // For example in WFImageSkyModel it might return the whole main image
210  //rather than facets
212 
213  // Return the fitted beam for each model
215 
216  // Set casacore::PGPlotter to be used
218 
219  // This is the factor by which you multiply the worst outer
220  // sidelobe by to get the threshold for the current cycle
221  void setCycleFactor(float x) { cycleFactor_p = x; }
222 
223  // Cycle threshold will double in this number of iterations
224  // (ie, use a large number if you don't want cycle threshold
225  // to inch up)
226  void setCycleSpeedup(float x) { cycleSpeedup_p = x; }
227 
228  // Yet another control for the minor cycle threshold.
229  // This is in response to CAS-2673
230  // This allows control similar to 'cyclefactor' - used in MFClarkCleanSkyModel
232 
233  // Set the variable that switches on the progress display
234  void setDisplayProgress (const casacore::Bool display ) {displayProgress_p = display; };
235 
236  // Set a variable to indicate the polarization frame in the data (circular or linear).
237  // This is used along with the user's choice of output casacore::Stokes parameter
238  // to decide the stokesCoordinate of the temporary images "cImage".
239  void setDataPolFrame(StokesImageUtil::PolRep datapolrep) {dataPolRep_p = datapolrep;};
240 
241  // Tries to return a pointer to a casacore::TempImage (allocated with new, so remember
242  // to use delete) with the given shape and CoordinateSystem.
243  //
244  // @param imgShp
245  // @param imgCoords
246  // @param nMouthsToFeed: If > 1 it is taken as a hint that it should leave
247  // room for nMouthsToFeed - 1 more TempImages.
248  //
249  // <throws>
250  // casacore::AipsError on memory allocation error.
251  // </throws>
252  template<class M>
254  const casacore::CoordinateSystem& imgCoords,
255  const casacore::uInt nMouthsToFeed=1);
256 
257  virtual casacore::Int getModelIndex(casacore::uInt field, casacore::uInt /*taylor*/){return field;};
258 
259  //try to make templattices use memory if possible
260  //if set to false then always use disk
261  virtual void setMemoryUse(casacore::Bool useMem=false);
263  //Set templattice tile vol in pixels
264  void setTileVol(const casacore::Int tileVol=1000000);
265 protected:
266 
267  // Make Newton Raphson step internally. This is really an implementation
268  // detail: it is useful for derived classes.
269  // The modelToMS parameter is for committing to MODEL_DATA column of the MS
270  // the predicted visibilities.
271 
273  casacore::Bool incremental=false, casacore::Bool modelToMS=false);
274 
275 
276  // Get casacore::PGPlotter to be used
278 
281  //MFS
283 
285 
288 
289  // ComponentList
291 
292  // Images
294  // Everything here can be just interface
297 
298  // We actually create these
305  // if (doFluxScale_p), image_p * fluxScale_p gives the true brightness
311 
313 
315 
318 
321 
324  // This is the factor by which you multiply the worst outer
325  // sidelobe by to get the threshold for the current cycle
327  // Cycle threshold will double in this number of iterations
328  // (ie, use a large number if you don't want cycle threshold
329  // to inch up)
331  // Cycle threshold = maxResidual x min(Max-Psf-Fraction , cyclefactor x maxpsfsidelobe)
333  // If PSF is done..should not redo it.
335  // check if model has been modified especially for continuing
336  // a deconvolution
338  // Parameter to indicate the polaraization type of the data (circular or linear)
339  // Required by cImage() to decide shapes.
344 };
345 
346 
347 
348 } //# NAMESPACE CASA - END
349 
350 
351 #ifndef AIPS_NO_TEMPLATE_SRC
352 #include <synthesis/MeasurementComponents/ImageSkyModel.tcc>
353 #endif //# AIPS_NO_TEMPLATE_SRC
354 
355 #endif
356 
357 
casacore::PtrBlock< casacore::ImageInterface< casacore::Float > * > fluxScale_p
if (doFluxScale_p), image_p * fluxScale_p gives the true brightness
casacore::Bool modified_p
check if model has been modified especially for continuing a deconvolution
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
casacore::Bool solveResiduals(SkyEquation &me, casacore::Bool modelToMS=false)
Solve explicitly for the residuals: same as solve for this class modelToMs determines if predicted vi...
int Int
Definition: aipstype.h:50
virtual casacore::Bool addResidual(casacore::Int image, casacore::ImageInterface< casacore::Float > &residual)
Add a residual image.
casacore::Vector< casacore::String > imageNames_p
Images.
casacore::Bool fix(casacore::Int model=0)
Temporary astronomical images.
virtual casacore::Bool updatemodel(ComponentList &compList)
update componentlist
virtual casacore::Bool add(ComponentList &compList)
Add a componentlist.
void setCycleFactor(float x)
This is the factor by which you multiply the worst outer sidelobe by to get the threshold for the cur...
casacore::ImageBeamSet & beam(casacore::Int model=0)
Return the fitted beam for each model.
virtual casacore::Double getReferenceFrequency()
MFS : Reference Frequency.
casacore::Bool useMem_p
casacore::Bool donePSF_p
If PSF is done..should not redo it.
virtual casacore::ImageInterface< casacore::Float > & getResidual(casacore::Int model=0)
Get current residual image: this is either that image specified via addResidual, or a scratch image...
virtual casacore::Bool getMemoryUse()
casacore::Long cacheSize(casacore::Int model)
static casacore::TempImage< M > * getTempImage(const casacore::TiledShape &imgShp, const casacore::CoordinateSystem &imgCoords, const casacore::uInt nMouthsToFeed=1)
Tries to return a pointer to a casacore::TempImage (allocated with new, so remember to use delete) wi...
casacore::ImageInterface< casacore::Float > & ggS(casacore::Int model=0)
Grad Grad chi-squared wrt pixels (diagonal elements only)
void setPGPlotter(casacore::PGPlotter &pgp)
Set casacore::PGPlotter to be used.
casacore::Int tileVol_p
casacore::PtrBlock< casacore::ImageInterface< casacore::Float > * > psf_p
casacore::ImageInterface< casacore::Float > & fluxScale(casacore::Int model=0)
if (doFluxScale(mod)) image(mod) * fluxScale(mod) gives actual brightness distribution ...
casacore::ImageInterface< casacore::Float > & gS(casacore::Int model=0)
Gradient of chi-squared wrt pixels.
casacore::ImageInterface< casacore::Float > & work(casacore::Int model=0)
Work image.
casacore::ImageInterface< casacore::Float > & residual(casacore::Int model=0)
casacore::ImageInterface< casacore::Complex > & cImage(casacore::Int model=0)
casacore::Complex image (needed for e.g.
casacore::PtrBlock< casacore::ImageInterface< casacore::Float > * > residualImage_p
casacore::Int maxNumXFR_p
casacore::Float cycleSpeedup_p
Cycle threshold will double in this number of iterations (ie, use a large number if you don&#39;t want cy...
casacore::PtrBlock< casacore::ImageInterface< casacore::Float > * > gS_p
void setMaxNumberModels(const casacore::Int maxNumModels)
void setTileVol(const casacore::Int tileVol=1000000)
Set templattice tile vol in pixels.
virtual void finalizeGradients()
Finalize for gradient search.
casacore::Block< casacore::Bool > solve_p
casacore::Block< casacore::Bool > doFluxScale_p
virtual casacore::Int numberOfTaylorTerms()
MFS : Number of taylor terms per model.
casacore::IPosition tileShape(casacore::Int model)
casacore::PtrBlock< casacore::ImageInterface< casacore::Float > * > residual_p
virtual casacore::Bool calculateCoeffResiduals()
MFS : In-place coefficient residual calculations.
ImageSkyModel & operator=(const ImageSkyModel &other)
Assignment operator.
casacore::PGPlotter * pgplotter_p
long Long
Definition: aipstype.h:52
Define the shape and tile shape.
Definition: TiledShape.h:99
casacore::ImageInterface< casacore::Float > & PSF(casacore::Int model=0)
PSF.
virtual void setMemoryUse(casacore::Bool useMem=false)
try to make templattices use memory if possible if set to false then always use disk ...
casacore::PtrBlock< casacore::ImageInterface< casacore::Float > * > image_p
Everything here can be just interface.
void setCycleMaxPsfFraction(float x)
Yet another control for the minor cycle threshold.
casacore::Bool displayProgress_p
Represents a set of restoring beams associated with an image.
Definition: ImageBeamSet.h:88
casacore::Bool makeNewtonRaphsonStep(SkyEquation &se, casacore::Bool incremental=false, casacore::Bool modelToMS=false)
Make Newton Raphson step internally.
double Double
Definition: aipstype.h:55
casacore::PtrBlock< casacore::ImageInterface< casacore::Complex > * > cxfr_p
casacore::PtrBlock< casacore::ImageInterface< casacore::Float > * > deltaimage_p
void setCycleSpeedup(float x)
Cycle threshold will double in this number of iterations (ie, use a large number if you don&#39;t want cy...
casacore::Bool workDirOnNFS_p
casacore::Bool isEmpty(casacore::Int model=0)
Is this model empty.
Image Sky Model: Image-based Model for the Sky Brightness.
Definition: ImageSkyModel.h:93
casacore::Bool hasComponentList()
Does this have a component list?
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
ComponentList * componentList_p
ComponentList.
casacore::Bool hasXFR(casacore::Int model=0)
float Float
Definition: aipstype.h:54
casacore::ImageInterface< casacore::Complex > & XFR(casacore::Int model=0, casacore::Int numXFR=0)
casacore::Complex XFR
A drop-in replacement for Block&lt;T*&gt;.
Definition: WProjectFT.h:54
virtual casacore::Int getTaylorIndex(casacore::Int index)
MFS : Index of Taylor term in array of nmodels x ntaylorterms virtual casacore::Int getTaylorIndex(c...
casacore::LogSink & logSink()
casacore::PtrBlock< casacore::Matrix< casacore::Float > * > weight_p
virtual ComponentList & componentList()
Return the component list.
ImageSkyModel(const casacore::Int maxNumModels=1)
Empty constructor.
casacore::Int nmodels_p
void mandateFluxScale(casacore::Int model=0)
require use of flux scale image
Sky Model: Model the Sky Brightness for the SkyEquation.
Definition: SkyModel.h:132
Standard plotting object for application programmers.
Definition: PGPlotter.h:95
casacore::PtrBlock< casacore::ImageInterface< casacore::Float > * > work_p
casacore::Int nfields_p
MFS.
casacore::Float cycleMaxPsfFraction_p
Cycle threshold = maxResidual x min(Max-Psf-Fraction, cyclefactor x maxpsfsidelobe) ...
casacore::LogSink logSink_p
virtual void makeApproxPSFs(SkyEquation &se)
Make the approximate PSFs needed for each model.
casacore::Float chisq_p
casacore::Bool isSolveable(casacore::Int model=0)
Is this model solveable?
casacore::PtrBlock< casacore::ImageInterface< casacore::Float > * > ggS_p
A class for manipulating groups of components.
virtual casacore::Int numberOfModels()
Number of models contained.
virtual ~ImageSkyModel()
Destructor.
Distribute LogMessages to their destination(s)
Definition: LogSink.h:141
casacore::Float cycleFactor_p
This is the factor by which you multiply the worst outer sidelobe by to get the threshold for the cur...
casacore::ImageInterface< casacore::Float > & deltaImage(casacore::Int model=0)
Increment in the image.
void setDataPolFrame(StokesImageUtil::PolRep datapolrep)
Set a variable to indicate the polarization frame in the data (circular or linear).
virtual casacore::Bool solve(SkyEquation &me)
Solve for this SkyModel: This replaces the image with the residual image.
virtual casacore::Bool calculateAlphaBeta(const casacore::Vector< casacore::String > &, const casacore::Vector< casacore::String > &)
MFS : Calculate restored alpha and beta.
casacore::Int maxnmodels_p
casacore::PtrBlock< casacore::ImageBeamSet * > beam_p
virtual casacore::Int getModelIndex(casacore::uInt field, casacore::uInt)
casacore::ImageInterface< casacore::Float > & image(casacore::Int model=0)
Return actual images to be used by SkyEquation.
casacore::Float sumwt_p
casacore::PGPlotter * getPGPlotter()
Get casacore::PGPlotter to be used.
void setDisplayProgress(const casacore::Bool display)
Set the variable that switches on the progress display.
casacore::Bool free()
Definition: Iterate.h:53
casacore::Bool doFluxScale(casacore::Int model=0)
tells if this model needs to be multiplied by a flux scale image
casacore::Matrix< casacore::Float > & weight(casacore::Int model=0)
Weight per model (channels, polarizations)
StokesImageUtil::PolRep dataPolRep_p
Parameter to indicate the polaraization type of the data (circular or linear) Required by cImage() to...
casacore::PtrBlock< casacore::ImageInterface< casacore::Complex > * > cimage_p
We actually create these.
Interconvert pixel and world coordinates.
virtual void initializeGradients()
Initialize for gradient search.
void addStatistics(casacore::Float sumwt, casacore::Float chisq)
Add to Sum weights, Chi-Squared.
unsigned int uInt
Definition: aipstype.h:51