LCOV - code coverage report
Current view: top level - synthesis/TransformMachines - StokesImageUtil.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 7 0.0 %
Date: 2024-11-06 17:42:47 Functions: 0 1 0.0 %

          Line data    Source code
       1             : //# StokesImageUtil.h: Definitions for casacore::Stokes Image utilities
       2             : //# Copyright (C) 1996,1997,1998,1999
       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             : #ifndef SYNTHESIS_STOKESIMAGEUTIL_H
      30             : #define SYNTHESIS_STOKESIMAGEUTIL_H
      31             : 
      32             : #include <array>
      33             : 
      34             : #include <casacore/casa/aips.h>
      35             : #include <casacore/casa/BasicSL/Complex.h>
      36             : #include <casacore/casa/BasicSL/String.h>
      37             : #include <casacore/images/Images/ImageInterface.h>
      38             : #include <casacore/casa/Quanta/Quantum.h>
      39             : #include <casacore/ms/MeasurementSets/MeasurementSet.h>
      40             : 
      41             : namespace casa { //# NAMESPACE CASA - BEGIN
      42             : 
      43             : // <summary> 
      44             : // </summary>
      45             : 
      46             : // <reviewed reviewer="" date="" tests="" demos="">
      47             : 
      48             : // <prerequisite>
      49             : // </prerequisite>
      50             : //
      51             : // <etymology>
      52             : // </etymology>
      53             : //
      54             : // <synopsis> 
      55             : // </synopsis> 
      56             : //
      57             : // <example>
      58             : // <srcblock>
      59             : // </srcblock>
      60             : // </example>
      61             : //
      62             : // <motivation>
      63             : // </motivation>
      64             : //
      65             : // <todo asof="">
      66             : // </todo>
      67             : 
      68             : 
      69             : class StokesImageUtil {
      70             :   
      71             : public:
      72             :  
      73             :   enum PolRep {
      74             :     CIRCULAR=0,
      75             :     LINEAR,
      76             :     UNKNOWN=-1
      77             :   };
      78             : 
      79           0 :   static const casacore::String & toString(PolRep polRep) {
      80           0 :       static const std::array<const casacore::String,3> polRepName {"CIRCULAR", "LINEAR", "UNKOWN"};
      81           0 :       switch(polRep) {
      82           0 :       case PolRep::CIRCULAR:
      83             :       case PolRep::LINEAR:
      84           0 :           return polRepName[polRep];
      85             :           break;
      86           0 :       default:
      87           0 :           return polRepName.back();
      88             :       }
      89             :   }
      90             :   // Make a Gaussian PSF
      91             :   //<group>
      92             :   static void MakeGaussianPSF(casacore::ImageInterface<casacore::Float>& psf, casacore::Vector<casacore::Float>& beam,
      93             :                               casacore::Bool norm=false);
      94             :   static void MakeGaussianPSF(casacore::ImageInterface<casacore::Float>& psf,
      95             :                               casacore::Quantity& bmaj, casacore::Quantity& bmin, casacore::Quantity& bpa,
      96             :                               casacore::Bool norm=false);
      97             :   //</group>
      98             :   
      99             :   // Fit a Gaussian PSF
     100             :   //<group>
     101             :       static casacore::Bool FitGaussianPSF(casacore::ImageInterface<casacore::Float>& psf, casacore::Vector<casacore::Float>& beam, casacore::Float psfcutoff = 0.35);
     102             :   static casacore::Bool FitGaussianPSF(casacore::ImageInterface<casacore::Float>& psf, casacore::GaussianBeam& beam, casacore::Float psfcutoff = 0.35);
     103             :   static casacore::Bool FitGaussianPSF(casacore::ImageInterface<casacore::Float>& psf, casacore::ImageBeamSet& beam, casacore::Float psfcutoff = 0.35);
     104             :   static void FindNpoints(casacore::Int& npoints , casacore::IPosition& blc,  casacore::IPosition& trc, casacore::Int nrow, casacore::Float amin,  casacore::Int px, casacore::Int py, casacore::Vector<casacore::Double>& deltas, casacore::Matrix<casacore::Double>& x , casacore::Vector<casacore::Double>& y, casacore::Vector<casacore::Double>& sigma, casacore::Matrix<casacore::Float>& lpsf);
     105             :     static  void ResamplePSF(casacore::Matrix<casacore::Float>& psf, casacore::Int& oversampling, casacore::Matrix<casacore::Float>& resampledPsf,casacore::String& InterpMethod);
     106             :   //</group>
     107             :   // Locat peak of PSF return pos, peak and first plane that satisfies
     108             :   // peak >0.9
     109             :   static void locatePeakPSF(casacore::ImageInterface<casacore::Float>& psf, casacore::Int& xpos, casacore::Int& ypos, 
     110             :                             casacore::Float& amp, casacore::Matrix<casacore::Float>& psfplane);
     111             :   ////make the psf of each plane have peak 1.0 (i.e peak in the inner 1/8 of each plane)
     112             :   /// you are on your own if the peak outside that zone :(
     113             :   /// It returns the maximum of the peak value found
     114             :   static casacore::Float normalizePSF(casacore::ImageInterface<casacore::Float>& psf);
     115             : 
     116             :   // Convolve a casacore::Stokes Image in place
     117             :   //<group>
     118             :   static void Convolve(casacore::ImageInterface<casacore::Float>& image,
     119             :                        casacore::ImageInterface<casacore::Float>& psf);
     120             :   static void Convolve(casacore::ImageInterface<casacore::Float>& image, casacore::Float bmaj,
     121             :                        casacore::Float bmin, casacore::Float bpa, casacore::Bool normalizeVolume=false);
     122             :   static void Convolve(casacore::ImageInterface<casacore::Float>& image,
     123             :                        casacore::GaussianBeam& beam,
     124             :                        casacore::Bool normalizeVolume=false);
     125             :   static void Convolve(casacore::ImageInterface<casacore::Float>& image,
     126             :                        casacore::ImageBeamSet& beams,
     127             :                        casacore::Bool normalizeVolume=false);
     128             :   //</group>
     129             :   
     130             :   
     131             :   // Zero selected planes of a casacore::Stokes image
     132             :   static void Zero(casacore::ImageInterface<casacore::Float>& image, casacore::Vector<casacore::Bool>& mask);
     133             : 
     134             :   // Mask mask iif(image > threshhold), where threshhold is in image's units.
     135             :   static void MaskFrom(casacore::ImageInterface<casacore::Float>& mask,
     136             :                        casacore::ImageInterface<casacore::Float>& image,
     137             :                        const casacore::Double threshhold);
     138             : 
     139             :   // This version uses threshold.get("Jy").getValue().
     140             :   static void MaskFrom(casacore::ImageInterface<casacore::Float>& mask,
     141             :                        casacore::ImageInterface<casacore::Float>& image,
     142             :                        const casacore::Quantity& threshold);
     143             :   
     144             : 
     145             :   // Zero pixels where casacore::Stokes I < some value
     146             :   static void MaskOnStokesI(casacore::ImageInterface<casacore::Float>& image, const casacore::Quantity& threshold);
     147             : 
     148             :   // Make a box mask
     149             :   static void BoxMask(casacore::ImageInterface<casacore::Float>& mask, const casacore::IPosition& blc,
     150             :                       const casacore::IPosition& trc, const casacore::Float value);
     151             : 
     152             :   // Constrain a casacore::Stokes Image
     153             :   static void Constrain(casacore::ImageInterface<casacore::Float>& image);
     154             :   
     155             :   // Convert from casacore::Stokes Image to "correlation" image.
     156             :   static void From(casacore::ImageInterface<casacore::Complex>& out,
     157             :                    const casacore::ImageInterface<casacore::Float>& in);
     158             :   
     159             :   // Convert to casacore::Stokes Image from "correlation" image.
     160             :   static void To(casacore::ImageInterface<casacore::Float>& out, casacore::ImageInterface<casacore::Complex>& in);
     161             : 
     162             :   // Direct copy from casacore::Float to casacore::Complex with 
     163             :   static void directCFromR(casacore::ImageInterface<casacore::Complex>& out,
     164             :                    const casacore::ImageInterface<casacore::Float>& in);
     165             :   
     166             :   // Direct copy To Float...
     167             :   static void directCToR(casacore::ImageInterface<casacore::Float>& out, casacore::ImageInterface<casacore::Complex>& in);
     168             : 
     169             :   
     170             :   // Convert to casacore::Stokes PSF
     171             :   static void ToStokesPSF(casacore::ImageInterface<casacore::Float>& out, casacore::ImageInterface<casacore::Complex>& in);
     172             : 
     173             :   static void ToStokesSumWt(casacore::Matrix<casacore::Float> sumwtStokes, casacore::Matrix<casacore::Float> sumwtCorr, const casacore::CoordinateSystem& outcoord, const casacore::CoordinateSystem& incoord);
     174             :   
     175             :   static void ToStokesSumWt(casacore::Matrix<casacore::Float> sumwtStokes, casacore::Matrix<casacore::Float> sumwtCorr);
     176             :   
     177             :   // Find the mapping from pixel on the casacore::Stokes Axis to I,Q,U,V
     178             :   static casacore::Int StokesPolMap(casacore::Vector<casacore::Int>& map, const casacore::CoordinateSystem& coord);
     179             :   
     180             :   // Find the mapping from pixel on the casacore::Stokes Axis to either XX,XY,YX,YY
     181             :   // of LL, LR, RL, RR. Return type as well: Linear:1, Circular 0
     182             :   static casacore::Int CStokesPolMap(casacore::Vector<casacore::Int>& map, StokesImageUtil::PolRep& polframe,
     183             :                            const casacore::CoordinateSystem& coord);
     184             :   
     185             :   // Find all mappings from coordinate to axis number
     186             :   static casacore::Bool StokesMap(casacore::Vector<casacore::Int>& map, const casacore::CoordinateSystem& coord);
     187             :   
     188             :   //Create a casacore::CoordinateSystem from a casacore::MeasurementSet and other info
     189             :   static casacore::CoordinateSystem StokesCoordFromMS(const casacore::IPosition& shape,
     190             :                                             casacore::Vector<casacore::Double>& deltas,
     191             :                                             casacore::MeasurementSet& ms);
     192             :   
     193             :   // Create a casacore::CoordinateSystem from a casacore::MeasurementSet and other info
     194             :   static casacore::CoordinateSystem StokesCoordFromMS(const casacore::IPosition& shape,
     195             :                                             casacore::Vector<casacore::Double>& deltas,
     196             :                                             casacore::MeasurementSet& ms,
     197             :                                             casacore::Vector<casacore::Int>& whichStokes,
     198             :                                             casacore::Bool doCStokes=false,
     199             :                                             casacore::Int fieldID=0, casacore::Int SPWID=0,
     200             :                                             casacore::Int feedID=0);
     201             :   
     202             :   // Create a casacore::CoordinateSystem 
     203             :   static casacore::CoordinateSystem CStokesCoord(//const casacore::IPosition& shape,
     204             :                                        const casacore::CoordinateSystem& coord, 
     205             :                                        casacore::Vector<casacore::Int>& whichStokes,
     206             :                                        StokesImageUtil::PolRep  polRep=StokesImageUtil::CIRCULAR);
     207             :   /*
     208             :   static CoordinateSystem
     209             :   CStokesCoordFromImage(const casacore::ImageInterface<casacore::Complex>& image,
     210             :                         casacore::Vector<casacore::Int>& whichStokes,
     211             :                         SkyModel::PolRep polRep);
     212             :   */
     213             :   // Change the stokes representation (but not the data!)
     214             :   static void changeCStokesRep(casacore::ImageInterface<casacore::Complex>& image,
     215             :                                StokesImageUtil::PolRep polRep);
     216             : 
     217             :   static void changeLabelsStokesToCorrStokes(casacore::StokesCoordinate &stokesCoord, 
     218             :                                                                      StokesImageUtil::PolRep polRep,
     219             :                                                                      casacore::Vector<casacore::Int>&whichStokes);
     220             : 
     221             :   // check to see if Image coordinates have the standard order:
     222             :   // Direction, casacore::Stokes, Spectral.  Returns false if this is not
     223             :   // the order, or if any are missing
     224             :   // <group>
     225             :   static casacore::Bool standardImageCoordinates(const casacore::CoordinateSystem& coords);
     226             :   static casacore::Bool standardImageCoordinates(const casacore::ImageInterface<casacore::Complex>& image);
     227             :   static casacore::Bool standardImageCoordinates(const casacore::ImageInterface<casacore::Float>& image);
     228             :   // </group>
     229             : 
     230             : };
     231             : 
     232             : } //# NAMESPACE CASA - END
     233             : 
     234             : #endif
     235             : 
     236             : 

Generated by: LCOV version 1.16