LCOV - code coverage report
Current view: top level - synthesis/TransformMachines - PBMath1DIPoly.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 32 67 47.8 %
Date: 2024-11-06 17:42:47 Functions: 4 7 57.1 %

          Line data    Source code
       1             : //# PBMath1DIPoly.cc: Implementation for PBMath1DIPoly
       2             : //# Copyright (C) 1996,1997,1998,1999,2003
       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             :  
      29             : #include <casacore/casa/aips.h>
      30             : #include <casacore/casa/BasicSL/Complex.h>
      31             : #include <casacore/casa/BasicMath/Math.h>
      32             : #include <synthesis/TransformMachines/PBMath1DIPoly.h>
      33             : #include <casacore/casa/Quanta.h>
      34             : #include <casacore/measures/Measures.h>
      35             : 
      36             : 
      37             : 
      38             : using namespace casacore;
      39             : namespace casa { //# NAMESPACE CASA - BEGIN
      40             : 
      41          13 : PBMath1DIPoly::PBMath1DIPoly(const Vector<Double>& coeff, Quantity maxRad,
      42             :                              Quantity refFreq, 
      43             :                              Bool isThisVP, 
      44             :                              BeamSquint squint,
      45          13 :                              Bool useSymmetricBeam) :
      46             :   PBMath1D(maxRad, refFreq, isThisVP, squint, useSymmetricBeam),
      47          13 :   coeff_p(coeff)
      48             : {
      49          13 :   fillPBArray();    
      50             : 
      51          13 :   if (useSymmetricBeam) {
      52           0 :     symmetrizeSquintedBeam();
      53             :   }
      54          13 : };
      55             : 
      56           0 : PBMath1DIPoly::PBMath1DIPoly(const Matrix<Double>& coeff,
      57             :                              const Vector<Double>& freqs, Quantity maxRad,
      58             :                              Quantity refFreq, 
      59             :                              Bool isThisVP, 
      60             :                              BeamSquint squint,
      61           0 :                              Bool useSymmetricBeam) :
      62             :   PBMath1D(maxRad, refFreq, isThisVP, squint, useSymmetricBeam),
      63           0 :   wbcoeff_p(coeff)
      64             : {
      65           0 :   wFreqs_p=freqs;
      66           0 :   wideFit_p = true;
      67           0 :   if (coeff.ncolumn()!=freqs.nelements()) {
      68           0 :     throw(AipsError("PBMath1DIPoly:: - coeff and freqs arguments do not match"));
      69             :   }
      70           0 :   fillPBArray();    
      71             : 
      72           0 :   if (useSymmetricBeam) {
      73           0 :     symmetrizeSquintedBeam();
      74             :   }
      75           0 : };
      76             : 
      77             : 
      78             : 
      79          26 : PBMath1DIPoly::~PBMath1DIPoly()
      80             : {
      81          26 : };
      82             : 
      83             : 
      84           0 : PBMath1DIPoly& PBMath1DIPoly::operator=(const PBMath1DIPoly& other)
      85             : {
      86           0 :   if (this == &other)
      87           0 :     return *this;
      88             : 
      89           0 :   PBMath1D::operator=(other);
      90           0 :   coeff_p = other.coeff_p;
      91           0 :   wbcoeff_p = other.wbcoeff_p;
      92           0 :   return *this;
      93             : };
      94             : 
      95             : 
      96             : 
      97             : 
      98          13 : void PBMath1DIPoly::fillPBArray()
      99             : {
     100             : 
     101          26 :   LogIO os(LogOrigin("PBMath1DIPoly", "fillPBArray"));
     102          13 :   uInt nSamples=10000;
     103          13 :   vp_p.resize(nSamples);
     104          13 :   Int nfreq = wFreqs_p.nelements();
     105          13 :   bool wide = nfreq>0;
     106          13 :   if (wide) wbvp_p.resize(nSamples,nfreq);
     107          13 :   if (wide) os << "Using wideband interpolated beam pattern"<<LogIO::NORMAL;
     108             : 
     109          13 :   inverseIncrementRadius_p=Double(nSamples-1)/maximumRadius_p.getValue("'");
     110             :   Double x2;   Double y;
     111             :   Double taper;
     112          26 :   for(Int n=0; n<max(1,nfreq); n++) {
     113      130013 :     for(uInt i=0;i<nSamples;i++) {
     114      130000 :       taper = 0.0;
     115      130000 :       x2 = square( (Double(i)/inverseIncrementRadius_p) );
     116      130000 :       y = 1;
     117      130000 :       if (wide) {
     118           0 :         for (uInt j=0; j<wbcoeff_p.nrow(); j++) {
     119           0 :           taper += y * wbcoeff_p(j,n);
     120           0 :           y *= x2;
     121             :         }
     122             :       } else {
     123      260000 :         for (uInt j=0;j<coeff_p.nelements();j++) {
     124      130000 :           taper += y * coeff_p(j);
     125      130000 :           y *= x2;
     126             :         }
     127             :       }
     128      130000 :       if (taper != 0.0) {
     129      130000 :         if (isThisVP_p) {
     130           0 :           taper = 1.0/taper;
     131             :         } else {
     132      130000 :           taper = 1.0/sqrt(taper);
     133             :         }
     134             :       }
     135      130000 :       if (wide) {
     136           0 :         wbvp_p(i,n) = taper;
     137             :       } else {
     138      130000 :         vp_p(i) = taper;
     139             :       }
     140             :     }
     141             :   }
     142          13 : };
     143             : 
     144             : 
     145             : // Bool PBMath1DIPoly::flushToTable(Table& beamSubTable, Int iRow)
     146             : // {};
     147             : 
     148             : 
     149             : void
     150           0 : PBMath1DIPoly::summary(Int nValues)
     151             : {
     152           0 :   PBMath1D::summary(nValues);
     153           0 :   LogIO os(LogOrigin("PBMath1DIPoly", "summary"));
     154           0 :   Int nfreq = wFreqs_p.nelements();     
     155           0 :   if (nfreq==0) {
     156           0 :     os << "Even Powered Coefficients: " << coeff_p <<  LogIO::POST;
     157             :   } else {
     158           0 :     for (Int i=0; i<nfreq; i++) {
     159           0 :       os << " Even Powered Coefficients for "<<wFreqs_p(i)/1e9<<" GHz: "<<wbcoeff_p.column(i)
     160           0 :          << endl;
     161             :     }
     162           0 :     os << LogIO::POST;
     163             :   }
     164           0 : };
     165             : 
     166             : } //# NAMESPACE CASA - END
     167             : 

Generated by: LCOV version 1.16