casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MosaicFT.h
Go to the documentation of this file.
1 //# MosaicFT.h: Definition for MosaicFT
2 //# Copyright (C) 2003-2016
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 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 General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU 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_TRANSFORM2_MOSAICFT_H
30 #define SYNTHESIS_TRANSFORM2_MOSAICFT_H
31 
34 #include <casa/Arrays/Matrix.h>
36 #include <msvis/MSVis/VisBuffer2.h>
39 #include <casa/Containers/Block.h>
40 #include <casa/Arrays/Array.h>
41 #include <casa/Arrays/Vector.h>
51 
52 namespace casacore{
53 
54  class MPosition;
55  class UVWMachine;
56 }
57 
58 namespace casa { //# NAMESPACE CASA - BEGIN
59 
60 // <summary> An FTMachine for Gridded Fourier transforms </summary>
61 
62 // <use visibility=export>
63 
64 // <reviewed reviewer="" date="" tests="" demos="">
65 
66 // <prerequisite>
67 // <li> <linkto class=FTMachine>FTMachine</linkto> module
68 // <li> <linkto class=SkyEquation>SkyEquation</linkto> module
69 // <li> <linkto class=VisBuffer>VisBuffer</linkto> module
70 // </prerequisite>
71 //
72 // <etymology>
73 // FTMachine is a Machine for Fourier Transforms. MosaicFT does
74 // Grid-based Fourier transforms.
75 // </etymology>
76 //
77 // <synopsis>
78 // The <linkto class=SkyEquation>SkyEquation</linkto> needs to be able
79 // to perform Fourier transforms on visibility data. MosaicFT
80 // allows efficient Fourier Transform processing using a
81 // <linkto class=VisBuffer>VisBuffer</linkto> which encapsulates
82 // a chunk of visibility (typically all baselines for one time)
83 // together with all the information needed for processing
84 // (e.g. UVW coordinates).
85 //
86 // Gridding and degridding in MosaicFT are performed using a
87 // novel sort-less algorithm. In this approach, the gridded plane is
88 // divided into small patches, a cache of which is maintained in memory
89 // using a general-purpose <linkto class=casacore::LatticeCache>LatticeCache</linkto> class. As the (time-sorted)
90 // visibility data move around slowly in the Fourier plane, patches are
91 // swapped in and out as necessary. Thus, optimally, one would keep at
92 // least one patch per baseline.
93 //
94 // A grid cache is defined on construction. If the gridded uv plane is smaller
95 // than this, it is kept entirely in memory and all gridding and
96 // degridding is done entirely in memory. Otherwise a cache of tiles is
97 // kept an paged in and out as necessary. Optimally the cache should be
98 // big enough to hold all polarizations and frequencies for all
99 // baselines. The paging rate will then be small. As the cache size is
100 // reduced below this critical value, paging increases. The algorithm will
101 // work for only one patch but it will be very slow!
102 //
103 // This scheme works well for arrays having a moderate number of
104 // antennas since the saving in space goes as the ratio of
105 // baselines to image size. For the ATCA, VLBA and WSRT, this ratio is
106 // quite favorable. For the VLA, one requires images of greater than
107 // about 200 pixels on a side to make it worthwhile.
108 //
109 // The FFT step is done plane by plane for images having less than
110 // 1024 * 1024 pixels on each plane, and line by line otherwise.
111 //
112 // The gridding and degridding steps are implemented in Fortran
113 // for speed. In gridding, the visibilities are added onto the
114 // grid points in the neighborhood using a weighting function.
115 // In degridding, the value is derived by a weight summ of the
116 // same points, using the same weighting function.
117 // </synopsis>
118 //
119 // <example>
120 // See the example for <linkto class=SkyModel>SkyModel</linkto>.
121 // </example>
122 //
123 // <motivation>
124 // Define an interface to allow efficient processing of chunks of
125 // visibility data
126 // </motivation>
127 //
128 // <todo asof="97/10/01">
129 // <ul> Deal with large VLA spectral line case
130 // </todo>
131  class MosaicFT;
132 
133 
134 namespace refim{
135  class SimplePBConvFunc;
136 
137 class MosaicFT : public FTMachine {
138 public:
139 
140  // Constructor: cachesize is the size of the cache in words
141  // (e.g. a few million is a good number), tilesize is the
142  // size of the tile used in gridding (cannot be less than
143  // 12, 16 works in most cases).
144  // <group>
147  casacore::Bool usezero=true, casacore::Bool useDoublePrec=false, casacore::Bool useConjConvFunc=false, casacore::Bool usePointingTable=false);
148  // </group>
149 
150  // Construct from a casacore::Record containing the MosaicFT state
151  MosaicFT(const casacore::RecordInterface& stateRec);
152 
153  // Copy constructor
154  MosaicFT(const MosaicFT &other);
155 
156  // Assignment operator
157  MosaicFT &operator=(const MosaicFT &other);
158 
159  ~MosaicFT();
160 
161  // Initialize transform to Visibility plane using the image
162  // as a template. The image is loaded and Fourier transformed.
164  const vi::VisBuffer2& vb);
165 
166  // Finalize transform to Visibility plane: flushes the image
167  // cache and shows statistics if it is being used.
168  void finalizeToVis();
169 
170  // Initialize transform to Sky plane: initializes the image
172  const vi::VisBuffer2& vb);
174 
175  // Finalize transform to Sky plane: flushes the image
176  // cache and shows statistics if it is being used. DOES NOT
177  // DO THE FINAL TRANSFORM!
179 
180  // Get actual coherence from grid by degridding
181  void get(vi::VisBuffer2& vb, casacore::Int row=-1);
182 
183 
184  // Put coherence to grid by gridding.
185  void put(const vi::VisBuffer2& vb, casacore::Int row=-1, casacore::Bool dopsf=false,
187 
188  // Make the entire image
193 
194  // Get the final image: do the Fourier transform and
195  // grid-correct, then optionally normalize by the summed weights
198  const casacore::Matrix<casacore::Double>& /*sumOfWts*/,
199  casacore::Lattice<casacore::Float>& /*sensitivityImage*/,
200  casacore::Bool /*fftNorm*/)
201  {throw(casacore::AipsError("MosaicFT::normalizeImage() called"));}
202 
203 
204  // Get the final weights image
206 
207  // Get a flux (divide by this to get a flux density correct image)
208  // image if there is one
210 
211  // Save and restore the MosaicFT to and from a record
213  casacore::Bool withImage=false, const casacore::String diskimage="");
215 
216  // Can this FTMachine be represented by Fourier convolutions?
217  casacore::Bool isFourier() {return true;}
218 
219  // Return name of this machine
220 
221  virtual casacore::String name() const;
222  virtual casacore::Bool useWeightImage(){return true;};
223 
224 
225  // Copy convolution function etc to another FT machine
226  // necessary if ft and ift are distinct but can share convfunctions
227 
230 
232 
233  //reset weight image
234  virtual void reset();
235  virtual void setMiscInfo(const casacore::Int qualifier){(void)qualifier;};
236  virtual void ComputeResiduals(vi::VisBuffer2&/*vb*/, casacore::Bool /*useCorrected*/) {};
237 
238 protected:
239 
241 
242  // Find the convolution function
244  const vi::VisBuffer2& vb);
245 
246 
247 
249  void prepGridForDegrid();
250 
252 
253 
254  // Get the appropriate data pointer
256 
257  void ok();
258 
259  void init();
260 
261  // Is this record on Grid? check both ends. This assumes that the
262  // ends bracket the middle
264 
265 
266  // Image cache
268 
269  // Sizes
272 
273  // Gridder
275 
276  // Is this tiled?
278 
279  // casacore::Array lattice
281 
282  // Lattice. For non-tiled gridding, this will point to arrayLattice,
283  // whereas for tiled gridding, this points to the image
286 
288 
289  // Useful IPositions
291 
292  // Image Scaling and offset
294 
295  // casacore::Array for non-tiled gridding
298  // Pointing columns
300 
301  // Antenna columns
303 
305 
307 
309 
311 
313 
314  // Grid/degrid zero spacing points?
316 
327 
329 
331 
333  const casacore::Double& interval);
334 
336 
340 
341  //Later this
348 
349 };
350 
351 }// namespace refim ends
352 
353 } //# NAMESPACE CASA - END
354 
355 #endif
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
virtual void finalizeToSky()=0
Finalize transform to Sky plane.
casacore::Vector< casacore::Double > uvScale
Image Scaling and offset.
Definition: MosaicFT.h:293
casacore::Vector< casacore::Int > convRowMap_p
Definition: MosaicFT.h:324
A Measure: astronomical direction.
Definition: MDirection.h:174
casacore::Vector< casacore::Int > convChanMap_p
Definition: MosaicFT.h:325
void findConvFunction(const casacore::ImageInterface< casacore::Complex > &image, const vi::VisBuffer2 &vb)
Find the convolution function.
A Measure: position on Earth.
Definition: MPosition.h:79
int Int
Definition: aipstype.h:50
casacore::Vector< casacore::Int > convPolMap_p
Definition: MosaicFT.h:326
void addBeamCoverage(casacore::ImageInterface< casacore::Complex > &image)
virtual void getFluxImage(casacore::ImageInterface< casacore::Float > &image)
Get a flux (divide by this to get a flux density correct image) image if there is one...
casacore::Int nint(casacore::Double val)
Definition: MosaicFT.h:240
defines interface for the Fourier Transform Machine
Definition: FTMachine.h:122
VisibilityIterator2 iterates through one or more readonly MeasurementSets.
casacore::CountedPtr< casacore::TempImage< casacore::Float > > skyCoverage_p
Definition: MosaicFT.h:337
casacore::Array< casacore::Complex > convFunc
Definition: MosaicFT.h:317
casacore::Bool doneWeightImage_p
Definition: MosaicFT.h:343
virtual casacore::Bool useWeightImage()
All FTMachines that fill weightimage, need to set this.
Definition: MosaicFT.h:222
virtual Type type()
Return the type enum.
casacore::Double timegrid_p
Definition: MosaicFT.h:347
casacore::Vector< casacore::Int > convSizePlanes_p
Definition: MosaicFT.h:323
casacore::Float maxAbsData
Definition: MosaicFT.h:287
casacore::MSAntennaColumns * msac
Antenna columns.
Definition: MosaicFT.h:302
casacore::ConvolveGridder< casacore::Double, casacore::Complex > * gridder
Gridder.
Definition: MosaicFT.h:274
virtual void ComputeResiduals(vi::VisBuffer2 &, casacore::Bool)
Make the VB and VBStore interefaces for the interim re-factoring work.
Definition: MosaicFT.h:236
casacore::Int tilesize
Definition: MosaicFT.h:271
casacore::Bool usezero_p
Grid/degrid zero spacing points?
Definition: MosaicFT.h:315
casacore::Bool recordOnGrid(const vi::VisBuffer2 &vb, casacore::Int rownr) const
Is this record on Grid? check both ends.
ABSTRACT TOOL CLASSES A PlotTool is a higher level event handler for a PlotCanvas The idea is to take common tasks which may require multiple events and put them in one place PlotTools also provide additional functionality in that they can be active and blocking non blocking The PlotCanvas will only send events to active and will not send events to later tools or event handlers if the latest tool was blocking In this way a single tool can be used to handle ALL user interaction via the GUI at one time
Definition: PlotTool.h:43
casacore::Double timemass_p
Definition: MosaicFT.h:347
A class to provide easy read-write access to MSPointing columns.
casacore::Int lastIndex_p
Definition: MosaicFT.h:330
LatticeExprNode floor(const LatticeExprNode &expr)
casacore::MSPointingColumns * mspc
Pointing columns.
Definition: MosaicFT.h:299
casacore::ImageInterface< casacore::Complex > & getImage(casacore::Matrix< casacore::Float > &, casacore::Bool normalize=true)
Get the final image: do the Fourier transform and grid-correct, then optionally normalize by the summ...
casacore::Int convSize
Definition: MosaicFT.h:320
casacore::Int priorCacheSize
Definition: MosaicFT.h:312
casacore::Bool isTiled
Is this tiled?
Definition: MosaicFT.h:277
void initializeToSky(casacore::ImageInterface< casacore::Complex > &image, casacore::Matrix< casacore::Float > &weight, const vi::VisBuffer2 &vb)
Initialize transform to Sky plane: initializes the image.
casacore::String stokes_p
Definition: MosaicFT.h:344
virtual casacore::Bool toRecord(casacore::String &error, casacore::RecordInterface &outRec, casacore::Bool withImage=false, const casacore::String diskimage="")
Save and restore the MosaicFT to and from a record.
casacore::CountedPtr< SimplePBConvFunc > pbConvFunc_p
Definition: MosaicFT.h:339
casacore::Bool isFourier()
Can this FTMachine be represented by Fourier convolutions?
Definition: MosaicFT.h:217
void setConvFunc(casacore::CountedPtr< SimplePBConvFunc > &pbconvFunc)
Copy convolution function etc to another FT machine necessary if ft and ift are distinct but can shar...
long Long
Definition: aipstype.h:52
casacore::Vector< casacore::Int > convSupportPlanes_p
Definition: MosaicFT.h:322
casacore::Array< casacore::Complex > weightConvFunc_p
Definition: MosaicFT.h:318
Referenced counted pointer for constant data.
Definition: VisModelData.h:42
casacore::Array< casacore::Complex > * getDataPointer(const casacore::IPosition &, casacore::Bool)
Get the appropriate data pointer.
A class to provide easy read-only access to MSPointing columns.
Interconvert pixel positions and directions (e.g. RA/DEC).
casacore::CountedPtr< casacore::Lattice< casacore::Complex > > lattice
Lattice.
Definition: MosaicFT.h:284
double Double
Definition: aipstype.h:55
casacore::Vector< casacore::Double > uvOffset
Definition: MosaicFT.h:293
casacore::DirectionCoordinate directionCoord
Definition: MosaicFT.h:304
casacore::TempImage< casacore::Complex > * convWeightImage_p
Definition: MosaicFT.h:338
virtual void setMiscInfo(const casacore::Int qualifier)
set the order of the Taylor term for MFS this is to tell A-casacore::Projection to qualify the accumu...
Definition: MosaicFT.h:235
Type
Types of known Images that may be made using the makeImage method.
Definition: FTMachine.h:127
Converts UVW coordinates between coordinate systems.
Definition: UVWMachine.h:160
A class to provide easy read-write access to MSAntenna columns.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
MosaicFT(SkyJones *sj, casacore::MPosition mloc, casacore::String stokes, casacore::Long cachesize, casacore::Int tilesize=16, casacore::Bool usezero=true, casacore::Bool useDoublePrec=false, casacore::Bool useConjConvFunc=false, casacore::Bool usePointingTable=false)
Constructor: cachesize is the size of the cache in words (e.g.
casacore::CountedPtr< casacore::Lattice< casacore::Complex > > weightLattice
Definition: MosaicFT.h:285
float Float
Definition: aipstype.h:54
virtual casacore::String name() const
Return name of this machine.
casacore::MDirection worldPosMeas
Definition: MosaicFT.h:310
void put(const vi::VisBuffer2 &vb, casacore::Int row=-1, casacore::Bool dopsf=false, FTMachine::Type type=FTMachine::OBSERVED)
Put coherence to grid by gridding.
casacore::Int convSampling
Definition: MosaicFT.h:319
Sky Jones: Model sky-plane instrumental effects for the SkyEquation.
Definition: SkyJones.h:174
casacore::Vector< casacore::Double > xyPos
Definition: MosaicFT.h:308
void finalizeToVis()
Finalize transform to Visibility plane: flushes the image cache and shows statistics if it is being u...
casacore::MDirection::Convert * pointingToImage
Definition: MosaicFT.h:306
casacore::Array< casacore::Complex > griddedWeight
casacore::Array for non-tiled gridding
Definition: MosaicFT.h:296
casacore::CountedPtr< casacore::TempImage< casacore::Float > > & getConvWeightImage()
void initializeToVis(casacore::ImageInterface< casacore::Complex > &image, const vi::VisBuffer2 &vb)
Initialize transform to Visibility plane using the image as a template.
void makeImage(FTMachine::Type type, vi::VisibilityIterator2 &vs, casacore::ImageInterface< casacore::Complex > &image, casacore::Matrix< casacore::Float > &weight)
Make the entire image.
VisBuffer2s encapsulate one chunk of visibility data for processing.
Definition: VisBuffer2.h:141
Base class for all Casacore library errors.
Definition: Error.h:134
casacore::Bool useConjConvFunc_p
Definition: MosaicFT.h:345
casacore::CountedPtr< SimplePBConvFunc > & getConvFunc()
void getWeightImage(casacore::ImageInterface< casacore::Float > &, casacore::Matrix< casacore::Float > &)
Get the final weights image.
casacore::Bool usePointingTable_p
Definition: MosaicFT.h:346
virtual casacore::Bool fromRecord(casacore::String &error, const casacore::RecordInterface &inRec)
String: the storage and methods of handling collections of characters.
Definition: String.h:223
casacore::Double timedegrid_p
Definition: MosaicFT.h:347
casacore::CountedPtr< casacore::Lattice< casacore::Complex > > arrayLattice
casacore::Array lattice
Definition: MosaicFT.h:280
casacore::Int getIndex(const casacore::ROMSPointingColumns &mspc, const casacore::Double &time, const casacore::Double &interval)
Abstract base class for Record classes.
casacore::LatticeCache< casacore::Complex > * imageCache
Image cache.
Definition: MosaicFT.h:267
MosaicFT & operator=(const MosaicFT &other)
Assignment operator.
casacore::Bool getXYPos(const vi::VisBuffer2 &vb, casacore::Int row)
casacore::Int convSupport
Definition: MosaicFT.h:321
virtual void reset()
reset weight image
casacore::ImageInterface< casacore::Complex > * image
Definition: FTMachine.h:395
casacore::IPosition centerLoc
Useful IPositions.
Definition: MosaicFT.h:290
casacore::Array< casacore::DComplex > griddedWeight2
Definition: MosaicFT.h:297
casacore::IPosition offsetLoc
Definition: MosaicFT.h:290
virtual void normalizeImage(casacore::Lattice< casacore::Complex > &, const casacore::Matrix< casacore::Double > &, casacore::Lattice< casacore::Float > &, casacore::Bool)
Definition: MosaicFT.h:197
casacore::Long cachesize
Sizes.
Definition: MosaicFT.h:270
casacore::String machineName_p
Later this.
Definition: MosaicFT.h:342
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42
casacore::Int wConvSize
Definition: MosaicFT.h:328