LCOV - code coverage report
Current view: top level - imageanalysis/ImageAnalysis - LinearPolarizationAngleCalculator.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 20 25 80.0 %
Date: 2024-12-11 20:54:31 Functions: 3 5 60.0 %

          Line data    Source code
       1             : //# Copyright (C) 1996,1997,1998,1999,2000,2001,2002,2003
       2             : //# Associated Universities, Inc. Washington DC, USA.
       3             : //#
       4             : //# This library is free software; you can redistribute it and/or modify it
       5             : //# under the terms of the GNU Library General Public License as published by
       6             : //# the Free Software Foundation; either version 2 of the License, or (at your
       7             : //# option) any later version.
       8             : //#
       9             : //# This library is distributed in the hope that it will be useful, but WITHOUT
      10             : //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
      11             : //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
      12             : //# License for more details.
      13             : //#
      14             : //# You should have received a copy of the GNU Library General Public License
      15             : //# along with this library; if not, write to the Free Software Foundation,
      16             : //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
      17             : //#
      18             : //# Correspondence concerning AIPS++ should be addressed as follows:
      19             : //#        Internet email: casa-feedback@nrao.edu.
      20             : //#        Postal address: AIPS++ Project Office
      21             : //#                        National Radio Astronomy Observatory
      22             : //#                        520 Edgemont Road
      23             : //#                        Charlottesville, VA 22903-2475 USA
      24             : //#
      25             : 
      26             : #include <imageanalysis/ImageAnalysis/LinearPolarizationAngleCalculator.h>
      27             : 
      28             : using namespace casacore;
      29             : namespace casa {
      30             : 
      31             : const String LinearPolarizationAngleCalculator::CLASS_NAME = "LinearPolarizationAngleCalculator";
      32             : 
      33           7 : LinearPolarizationAngleCalculator::LinearPolarizationAngleCalculator(
      34             :     const SPCIIF image, const String& outname, Bool overwrite
      35           7 : ) : ImagePolTask(image, outname, overwrite) {}
      36             : 
      37           7 : LinearPolarizationAngleCalculator::~LinearPolarizationAngleCalculator() {}
      38             : 
      39           7 : SPIIF LinearPolarizationAngleCalculator::compute(Bool radians) {
      40           7 :     *_getLog() << LogOrigin(CLASS_NAME, __func__, WHERE);
      41           7 :     auto q = _getStokesImage(Q);
      42           7 :     auto u = _getStokesImage(U);
      43           7 :     ThrowIf (
      44             :         ! q || ! u,
      45             :         "This image does not have Stokes Q and/or U so cannot "
      46             :         "compute linear polarization angle"
      47             :     );
      48           7 :     _checkQUBeams(False);
      49             :     // Make expression. LEL function "pa" returns degrees
      50           7 :     Float fac = radians ? C::pi / 180.0 : 1.0;
      51          14 :     LatticeExprNode node(fac*pa(*u, *q));
      52           7 :     LatticeExpr<Float> le(node);
      53          14 :     ImageExpr<Float> ie(le, String("LinearlyPolarizedPositionAngle"));
      54           7 :     ie.setUnits(Unit(radians ? "rad" : "deg"));
      55           7 :     ImageInfo ii = _getImage()->imageInfo();
      56           7 :     if (ii.hasMultipleBeams()) {
      57           0 :         *this->_getLog() << LogIO::WARN << "The input image has "
      58             :             << "multiple beams. Because these beams can vary with "
      59             :             << "stokes/polarization, they will not be copied to the "
      60           0 :             << "output image" << LogIO::POST;
      61           0 :         ii.removeRestoringBeam();
      62             :     }
      63           7 :     ie.setImageInfo(ii);
      64           7 :     _fiddleStokesCoordinate(ie, Stokes::Pangle);
      65          14 :     return _prepareOutputImage(ie);
      66           7 : }
      67             : 
      68           0 : String LinearPolarizationAngleCalculator::getClass() const {
      69           0 :     return CLASS_NAME;
      70             : }
      71             : 
      72             : }

Generated by: LCOV version 1.16