LCOV - code coverage report
Current view: top level - synthesis/TransformMachines2 - SimplePBConvFunc.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 4 8 50.0 %
Date: 2024-11-06 17:42:47 Functions: 4 6 66.7 %

          Line data    Source code
       1             : //# SimplePBConvFunc.h: Definition for PixelatedConvFunc
       2             : //# Copyright (C) 2007
       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: casa-feedback@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             : #ifndef SYNTHESIS_TRANSFORM2_SIMPLEPBCONVFUNC_H
      29             : #define SYNTHESIS_TRANSFORM2_SIMPLEPBCONVFUNC_H
      30             : 
      31             : #include <casacore/casa/Arrays/Vector.h>
      32             : #include <synthesis/TransformMachines/PBMathInterface.h>
      33             : #include <casacore/casa/Containers/Block.h>
      34             : #include <casacore/casa/Utilities/CountedPtr.h>
      35             : #include <msvis/MSVis/VisBufferUtil.h>
      36             : #include <synthesis/Utilities/FFT2D.h>
      37             : #include <casacore/casa/Arrays/ArrayFwd.h>
      38             : 
      39             : #include <wcslib/wcsconfig.h>  /** HAVE_SINCOS **/
      40             : 
      41             : #if HAVE_SINCOS
      42             : #define SINCOS(a,s,c) sincos(a,&s,&c)
      43             : #else
      44             : #define SINCOS(a,s,c)                   \
      45             :      s = sin(a);                        \
      46             :      c = cos(a)
      47             : #endif
      48             : 
      49             : 
      50             : namespace casacore{
      51             : 
      52             :   template<class T> class ImageInterface;
      53             :   class CoordinateSystem;
      54             :   class DirectionCoordinate;
      55             : }
      56             : 
      57             : namespace casa{
      58             : 
      59             :   // <summary>  A class to support FTMachines get their convolution casacore::Function </summary>
      60             :   
      61             :   // <use visibility=export>
      62             :   // <prerequisite>
      63             :   //   <li> <linkto class=VisBuffer>VisBuffer</linkto> module
      64             : // </prerequisite>
      65             :   // <etymology>
      66             :   // "Simple" for cases that does not need parallactic angle and or frequency 
      67             :   // dependence ...hence one convolution function per pointing
      68             :   // "PB" for primary beam based convolution function
      69             :   // </etymology>
      70             :   //
      71             :   // <synopsis> 
      72             :   // FTMachines like WProjection and MosaicFT need convolution functions to 
      73             :   // deal with directional dependent issues...
      74             :   // this class and related ones provide and cache  such functions for re-use 
      75             :   //</synopsis>
      76             :   //Forward declarations
      77             :   
      78             :  
      79             :   namespace vi{class VisBuffer2;}
      80             : 
      81             : 
      82             : namespace refim{ //namespace for imaging refactor
      83             :   class SkyJones;
      84             :     
      85             : 
      86             :   class SimplePBConvFunc 
      87             : 
      88             :     {
      89             :     public:
      90             :       SimplePBConvFunc();
      91             :       SimplePBConvFunc(const PBMathInterface::PBClass typeToUse);
      92             :       SimplePBConvFunc(const casacore::RecordInterface& rec, casacore::Bool calcFlux_needed);
      93             :       virtual ~SimplePBConvFunc();
      94             :       // Inputs are the image, visbuffer, convSampling and skyjones
      95             :       // findconv return a cached convvolution function appropriate for this 
      96             :       // visbuffer and skyjones ...this one should be superseded 
      97             :       // by the one below and call setSkyJones when necessary
      98           0 :       virtual void findConvFunction(const casacore::ImageInterface<casacore::Complex>& , 
      99             :                                     const vi::VisBuffer2& ,const casacore::Int& ,
     100             :                             SkyJones& ,
     101             :                             casacore::Matrix<casacore::Complex>& , 
     102             :                             casacore::Matrix<casacore::Complex>& , casacore::Int& ,
     103           0 :                                     casacore::Int& ){};
     104             :       
     105             :       ////Returns the convfunctions in the Cubes...the casacore::Matrix rowChanMap maps 
     106             :       // the vb.row and channel 
     107             :       //to the plane of the convfunc appropriate 
     108             :       
     109             :       virtual void findConvFunction(const casacore::ImageInterface<casacore::Complex>& iimage, 
     110             :                                     const vi::VisBuffer2& vb,
     111             :                                     const casacore::Int& convSampling,
     112             :                                     const casacore::Vector<casacore::Double>& visFreq,
     113             :                                     casacore::Array<casacore::Complex>& convFunc,
     114             :                                     casacore::Array<casacore::Complex>& weightConvFunc,
     115             :                                     casacore::Vector<casacore::Int>& convsize,
     116             :                                     casacore::Vector<casacore::Int>& convSupport,
     117             :                                     casacore::Vector<casacore::Int>& polMap, casacore::Vector<casacore::Int>& chanMap, casacore::Vector<casacore::Int>& rowMap, const casacore::Bool getConjFreqConvFunc=false, const casacore::MVDirection& extraShift=casacore::MVDirection(0.0), const casacore::Bool useExtraShift=casacore::False);
     118             :       virtual casacore::ImageInterface<casacore::Float>&  getFluxScaleImage();
     119             :       // slice fluxscale image by npol 
     120             :       virtual void sliceFluxScale(casacore::Int npol);
     121             :       //This is a function to just store the final weight image
     122             :       //as FT machines will share this object ...they can get share this too
     123             :       virtual void setWeightImage(casacore::CountedPtr<casacore::TempImage<casacore::Float> >& wgtimage);
     124             : 
     125             :       virtual void setSkyJones(SkyJones* sj);
     126         370 :       virtual void setVBUtil(casacore::CountedPtr<VisBufferUtil> vbutil) {vbutil_p=vbutil;};
     127       85077 :       virtual  casacore::CountedPtr<VisBufferUtil> getVBUtil() {return vbutil_p;};
     128             :       casacore::Bool findSupport(casacore::Array<casacore::Complex>& /*func*/, casacore::Float& /*threshold*/,casacore::Int& /*origin*/, casacore::Int& /*R*/) 
     129             :       {throw(casacore::AipsError("SimplePBConvFunc::findSupport() not implemented"));};
     130           0 :       virtual casacore::Bool makeAverageResponse(const vi::VisBuffer2& /*vb*/, 
     131             :                                        const casacore::ImageInterface<casacore::Complex>& /*image*/,
     132             :                                        casacore::ImageInterface<casacore::Float>& /*theavgPB*/,
     133             :                                        casacore::Bool /*reset=true*/)
     134           0 :       {throw(casacore::AipsError("SimplePBConvFunc::makeAverageRes() called"));};
     135             : 
     136             :       //Serialization
     137             :      virtual  casacore::Bool toRecord(casacore::RecordInterface& outRec);
     138             :       //From record 
     139             :       //set calcfluxneeded to true if flux scale need to be computed
     140             :       virtual casacore::Bool fromRecord(casacore::String& err, const casacore::RecordInterface& rec, casacore::Bool calcFluxneeded=false);
     141             :       //give possibility to erase history
     142             :       virtual void reset();
     143       13448 :       virtual casacore::String name() {return casacore::String("SimplePBConvFunc");};
     144         370 :       void setUsePointing(casacore::Bool usepointing){usePointingTable_p=usepointing;};
     145             :       void findUsefulChannels(std::vector<double>& freqs, const vi::VisBuffer2& vb);
     146             :       //Spply phase gradient to convfuncs 5 dim convfuncs expected X,Y, pol, chan, row
     147             :       virtual void rephaseConvFunc(const casacore::ImageInterface<casacore::Complex>& iimage, 
     148             :                                  const vi::VisBuffer2& vb,const casacore::Int& convSampling, casacore::Array<casacore::Complex>& convFunc, 
     149             :                                  casacore::Array<casacore::Complex>& weightConvFunc,
     150             :                                  const std::vector<casacore::Int>& pmap, 
     151             :                                  const std::vector<casacore::Int>& cmap, 
     152             :                                  const std::vector<casacore::Int>& rmap, 
     153             :                                  const casacore::MVDirection& extraShift, const casacore::Bool useExtraShift);
     154             :      
     155             : 
     156             :     protected:
     157             :       SkyJones* sj_p;
     158             :       casacore::TempImage<casacore::Float> fluxScale_p;
     159             :       casacore::Int nx_p; 
     160             :       casacore::Int ny_p;
     161             :       casacore::Int nchan_p;
     162             :       casacore::Int npol_p;
     163             :       casacore::CoordinateSystem csys_p;
     164             :       casacore::DirectionCoordinate dc_p;
     165             :       casacore::MDirection::Convert pointToPix_p;
     166             :       casacore::MeasFrame pointFrame_p;
     167             :       casacore::MEpoch::Types timeMType_p;
     168             :       casacore::Unit timeUnit_p;
     169             :       casacore::Int directionIndex_p;
     170             :       casacore::MDirection direction1_p;
     171             :       casacore::MDirection direction2_p;
     172             :       casacore::Vector<casacore::Double> thePix_p;
     173             :       casacore::Bool filledFluxScale_p;
     174             :       casacore::Vector<casacore::Bool> doneMainConv_p;
     175             :       casacore::Bool calcFluxScale_p;
     176             :       std::map<casacore::String, casacore::Int> vbConvIndex_p;
     177             :       virtual casacore::Int convIndex(const vi::VisBuffer2& vb, const casacore::uInt nchan);
     178             :       std::map<casacore::String, casacore::Int> ant1PointVal_p;
     179             :       casacore::Vector<casacore::MDirection> ant1PointingCache_p;
     180             :       const casacore::MDirection& pointingDirAnt1(const vi::VisBuffer2& vb);
     181             :       virtual void storeImageParams(const casacore::ImageInterface<casacore::Complex>& iimage, const vi::VisBuffer2& vb);
     182             :       virtual void findUsefulChannels(casacore::Vector<casacore::Int>& chanMap, casacore::Vector<casacore::Double>& chanFreqs,  const vi::VisBuffer2& vb, const casacore::Vector<casacore::Double>& visFreq);
     183             :       //return the direction pixel corresponding to a direction
     184             :       virtual void toPix(const vi::VisBuffer2& vb, const casacore::MVDirection& extraShift=casacore::MVDirection(0.0), const casacore::Bool useExtraShift=casacore::False);
     185             :       FFT2D ft_p;
     186             :       casacore::CountedPtr<casacore::TempImage<casacore::Float> > convWeightImage_p;
     187             :       casacore::String bandName_p;
     188             :       casacore::CountedPtr<VisBufferUtil> vbutil_p;
     189             :       casacore::Bool usePointingTable_p;
     190             :     private:
     191             :       casacore::Bool checkPBOfField(const vi::VisBuffer2& vb);
     192             :       void addPBToFlux(const vi::VisBuffer2& vb);
     193             :       std::map <casacore::String, casacore::Int> convFunctionMap_p;
     194             :       casacore::Int actualConvIndex_p;
     195             :       PBMathInterface::PBClass pbClass_p;
     196             : 
     197             :       casacore::Matrix<casacore::Complex> convFunc_p;
     198             :       casacore::Matrix<casacore::Complex> weightConvFunc_p;
     199             :       casacore::Matrix<casacore::Complex> convSave_p;
     200             :       casacore::Matrix<casacore::Complex> weightSave_p;
     201             :       casacore::Int convSize_p; 
     202             :       casacore::Int convSupport_p;
     203             :       //These are Arrays of 5 dimension (x, y, npol, nchan, nrow)
     204             :       //Thus every baseline may have its own.
     205             :       casacore::Block <casacore::CountedPtr<casacore::Array<casacore::Complex> > > convFunctions_p;
     206             :       casacore::Block <casacore::CountedPtr<casacore::Array<casacore::Complex> > > convWeights_p;
     207             :       casacore::Block<casacore::CountedPtr<casacore::Vector<casacore::Int> > > convSizes_p;
     208             :       casacore::Block <casacore::CountedPtr<casacore::Vector<casacore::Int> > > convSupportBlock_p;
     209             :       casacore::Matrix<casacore::Bool> pointingPix_p;
     210             :       
     211             :     };
     212             :   }; //end of refim namespace
     213             : };// end of namespace
     214             : #endif

Generated by: LCOV version 1.16