LCOV - code coverage report
Current view: top level - synthesis/MeasurementComponents - SDGrid.h (source / functions) Hit Total Coverage
Test: ctest_coverage.info Lines: 0 4 0.0 %
Date: 2023-11-06 10:06:49 Functions: 0 3 0.0 %

          Line data    Source code
       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: 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_SDGRID_H
      30             : #define SYNTHESIS_SDGRID_H
      31             : 
      32             : #define SDGRID_PERFS
      33             : #if defined(SDGRID_PERFS) 
      34             : #include <iostream>
      35             : #include <string>
      36             : #include <chrono>
      37             : #endif
      38             : 
      39             : #include <casacore/casa/Arrays/Array.h>
      40             : #include <casacore/casa/Arrays/Matrix.h>
      41             : #include <casacore/casa/Arrays/Vector.h>
      42             : #include <casacore/casa/Containers/Block.h>
      43             : #include <casacore/coordinates/Coordinates/DirectionCoordinate.h>
      44             : #include <casacore/images/Images/ImageInterface.h>
      45             : #include <casacore/lattices/Lattices/ArrayLattice.h>
      46             : #include <casacore/lattices/Lattices/LatticeCache.h>
      47             : #include <casacore/measures/Measures/Measure.h>
      48             : #include <casacore/measures/Measures/MDirection.h>
      49             : #include <casacore/measures/Measures/MPosition.h>
      50             : #include <casacore/ms/MeasurementSets/MSColumns.h>
      51             : #include <msvis/MSVis/VisBuffer.h>
      52             : #include <msvis/MSVis/VisibilityIterator.h>
      53             : #include <casacore/scimath/Mathematics/FFTServer.h>
      54             : 
      55             : #include <synthesis/TransformMachines/FTMachine.h>
      56             : #include <synthesis/TransformMachines/SkyJones.h>
      57             : #include <synthesis/Utilities/SDPosInterpolator.h>
      58             : 
      59             : namespace casa { //# NAMESPACE CASA - BEGIN
      60             : 
      61             : // <summary> An FTMachine for Gridding Single Dish data
      62             : // </summary>
      63             : 
      64             : // <use visibility=export>
      65             : 
      66             : // <reviewed reviewer="" date="" tests="" demos="">
      67             : 
      68             : // <prerequisite>
      69             : //   <li> <linkto class=FTMachine>FTMachine</linkto> module
      70             : //   <li> <linkto class=SkyEquation>SkyEquation</linkto> module
      71             : //   <li> <linkto class=VisBuffer>VisBuffer</linkto> module
      72             : // </prerequisite>
      73             : //
      74             : // <etymology>
      75             : // FTMachine is a Machine for Fourier Transforms. SDGrid does
      76             : // Single Dish gridding in a similar way
      77             : // </etymology>
      78             : //
      79             : // <synopsis> 
      80             : // The <linkto class=SkyEquation>SkyEquation</linkto> needs to be able
      81             : // to perform Fourier transforms on visibility data and to grid
      82             : // single dish data.
      83             : // SDGrid allows efficient Single Dish processing using a 
      84             : // <linkto class=VisBuffer>VisBuffer</linkto> which encapsulates
      85             : // a chunk of visibility (typically all baselines for one time)
      86             : // together with all the information needed for processing
      87             : // (e.g. direction coordinates).
      88             : //
      89             : // Gridding and degridding in SDGrid are performed using a
      90             : // novel sort-less algorithm. In this approach, the gridded plane is
      91             : // divided into small patches, a cache of which is maintained in memory
      92             : // using a general-purpose <linkto class=casacore::LatticeCache>LatticeCache</linkto> class. As the (time-sorted)
      93             : // visibility data move around slowly in the image plane, patches are
      94             : // swapped in and out as necessary. Thus, optimally, one would keep at
      95             : // least one patch per scan line of data.
      96             : //
      97             : // A grid cache is defined on construction. If the gridded image plane is smaller
      98             : // than this, it is kept entirely in memory and all gridding and
      99             : // degridding is done entirely in memory. Otherwise a cache of tiles is
     100             : // kept an paged in and out as necessary. Optimally the cache should be
     101             : // big enough to hold all polarizations and frequencies for one
     102             : // complete scan line.
     103             : // The paging rate will then be small. As the cache size is
     104             : // reduced below this critical value, paging increases. The algorithm will
     105             : // work for only one patch but it will be very slow!
     106             : //
     107             : // The gridding and degridding steps are implemented in Fortran
     108             : // for speed. In gridding, the visibilities are added onto the
     109             : // grid points in the neighborhood using a weighting function.
     110             : // In degridding, the value is derived by a weight summ of the
     111             : // same points, using the same weighting function.
     112             : // </synopsis> 
     113             : //
     114             : // <example>
     115             : // See the example for <linkto class=SkyModel>SkyModel</linkto>.
     116             : // </example>
     117             : //
     118             : // <motivation>
     119             : // Define an interface to allow efficient processing of chunks of 
     120             : // visibility data
     121             : // </motivation>
     122             : //
     123             : // <todo asof="97/10/01">
     124             : // <ul> Deal with large VLA spectral line case 
     125             : // </todo>
     126             : 
     127             : #if defined(SDGRID_PERFS)
     128             : namespace sdgrid_perfs {
     129             : class ChronoStat {
     130             : public:
     131             :     using Clock = std::chrono::steady_clock;
     132             :     using Duration = Clock::duration;
     133             :     using TimePoint = Clock::time_point;
     134             : 
     135             :     ChronoStat(const std::string & name = "");
     136             :     const std::string& name() const;
     137             :     void setName(const std::string& name);
     138             :     void start();
     139             :     void stop();
     140             :     bool isEmpty() const;
     141             :     Duration lapsSum() const;
     142             :     Duration lapsMin() const;
     143             :     Duration lapsMax() const;
     144             :     Duration lapsMean() const;
     145             :     unsigned int lapsCount() const;
     146             :     unsigned int nOverflows() const;
     147             :     unsigned int nUnderflows() const;
     148             :     std::string json() const;
     149             : 
     150             : private:
     151             :     std::string name_;
     152             :     bool started_;
     153             :     unsigned int n_laps_;
     154             :     unsigned int n_overflows_;
     155             :     unsigned int n_underflows_;
     156             : 
     157             :     TimePoint lap_start_time_;
     158             :     Duration laps_sum_;
     159             :     Duration laps_min_;
     160             :     Duration laps_max_;
     161             :     
     162             :     std::string quote(const std::string& s) const;
     163             : };
     164             : 
     165             : std::ostream& operator<<(std::ostream &os, const ChronoStat &c);
     166             : 
     167             : class StartStop {
     168             : public:
     169             :     StartStop(ChronoStat &c);
     170             :     ~StartStop();
     171             : private:
     172             :     ChronoStat& c_;
     173             : };
     174             : 
     175             : }
     176             : 
     177             : #endif
     178             : class SDGrid : public FTMachine {
     179             : public:
     180             : 
     181             :   // Constructor: cachesize is the size of the cache in words
     182             :   // (e.g. a few million is a good number), tilesize is the
     183             :   // size of the tile used in gridding (cannot be less than
     184             :   // 12, 16 works in most cases), and convType is the type of
     185             :   // gridding used (SF is prolate spheriodal wavefunction,
     186             :   // and BOX is plain box-car summation). mLocation is
     187             :   // the position to be used in some phase rotations. If
     188             :   // mTangent is specified then the uvw rotation is done for
     189             :   // that location iso the image center. userSupport is to allow 
     190             :   // larger support for the convolution if the user wants it ..-1 will 
     191             :   // use the default  i.e 1 for BOX and 3 for others
     192             :   // USEIMAGINGWEIGHT
     193             :   // The parameter useImagingWeight in the constructors is to explicitly  
     194             :   // use vb.imagingweight while gridding,
     195             :   // When doing just SD imaging then setting it to false is fine (in fact recommended as vb.imagingweight
     196             :   // is set to zero if any pol is flagged this may change later .....today being 2014/08/06) 
     197             :   // when using it in conjuction with interferometer gridding then set useImagingWeight to true
     198             :   // this is to allow for proper non natural weighting scheme while imaging
     199             :   // <group>
     200             :   SDGrid(SkyJones& sj, casacore::Int cachesize, casacore::Int tilesize,
     201             :      casacore::String convType="BOX", casacore::Int userSupport=-1, casacore::Bool useImagingWeight=false);
     202             :   SDGrid(casacore::MPosition& ml, SkyJones& sj, casacore::Int cachesize,
     203             :      casacore::Int tilesize, casacore::String convType="BOX", casacore::Int userSupport=-1,
     204             :      casacore::Float minweight=0., casacore::Bool clipminmax=false, casacore::Bool useImagingWeight=false);
     205             :   SDGrid(casacore::Int cachesize, casacore::Int tilesize,
     206             :      casacore::String convType="BOX", casacore::Int userSupport=-1, casacore::Bool useImagingWeight=false);
     207             :   SDGrid(casacore::MPosition& ml, casacore::Int cachesize, casacore::Int tilesize,
     208             :      casacore::String convType="BOX", casacore::Int userSupport=-1, casacore::Float minweight=0., casacore::Bool clipminmax=false,
     209             :      casacore::Bool useImagingWeight=false);
     210             :   SDGrid(casacore::MPosition& ml, casacore::Int cachesize, casacore::Int tilesize,
     211             :      casacore::String convType="TGAUSS", casacore::Float truncate=-1.0, 
     212             :      casacore::Float gwidth=0.0, casacore::Float jwidth=0.0, casacore::Float minweight=0., casacore::Bool clipminmax=false,
     213             :      casacore::Bool useImagingWeight=false);
     214             :   // </group>
     215             : 
     216             :   // Copy constructor
     217             :   SDGrid(const SDGrid &other);
     218             : 
     219             :   // Assignment operator
     220             :   SDGrid &operator=(const SDGrid &other);
     221             : 
     222             :   ~SDGrid();
     223             : 
     224             :   // Initialize transform to Visibility plane using the image
     225             :   // as a template. The image is loaded and Fourier transformed.
     226             :   void initializeToVis(casacore::ImageInterface<casacore::Complex>& image,
     227             :                        const VisBuffer& vb);
     228             : 
     229             :   // Finalize transform to Visibility plane: flushes the image
     230             :   // cache and shows statistics if it is being used.
     231             :   void finalizeToVis();
     232             : 
     233             :   // Initialize transform to Sky plane: initializes the image
     234             :   void initializeToSky(casacore::ImageInterface<casacore::Complex>& image,  casacore::Matrix<casacore::Float>& weight,
     235             :                        const VisBuffer& vb);
     236             : 
     237             :   // Finalize transform to Sky plane: flushes the image
     238             :   // cache and shows statistics if it is being used. DOES NOT
     239             :   // DO THE FINAL TRANSFORM!
     240             :   void finalizeToSky();
     241             : 
     242             :   // Get actual coherence from grid by degridding
     243             :   void get(VisBuffer& vb, casacore::Int row=-1);
     244             : 
     245             :   // Put coherence to grid by gridding.
     246             :   void put(const VisBuffer& vb, casacore::Int row=-1, casacore::Bool dopsf=false,
     247             :            FTMachine::Type type=FTMachine::OBSERVED);
     248             : 
     249             :   // Make the entire image using a ROVisIter...
     250             :   // This is an overload for FTMachine version as 
     251             :   //SDGrid now does everything in memory
     252             :   // so for large cube ..proceed by slices that fit in memory here.
     253             :   virtual void makeImage(FTMachine::Type type,
     254             :                          ROVisibilityIterator& vi,
     255             :                          casacore::ImageInterface<casacore::Complex>& image,
     256             :                          casacore::Matrix<casacore::Float>& weight);
     257             : 
     258             :   // Get the final image: 
     259             :   //  optionally normalize by the summed weights
     260             :   casacore::ImageInterface<casacore::Complex>& getImage(casacore::Matrix<casacore::Float>&, casacore::Bool normalize=true);
     261           0 :   virtual void normalizeImage(casacore::Lattice<casacore::Complex>& /*skyImage*/,
     262             :                               const casacore::Matrix<casacore::Double>& /*sumOfWts*/,
     263             :                               casacore::Lattice<casacore::Float>& /*sensitivityImage*/,
     264             :                               casacore::Bool /*fftNorm*/)
     265           0 :     {throw(casacore::AipsError("SDGrid::normalizeImage() called"));}
     266             : 
     267             :   // Get the final weights image
     268             :   void getWeightImage(casacore::ImageInterface<casacore::Float>&, casacore::Matrix<casacore::Float>&);
     269             : 
     270             :   // Has this operator changed since the last application?
     271             :   virtual casacore::Bool changed(const VisBuffer& vb);
     272           0 :   virtual void setMiscInfo(const casacore::Int qualifier){(void)qualifier;};
     273           0 :   virtual void ComputeResiduals(VisBuffer& /*vb*/, casacore::Bool /*useCorrected*/) {};
     274             : 
     275             :   virtual casacore::String name() const;
     276             : 
     277             :   // Enable/disable SDGrid::Cache
     278             :   void setEnableCache(casacore::Bool doEnable);
     279             : 
     280             :   // Interpolation-Conversion processing scheme
     281             :   enum class ConvertFirst {
     282             :     NEVER = 0,
     283             :     ALWAYS = 1,
     284             :     AUTO = 2
     285             :   };
     286             :   static const casacore::String & toString(const ConvertFirst convertFirst);
     287             :   static ConvertFirst fromString(const casacore::String & name);
     288             :   void setConvertFirst(const casacore::String &convertFirst);
     289             : 
     290             : private:
     291             : 
     292             :   // Find the Primary beam and convert it into a convolution buffer
     293             :   void findPBAsConvFunction(const casacore::ImageInterface<casacore::Complex>& image,
     294             :                             const VisBuffer& vb);
     295             : 
     296             :   SkyJones* sj_p;
     297             : 
     298             :   // Get the appropriate data pointer
     299             :   casacore::Array<casacore::Complex>* getDataPointer(const casacore::IPosition&, casacore::Bool);
     300             :   casacore::Array<casacore::Float>* getWDataPointer(const casacore::IPosition&, casacore::Bool);
     301             : 
     302             :   void ok();
     303             : 
     304             :   void init();
     305             : 
     306             :   // Image cache
     307             :   casacore::LatticeCache<casacore::Complex> * imageCache;
     308             :   casacore::LatticeCache<casacore::Float> * wImageCache;
     309             : 
     310             :   // Sizes
     311             :   casacore::Int cachesize, tilesize;
     312             : 
     313             :   // Is this tiled?
     314             :   casacore::Bool isTiled;
     315             : 
     316             :   // Storage for weights
     317             :   casacore::ImageInterface<casacore::Float>* wImage;
     318             : 
     319             :   // casacore::Array lattice
     320             :   casacore::Lattice<casacore::Complex> * arrayLattice;
     321             :   casacore::Lattice<casacore::Float> * wArrayLattice;
     322             : 
     323             :   // Lattice. For non-tiled gridding, this will point to arrayLattice,
     324             :   //  whereas for tiled gridding, this points to the image
     325             :   casacore::Lattice<casacore::Complex>* lattice;
     326             :   casacore::Lattice<casacore::Float>* wLattice;
     327             : 
     328             :   casacore::String convType;
     329             : 
     330             :   // Useful IPositions
     331             :   casacore::IPosition centerLoc, offsetLoc;
     332             : 
     333             :   // casacore::Array for non-tiled gridding
     334             :   casacore::Array<casacore::Float> wGriddedData;
     335             : 
     336             : 
     337             :   casacore::DirectionCoordinate directionCoord;
     338             : 
     339             :   casacore::MDirection::Convert* pointingToImage;
     340             : 
     341             :   // Stores - for spectra in the current MeasurementSet row -
     342             :   // coordinates of antenna's direction at data-taking time (ms.MAIN.TIME),
     343             :   // projected on image's spatial geometric plane.
     344             :   casacore::Vector<casacore::Double> xyPos;
     345             : 
     346             :   // Keep track of xyPos member's validity
     347             :   struct MaskedPixelRef {
     348             :       MaskedPixelRef(casacore::Vector<casacore::Double>& xy, casacore::Bool isValid = false);
     349             :       MaskedPixelRef& operator=(const MaskedPixelRef &other);
     350             :       casacore::Vector<casacore::Double>& xy;
     351             :       casacore::Bool isValid;
     352             :   };
     353             :   MaskedPixelRef rowPixel;
     354             : 
     355             :   //Original xypos of moving source
     356             :   casacore::Vector<casacore::Double> xyPosMovingOrig_p;
     357             : 
     358             :   casacore::MDirection worldPosMeas;
     359             : 
     360             :   casacore::Cube<casacore::Int> flags;
     361             : 
     362             :   casacore::Vector<casacore::Float> convFunc;
     363             :   casacore::Int convSampling;
     364             :   casacore::Int convSize;
     365             :   casacore::Int convSupport;
     366             :   casacore::Int userSetSupport_p;
     367             :   
     368             :   casacore::Float truncate_p;
     369             :   casacore::Float gwidth_p;
     370             :   casacore::Float jwidth_p;
     371             : 
     372             :   casacore::Float minWeight_p;
     373             : 
     374             :   casacore::Int lastIndex_p;
     375             :   casacore::Vector<casacore::Int> lastIndexPerAnt_p;
     376             :   casacore::Bool useImagingWeight_p;
     377             :   casacore::Int lastAntID_p;
     378             :   casacore::Int msId_p;
     379             : 
     380             :   casacore::Bool isSplineInterpolationReady;
     381             :   SDPosInterpolator* interpolator;
     382             : 
     383             :   // for minmax clipping
     384             :   casacore::Bool clipminmax_;
     385             :   casacore::Array<casacore::Complex> gmin_;
     386             :   casacore::Array<casacore::Complex> gmax_;
     387             :   casacore::Array<casacore::Float> wmin_;
     388             :   casacore::Array<casacore::Float> wmax_;
     389             :   casacore::Array<casacore::Int> npoints_;
     390             :   void clipMinMax();
     391             : 
     392             :   casacore::Int getIndex(const casacore::MSPointingColumns& mspc, const casacore::Double& time,
     393             :                     const casacore::Double& interval=-1.0, const casacore::Int& antid=-1);
     394             : 
     395             :   casacore::Bool getXYPos(const VisBuffer& vb, casacore::Int row);
     396             : 
     397             :   //get the casacore::MDirection from a chosen column of pointing table
     398             :   casacore::MDirection directionMeas(const casacore::MSPointingColumns& mspc, const casacore::Int& index);
     399             :   casacore::MDirection directionMeas(const casacore::MSPointingColumns& mspc, const casacore::Int& index, const casacore::Double& time);
     400             :   casacore::MDirection interpolateDirectionMeas(const casacore::MSPointingColumns& mspc, const casacore::Double& time,
     401             :                                   const casacore::Int& index, const casacore::Int& index1, const casacore::Int& index2);
     402             : 
     403             :   void pickWeights(const VisBuffer&vb, casacore::Matrix<casacore::Float>& weight);
     404             : 
     405             :   // Cache
     406             :   struct MaskedPixel {
     407             :       MaskedPixel(
     408             :           casacore::Double x = 0.0,
     409             :           casacore::Double y = 0.0,
     410             :           casacore::Bool isValid = false
     411             :       );
     412             :       casacore::Double x;
     413             :       casacore::Double y;
     414             :       casacore::Bool isValid;
     415             :   };
     416             : 
     417             :   // Description:
     418             :   // A cache aimed at storing expensive (spectra pixels) computation results,
     419             :   // which can be re-used across consecutive iterations
     420             :   // over the same input MeasurementSets.
     421             :   // Designed to be VisibilityIterator-friendly.
     422             :   // Since it is currently not aimed to be re-used elsewhere,
     423             :   // it is "welded" to its SDGrid container.
     424             :   //
     425             :   // Motivation:
     426             :   // CASA sdimaging task always iterates twice over the same input MeasurementSets,
     427             :   // to compute a normal image and a weight image.
     428             :   class Cache {
     429             :   public:
     430             :       enum class AccessMode {
     431             :           READ,
     432             :           WRITE
     433             :       };
     434             : 
     435             :   public:
     436             :       Cache(SDGrid &parent);
     437             : 
     438             :       static const casacore::String& className();
     439             : 
     440             :       Cache& operator=(const Cache &other);
     441             : 
     442             :       void open(AccessMode accessMode);
     443             :       void close();
     444             :       void clear();
     445             : 
     446             :       casacore::Bool isEmpty() const;
     447             :       casacore::Bool isReadable() const;
     448             :       casacore::Bool isWriteable() const;
     449             : 
     450             :       // Synchronize the cache with the VisibilityIterator.
     451             :       // Must be called exactly once each time the VisibilityIterator
     452             :       // starts iterating over a new MS (including the first one)
     453             :       void newMS(const casacore::MeasurementSet& ms);
     454             : 
     455             :       // Cache spatial pixel computation result for the current row.
     456             :       // Must be called exactly once per MeasurementSet row.
     457             :       void storeRowPixel();
     458             : 
     459             :       // Load from the cache Image's spatial pixel for the current row.
     460             :       // Must be called exactly once per MeasurementSet row.
     461             :       void loadRowPixel();
     462             : 
     463             :   private:
     464             :       void rewind();
     465             : 
     466             :       SDGrid& sdgrid;
     467             : 
     468             :       using Pixels = std::vector<MaskedPixel>;
     469             : 
     470             :       struct MsCache {
     471             :           MsCache(const casacore::String& msPath, const casacore::String& msTableName, casacore::rownr_t nRows);
     472             :           casacore::Bool isConsistent() const;
     473             :           casacore::String msPath;
     474             :           casacore::String msTableName;
     475             :           casacore::rownr_t nRows;
     476             :           Pixels pixels;
     477             :       };
     478             : 
     479             :       using MsCaches = std::vector<MsCache>;
     480             : 
     481             :       MsCaches msCaches;
     482             : 
     483             :       // State Control
     484             :       casacore::Bool isOpened;
     485             :       AccessMode accessMode;
     486             :       casacore::Bool canRead;
     487             :       casacore::Bool canWrite;
     488             : 
     489             :       // Input/Output
     490             :       // ---- Storing to the cache
     491             :       const MaskedPixelRef& inputPixel;
     492             :       Pixels *msPixels;
     493             : 
     494             :       // ---- Loading from the cache
     495             :       MaskedPixelRef& outputPixel;
     496             :       MsCaches::const_iterator msCacheReadIterator;
     497             :       Pixels::const_iterator pixelReadIterator;
     498             : 
     499             :   };
     500             : 
     501             :   Cache cache;
     502             :   casacore::Bool cacheIsEnabled;
     503             : 
     504             : // Description:
     505             : // Helper class handling SDGrid::Cache open/close.
     506             : // A CacheManager does nothing if it is not on duty.
     507             : // Otherwise, it opens the cache on construction,
     508             : // and closes it on destruction.
     509             : //
     510             : // Motivation:
     511             : // Synchronization matters most when dealing with caches.
     512             :   class CacheManager {
     513             :   public:
     514             :       CacheManager(Cache &cache,
     515             :         casacore::Bool onDuty=false, 
     516             :         Cache::AccessMode accessMode=Cache::AccessMode::READ);
     517             :       ~CacheManager();
     518             :   private:
     519             :       Cache& cache;
     520             :       casacore::Bool onDuty;
     521             :       Cache::AccessMode accessMode;
     522             :   };
     523             : 
     524             : // Description:
     525             : // Helper class for storing data into SDGrid::Cache.
     526             : // A CacheWriter does nothing if it is not on duty.
     527             : // Otherwise, it stores on destruction
     528             : // the pixel of spectra in the current row
     529             : // of the current MeasurementSet.
     530             : //
     531             : // Motivation:
     532             : // SDGrid::getXYPos() has a lot of branches.
     533             : 
     534             :   class CacheWriter {
     535             :   public:
     536             :       CacheWriter(Cache &cache,
     537             :         casacore::Bool onDuty=false);
     538             :       ~CacheWriter();
     539             :   private:
     540             :       Cache& cache;
     541             :       casacore::Bool onDuty;
     542             :   };
     543             : 
     544             :   //for debugging
     545             :   //FILE *pfile;
     546             : 
     547             :   void dumpConvolutionFunction(const casacore::String &outfile, const casacore::Vector<casacore::Float> &f) const;
     548             : 
     549             :   void initPerfs();
     550             :   void collectPerfs();
     551             :   void nextChunk(ROVisibilityIterator &vi);
     552             : #if defined(SDGRID_PERFS)
     553             :   sdgrid_perfs::ChronoStat cNextChunk;
     554             :   sdgrid_perfs::ChronoStat cMatchAllSpwChans;
     555             :   sdgrid_perfs::ChronoStat cMatchChannel;
     556             :   sdgrid_perfs::ChronoStat cPickWeights;
     557             :   sdgrid_perfs::ChronoStat cInterpolateFrequencyToGrid;
     558             :   sdgrid_perfs::ChronoStat cSearchValidPointing;
     559             :   sdgrid_perfs::ChronoStat cComputeSplines;
     560             :   sdgrid_perfs::ChronoStat cResetFrame;
     561             :   sdgrid_perfs::ChronoStat cInterpolateDirection;
     562             :   sdgrid_perfs::ChronoStat cConvertDirection;
     563             :   sdgrid_perfs::ChronoStat cComputeDirectionPixel;
     564             :   sdgrid_perfs::ChronoStat cHandleMovingSource;
     565             :   sdgrid_perfs::ChronoStat cGridData;
     566             : #endif
     567             : 
     568             :     // Computation of image's spatial coordinates:
     569             :     // conversion-interpolation scheme
     570             :     casacore::Bool convertFirst;
     571             :     ConvertFirst processingScheme;
     572             : 
     573             :     casacore::MSPointing ramPointingTable;
     574             :     casacore::CountedPtr<casacore::MSPointingColumns> ramPointingColumnsPtr;
     575             : 
     576             :     // Control logic
     577             :     // Decide if we must convert the user-specified pointing column
     578             :     casacore::Bool mustConvertPointingColumn(
     579             :         const casacore::MeasurementSet &ms
     580             :     );
     581             :     void handleNewMs(
     582             :         ROVisibilityIterator &vi,
     583             :         const casacore::ImageInterface<Complex>& image
     584             :     );
     585             :     void convertPointingColumn(
     586             :         const casacore::MeasurementSet & ms,
     587             :         const casacore::MSPointingEnums::PredefinedColumns columnEnum,
     588             :         const casacore::MDirection::Types refTypeType
     589             :     );
     590             :     void initRamPointingTable(
     591             :         const casacore::MSPointing & pointingTable,
     592             :         const casacore::MSPointingEnums::PredefinedColumns columnEnum,
     593             :         const casacore::MDirection::Types refType
     594             :     );
     595             :     std::pair<casacore::MeasFrame,casacore::MDirection::Convert>
     596             :     setupConversionTools(
     597             :         const casacore::MeasurementSet & ms,
     598             :         const casacore::MDirection::Types refType
     599             :     );
     600             : };
     601             : 
     602             : } //# NAMESPACE CASA - END
     603             : 
     604             : #endif

Generated by: LCOV version 1.16