casa
$Rev:20696$
|
00001 //# SkyModel.h: Definition for SkyModel 00002 //# Copyright (C) 1996,1997,1998,1999,2000,2002 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 adressed 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_SKYMODEL_H 00030 #define SYNTHESIS_SKYMODEL_H 00031 00032 #include <casa/aips.h> 00033 #include <synthesis/MeasurementEquations/Iterate.h> 00034 #include <synthesis/TransformMachines/StokesImageUtil.h> 00035 #include <images/Images/ImageInterface.h> 00036 #include <components/ComponentModels/ComponentList.h> 00037 #include <casa/BasicSL/String.h> 00038 00039 namespace casa { //# NAMESPACE CASA - BEGIN 00040 00041 //forward declarations 00042 class SkyEquation; 00043 00044 // <summary> 00045 // Sky Model: Model the Sky Brightness for the SkyEquation 00046 // </summary> 00047 00048 // <use visibility=export> 00049 00050 // <reviewed reviewer="" date="" tests="" demos=""> 00051 00052 // <prerequisite> 00053 // <li> Matrix module 00054 // <li> Vector module 00055 // <li> MeasurementComponents module 00056 // <li> VisSet module 00057 // </prerequisite> 00058 // 00059 // <etymology> 00060 // SkyModel describes an interface for Models to be used in 00061 // the SkyEquation. It is an Abstract Base Class: most methods 00062 // must be defined in derived classes. 00063 // </etymology> 00064 // 00065 // <synopsis> 00066 // A SkyModel contains a number of separate models. The interface to 00067 // SkyEquation is via an image per model. SkyEquation uses this image to 00068 // calculate Fourier transforms, etc. Some (most) SkyModels are 00069 // solvable: the SkyEquation can be used by the SkyModel to return 00070 // gradients with respect to itself (via the image interface). Thus 00071 // for a SkyModel to solve for itself, it calls the SkyEquation 00072 // methods to get gradients of chi-squared with respect to the 00073 // image pixel values (thus returning an image: basically a residual 00074 // image). The SkyModel then uses these gradients as appropriate to 00075 // update itself. 00076 // 00077 // The following examples illustrate how a SkyModel can be 00078 // used: 00079 // <ul> 00080 // <li> Simple cleaning: one model. The gradient gives the 00081 // residual image. A special method gives a PSF. 00082 // <li> Cleaning with visibility-based subtraction: one model. The 00083 // gradient can be calculated as needed (using the SkyEquation) 00084 // to produce the correct residual image. 00085 // <li> Wide-field imaging: one model per patch of the sky 00086 // that is to be imaged. 00087 // <li> Non-coplanar baselines imaging: one model per facet of 00088 // the polyhedron. At the end of processing all facets are combined 00089 // into one overall image. 00090 // <li> Mosaicing: one model per primary beam pointing. Each model 00091 // is derived (as needed) by cutting out a patch from the full-field 00092 // mosaic. 00093 // </ul> 00094 // </synopsis> 00095 // 00096 // <example> 00097 // <srcblock> 00098 // // Read the VisSet from disk 00099 // VisSet vs("3c84.MS"); 00100 // 00101 // // Create an ImageSkyModel from an image on disk 00102 // ImageSkyModel ism(PagedImage<Float>("3c84.modelImage")); 00103 // 00104 // // Make an FTMachine: here we use a simple Grid and FT. 00105 // GridFT ft; 00106 // 00107 // SkyEquation se(ism, vs, ft); 00108 // 00109 // // Predict the visibility set 00110 // se.predict(); 00111 // 00112 // // Make a Clean Image and write it out 00113 // HogbomCleanImageSkyModel csm(ism); 00114 // if (csm.solve()) { 00115 // PagedImage<Float> cleanImage=csm.image(0); 00116 // cleanImage.setName("3c84.cleanImage"); 00117 // } 00118 // 00119 // </srcblock> 00120 // </example> 00121 // 00122 // <motivation> 00123 // The properties of a model of the sky must be described 00124 // for the SkyEquation. 00125 // </motivation> 00126 // 00127 // <todo asof="97/10/01"> 00128 // <li> Multiple images in SkyModel 00129 // <li> ComponentModel 00130 // </todo> 00131 00132 class SkyModel : public Iterate { 00133 00134 public: 00135 00136 enum PolRep { 00137 CIRCULAR=StokesImageUtil::CIRCULAR, 00138 LINEAR=StokesImageUtil::LINEAR 00139 }; 00140 00141 SkyModel() : itsAlgorithm(""), itsSubAlgorithm(""), imageRegion_p(0), isImageNormalized_p(False) { } 00142 00143 // Number of models contained 00144 virtual Int numberOfModels() = 0; 00145 00146 // MFS : Number of taylor terms per model 00147 virtual Int numberOfTaylorTerms() = 0; 00148 00149 // MFS : Reference Frequency 00150 virtual Double getReferenceFrequency() = 0; 00151 00152 // MFS : Index of Taylor term in array of nmodels x ntaylorterms 00153 virtual Int getTaylorIndex(Int index=0) = 0; 00154 00155 // Is this SkyModel solveable? 00156 virtual Bool isSolveable(Int model=0) = 0; 00157 00158 // Is there a flux scale image associated with this model? 00159 virtual Bool doFluxScale(Int model=0) = 0; 00160 00161 // Initialize for gradient search 00162 virtual void initializeGradients() = 0; 00163 00164 // Finalize for gradient search 00165 virtual void finalizeGradients() = 0; 00166 00167 // Return the component list 00168 virtual ComponentList& componentList() = 0; 00169 00170 // Return the component list 00171 virtual Bool hasComponentList() = 0; 00172 00173 // Image interface for this model (Stokes representation) 00174 virtual ImageInterface<Float>& image(Int model=0) = 0; 00175 00176 // Increment in the image 00177 virtual ImageInterface<Float>& deltaImage(Int model=0) = 0; 00178 00179 // Complex image (needed for e.g. RR,RL,LR,LL) 00180 virtual ImageInterface<Complex>& cImage(Int model=0) = 0; 00181 00182 // Complex XFR 00183 virtual ImageInterface<Complex>& XFR(Int model=0, Int numXFR=0) = 0; 00184 virtual Bool hasXFR(Int model=0) = 0; 00185 00186 // PSF 00187 virtual ImageInterface<Float>& PSF(Int model=0) = 0; 00188 00189 // Gradient of chi-squared wrt pixels 00190 virtual ImageInterface<Float>& gS(Int model=0) = 0; 00191 00192 // Grad Grad chi-squared wrt pixels (diagonal elements only) 00193 virtual ImageInterface<Float>& ggS(Int model=0) = 0; 00194 00195 // FluxScale image: image * fluxScale => true brightness distribution 00196 virtual ImageInterface<Float>& fluxScale(Int model=0) = 0; 00197 00198 // Work image 00199 virtual ImageInterface<Float>& work(Int model=0) = 0; 00200 00201 // Add to Sum weights, Chi-Squared 00202 virtual void addStatistics(Float sumwt, Float chisq) = 0; 00203 00204 // Weight per model (channels, polarizations) 00205 virtual Matrix<Float>& weight(Int model=0) = 0; 00206 00207 // Solve for this SkyModel 00208 virtual Bool solve (SkyEquation& se) = 0; 00209 00210 // Is this model empty 00211 virtual Bool isEmpty(Int model=0) = 0; 00212 00213 virtual Int getModelIndex(uInt field=0, uInt taylor=0) = 0; 00214 00215 //set Algorithm (e.g clean, mem, nnls) 00216 void setAlgorithm(const String& alg) {itsAlgorithm = alg;} 00217 00218 // get Algorithm 00219 const String getAlgorithm() { return itsAlgorithm; } 00220 00221 // set Sub Algorithm 00222 void setSubAlgorithm(const String& alg) { itsSubAlgorithm = alg; } 00223 00224 // get Sub Algorithm 00225 const String getSubAlgorithm() { return itsSubAlgorithm; } 00226 00227 // Set the imageregion that will be used for the next XFR generation 00228 // <group> 00229 void setImageRegion( ImageRegion& ir ) { imageRegion_p = &ir; } 00230 // use the default shape 00231 void unsetImageRegion() { imageRegion_p = 0; } 00232 // </group> 00233 00234 void setImageNormalization(Bool val) {isImageNormalized_p = val;}; 00235 Bool isImageNormalized() {return isImageNormalized_p;}; 00236 00237 protected: 00238 String itsAlgorithm; 00239 String itsSubAlgorithm; 00240 // this ImageRegion is used to suggest the shape for the 00241 // XFR. If null, then just use the shape of image(model) 00242 ImageRegion *imageRegion_p; 00243 Bool isImageNormalized_p; 00244 00245 private: 00246 }; 00247 00248 00249 } //# NAMESPACE CASA - END 00250 00251 #endif