LCOV - code coverage report
Current view: top level - synthesis/TransformMachines2 - VisibilityResampler.h (source / functions) Hit Total Coverage
Test: ctest_coverage.info Lines: 0 45 0.0 %
Date: 2023-11-02 14:27:30 Functions: 0 24 0.0 %

          Line data    Source code
       1             : // -*- C++ -*-
       2             : //# VisibilityResampler.h: Definition of the VisibilityResampler 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: aips2-request@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_VISIBILITYRESAMPLER_H
      30             : #define SYNTHESIS_TRANSFORM2_VISIBILITYRESAMPLER_H
      31             : 
      32             : #include <synthesis/TransformMachines2/CFStore.h>
      33             : #include <synthesis/TransformMachines2/Utils.h>
      34             : #include <synthesis/TransformMachines2/VBStore.h>
      35             : #include <synthesis/TransformMachines2/VisibilityResamplerBase.h>
      36             : #include <msvis/MSVis/VisBuffer2.h>
      37             : #include <casacore/casa/Arrays/Array.h>
      38             : #include <casacore/casa/Arrays/Vector.h>
      39             : //#include <msvis/MSVis/AsynchronousTools.h>
      40             : 
      41             : #include <casacore/casa/Logging/LogIO.h>
      42             : #include <casacore/casa/Logging/LogSink.h>
      43             : #include <casacore/casa/Logging/LogMessage.h>
      44             : 
      45             : namespace casa { //# NAMESPACE CASA - BEGIN
      46             :   namespace refim{
      47             :   class VisibilityResampler: public VisibilityResamplerBase
      48             :   {
      49             :   public: 
      50           0 :     VisibilityResampler(): VisibilityResamplerBase() {nVBs_p=nVisGridded_p=0;};
      51             :     //    VisibilityResampler(const CFStore& cfs): VisibilityResamplerBase(cfs) {};
      52           0 :     VisibilityResampler(const VisibilityResampler& other):VisibilityResamplerBase()
      53           0 :     {copy(other);}
      54             : 
      55             :     //    {setConvFunc(cfs);};
      56           0 :     virtual ~VisibilityResampler()
      57           0 :     {
      58             :       // cerr << "~VisibilityResampler:: "
      59             :       //           << "No. of VBs  processed: " << nVBs_p << endl
      60             :       //           << "No. of vis. processed: " << nVisGridded_p << endl;
      61           0 :     };
      62             : 
      63             :     //    VisibilityResampler& operator=(const VisibilityResampler& other);
      64             : 
      65           0 :     void copy(const VisibilityResamplerBase& other)
      66           0 :     {VisibilityResamplerBase::copy(other);}
      67             : 
      68           0 :     virtual Bool needCFPhaseScreen() {return true;};
      69           0 :     virtual VisibilityResamplerBase* clone() 
      70           0 :     {return new VisibilityResampler(*this);}
      71             : 
      72           0 :     virtual void getParams(casacore::Vector<casacore::Double>& uvwScale, casacore::Vector<casacore::Double>& offset, casacore::Vector<casacore::Double>& dphase)
      73           0 :     {uvwScale.assign(uvwScale_p); offset.assign(offset_p); dphase.assign(dphase_p);};
      74           0 :     virtual void setParams(const casacore::Vector<casacore::Double>& uvwScale, const casacore::Vector<casacore::Double>& offset,
      75             :                            const casacore::Vector<casacore::Double>& dphase)
      76             :     {
      77             :       // SynthesisUtils::SETVEC(uvwScale_p, uvwScale); 
      78             :       // SynthesisUtils::SETVEC(offset_p, offset);
      79             :       // SynthesisUtils::SETVEC(dphase_p, dphase);
      80           0 :       uvwScale_p.reference(uvwScale);
      81           0 :       offset_p.reference(offset);
      82           0 :       dphase_p.reference(dphase);
      83           0 :     };
      84             : 
      85           0 :     virtual void setMaps(const casacore::Vector<casacore::Int>& chanMap, const casacore::Vector<casacore::Int>& polMap)
      86             :     {
      87             :       // SynthesisUtils::SETVEC(chanMap_p,chanMap);
      88             :       // SynthesisUtils::SETVEC(polMap_p,polMap);
      89           0 :       chanMap_p.reference(chanMap);
      90           0 :       polMap_p.reference(polMap);
      91           0 :     }
      92             : 
      93           0 :     virtual void setFreqMaps(const casacore::Matrix<casacore::Double>& spwChanFreqs, const casacore::Matrix<casacore::Double>& spwChanConjFreqs)
      94             :     {
      95           0 :       spwChanFreq_p.assign(spwChanFreqs);
      96           0 :       spwChanConjFreq_p.assign(spwChanConjFreqs);
      97           0 :     }
      98             : 
      99           0 :     virtual void setConvFunc(const CFStore& cfs) 
     100             :     {
     101           0 :       convFuncStore_p = cfs;
     102           0 :     };
     103           0 :     virtual void setCFMaps(const casacore::Vector<casacore::Int>& cfMap, const casacore::Vector<casacore::Int>& conjCFMap) {(void)cfMap;(void)conjCFMap;};
     104           0 :     virtual void setPATolerance(const double& dPA) {paTolerance_p = dPA;};
     105             :     //
     106             :     //------------------------------------------------------------------------------
     107             :     //
     108             :     // Re-sample the griddedData on the VisBuffer (a.k.a gridding).
     109             :     //
     110             :     // In this class, these just call the private templated version.
     111             :     // The first variant grids onto a double precision grid while the
     112             :     // second one does it on a single precision grid.
     113             :     //
     114           0 :     virtual void DataToGrid(casacore::Array<casacore::DComplex>& griddedData, VBStore& vbs, 
     115             :                             casacore::Matrix<casacore::Double>& sumwt, const casacore::Bool& dopsf,
     116             :                             casacore::Bool /*useConjFreqCF*/=false)
     117           0 :     {DataToGridImpl_p(griddedData, vbs, dopsf, sumwt);}
     118             : 
     119           0 :     virtual void DataToGrid(casacore::Array<casacore::Complex>& griddedData, VBStore& vbs, 
     120             :                             casacore::Matrix<casacore::Double>& sumwt, const casacore::Bool& dopsf,
     121             :                             casacore::Bool /*useConjFreqCF*/=false)
     122           0 :     {DataToGridImpl_p(griddedData, vbs, dopsf, sumwt);}
     123             : 
     124             :     //
     125             :     //------------------------------------------------------------------------------
     126             :     //
     127             :     // Re-sample VisBuffer to a regular grid (griddedData) (a.k.a. de-gridding)
     128             :     //
     129             :     virtual void GridToData(VBStore& vbs,const casacore::Array<casacore::Complex>& griddedData); 
     130             :     //    virtual void GridToData(VBStore& vbs, casacore::Array<casacore::Complex>& griddedData); 
     131             : 
     132             :     virtual void ComputeResiduals(VBStore& vbs);
     133           0 :     virtual void setMutex(async::Mutex *mu) {myMutex_p = mu;};
     134             : 
     135             :     // Genealogical baggage -- required for the
     136             :     // MultiThreadedVisibilityResampler -- that everyone else has to
     137             :     // carray around.
     138             :     //
     139             :     // These are no-ops for unithreaded samplers.
     140             :     //
     141           0 :     virtual void init(const casacore::Bool& doublePrecision) {(void)doublePrecision;};
     142           0 :     virtual void GatherGrids(casacore::Array<casacore::DComplex>& griddedData, casacore::Matrix<casacore::Double>& sumwt) {(void)griddedData;(void)sumwt;};
     143           0 :     virtual void GatherGrids(casacore::Array<casacore::Complex>& griddedData, casacore::Matrix<casacore::Double>& sumwt) {(void)griddedData;(void)sumwt;};
     144           0 :     virtual void initializePutBuffers(const casacore::Array<casacore::DComplex>& griddedData,
     145           0 :                                       const casacore::Matrix<casacore::Double>& sumwt) {(void)griddedData;(void)sumwt;};
     146           0 :     virtual void initializePutBuffers(const casacore::Array<casacore::Complex>& griddedData,
     147           0 :                                       const casacore::Matrix<casacore::Double>& sumwt) {(void)griddedData;(void)sumwt;};
     148           0 :     virtual void initializeDataBuffers(VBStore& vbs) {(void)vbs;};
     149             : 
     150           0 :     virtual void releaseBuffers() {};
     151             :     //
     152             :     //------------------------------------------------------------------------------
     153             :     //----------------------------Private parts-------------------------------------
     154             :     //------------------------------------------------------------------------------
     155             :     //
     156             :   protected:
     157             :     async::Mutex *myMutex_p;
     158             :     double nVBs_p, nVisGridded_p;
     159             :     // casacore::Vector<casacore::Double> uvwScale_p, offset_p, dphase_p;
     160             :     // casacore::Vector<casacore::Int> chanMap_p, polMap_p;
     161             :     // CFStore convFuncStore_p;
     162             :     //    casacore::Int inc0_p, inc1_p, inc2_p, inc3_p;
     163             :     //
     164             :     // Re-sample the griddedData on the VisBuffer (a.k.a de-gridding).
     165             :     //
     166             :     template <class T>
     167             :     void DataToGridImpl_p(casacore::Array<T>& griddedData, VBStore& vb,  
     168             :                           const casacore::Bool& dopsf, casacore::Matrix<casacore::Double>& sumwt,casacore::Bool useConjFreqCF=false);
     169             : 
     170             :     // void sgrid(casacore::Vector<casacore::Double>& pos, casacore::Vector<casacore::Int>& loc, casacore::Vector<casacore::Int>& off, 
     171             :     //         casacore::Complex& phasor, const casacore::Int& irow, const casacore::Matrix<casacore::Double>& uvw, 
     172             :     //         const casacore::Double& dphase, const casacore::Double& freq, 
     173             :     //         const casacore::Vector<casacore::Double>& scale, const casacore::Vector<casacore::Double>& offset,
     174             :     //         const casacore::Vector<casacore::Float>& sampling);
     175             : 
     176             :     /*
     177             :     void sgrid(casacore::Int& ndim, casacore::Double* pos, casacore::Int* loc, casacore::Int* off, 
     178             :                casacore::Complex& phasor, const casacore::Int& irow, const casacore::Double* uvw, 
     179             :                const casacore::Double& dphase, const casacore::Double& freq, 
     180             :                const casacore::Double* scale, const casacore::Double* offset,
     181             :                const casacore::Float* sampling);
     182             : 
     183             :     inline casacore::Bool onGrid (const casacore::Int& nx, const casacore::Int& ny, 
     184             :                         const casacore::Vector<casacore::Int>& __restrict__ loc, 
     185             :                         const casacore::Vector<casacore::Int>& __restrict__ support) __restrict__ 
     186             :     {
     187             :       return (((loc(0)-support[0]) >= 0 ) && ((loc(0)+support[0]) < nx) &&
     188             :               ((loc(1)-support[1]) >= 0 ) && ((loc(1)+support[1]) < ny));
     189             :     };
     190             :     inline casacore::Bool onGrid (const casacore::Int& nx, const casacore::Int& ny, 
     191             :                         const casacore::Int& loc0, const casacore::Int& loc1, 
     192             :                         const casacore::Int& support) __restrict__ 
     193             :     {
     194             :       return (((loc0-support) >= 0 ) && ((loc0+support) < nx) &&
     195             :               ((loc1-support) >= 0 ) && ((loc1+support) < ny));
     196             :     };
     197             : 
     198             :     // casacore::Array assignment operator in CASACore requires lhs.nelements()
     199             :     // == 0 or lhs.nelements()=rhs.nelements()
     200             :     // template <class T>
     201             :     // inline void SETVEC(casacore::Vector<T>& lhs, const casacore::Vector<T>& rhs)
     202             :     // {lhs.resize(rhs.shape()); lhs = rhs;};
     203             : 
     204             : 
     205             :     //
     206             :     // Internal methods to address a 4D array.  These should ulimately
     207             :     // moved to a Array4D class in CASACore
     208             :     //
     209             : 
     210             :     // This is called less frequently.  Currently once per VisBuffer
     211             :     inline void cacheAxisIncrements(casacore::Int& n0, casacore::Int& n1, casacore::Int& n2, casacore::Int& n3)
     212             :     {inc0_p=1, inc1_p=inc0_p*n0, inc2_p=inc1_p*n1, inc3_p=inc2_p*n2;(void)n3;}
     213             : 
     214             : 
     215             :     // The following two methods are called in the innermost loop.
     216             :     inline casacore::Complex getFrom4DArray(const casacore::Complex* __restrict__ store,
     217             :                                   const casacore::Int* __restrict__ iPos) __restrict__ 
     218             :     {return store[iPos[0] + iPos[1]*inc1_p + iPos[2]*inc2_p +iPos[3]*inc3_p];};
     219             : 
     220             :     template <class T>
     221             :     void addTo4DArray(T* __restrict__ store,
     222             :                       const casacore::Int* __restrict__ iPos, 
     223             :                       casacore::Complex& nvalue, casacore::Double& wt) __restrict__ 
     224             :     {store[iPos[0] + iPos[1]*inc1_p + iPos[2]*inc2_p +iPos[3]*inc3_p] += (nvalue*wt);}
     225             :     */
     226             :   };
     227             : }; //# NAMESPACE CASA - END
     228             : };
     229             : #endif // 

Generated by: LCOV version 1.16