casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Go to the documentation of this file.
1 //# SDGrid.h: Definition for SDGrid
2 //# Copyright (C) 1996,1997,1998,1999,2000,2001,2002,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 adressed as follows:
20 //# Internet email:
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$
32 #include <casa/Arrays/Array.h>
33 #include <casa/Arrays/Matrix.h>
34 #include <casa/Arrays/Vector.h>
35 #include <casa/Containers/Block.h>
44 #include <msvis/MSVis/VisBuffer.h>
50 namespace casa { //# NAMESPACE CASA - BEGIN
52 // <summary> An FTMachine for Gridding Single Dish data
53 // </summary>
55 // <use visibility=export>
57 // <reviewed reviewer="" date="" tests="" demos="">
59 // <prerequisite>
60 // <li> <linkto class=FTMachine>FTMachine</linkto> module
61 // <li> <linkto class=SkyEquation>SkyEquation</linkto> module
62 // <li> <linkto class=VisBuffer>VisBuffer</linkto> module
63 // </prerequisite>
64 //
65 // <etymology>
66 // FTMachine is a Machine for Fourier Transforms. SDGrid does
67 // Single Dish gridding in a similar way
68 // </etymology>
69 //
70 // <synopsis>
71 // The <linkto class=SkyEquation>SkyEquation</linkto> needs to be able
72 // to perform Fourier transforms on visibility data and to grid
73 // single dish data.
74 // SDGrid allows efficient Single Dish processing using a
75 // <linkto class=VisBuffer>VisBuffer</linkto> which encapsulates
76 // a chunk of visibility (typically all baselines for one time)
77 // together with all the information needed for processing
78 // (e.g. direction coordinates).
79 //
80 // Gridding and degridding in SDGrid are performed using a
81 // novel sort-less algorithm. In this approach, the gridded plane is
82 // divided into small patches, a cache of which is maintained in memory
83 // using a general-purpose <linkto class=casacore::LatticeCache>LatticeCache</linkto> class. As the (time-sorted)
84 // visibility data move around slowly in the image plane, patches are
85 // swapped in and out as necessary. Thus, optimally, one would keep at
86 // least one patch per scan line of data.
87 //
88 // A grid cache is defined on construction. If the gridded image plane is smaller
89 // than this, it is kept entirely in memory and all gridding and
90 // degridding is done entirely in memory. Otherwise a cache of tiles is
91 // kept an paged in and out as necessary. Optimally the cache should be
92 // big enough to hold all polarizations and frequencies for one
93 // complete scan line.
94 // The paging rate will then be small. As the cache size is
95 // reduced below this critical value, paging increases. The algorithm will
96 // work for only one patch but it will be very slow!
97 //
98 // The gridding and degridding steps are implemented in Fortran
99 // for speed. In gridding, the visibilities are added onto the
100 // grid points in the neighborhood using a weighting function.
101 // In degridding, the value is derived by a weight summ of the
102 // same points, using the same weighting function.
103 // </synopsis>
104 //
105 // <example>
106 // See the example for <linkto class=SkyModel>SkyModel</linkto>.
107 // </example>
108 //
109 // <motivation>
110 // Define an interface to allow efficient processing of chunks of
111 // visibility data
112 // </motivation>
113 //
114 // <todo asof="97/10/01">
115 // <ul> Deal with large VLA spectral line case
116 // </todo>
118 class SDGrid : public FTMachine {
119 public:
121  // Constructor: cachesize is the size of the cache in words
122  // (e.g. a few million is a good number), tilesize is the
123  // size of the tile used in gridding (cannot be less than
124  // 12, 16 works in most cases), and convType is the type of
125  // gridding used (SF is prolate spheriodal wavefunction,
126  // and BOX is plain box-car summation). mLocation is
127  // the position to be used in some phase rotations. If
128  // mTangent is specified then the uvw rotation is done for
129  // that location iso the image center. userSupport is to allow
130  // larger support for the convolution if the user wants it ..-1 will
131  // use the default i.e 1 for BOX and 3 for others
133  // The parameter useImagingWeight in the constructors is to explicitly
134  // use vb.imagingweight while gridding,
135  // When doing just SD imaging then setting it to false is fine (in fact recommended as vb.imagingweight
136  // is set to zero if any pol is flagged this may change later being 2014/08/06)
137  // when using it in conjuction with interferometer gridding then set useImagingWeight to true
138  // this is to allow for proper non natural weighting scheme while imaging
139  // <group>
141  casacore::String convType="BOX", casacore::Int userSupport=-1, casacore::Bool useImagingWeight=false);
142  SDGrid(casacore::MPosition& ml, SkyJones& sj, casacore::Int cachesize,
143  casacore::Int tilesize, casacore::String convType="BOX", casacore::Int userSupport=-1,
144  casacore::Float minweight=0., casacore::Bool clipminmax=false, casacore::Bool useImagingWeight=false);
145  SDGrid(casacore::Int cachesize, casacore::Int tilesize,
146  casacore::String convType="BOX", casacore::Int userSupport=-1, casacore::Bool useImagingWeight=false);
147  SDGrid(casacore::MPosition& ml, casacore::Int cachesize, casacore::Int tilesize,
148  casacore::String convType="BOX", casacore::Int userSupport=-1, casacore::Float minweight=0., casacore::Bool clipminmax=false,
149  casacore::Bool useImagingWeight=false);
150  SDGrid(casacore::MPosition& ml, casacore::Int cachesize, casacore::Int tilesize,
151  casacore::String convType="TGAUSS", casacore::Float truncate=-1.0,
152  casacore::Float gwidth=0.0, casacore::Float jwidth=0.0, casacore::Float minweight=0., casacore::Bool clipminmax=false,
153  casacore::Bool useImagingWeight=false);
154  // </group>
156  // Copy constructor
157  SDGrid(const SDGrid &other);
159  // Assignment operator
160  SDGrid &operator=(const SDGrid &other);
162  ~SDGrid();
164  // Initialize transform to Visibility plane using the image
165  // as a template. The image is loaded and Fourier transformed.
167  const VisBuffer& vb);
169  // Finalize transform to Visibility plane: flushes the image
170  // cache and shows statistics if it is being used.
171  void finalizeToVis();
173  // Initialize transform to Sky plane: initializes the image
175  const VisBuffer& vb);
177  // Finalize transform to Sky plane: flushes the image
178  // cache and shows statistics if it is being used. DOES NOT
180  void finalizeToSky();
182  // Get actual coherence from grid by degridding
183  void get(VisBuffer& vb, casacore::Int row=-1);
185  // Put coherence to grid by gridding.
186  void put(const VisBuffer& vb, casacore::Int row=-1, casacore::Bool dopsf=false,
189  // Make the entire image using a ROVisIter...
190  // This is an overload for FTMachine version as
191  //SDGrid now does everything in memory
192  // so for large cube ..proceed by slices that fit in memory here.
193  virtual void makeImage(FTMachine::Type type,
198  // Get the final image:
199  // optionally normalize by the summed weights
202  const casacore::Matrix<casacore::Double>& /*sumOfWts*/,
203  casacore::Lattice<casacore::Float>& /*sensitivityImage*/,
204  casacore::Bool /*fftNorm*/)
205  {throw(casacore::AipsError("SDGrid::normalizeImage() called"));}
207  // Get the final weights image
210  // Has this operator changed since the last application?
211  virtual casacore::Bool changed(const VisBuffer& vb);
212  virtual void setMiscInfo(const casacore::Int qualifier){(void)qualifier;};
213  virtual void ComputeResiduals(VisBuffer& /*vb*/, casacore::Bool /*useCorrected*/) {};
215  virtual casacore::String name() const;
217 private:
219  // Find the Primary beam and convert it into a convolution buffer
221  const VisBuffer& vb);
225  // Get the appropriate data pointer
229  void ok();
231  void init();
233  // Image cache
237  // Sizes
240  // Is this tiled?
243  // Storage for weights
246  // casacore::Array lattice
250  // Lattice. For non-tiled gridding, this will point to arrayLattice,
251  // whereas for tiled gridding, this points to the image
257  // Useful IPositions
260  // casacore::Array for non-tiled gridding
269  //Original xypos of moving source
297  // for minmax clipping
304  void clipMinMax();
307  const casacore::Double& interval=-1.0, const casacore::Int& antid=-1);
311  //get the casacore::MDirection from a chosen column of pointing table
315  const casacore::Int& index, const casacore::Int& index1, const casacore::Int& index2);
319  //for debugging
320  //FILE *pfile;
321 };
325 #endif
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
casacore::Int cachesize
Definition: SDGrid.h:238
casacore::Int convSupport
Definition: SDGrid.h:279
A Measure: astronomical direction.
Definition: MDirection.h:174
casacore::LatticeCache< casacore::Complex > * imageCache
Image cache.
Definition: SDGrid.h:234
casacore::Array< casacore::Complex > gmin_
Definition: SDGrid.h:299
A Measure: position on Earth.
Definition: MPosition.h:79
int Int
Definition: aipstype.h:50
casacore::Int getIndex(const casacore::ROMSPointingColumns &mspc, const casacore::Double &time, const casacore::Double &interval=-1.0, const casacore::Int &antid=-1)
void finalizeToSky()
Finalize transform to Sky plane: flushes the image cache and shows statistics if it is being used...
casacore::Float gwidth_p
Definition: SDGrid.h:283
casacore::Vector< casacore::Double > xyPos
Definition: SDGrid.h:268
casacore::DirectionCoordinate directionCoord
Definition: SDGrid.h:264
casacore::Int tilesize
Definition: SDGrid.h:238
casacore::Bool useImagingWeight_p
Definition: SDGrid.h:290
casacore::Array< casacore::Float > wmin_
Definition: SDGrid.h:301
void initializeToVis(casacore::ImageInterface< casacore::Complex > &image, const VisBuffer &vb)
Initialize transform to Visibility plane using the image as a template.
void clipMinMax()
virtual Type type()
Return the type enum.
SDPosInterpolator * interpolator
Definition: SDGrid.h:295
casacore::Lattice< casacore::Float > * wArrayLattice
Definition: SDGrid.h:248
casacore::Lattice< casacore::Complex > * arrayLattice
casacore::Array lattice
Definition: SDGrid.h:247
casacore::Int convSampling
Definition: SDGrid.h:277
casacore::Int convSize
Definition: SDGrid.h:278
casacore::Array< casacore::Complex > gmax_
Definition: SDGrid.h:300
void put(const VisBuffer &vb, casacore::Int row=-1, casacore::Bool dopsf=false, FTMachine::Type type=FTMachine::OBSERVED)
Put coherence to grid by gridding.
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::Lattice< casacore::Float > * wLattice
Definition: SDGrid.h:253
casacore::Float truncate_p
Definition: SDGrid.h:282
casacore::ImageInterface< casacore::Complex > * image
Definition: FTMachine.h:409
casacore::ImageInterface< casacore::Complex > & getImage(casacore::Matrix< casacore::Float > &, casacore::Bool normalize=true)
Get the final image: optionally normalize by the summed weights.
void findPBAsConvFunction(const casacore::ImageInterface< casacore::Complex > &image, const VisBuffer &vb)
Find the Primary beam and convert it into a convolution buffer.
void initializeToSky(casacore::ImageInterface< casacore::Complex > &image, casacore::Matrix< casacore::Float > &weight, const VisBuffer &vb)
Initialize transform to Sky plane: initializes the image.
void pickWeights(const VisBuffer &vb, casacore::Matrix< casacore::Float > &weight)
casacore::String convType
Definition: SDGrid.h:255
casacore::Int lastIndex_p
Definition: SDGrid.h:288
casacore::Array< casacore::Float > * getWDataPointer(const casacore::IPosition &, casacore::Bool)
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::Int msId_p
Definition: SDGrid.h:292
double Double
Definition: aipstype.h:55
casacore::IPosition centerLoc
Useful IPositions.
Definition: SDGrid.h:258
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: SDGrid.h:212
casacore::Vector< casacore::Float > convFunc
Definition: SDGrid.h:276
casacore::Float jwidth_p
Definition: SDGrid.h:284
casacore::ImageInterface< casacore::Float > * wImage
Storage for weights.
Definition: SDGrid.h:244
casacore::MDirection worldPosMeas
Definition: SDGrid.h:272
void getWeightImage(casacore::ImageInterface< casacore::Float > &, casacore::Matrix< casacore::Float > &)
Get the final weights image.
Types of known Images that may be made using the makeImage method.
Definition: FTMachine.h:125
casacore::Int userSetSupport_p
Definition: SDGrid.h:280
virtual void normalizeImage(casacore::Lattice< casacore::Complex > &, const casacore::Matrix< casacore::Double > &, casacore::Lattice< casacore::Float > &, casacore::Bool)
Definition: SDGrid.h:201
SDGrid & operator=(const SDGrid &other)
Assignment operator.
void finalizeToVis()
Finalize transform to Visibility plane: flushes the image cache and shows statistics if it is being u...
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
casacore::Vector< casacore::Int > lastIndexPerAnt_p
Definition: SDGrid.h:289
float Float
Definition: aipstype.h:54
casacore::Cube< casacore::Int > flags
Definition: SDGrid.h:274
casacore::Bool isSplineInterpolationReady
Definition: SDGrid.h:294
casacore::MDirection interpolateDirectionMeas(const casacore::ROMSPointingColumns &mspc, const casacore::Double &time, const casacore::Int &index, const casacore::Int &index1, const casacore::Int &index2)
An FTMachine for Gridding Single Dish data.
Definition: SDGrid.h:118
casacore::Vector< casacore::Double > xyPosMovingOrig_p
Original xypos of moving source.
Definition: SDGrid.h:270
SDGrid(SkyJones &sj, casacore::Int cachesize, casacore::Int tilesize, casacore::String convType="BOX", casacore::Int userSupport=-1, casacore::Bool useImagingWeight=false)
Constructor: cachesize is the size of the cache in words (e.g.
casacore::Float minWeight_p
Definition: SDGrid.h:286
casacore::Int lastAntID_p
Definition: SDGrid.h:291
casacore::Bool getXYPos(const VisBuffer &vb, casacore::Int row)
casacore::Array< casacore::Int > npoints_
Definition: SDGrid.h:303
casacore::Bool isTiled
Is this tiled?
Definition: SDGrid.h:241
Sky Jones: Model sky-plane instrumental effects for the SkyEquation.
Definition: SkyJones.h:172
SkyJones * sj_p
Definition: SDGrid.h:223
Base class for all Casacore library errors.
Definition: Error.h:134
casacore::Array< casacore::Float > wGriddedData
casacore::Array for non-tiled gridding
Definition: SDGrid.h:261
casacore::Bool clipminmax_
for minmax clipping
Definition: SDGrid.h:298
String: the storage and methods of handling collections of characters.
Definition: String.h:223
VisBuffers encapsulate one chunk of visibility data for processing.
Definition: VisBuffer.h:153
casacore::MDirection directionMeas(const casacore::ROMSPointingColumns &mspc, const casacore::Int &index)
get the casacore::MDirection from a chosen column of pointing table
virtual casacore::String name() const
Return the name of the machine.
casacore::MDirection::Convert * pointingToImage
Definition: SDGrid.h:266
ROVisibilityIterator iterates through one or more readonly MeasurementSets.
virtual void ComputeResiduals(VisBuffer &, casacore::Bool)
Make the VB and VBStore interefaces for the interim re-factoring work.
Definition: SDGrid.h:213
casacore::Lattice< casacore::Complex > * lattice
Definition: SDGrid.h:252
casacore::IPosition offsetLoc
Definition: SDGrid.h:258
virtual void makeImage(FTMachine::Type type, ROVisibilityIterator &vi, casacore::ImageInterface< casacore::Complex > &image, casacore::Matrix< casacore::Float > &weight)
Make the entire image using a ROVisIter...
virtual casacore::Bool changed(const VisBuffer &vb)
Has this operator changed since the last application?
casacore::Array< casacore::Float > wmax_
Definition: SDGrid.h:302
casacore::LatticeCache< casacore::Float > * wImageCache
Definition: SDGrid.h:235
defines interface for the Fourier Transform Machine
Definition: FTMachine.h:120