LCOV - code coverage report
Current view: top level - synthesis/TransformMachines2 - VisibilityResamplerBase.cc (source / functions) Hit Total Coverage
Test: casa_coverage.info Lines: 17 37 45.9 %
Date: 2023-10-25 08:47:59 Functions: 2 6 33.3 %

          Line data    Source code
       1             : // -*- C++ -*-
       2             : //# VisibilityResamplerBase.cc: Implementation of the VisibilityResamplerBase 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             : #include <synthesis/TransformMachines2/VisibilityResamplerBase.h>
      30             : #include <synthesis/TransformMachines2/PolOuterProduct.h>
      31             : #include <synthesis/TransformMachines/SynthesisError.h>
      32             : #include <synthesis/TransformMachines2/Utils.h>
      33             : #include <stdcasa/thread/AsynchronousTools.h>
      34             : #include <casacore/casa/Quanta/MVTime.h>
      35             : #include <fstream>
      36             : 
      37             : using namespace casacore;
      38             : namespace casa{
      39             :   using namespace refim;
      40             :   //
      41             :   //-----------------------------------------------------------------------------------
      42             :   //
      43        7171 :   void VisibilityResamplerBase::copy(const VisibilityResamplerBase& other)
      44             :   {
      45        7171 :     SynthesisUtils::SETVEC(uvwScale_p, other.uvwScale_p);
      46        7171 :     SynthesisUtils::SETVEC(offset_p, other.offset_p);
      47        7171 :     SynthesisUtils::SETVEC(dphase_p, other.dphase_p);
      48        7171 :     SynthesisUtils::SETVEC(chanMap_p, other.chanMap_p);
      49        7171 :     SynthesisUtils::SETVEC(polMap_p, other.polMap_p);
      50        7171 :     SynthesisUtils::SETVEC(spwChanFreq_p, other.spwChanFreq_p);
      51        7171 :     SynthesisUtils::SETVEC(spwChanConjFreq_p, other.spwChanConjFreq_p);
      52        7171 :     SynthesisUtils::SETVEC(cfMap_p, other.cfMap_p);
      53        7171 :     SynthesisUtils::SETVEC(conjCFMap_p, other.conjCFMap_p);
      54             :     //    vbRow2CFMap_p.assign(other.vbRow2CFMap_p);
      55        7171 :     convFuncStore_p = other.convFuncStore_p;
      56        7171 :     paTolerance_p = other.paTolerance_p;
      57        7171 :     vb2CFBMap_p = other.vb2CFBMap_p;
      58             : 
      59        7171 :   }
      60             :   
      61       26675 :   void VisibilityResamplerBase::setVB2CFMap(const casacore::CountedPtr<refim::VB2CFBMap>& thisMap) 
      62             :   {
      63       26675 :     vb2CFBMap_p = thisMap;
      64             :     // uInt n=vb2CFBMap_p->vbRow2BLMap_p.size();
      65             :     // for(uInt i=0;i<n;i++)
      66             :     //   cerr << i << " " << vb2CFBMap_p->vbRow2BLMap_p[i]<< " " << thisMap->vbRow2BLMap_p[i] << endl;
      67             :     // return;
      68       26675 :   }
      69             :   //
      70             :   //-----------------------------------------------------------------------------------
      71             :   //
      72           0 :   VisibilityResamplerBase& VisibilityResamplerBase::operator=(const VisibilityResamplerBase& other)
      73             :   {
      74           0 :     copy(other);
      75           0 :     return *this;
      76             :   }
      77             :   //
      78             :   //-----------------------------------------------------------------------------------
      79             :   //
      80             :   // template void VisibilityResamplerBase::addTo4DArray(DComplex* store,const Int* iPos, Complex& val, Double& wt) __restrict__;
      81             :   // template void VisibilityResamplerBase::addTo4DArray(Complex* store,const Int* iPos, Complex& val, Double& wt) __restrict__;
      82             :   //
      83             :   //-----------------------------------------------------------------------------------
      84             :   //
      85           0 :   void VisibilityResamplerBase::sgrid(Int& uvwDim,
      86             :                                       Double* __restrict__ pos, 
      87             :                                       Int* __restrict__ loc, 
      88             :                                       Int* __restrict__ off, 
      89             :                                       Complex& phasor, const Int& irow,
      90             :                                       // const Matrix<Double>& __restrict__ uvw, 
      91             :                                       const Double* __restrict__ uvw, 
      92             :                                       const Double&  dphase, 
      93             :                                       const Double&  freq, 
      94             :                                       const Double* __restrict__ scale, 
      95             :                                       const Double* __restrict__ offset,
      96             :                                       const Float* __restrict__ sampling) // __restrict__ 
      97             :                                   // const Vector<Double>& __restrict__ scale, 
      98             :                                   // const Vector<Double>& __restrict__ offset,
      99             :                                   // const Vector<Float>& __restrict__ sampling) __restrict__ 
     100             :   {
     101             :     Double phase;
     102           0 :     Int ndim=2;
     103             : 
     104           0 :     for(Int idim=0;idim<ndim;idim++)
     105             :       {
     106           0 :         pos[idim]=scale[idim]*uvw[idim+irow*uvwDim]*freq/C::c+offset[idim];
     107           0 :         loc[idim]=(Int)std::floor(pos[idim]+0.5);
     108           0 :         off[idim]=(Int)std::floor(((loc[idim]-pos[idim])*sampling[idim])+0.5);
     109             :       }
     110             : 
     111           0 :     if (dphase != 0.0)
     112             :       {
     113           0 :         phase=-2.0*C::pi*dphase*freq/C::c;
     114           0 :         phasor=Complex(cos(phase), sin(phase));
     115             :       }
     116             :     else
     117           0 :       phasor=Complex(1.0);
     118             :     //cerr << "### " << pos[0] << " " << offset[0] << " " << off[0] << endl;
     119           0 :   }
     120             : 
     121             :   //
     122             :   //-----------------------------------------------------------------------------------
     123             :   //
     124             :   // Int VisibilityResamplerBase::makeVBRow2CFBMap(CFStore2& cfs,
     125             :   //                                           ConvolutionFunction& cf,
     126             :   //                                           const VisBuffer2& vbs, 
     127             :   //                                           const Quantity& dPA,
     128             :   //                                           const Vector<Int>& /*dataChan2ImChanMap*/,
     129             :   //                                           const Vector<Int>& /*dataPol2ImPolMap*/,
     130             :   //                                           const Vector<Double>& pointingOffset)
     131             :   // {
     132             :   //   //    VBRow2CFMapType& vbRow2CFMap_p,
     133             :   //   const Int nRow=vbs.nRows(); 
     134             :   //   //UNUSED: nChan=dataChan2ImChanMap.nelements(), 
     135             :   //   //UNUSED: nPol=dataPol2ImPolMap.nelements();
     136             :   //   //    vbRow2CFMap_p.resize(nPol, nChan, nRow);
     137             :   //   vbRow2CFBMap_p.resize(nRow);
     138             :   //   Quantity pa(getPA(vbs),"rad");
     139             :   //   PolOuterProduct outerProduct;
     140             :   //   Int statusCode=CFDefs::MEMCACHE;
     141             :   //   for (Int irow=0;irow<nRow;irow++)
     142             :   //     {
     143             :   //    //
     144             :   //    // Translate antenna ID to antenna type
     145             :   //    //
     146             :   //    Int ant1Type = cf.mapAntIDToAntType(vbs.antenna1()(irow)),
     147             :   //      ant2Type = cf.mapAntIDToAntType(vbs.antenna2()(irow));
     148             :   //    //
     149             :   //    // Get the CFBuffer for the given PA and baseline catagorized
     150             :   //    // by the two antenna types.  For homgeneous arrays, all
     151             :   //    // baselines will map to a single antenna-type pair.
     152             :   //    //
     153             : 
     154             :   //    CountedPtr<CFBuffer> cfb_l;
     155             :   //    try
     156             :   //      {
     157             :   //       cfb_l = cfs.getCFBuffer(pa, dPA, ant1Type, ant2Type);
     158             :   //       //cfb_l->show("From VRB: ");
     159             :   //      }
     160             :   //    catch (CFNotCached& x)
     161             :   //      {
     162             :   //        LogIO log_l(LogOrigin("VisibilityResamplerBase2", "makeVBRow2CFMap"));
     163             :   //        log_l << "CFs not cached for " << pa.getValue("deg") 
     164             :   //              << " deg, dPA = " << dPA.getValue("deg") 
     165             :   //              << " Field ID = " << vbs.fieldId()(0);
     166             :   //          //                  << " TimeStamps(0-10) = " << vbs.feedPa1(getCurrentTimeStamp(vbs)).nelements() << " ";
     167             :   //          //                  << " TimeStamps(0-10) = " << vbs.feedPa1().nelements() << " ";
     168             :   //        // for (Int i=0;i<10;i++) 
     169             :   //        //   {
     170             :   //        //  //              log_l << MVTime(vbs.time()(i)).string(MVTime::TIME) << " ";
     171             :   //        //  log_l << vbs.time()(i)/1.0e8 << " ";
     172             :   //        //  log_l << "(" << (vbs.feed_pa(getCurrentTimeStamp(vbs))(i))*57.2956 << ") ";
     173             :   //        //   }
     174             :   //        log_l << " Ant1Type, Ant2Type = " << ant1Type << "," << ant2Type << LogIO::POST;
     175             :   //        statusCode=CFDefs::NOTCACHED;
     176             :   //      }
     177             : 
     178             :   //    if (statusCode==CFDefs::NOTCACHED)
     179             :   //      {
     180             :   //        break;
     181             :   //      }
     182             :   //    else
     183             :   //      {
     184             :   //        cfb_l->setPointingOffset(pointingOffset);
     185             :   //        vbRow2CFBMap_p(irow) = cfb_l;
     186             :   //      }
     187             : 
     188             :   //    /*
     189             :   //    //
     190             :   //    // Now do the in-row mappings.
     191             :   //    // 
     192             :   //    // Convert the VB polarizations to MuelllerElements.  
     193             :   //    for (Int ichan=0;ichan<nChan;ichan++)
     194             :   //      {
     195             :   //        //      Double freq = vb.freq_p(ichan), wVal=vbs.uvw_p(irow,2);
     196             :   //        Double freq = vbs.frequency()(ichan), wVal=abs(vbs.uvw()(irow)(2));
     197             :   //        wVal *= freq/C::c;
     198             :   //        for (Int ipol=0;ipol<nPol;ipol++)
     199             :   //          {
     200             :   //            Vector<Int> vbPol = vbs.corrType();
     201             :   //            if (dataPol2ImPolMap(ipol) >= 0)
     202             :   //              {
     203             :   //                // The translate global functions comes from
     204             :   //                // PolOuterProduct.{cc,h}.
     205             :   //                //
     206             :   //                // The code below translates, e.g.,
     207             :   //                // Stokes::RR-->PolCrossProduct::RR-->MuellerElement.
     208             :   //                MuellerElementType muellerElement;// = outerProduct.getMuellerElement(translateStokesToCrossPol(vbPol(ipol)));
     209             :   //                Bool found=false;
     210             :   //                Double f,w;
     211             :   //                f=cfb_l->nearestFreq(found,freq);
     212             :   //                w=cfb_l->nearestWVal(found,wVal);
     213             :   //                if (!found) log_l << "Nearest freq. or w value not found " 
     214             :   //                                  << freq << " " << wVal << LogIO::EXCEPTION;
     215             : 
     216             :   //                vbRow2CFMap_p(ipol,ichan,irow) = cfb_l->getCFCellPtr(f, w, muellerElement);
     217             : 
     218             :   //                // Bool Dummy;
     219             :   //                // if (irow == 1)
     220             :   //                //   {
     221             :   //                //  cerr << "#### " << ipol << ", " << ichan << ", " << irow << " " 
     222             :   //                //       << vbRow2CFMap_p(ipol,ichan,irow)->getStorage()->getStorage(Dummy) << endl;
     223             :   //                //   }
     224             :   //              }
     225             :   //          }
     226             :   //      }
     227             :   //    */
     228             :   //     }
     229             :   //   return statusCode;
     230             :   // }
     231             : 
     232           0 :   std::shared_ptr<std::complex<double>> VisibilityResamplerBase::getGridPtr(size_t& size) const
     233             :   {
     234           0 :     size = 0;
     235           0 :     return std::shared_ptr<std::complex<double>>();
     236             :   }
     237             : 
     238           0 :   std::shared_ptr<double> VisibilityResamplerBase::getSumWeightsPtr(size_t& size) const
     239             :   {
     240           0 :     size = 0;
     241           0 :     return std::shared_ptr<double>();
     242             :   }
     243             : 
     244             : using namespace casacore;
     245             : };// end namespace casa

Generated by: LCOV version 1.16