LCOV - code coverage report
Current view: top level - synthesis/TransformMachines2 - AWVisResampler.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 37 0.0 %
Date: 2024-10-29 13:38:20 Functions: 0 18 0.0 %

          Line data    Source code
       1             : // -*- C++ -*-
       2             : //# AWVisResampler.h: Definition of the AWVisResampler class
       3             : //# Copyright (C) 1997,1998,1999,2000,2001,2002,2003
       4             : //# Associated Universities, Inc. Washington DC, USA.
       5             : //#
       6             : //# This library is free software; you can redistribute it and/or modify it
       7             : //# under the terms of the GNU Library General Public License as published by
       8             : //# the Free Software Foundation; either version 2 of the License, or (at your
       9             : //# option) any later version.
      10             : //#
      11             : //# This library is distributed in the hope that it will be useful, but WITHOUT
      12             : //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
      13             : //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
      14             : //# License for more details.
      15             : //#
      16             : //# You should have received a copy of the GNU Library General Public License
      17             : //# along with this library; if not, write to the Free Software Foundation,
      18             : //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
      19             : //#
      20             : //# Correspondence concerning AIPS++ should be addressed as follows:
      21             : //#        Internet email: casa-feedback@nrao.edu.
      22             : //#        Postal address: AIPS++ Project Office
      23             : //#                        National Radio Astronomy Observatory
      24             : //#                        520 Edgemont Road
      25             : //#                        Charlottesville, VA 22903-2475 USA
      26             : //#
      27             : //# $Id$
      28             : 
      29             : #ifndef SYNTHESIS_TRANSFORM2_AWVISRESAMPLER_H
      30             : #define SYNTHESIS_TRANSFORM2_AWVISRESAMPLER_H
      31             : 
      32             : #include <synthesis/TransformMachines2/CFStore.h>
      33             : #include <synthesis/TransformMachines2/VBStore.h>
      34             : #include <synthesis/TransformMachines2/VisibilityResampler.h>
      35             : #include <msvis/MSVis/VisBuffer2.h>
      36             : #include <casacore/casa/Arrays/Array.h>
      37             : #include <casacore/casa/Arrays/Vector.h>
      38             : 
      39             : #include <casacore/casa/Logging/LogIO.h>
      40             : #include <casacore/casa/Logging/LogSink.h>
      41             : #include <casacore/casa/Logging/LogMessage.h>
      42             : 
      43             : namespace casa { //# NAMESPACE CASA - BEGIN
      44             :   namespace refim{
      45             :   class AWVisResampler: public VisibilityResampler
      46             :   {
      47             :   public: 
      48           0 :     AWVisResampler(): VisibilityResampler(),
      49             :                       //                      cached_phaseGrad_p(),
      50           0 :                       cached_PointingOffset_p()
      51           0 :     {cached_PointingOffset_p.resize(2);cached_PointingOffset_p=-1000.0;runTimeG_p=runTimeDG_p=0.0;};
      52             :     //    AWVisResampler(const CFStore& cfs): VisibilityResampler(cfs)      {}
      53           0 :     virtual ~AWVisResampler()                                         {};
      54             : 
      55           0 :     virtual VisibilityResamplerBase* clone()
      56           0 :     {return new AWVisResampler(*this);}
      57             :     
      58             :     // AWVisResampler(const AWVisResampler& other): VisibilityResampler(other),cfMap_p(), conjCFMap_p()
      59             :     // {copy(other);}
      60             : 
      61           0 :     virtual void copyMaps(const AWVisResampler& other)
      62           0 :     {setCFMaps(other.cfMap_p, other.conjCFMap_p);}
      63           0 :     virtual void copy(const VisibilityResamplerBase& other) 
      64             :     {
      65           0 :       VisibilityResampler::copy(other);
      66           0 :     }
      67           0 :     virtual Bool needCFPhaseScreen() {return true;};
      68             : 
      69           0 :     virtual void copy(const AWVisResampler& other) 
      70             :     {
      71           0 :       VisibilityResampler::copy(other);
      72           0 :       SynthesisUtils::SETVEC(cached_phaseGrad_p, other.cached_phaseGrad_p);
      73           0 :       SynthesisUtils::SETVEC(cached_PointingOffset_p, other.cached_PointingOffset_p);
      74           0 :     }
      75             : 
      76             :     AWVisResampler& operator=(const AWVisResampler& other) 
      77             :     {
      78             :       copy(other);      
      79             :       SynthesisUtils::SETVEC(cached_phaseGrad_p, other.cached_phaseGrad_p);
      80             :       SynthesisUtils::SETVEC(cached_PointingOffset_p, other.cached_PointingOffset_p);
      81             :       return *this;
      82             :     }
      83             : 
      84           0 :     virtual void setCFMaps(const casacore::Vector<casacore::Int>& cfMap, const casacore::Vector<casacore::Int>& conjCFMap)
      85           0 :     {SETVEC(cfMap_p,cfMap);SETVEC(conjCFMap_p,conjCFMap);}
      86             :     //
      87             :     //------------------------------------------------------------------------------
      88             :     //
      89             :     // Re-sample the griddedData on the VisBuffer (a.k.a gridding).
      90             :     //
      91             :     // In this class, these just call the private templated version.
      92             :     // The first variant grids onto a double precision grid while the
      93             :     // second one does it on a single precision grid.
      94             :     //
      95           0 :     virtual void DataToGrid(casacore::Array<casacore::DComplex>& griddedData, VBStore& vbs, casacore::Matrix<casacore::Double>& sumwt,
      96             :                             const casacore::Bool& dopsf,casacore::Bool useConjFreqCF=false)
      97           0 :     {DataToGridImpl_p(griddedData, vbs, sumwt,dopsf,useConjFreqCF);}
      98             : 
      99           0 :     virtual void DataToGrid(casacore::Array<casacore::Complex>& griddedData, VBStore& vbs, casacore::Matrix<casacore::Double>& sumwt,
     100             :                             const casacore::Bool& dopsf,casacore::Bool useConjFreqCF=false)
     101           0 :     {DataToGridImpl_p(griddedData, vbs, sumwt,dopsf,useConjFreqCF);}
     102             : 
     103             :     //
     104             :     //------------------------------------------------------------------------------
     105             :     //
     106             :     // Re-sample VisBuffer to a regular grid (griddedData) (a.k.a. de-gridding)
     107             :     //
     108             :     virtual void GridToData(VBStore& vbs,const casacore::Array<casacore::Complex>& griddedData); 
     109             :   protected:
     110             :     //
     111             :     //------------------------------------------------------------------------------
     112             :     //----------------------------Private parts-------------------------------------
     113             :     //------------------------------------------------------------------------------
     114             :     //
     115             : 
     116             :     //  private:
     117             : 
     118             :     casacore::Vector<casacore::Int> gridInc_p, cfInc_p;
     119             :     casacore::Vector<casacore::Double> cached_PointingOffset_p;
     120             :     //
     121             :     // Re-sample the griddedData on the VisBuffer (a.k.a de-gridding).
     122             :     //
     123             :     template <class T>
     124             :     void DataToGridImpl_p(casacore::Array<T>& griddedData, VBStore& vb,  
     125             :                           casacore::Matrix<casacore::Double>& sumwt,const casacore::Bool& dopsf,
     126             :                           casacore::Bool /*useConjFreqCF*/);
     127             : 
     128             :     void sgrid(casacore::Vector<casacore::Double>& pos, casacore::Vector<casacore::Int>& loc, casacore::Vector<casacore::Double>& off, 
     129             :                casacore::Complex& phasor, const casacore::Int& irow, const casacore::Matrix<casacore::Double>& uvw, 
     130             :                const casacore::Double& dphase, const casacore::Double& freq, 
     131             :                const casacore::Vector<casacore::Double>& scale, const casacore::Vector<casacore::Double>& offset,
     132             :                const casacore::Vector<casacore::Float>& sampling);
     133             : 
     134           0 :     inline casacore::Bool onGrid (const casacore::Int& nx, const casacore::Int& ny, const casacore::Int& nw, 
     135             :                         const casacore::Vector<casacore::Int>& loc, 
     136             :                         const casacore::Vector<casacore::Int>& support)
     137             :     {
     138           0 :       return (((loc(0)-support[0]) >= 0 ) && ((loc(0)+support[0]) < nx) &&
     139           0 :               ((loc(1)-support[1]) >= 0 ) && ((loc(1)+support[1]) < ny) &&
     140           0 :               (loc(2) >= 0) && (loc(2) <= nw));
     141             :     };
     142             : 
     143             :     // casacore::Array assignment operator in CASACore requires lhs.nelements()
     144             :     // == 0 or lhs.nelements()=rhs.nelements()
     145             :     template <class T>
     146           0 :     inline void SETVEC(casacore::Vector<T>& lhs, const casacore::Vector<T>& rhs)
     147           0 :     {lhs.resize(rhs.shape()); lhs = rhs;};
     148             : 
     149             : 
     150             :     //
     151             :     // Internal methods to address a 4D array.  These should ulimately
     152             :     // moved to a Array4D class in CASACore
     153             :     //
     154             : 
     155             :     // This is called less frequently.  Currently once per VisBuffer
     156             :     // inline void cacheAxisIncrements(const casacore::Vector<casacore::Int>& n, casacore::Vector<casacore::Int>& inc)
     157             :     // {inc.resize(4);inc[0]=1, inc[1]=inc[0]*n[0], inc[2]=inc[1]*n[1], inc[3]=inc[2]*n[2];(void)n[3];}
     158             : 
     159             : 
     160             :     // The following method is also called from the inner loop, but
     161             :     // does not use CASA casacore::Vector (which are not thread safe, I (SB) am
     162             :     // told).
     163           0 :     inline casacore::Complex getFrom4DArray(const casacore::Complex *__restrict__& store,
     164             :                                   const casacore::Int* iPos, const casacore::Int* inc)
     165             :     {
     166           0 :       return *(store+(iPos[0] + iPos[1]*inc[1] + iPos[2]*inc[2] +iPos[3]*inc[3]));
     167             :       //      return store[iPos[0] + iPos[1]*inc[1] + iPos[2]*inc[2] +iPos[3]*inc[3]];
     168             :     };
     169             : 
     170             :     // The following two methods are called in the innermost loop.
     171             :     inline casacore::Complex getFrom4DArray(const casacore::Complex *__restrict__& store,
     172             :                                   const casacore::Vector<casacore::Int>& iPos, const casacore::Vector<casacore::Int>& inc)
     173             :     {
     174             :       return *(store+(iPos[0] + iPos[1]*inc[1] + iPos[2]*inc[2] +iPos[3]*inc[3]));
     175             :       //      return store[iPos[0] + iPos[1]*inc[1] + iPos[2]*inc[2] +iPos[3]*inc[3]];
     176             :     };
     177             :     inline casacore::DComplex getFrom4DArray(const casacore::DComplex *__restrict__& store,
     178             :                                   const casacore::Vector<casacore::Int>& iPos, const casacore::Vector<casacore::Int>& inc)
     179             :     {
     180             :       return *(store+(iPos[0] + iPos[1]*inc[1] + iPos[2]*inc[2] +iPos[3]*inc[3]));
     181             :       //      return store[iPos[0] + iPos[1]*inc[1] + iPos[2]*inc[2] +iPos[3]*inc[3]];
     182             :     };
     183             : 
     184             :     template <class T>
     185           0 :     void addTo4DArray(T *__restrict__& store,
     186             :                       const casacore::Int *__restrict__& iPos, const casacore::Vector<casacore::Int>& inc, 
     187             :                       casacore::Complex& nvalue, casacore::Complex& wt) __restrict__
     188             :     {
     189             :       // T *tmp=store+(iPos[0] + iPos[1]*inc[1] + iPos[2]*inc[2] +iPos[3]*inc[3]);
     190             :       // *tmp += nvalue*wt;
     191           0 :       store[iPos[0] + iPos[1]*inc[1] + iPos[2]*inc[2] +iPos[3]*inc[3]] += (nvalue*wt);
     192           0 :     }
     193             : 
     194             :     template <class T>
     195           0 :     void addTo4DArray_ptr(T *__restrict__& store,
     196             :                           const casacore::Int *__restrict__& iPos,
     197             :                           const casacore::Int *__restrict__& inc, 
     198             :                           casacore::Complex& nvalue, casacore::Complex& wt) __restrict__
     199             :     {
     200             :       // T *tmp=store+(iPos[0] + iPos[1]*inc[1] + iPos[2]*inc[2] +iPos[3]*inc[3]);
     201             :       // *tmp += nvalue*wt;
     202           0 :       store[iPos[0] + iPos[1]*inc[1] + iPos[2]*inc[2] +iPos[3]*inc[3]] += (nvalue*wt);
     203           0 :     }
     204             : 
     205             :     //
     206             :     // This rotates the convolution function by rotating the
     207             :     // co-ordinate system.  For the accuracies already required for
     208             :     // EVLA and ALMA, this is not useful.  Leaving it hear for now....
     209             :     //
     210             :     // casacore::Bool reindex(const casacore::Vector<casacore::Int>& in, casacore::Vector<casacore::Int>& out,
     211             :     //                     const casacore::Double& sinDPA, const casacore::Double& cosDPA,
     212             :     //                     const casacore::Vector<casacore::Int>& Origin, const casacore::Vector<casacore::Int>& size);
     213             : 
     214             :     casacore::Complex* getConvFunc_p(const double& vbPA,
     215             :                                      casacore::Vector<casacore::Int>& cfShape,
     216             :                                      casacore::Vector<int>& support,
     217             :                                      int& muellerElement,
     218             :                                      CountedPtr<CFBuffer>& cfb,
     219             :                                      casacore::Double& wVal, casacore::Int& fndx, 
     220             :                                      casacore::Int& wndx,
     221             :                                      PolMapType& mNdx, PolMapType& conjMNdx,
     222             :                                      casacore::Int& ipol, casacore::uInt& mRow);
     223             :     void cachePhaseGrad_p(const casacore::Vector<casacore::Double>& pointingOffset,
     224             :                           const casacore::Vector<casacore::Int>&cfShape,
     225             :                           const casacore::Vector<casacore::Int>& convOrigin,
     226             :                           const casacore::Double& cfRefFreq,
     227             :                           const casacore::Double& imRefFreq,
     228             :                           const casacore::Int& spwID=0, const casacore::Int& fieldId=0);
     229             :   };
     230             : }; //# NAMESPACE CASA - END
     231             : };
     232             : #endif // 

Generated by: LCOV version 1.16