LCOV - code coverage report
Current view: top level - synthesis/TransformMachines - VisibilityResamplerBase.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 51 0.0 %
Date: 2024-12-11 20:54:31 Functions: 0 4 0.0 %

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

Generated by: LCOV version 1.16