casa
$Rev:20696$
|
00001 //# GridBoth.h: Definition for GridBoth 00002 //# Copyright (C) 1996,1997,1998,1999,2000,2001,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_GRIDBOTH_H 00030 #define SYNTHESIS_GRIDBOTH_H 00031 00032 #include <synthesis/TransformMachines/GridFT.h> 00033 #include <synthesis/MeasurementComponents/SDGrid.h> 00034 00035 namespace casa { //# NAMESPACE CASA - BEGIN 00036 00037 // <summary> An FTMachine for Gridding Single Dish data 00038 // </summary> 00039 00040 // <use visibility=export> 00041 00042 // <reviewed reviewer="" date="" tests="" demos=""> 00043 00044 // <prerequisite> 00045 // <li> <linkto class=FTMachine>FTMachine</linkto> module 00046 // <li> <linkto class=SkyEquation>SkyEquation</linkto> module 00047 // <li> <linkto class=VisBuffer>VisBuffer</linkto> module 00048 // </prerequisite> 00049 // 00050 // <etymology> 00051 // FTMachine is a Machine for Fourier Transforms. GridBoth does 00052 // Single Dish gridding in a similar way 00053 // </etymology> 00054 // 00055 // <synopsis> 00056 // The <linkto class=SkyEquation>SkyEquation</linkto> needs to be able 00057 // to perform Fourier transforms on visibility data and to grid 00058 // single dish data. 00059 // GridBoth allows efficient Single Dish processing using a 00060 // <linkto class=VisBuffer>VisBuffer</linkto> which encapsulates 00061 // a chunk of visibility (typically all baselines for one time) 00062 // together with all the information needed for processing 00063 // (e.g. direction coordinates). 00064 // 00065 // Gridding and degridding in GridBoth are performed using a 00066 // novel sort-less algorithm. In this approach, the gridded plane is 00067 // divided into small patches, a cache of which is maintained in memory 00068 // using a general-purpose <linkto class=LatticeCache>LatticeCache</linkto> class. As the (time-sorted) 00069 // visibility data move around slowly in the image plane, patches are 00070 // swapped in and out as necessary. Thus, optimally, one would keep at 00071 // least one patch per scan line of data. 00072 // 00073 // A grid cache is defined on construction. If the gridded image plane is smaller 00074 // than this, it is kept entirely in memory and all gridding and 00075 // degridding is done entirely in memory. Otherwise a cache of tiles is 00076 // kept an paged in and out as necessary. Optimally the cache should be 00077 // big enough to hold all polarizations and frequencies for one 00078 // complete scan line. 00079 // The paging rate will then be small. As the cache size is 00080 // reduced below this critical value, paging increases. The algorithm will 00081 // work for only one patch but it will be very slow! 00082 // 00083 // The gridding and degridding steps are implemented in Fortran 00084 // for speed. In gridding, the visibilities are added onto the 00085 // grid points in the neighborhood using a weighting function. 00086 // In degridding, the value is derived by a weight summ of the 00087 // same points, using the same weighting function. 00088 // </synopsis> 00089 // 00090 // <example> 00091 // See the example for <linkto class=SkyModel>SkyModel</linkto>. 00092 // </example> 00093 // 00094 // <motivation> 00095 // Define an interface to allow efficient processing of chunks of 00096 // visibility data 00097 // </motivation> 00098 // 00099 // <todo asof="97/10/01"> 00100 // <ul> Deal with large VLA spectral line case 00101 // </todo> 00102 00103 template<class T> class TempImage; 00104 00105 class GridBoth : public FTMachine { 00106 public: 00107 00108 // Constructor: cachesize is the size of the cache in words 00109 // (e.g. a few million is a good number), tilesize is the 00110 // size of the tile used in gridding (cannot be less than 00111 // 12, 16 works in most cases), and convType is the type of 00112 // gridding used (SF is prolate spheriodal wavefunction, 00113 // and BOX is plain box-car summation). mLocation is 00114 // the position to be used in some phase rotations. If 00115 // mTangent is specified then the uvw rotation is done for 00116 // that location iso the image center. 00117 // <group> 00118 GridBoth(SkyJones& sj, Long cachesize, Int tilesize, 00119 String sdConvType="BOX", 00120 String synConvType="SF", 00121 Float padding=1.0, 00122 Float sdScale=1.0, 00123 Float sdWeight=1.0); 00124 GridBoth(SkyJones& sj, Long cachesize, Int tilesize, 00125 MPosition mLocation, 00126 String sdConvType="BOX", 00127 String synConvType="SF", 00128 Float padding=1.0, 00129 Float sdScale=1.0, 00130 Float sdWeight=1.0); 00131 GridBoth(SkyJones& sj, Long cachesize, Int tilesize, 00132 MPosition mLocation, MDirection mTangent, 00133 String sdConvType="BOX", 00134 String synConvType="SF", 00135 Float padding=1.0, 00136 Float sdScale=1.0, 00137 Float sdWeight=1.0); 00138 // </group> 00139 00140 // Copy constructor 00141 GridBoth(const GridBoth &other); 00142 00143 // Assignment operator 00144 GridBoth &operator=(const GridBoth &other); 00145 00146 ~GridBoth(); 00147 00148 // Construct from a Record containing the GridFT state 00149 GridBoth(const RecordInterface& stateRec); 00150 00151 // Initialize transform to Visibility plane using the image 00152 // as a template. The image is loaded and Fourier transformed. 00153 void initializeToVis(ImageInterface<Complex>& image, 00154 const VisBuffer& vb); 00155 00156 // Finalize transform to Visibility plane: flushes the image 00157 // cache and shows statistics if it is being used. 00158 void finalizeToVis(); 00159 00160 // Initialize transform to Sky plane: initializes the image 00161 void initializeToSky(ImageInterface<Complex>& image, Matrix<Float>& weight, 00162 const VisBuffer& vb); 00163 00164 // Finalize transform to Sky plane: flushes the image 00165 // cache and shows statistics if it is being used. DOES NOT 00166 // DO THE FINAL TRANSFORM! 00167 void finalizeToSky(); 00168 00169 // Get actual coherence from grid by degridding 00170 void get(VisBuffer& vb, Int row=-1); 00171 00172 // Put coherence to grid by gridding. 00173 void put(const VisBuffer& vb, Int row=-1, Bool dopsf=False, 00174 FTMachine::Type type=FTMachine::OBSERVED); 00175 00176 // Get the final image: do the Fourier transform and 00177 // grid-correct, then optionally normalize by the summed weights 00178 ImageInterface<Complex>& getImage(Matrix<Float>&, Bool normalize=True); 00179 virtual void normalizeImage(Lattice<Complex>& /*skyImage*/, 00180 const Matrix<Double>& /*sumOfWts*/, 00181 Lattice<Float>& /*sensitivityImage*/, 00182 Bool /*fftNorm*/) 00183 {throw(AipsError("GridBoth::normalizeImage() called"));} 00184 00185 // Get the final weights image 00186 void getWeightImage(ImageInterface<Float>&, Matrix<Float>&); 00187 00188 // Save and restore the GridFT to and from a record 00189 virtual Bool toRecord(String& error, RecordInterface& outRec, 00190 Bool withImage=False); 00191 virtual Bool fromRecord(String& error, const RecordInterface& inRec); 00192 00193 // Has this operator changed since the last application? 00194 virtual Bool changed(const VisBuffer& vb); 00195 virtual void setMiscInfo(const Int qualifier){(void)qualifier;}; 00196 virtual void ComputeResiduals(VisBuffer&/*vb*/, Bool /*useCorrected*/) {}; 00197 virtual String name() const { return "GridBoth";}; 00198 00199 private: 00200 00201 FTMachine* synMachine_p; // Synthesis machine 00202 FTMachine* sdMachine_p; // Single Dish machine 00203 FTMachine* lastMachine_p; // Last Machine used 00204 00205 // Images for Synthesis and SD 00206 TempImage<Complex>* sdImage_p; 00207 TempImage<Complex>* synImage_p; 00208 00209 Float sdScale_p, sdWeight_p; 00210 00211 void ok(); 00212 00213 void init(); 00214 00215 }; 00216 00217 } //# NAMESPACE CASA - END 00218 00219 #endif