LCOV - code coverage report
Current view: top level - synthesis/TransformMachines2 - AWConvFunc.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 10 0.0 %
Date: 2024-10-10 19:51:30 Functions: 0 8 0.0 %

          Line data    Source code
       1             : // -*- C++ -*-
       2             : //# AWConvFunc.h: Definition of the AWConvFunc class
       3             : //# Copyright (C) 1997-2023
       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_AWCONVFUNC_H
      30             : #define SYNTHESIS_TRANSFORM2_AWCONVFUNC_H
      31             : 
      32             : #include <synthesis/TransformMachines2/ConvolutionFunction.h>
      33             : #include <synthesis/TransformMachines2/PolOuterProduct.h>
      34             : #include <casacore/coordinates/Coordinates/DirectionCoordinate.h>
      35             : #include <synthesis/TransformMachines2/CFStore.h>
      36             : #include <synthesis/TransformMachines2/CFStore2.h>
      37             : #include <synthesis/TransformMachines2/CFBuffer.h>
      38             : #include <synthesis/TransformMachines2/VB2CFBMap.h>
      39             : #include <synthesis/TransformMachines2/PSTerm.h>
      40             : #include <synthesis/TransformMachines2/WTerm.h>
      41             : #include <synthesis/TransformMachines2/ATerm.h>
      42             : #include <casacore/images/Images/ImageInterface.h>
      43             : #include <casacore/images/Images/TempImage.h>
      44             : #include <casacore/casa/Logging/LogIO.h>
      45             : #include <casacore/casa/Logging/LogSink.h>
      46             : #include <casacore/casa/Logging/LogOrigin.h>
      47             : #include <casacore/casa/Arrays/ArrayFwd.h>
      48             : #include <msvis/MSVis/VisBuffer2.h>
      49             : namespace casacore{
      50             : 
      51             :   template<class T> class ImageInterface;
      52             : 
      53             : }
      54             : 
      55             : namespace casa { //# NAMESPACE CASA - BEGIN
      56             :   using namespace vi;
      57             :   //  class VisBuffer2;
      58             :   //
      59             :   //-------------------------------------------------------------------------------------------
      60             :   //
      61             :   namespace refim{
      62             :     //forward decs
      63             :     class WPConvFunc;
      64             :     class EVLAAperture;
      65             :   class AWConvFunc : public ConvolutionFunction
      66             :   {
      67             :   public:
      68             :     AWConvFunc(const casacore::CountedPtr<ATerm> ATerm,
      69             :                const casacore::CountedPtr<PSTerm> psTerm,
      70             :                const casacore::CountedPtr<WTerm> wTerm,
      71             :                const casacore::Bool wbAWP=false,
      72             :                const casacore::Bool conjPB=casacore::True);
      73             :     
      74             :     //this constructor is from 2023 to generate aw convfunc on the fly
      75             :     //For now noot using generic Aterm but specificall ELVA/VLA specialization
      76             :     AWConvFunc(std::shared_ptr<EVLAAperture> aterm, std::shared_ptr<WPConvFunc> wterm);
      77             :     
      78             :     
      79             :     
      80             :     
      81             : 
      82           0 :     ~AWConvFunc() {};
      83             :     //Makes the FT of PB (should be replicated to apply product of 2 different VP for 
      84             :     //heterogenous array
      85             :     // No oversampling at this stage
      86             :     // return conv function RR, RL, LR LL and freq axis as long a freq vector, 
      87             :     // supports are freqlist long
      88             :     // if dosquint=false pa ignored and a average RR, LL  beam is made
      89             :     // The shape of convFunc is [convSize, convSize, 4, len(freqlist)]
      90             :     // npix will be support on which the beam will be calculated
      91             :     // this can be used to rescale the beam along with the csys to the grid it is being 
      92             :     //applied
      93             :     void makeAConvFunc(casacore::Array<casacore::Complex>& convFunc, 
      94             :                        casacore::Array<casacore::Complex>& wtconv,
      95             :                        casacore::CoordinateSystem& csys,
      96             :                        casacore::Vector<casacore::Int>& asupport, 
      97             :                        casacore::Int& npix,
      98             :                        const casacore::Vector<casacore::Double>& freqlist, 
      99             :                        const casacore::Bool dosquint=False,
     100             :                        const casacore::Double& pa=0.0);
     101             :     //Makes the combination of wvals along A terms freqScale
     102             :     //return shapes of convFunc as [convSize, convSize, 4, len(freq), len(Wvals)]
     103             :     //returned matrix support is of shape [len(freq], len(wVals)]
     104             :     void makeAWConvFunc(casacore::Array<casacore::Complex>& convFunc, 
     105             :                        casacore::Array<casacore::Complex>& wtconv,
     106             :                        casacore::CoordinateSystem& csys,
     107             :                        casacore::Matrix<casacore::Int>& awsupport,
     108             :                        casacore::Int& npix,
     109             :                        const casacore::Vector<casacore::Double>& freqlist, 
     110             :                        const casacore::Vector<casacore::Double>& wVals,
     111             :                        const casacore::Bool dosquint=False,
     112             :                        const casacore::Double& pa=0.0);
     113             :     
     114             :     
     115             :     
     116             :     
     117             :     AWConvFunc& operator=(const AWConvFunc& other);
     118             :     virtual void makeConvFunction(const casacore::ImageInterface<casacore::Complex>& image,
     119             :                                   const VisBuffer2& vb,
     120             :                                   const casacore::Int wConvSize,
     121             :                                   const casacore::CountedPtr<PolOuterProduct>& pop,
     122             :                                   const casacore::Float pa,
     123             :                                   const casacore::Float dpa,
     124             :                                   const casacore::Vector<casacore::Double>& uvScale, const casacore::Vector<casacore::Double>& uvOffset,
     125             :                                   const casacore::Matrix<casacore::Double>& vbFreqSelection,
     126             :                                   CFStore2& cfs,
     127             :                                   CFStore2& cfwts,
     128             :                                   casacore::Bool fillCF=true);
     129             :     virtual void fillConvFuncBuffer(CFBuffer& cfb, CFBuffer& cfWtb,
     130             :                                     const casacore::Int& skyNX, const casacore::Int& skyNY,
     131             :                                     const casacore::Vector<casacore::Double>& skyIncr,
     132             :                                     const casacore::Int& nx, const casacore::Int& ny,
     133             :                                     const casacore::Vector<casacore::Double>& freqValues,
     134             :                                     const casacore::Vector<casacore::Double>& wValues,
     135             :                                     const casacore::Double& wScale,
     136             :                                     const casacore::Double& vbPA, const casacore::Double& freqHi,
     137             :                                     const PolMapType& muellerElements,
     138             :                                     const PolMapType& muellerElementsIndex,
     139             :                                     const VisBuffer2& vb, const casacore::Float& psScale,
     140             :                                     PSTerm& psTerm, WTerm& wTerm, ATerm& aTerm, 
     141             :                                     casacore::Bool isDryRun=false);
     142             :     static void makeConvFunction2(const casacore::String& uvGridDiskimage,
     143             :                                   const casacore::Vector<casacore::Double>& uvScale, const casacore::Vector<casacore::Double>& uvOffset,
     144             :                                   const casacore::Matrix<casacore::Double>& vbFreqSelection,
     145             :                                   CFStore2& cfs,
     146             :                                   CFStore2& cfwts,
     147             :                                   const casacore::Bool psTermOn,
     148             :                                   const casacore::Bool aTermOn,
     149             :                                   const casacore::Bool conjBeams);
     150             :     static void fillConvFuncBuffer2(CFBuffer& cfb, CFBuffer& cfWtb,
     151             :                                     const casacore::Int& nx, const casacore::Int& ny,
     152             :                                     const casacore::ImageInterface<casacore::Complex>& skyImage,
     153             :                                     const CFCStruct& miscInfo,
     154             :                                     PSTerm& psTerm, WTerm& wTerm, ATerm& aTerm,
     155             :                                     casacore::Bool conjBeams);
     156             : 
     157             :     virtual casacore::Bool makeAverageResponse(const VisBuffer2& vb, 
     158             :                                      const casacore::ImageInterface<casacore::Complex>& image,
     159             :                                      casacore::ImageInterface<casacore::Float>& theavgPB,
     160             :                                      casacore::Bool reset=true);
     161             :     virtual casacore::Bool makeAverageResponse(const VisBuffer2& vb, 
     162             :                                      const casacore::ImageInterface<casacore::Complex>& image,
     163             :                                      casacore::ImageInterface<casacore::Complex>& theavgPB,
     164             :                                      casacore::Bool reset=true);
     165           0 :     virtual int getVisParams(const VisBuffer2& vb,const casacore::CoordinateSystem& skyCoord=casacore::CoordinateSystem())
     166           0 :     {return aTerm_p->getVisParams(vb,skyCoord);};
     167           0 :     virtual void setPolMap(const casacore::Vector<casacore::Int>& polMap) {aTerm_p->setPolMap(polMap);};
     168             :     //    virtual void setFeedStokes(const casacore::Vector<casacore::Int>& feedStokes) {aTerm_p->setFeedStokes(feedStokes);};
     169             :     virtual casacore::Bool findSupport(casacore::Array<casacore::Complex>& func, casacore::Float& threshold,casacore::Int& origin, casacore::Int& R);
     170           0 :     virtual casacore::Vector<casacore::Double> findPointingOffset(const casacore::ImageInterface<casacore::Complex>& /*image*/,
     171           0 :                                               const VisBuffer2& /*vb*/) {casacore::Vector<casacore::Double> tt(2); tt=0;return tt;};
     172             :     //virtual void prepareConvFunction(const VisBuffer2& vb, VBRow2CFBMapType& cfs);
     173             :     virtual void prepareConvFunction(const VisBuffer2& vb, VB2CFBMap& cfs);
     174           0 :     casacore::Int mapAntIDToAntType(const casacore::Int& ant) {return aTerm_p->mapAntIDToAntType(ant);};
     175             : 
     176             :     virtual casacore::Vector<casacore::Double> makeFreqValList(casacore::Double& freqScale,
     177             :                                                                const VisBuffer2& vb, 
     178             :                                                                const casacore::ImageInterface<casacore::Complex>& uvGrid,
     179             :                                                                casacore::Vector<casacore::String>& bandNames);
     180             :     virtual casacore::Vector<casacore::Double> makeWValList(const casacore::Double &dW, const casacore::Int &nW);
     181             : 
     182             :     virtual void setMiscInfo(const casacore::RecordInterface& params);
     183             :     virtual casacore::Matrix<casacore::Double> getFreqRangePerSpw(const VisBuffer2& vb);
     184             : 
     185             : 
     186             : 
     187             :     //
     188             :     // Global methods (services)
     189             :     //
     190             :     static void makeConjPolAxis(casacore::CoordinateSystem& cs, casacore::Int conjStokes_in=-1);
     191             :     static casacore::Complex cfArea(casacore::Matrix<casacore::Complex>& cf, const casacore::Int& xSupport, const casacore::Int& ySupport, const casacore::Float& sampling);
     192             :     static casacore::Bool awFindSupport(casacore::Array<casacore::Complex>& func, casacore::Float& threshold, casacore::Int& origin, casacore::Int& radius);
     193             :     static casacore::Bool setUpCFSupport(casacore::Array<casacore::Complex>& func, casacore::Int& xSupport, casacore::Int& ySupport,
     194             :                                const casacore::Float& sampling, const casacore::Complex& peak);
     195             :     static casacore::Bool resizeCF(casacore::Array<casacore::Complex>& func,  casacore::Int& xSupport, casacore::Int& ySupport,
     196             :                          const casacore::Int& supportBuffer, const casacore::Float& sampling, const casacore::Complex& peak);
     197             :     static int getOversampling(PSTerm& psTerm, WTerm& wTerm, ATerm& aTerm);
     198           0 :     int getOversampling(){return getOversampling(*psTerm_p, *wTerm_p, *aTerm_p);}
     199             : 
     200           0 :     virtual casacore::CountedPtr<CFTerms> getTerm(const casacore::String& name)
     201           0 :     {if (name=="ATerm") return aTerm_p; else return NULL;}
     202             :     
     203             :     // virtual casacore::Vector<casacore::Vector<casacore::Double> >findPointingOffset(const casacore::ImageInterface<casacore::Complex>& /*image*/,
     204             :     //                                                            const VisBuffer2& /*vb*/, const casacore::Bool& doPointing);
     205             : 
     206             : 
     207             : 
     208             :     casacore::CountedPtr<ATerm> aTerm_p;
     209             :     casacore::CountedPtr<PSTerm> psTerm_p;
     210             :     casacore::CountedPtr<WTerm> wTerm_p;
     211             : 
     212             :   protected:
     213             :     void normalizeAvgPB(casacore::ImageInterface<casacore::Complex>& inImage,
     214             :                         casacore::ImageInterface<casacore::Float>& outImage);
     215             :     casacore::Bool makeAverageResponse_org(const VisBuffer2& vb, 
     216             :                                  const casacore::ImageInterface<casacore::Complex>& image,
     217             :                                  casacore::ImageInterface<casacore::Float>& theavgPB,
     218             :                                  casacore::Bool reset=true);
     219             :     void makePBSq(casacore::ImageInterface<casacore::Complex>& inImage);
     220             : 
     221             :     //for now this will support EVLA and VLA defined bands in evla L to Q
     222             :     //and VLA L to Q
     223             :     // return optimal cellsize and npix to calculate beam on
     224             :     std::pair<casacore::Quantity, int> getBeamCellSize(const String& bandName="EVLA_L");
     225             :     //find support and normalize convfunc for A Term only
     226             :     casacore::Bool supportAndNormalizeAFunc(casacore::Int& sup, 
     227             :                                        casacore::Array<casacore::Complex>& conv,
     228             :                                        casacore::Array<casacore::Complex>& wtconv);
     229             :     //support returned is row is freq axis, col is w axis
     230             :     //It will reduce the array XY size to match largest support found 
     231             :     // aTermsup is just to make sure any support found is not smaller than support for
     232             :     // just a Aterm conv
     233             :     casacore::Bool supportResizeAWConv(casacore::Matrix<casacore::Int>& sup, casacore::Array<casacore::Complex>& conv, const casacore::Vector<casacore::Int>& aTermSup);
     234             : 
     235             :         
     236             :         
     237             : 
     238             :     casacore::Vector<casacore::Double> thePix_p;
     239             :     casacore::Vector<casacore::Vector<casacore::Double> >pixFieldGrad_p;
     240             :     casacore::Double imRefFreq_p;
     241             :     casacore::Bool wbAWP_p, conjPB_p;
     242             :     casacore::CountedPtr<CFBuffer> baseCFB_p;
     243             :     ///These are the object that generates image/and UV domains A and W term
     244             :     std::shared_ptr<EVLAAperture> atermMaker_p;
     245             :     std::shared_ptr<WPConvFunc> wtermMaker_p;
     246             :     refim::MathUtils mutils_p;
     247             :     casacore::CoordinateSystem csys_p;
     248             :   };
     249             :   //
     250             :   //-------------------------------------------------------------------------------------------
     251             :   //
     252             : };
     253             : };
     254             : #endif

Generated by: LCOV version 1.16