LCOV - code coverage report
Current view: top level - imageanalysis/ImageAnalysis - PVGenerator.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 9 0.0 %
Date: 2024-10-28 15:53:10 Functions: 0 3 0.0 %

          Line data    Source code
       1             : //# tSubImage.cc: Test program for class SubImage
       2             : //# Copyright (C) 1998,1999,2000,2001,2003
       3             : //# Associated Universities, Inc. Washington DC, USA.
       4             : //#
       5             : //# This program is free software; you can redistribute it and/or modify it
       6             : //# under the terms of the GNU General Public License as published by the Free
       7             : //# Software Foundation; either version 2 of the License, or (at your option)
       8             : //# any later version.
       9             : //#
      10             : //# This program 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 General Public License for
      13             : //# more details.
      14             : //#
      15             : //# You should have received a copy of the GNU General Public License along
      16             : //# with this program; if not, write to the Free Software Foundation, Inc.,
      17             : //# 675 Massachusetts Ave, Cambridge, MA 02139, USA.
      18             : //#
      19             : //# Correspondence concerning AIPS++ should be addressed 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             : //# $Id: tSubImage.cc 20567 2009-04-09 23:12:39Z gervandiepen $
      27             : 
      28             : #ifndef IMAGES_PVGENERATOR_H
      29             : #define IMAGES_PVGENERATOR_H
      30             : 
      31             : #include <imageanalysis/ImageAnalysis/ImageTask.h>
      32             : #include <casacore/casa/namespace.h>
      33             : 
      34             : 
      35             : namespace casacore{
      36             : 
      37             : class MDirection;
      38             : }
      39             : 
      40             : namespace casa {
      41             : 
      42             : class PVGenerator : public ImageTask<casacore::Float> {
      43             :     // <summary>
      44             :     // Top level interface for generating position-velocity images
      45             :     // </summary>
      46             : 
      47             :     // <reviewed reviewer="" date="" tests="" demos="">
      48             :     // </reviewed>
      49             : 
      50             :     // <prerequisite>
      51             :     // </prerequisite>
      52             : 
      53             :     // <etymology>
      54             :     // Collapses image.
      55             :     // </etymology>
      56             : 
      57             :     // <synopsis>
      58             :     // High level interface for generating position-velocity images.
      59             :     // </synopsis>
      60             : 
      61             :     // <example>
      62             :     // <srcblock>
      63             :     // ImageCollapser collapser();
      64             :     // collapser.collapse();
      65             :     // </srcblock>
      66             :     // </example>
      67             : 
      68             : public:
      69             : 
      70             :     PVGenerator() = delete;
      71             : 
      72             :     // The region selection in the constructor only applies to the non-direction coordinates.
      73             :     // The direction coordinate limits are effectively set by calling setEndPoints()
      74             :     // after construction. The region selection in the constructor is only for things like
      75             :     // spectral selection and polarization selection. In addition at most one of <src>regionRec</src>
      76             :     // and <src>chanInp/stokes</src> should be supplied. If specifying <src>regionRec</src> that should
      77             :     // be a non-null pointer and chanInp and stokes should both be empty strings. If specifying either or
      78             :     // both of chanInp and/or stokes, the one(s) being specified should be non-empty strings corresponding
      79             :     // to correct syntax for that particular parameter, and regionRec should be null.
      80             :     // If you specify <src>regionRec</src>=0
      81             :     // and <src>stokes</src>="", and <src>chanInp</src>="", that implies you want to use all
      82             :     // spectral channels and all polarization planes in the input image.
      83             :     PVGenerator(
      84             :         const SPCIIF image,
      85             :         const casacore::Record *const &regionRec, const casacore::String& chanInp,
      86             :         const casacore::String& stokes, const casacore::String& maskInp,
      87             :         const casacore::String& outname, const casacore::Bool overwrite
      88             :     );
      89             : 
      90             :     PVGenerator(const PVGenerator&) = delete;
      91             : 
      92             :     // destructor
      93             :     ~PVGenerator();
      94             : 
      95             :     // perform the collapse. Returns a pointer to the
      96             :     // collapsed image.
      97             :     SPIIF generate() const;
      98             : 
      99             :     // set the end points of the slice in direction space. casacore::Input values represent pixel
     100             :     // coordinates in the input image.
     101             :     void setEndpoints(
     102             :         const std::pair<casacore::Double, casacore::Double>& start,
     103             :         const std::pair<casacore::Double, casacore::Double>& end
     104             :     );
     105             : 
     106             :     // set end points given center in pixels, length of segment in pixels, and position angle
     107             :     // taken in the normal astronomical sense, measured from north through east.
     108             :     void setEndpoints(
     109             :         const std::pair<casacore::Double, casacore::Double>& center, casacore::Double length,
     110             :         const casacore::Quantity& pa
     111             :     );
     112             : 
     113             :     void setEndpoints(
     114             :         const std::pair<casacore::Double, casacore::Double>& center, const casacore::Quantity& length,
     115             :         const casacore::Quantity& pa
     116             :     );
     117             : 
     118             :     void setEndpoints(
     119             :         const casacore::MDirection& center, const casacore::Quantity& length,
     120             :         const casacore::Quantity& pa
     121             :     );
     122             : 
     123             :     // <src>length in pixels</src>
     124             :     void setEndpoints(
     125             :         const casacore::MDirection& center, casacore::Double length,
     126             :         const casacore::Quantity& pa
     127             :     );
     128             : 
     129             :     void setEndpoints(
     130             :         const casacore::MDirection& start, const casacore::MDirection& end
     131             :     );
     132             : 
     133             :     // Set the number of pixels perpendicular to the slice for which averaging
     134             :     // should occur. Must be odd and >= 1. 1 => just use the pixels coincident with the slice
     135             :     // (no averaging). 3 => Average three pixels, one pixel on either side of the slice and the
     136             :     // pixel lying on the slice.
     137             :     // Note this average is done after the image has been rotated.
     138             :     void setWidth(casacore::uInt width);
     139             :     // This will set the width by rounding <src>q</src> up so that the width is an odd number of pixels.
     140             :     void setWidth(const casacore::Quantity& q);
     141             : 
     142             :     casacore::String getClass() const;
     143             : 
     144             :     // set the unit to be used for the offset axis in the resulting image (from calling
     145             :     // generate()). Must conform to angular units
     146             :     void setOffsetUnit(const casacore::String& s);
     147             : 
     148             : 
     149             : protected:
     150           0 :     inline  CasacRegionManager::StokesControl _getStokesControl() const {
     151           0 :         return CasacRegionManager::USE_ALL_STOKES;
     152             :     }
     153             : 
     154           0 :     inline std::vector<casacore::Coordinate::Type> _getNecessaryCoordinates() const {
     155           0 :         std::vector<casacore::Coordinate::Type> v;
     156           0 :         v.push_back(casacore::Coordinate::SPECTRAL);
     157           0 :         v.push_back(casacore::Coordinate::DIRECTION);
     158           0 :         return v;
     159           0 :      }
     160             : 
     161           0 :     virtual casacore::Bool _mustHaveSquareDirectionPixels() const {return true;}
     162             : 
     163             : private:
     164             :     std::unique_ptr<std::vector<casacore::Double> > _start, _end;
     165             :     casacore::uInt _width;
     166             :     casacore::String _unit;
     167             :     static const casacore::String _class;
     168             : 
     169             :     void _checkRotatedImageSanity(
     170             :         SPCIIF rotated, const Vector<Double>& rotPixStart,
     171             :         const Vector<Double>& rotPixEnd, Int xAxis, Int yAxis,
     172             :         Double xdiff, Double ydiff
     173             :     ) const;
     174             : 
     175             :     SPIIF _doCollapse(
     176             :         Int& collapsedAxis, SPCIIF rotated, Int xAxis, Int yAxis, const Vector<Double>& rotPixStart,
     177             :         const Vector<Double>& rotPixEnd, Double halfwidth
     178             :     ) const;
     179             : 
     180             :     SPCIIF _doRotate(
     181             :         SPIIF subImage, const std::vector<Double>& start, const std::vector<Double>& end,
     182             :         Int xAxis, Int yAxis, Double halfwidth, Double paInRad
     183             :     ) const;
     184             : 
     185             :     SPIIF _dropDegen(SPIIF collapsed, Int collapsedAxis) const;
     186             : 
     187             :     void _checkWidth(const casacore::Int64 xShape, const casacore::Int64 yShape) const;
     188             : 
     189             :     void _checkWidthSanity(
     190             :         Double paInRad, Double halfwidth, const std::vector<Double>& start,
     191             :         const std::vector<Double>& end, SPCIIF subImage, Int xAxis, Int yAxis
     192             :     ) const;
     193             : 
     194             :     casacore::Quantity _increment() const;
     195             : 
     196             :     void _moveRefPixel(
     197             :         SPIIF subImage, CoordinateSystem& subCoords, const std::vector<Double>& start,
     198             :         const std::vector<Double>& end, Double paInDeg, Int xAxis, Int yAxis
     199             :     ) const;
     200             :     
     201             :     static casacore::String _pairToString(const std::pair<casacore::Double, casacore::Double>& p);
     202             : 
     203             : };
     204             : }
     205             : 
     206             : #endif

Generated by: LCOV version 1.16