LCOV - code coverage report
Current view: top level - flagging/Flagging - DDMapper.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 8 0.0 %
Date: 2024-10-12 00:35:29 Functions: 0 14 0.0 %

          Line data    Source code
       1             : //# DDMapper.h: this defines DDMapper
       2             : //# Copyright (C) 2000,2001
       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 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$
      27             : #ifndef FLAGGING_DDMAPPER_H
      28             : #define FLAGGING_DDMAPPER_H
      29             : 
      30             : #include <casacore/casa/Arrays/Vector.h> 
      31             : #include <casacore/casa/Arrays/Cube.h> 
      32             : #include <casacore/casa/Exceptions/Error.h>
      33             : #include <casacore/measures/Measures/Stokes.h> 
      34             : #include <casacore/casa/BasicSL/Complex.h>
      35             :     
      36             : namespace casa { //# NAMESPACE CASA - BEGIN
      37             : 
      38             : // <summary>
      39             : // Abstract Derived casacore::Data Mapper class
      40             : // </summary>
      41             : 
      42             : // <use visibility=local>
      43             : 
      44             : // <reviewed reviewer="" date="" tests="" demos="">
      45             : // </reviewed>
      46             : 
      47             : // <synopsis>
      48             : // The DDMapper class defines an interface for mapping complex visibilities
      49             : // into casacore::Float derived values. DDMappers are used by several flagging
      50             : // agents.
      51             : // </synopsis>
      52             : //
      53             : // <motivation>
      54             : // A lot of algorithms are expressed in terms of some real value
      55             : // derived from a set of visibilities (i.e., |XX|, |XX|-|YY|, etc.). The
      56             : // DDMapper hierarchy provides a uniform interface for deriving such values.
      57             : // </motivation>
      58             : //
      59             : // <todo asof="2001/04/16">
      60             : //   <li> add this feature
      61             : // </todo>
      62             : 
      63             : class DDMapper
      64             : {
      65             : protected:
      66             :   casacore::Bool valid;
      67             :   casacore::uShort corrmask; // mask of affected correlations
      68             :   
      69             : public:
      70           0 :   DDMapper ()         { valid=false; }
      71           0 :   virtual ~DDMapper () {};
      72             :   
      73             :   // Given a vector of correlation types, recomputes internal indices.
      74             :   // returns true if all indices were found successfully.
      75             :   virtual casacore::Bool reset ( const casacore::Vector<casacore::Int> &corr ) =0;
      76             :   
      77             :   // Maps a slice of visibilities at (*,ich,irow) from the given 
      78             :   // viscube into a the derived value. 
      79             :   virtual casacore::Float map  ( const casacore::Cube<casacore::Complex> &vis,casacore::uInt ich,casacore::uInt irow ) const =0;
      80             :   
      81             :   // Returns the "mask" of correlations which are used by this mapper.
      82             :   // by this mapper. Bit "i" is set if corr. "i" is used.
      83           0 :   casacore::uShort  corrMask () const         { return corrmask; }
      84             : 
      85             :   // Returns true if given correlations is masked
      86             :   casacore::Bool    masked (casacore::uInt icorr) const  { return (corrmask&(1<<icorr)) != 0; }
      87             :   
      88             :   // Tells if mapper is valid
      89             :   casacore::Bool    isValid () { return valid; }
      90             : };
      91             : 
      92             : // <summary>
      93             : // DDDummy: dummy mapper, throws an excpetion if any methods are called
      94             : // </summary>
      95             : // <use visibility=local>
      96             : class DDDummy : public DDMapper
      97             : {
      98             : public:
      99             :   DDDummy ();
     100             :   ~DDDummy ();
     101             :   
     102             :   virtual void puke () const
     103             :               { throw(casacore::AipsError("Uninitialized DDMapper used")); }
     104             :   
     105             :   virtual casacore::Bool  reset ( const casacore::Vector<casacore::Int> & )
     106             :               { puke(); return false; }
     107             :   virtual casacore::Float map   ( const casacore::Cube<casacore::Complex> &,casacore::uInt,casacore::uInt ) const
     108             :               { puke(); return 0.; }
     109             : 
     110             : };
     111             : 
     112             : // <summary>
     113             : // DDFunc: maps correlation A into func(A)
     114             : // </summary>
     115             : // <use visibility=local>
     116             : class DDFunc : public DDMapper
     117             : {
     118             : public:
     119             :   typedef casacore::Float (*FuncSignature)(const casacore::Complex &);
     120             :   
     121             :   DDFunc ( FuncSignature fsig,const casacore::String &corr );
     122           0 :   ~DDFunc() {};
     123             :   
     124             :   virtual casacore::Bool  reset ( const casacore::Vector<casacore::Int> &corr );
     125             :   virtual casacore::Float map   ( const casacore::Cube<casacore::Complex> &vis,casacore::uInt ich,casacore::uInt irow ) const;
     126             : 
     127             : // Define these functions, because using std::real/imag in getFunction
     128             : // matches multiple functions.
     129             :   static casacore::Float real (const casacore::Complex&);
     130             :   static casacore::Float imag (const casacore::Complex&);
     131             : 
     132             : // Static function to map a function name into a function pointer
     133             : // Functions currently recognized: ABS ARG NORM RE IM 
     134             :   static FuncSignature getFunction( const casacore::String &name );
     135             : 
     136             : // Static function to map string expression into a DDMapper
     137             : // Possible syntax is:
     138             : //   <FUNC> <CC>
     139             : //   SUM <FUNC> <CC> <CC>
     140             : //   DIFF <FUNC> <CC> <CC>
     141             : //   <FUNC> SUM <CC> <CC>
     142             : //   <FUNC> DIFF <CC> <CC>
     143             :   static DDMapper * getMapper ( casacore::String &desc,const casacore::Vector<casacore::String> &expr,casacore::Bool throw_excp=false );
     144             :   
     145             : protected:
     146             :   casacore::Int icorr;
     147             :   casacore::Stokes::StokesTypes corrtype;
     148             :   FuncSignature func;
     149             : };
     150             : 
     151             : // <summary>
     152             : // DDSumFunc: maps two correlations A and B into func(A)+func(B)
     153             : // </summary>
     154             : // <use visibility=local>
     155             : class DDSumFunc : public DDFunc
     156             : {
     157             : public:
     158             :   DDSumFunc ( FuncSignature fsig,const casacore::String &corr1,const casacore::String &corr2 );
     159           0 :   virtual ~DDSumFunc() {};
     160             :   
     161             :   virtual casacore::Bool  reset ( const casacore::Vector<casacore::Int> &corr );
     162             :   virtual casacore::Float map   ( const casacore::Cube<casacore::Complex> &vis,casacore::uInt ich,casacore::uInt irow ) const;
     163             : 
     164             : protected:
     165             :   casacore::Int icorr2;
     166             :   casacore::Stokes::StokesTypes corrtype2;
     167             : };
     168             : 
     169             : // <summary>
     170             : // DDFuncSum: maps two correlations A and B into func(A+B)
     171             : // </summary>
     172             : // <use visibility=local>
     173             : class DDFuncSum : public DDSumFunc
     174             : {
     175             : public:
     176             :   DDFuncSum ( FuncSignature fsig,const casacore::String &corr1,const casacore::String &corr2 );
     177           0 :   virtual ~DDFuncSum() {};
     178             :   
     179             :   virtual casacore::Float map   ( const casacore::Cube<casacore::Complex> &vis,casacore::uInt ich,casacore::uInt irow ) const;
     180             : };
     181             : 
     182             : // <summary>
     183             : // DDFuncDiff: maps two correlations A and B into func(A-B)
     184             : // </summary>
     185             : // <use visibility=local>
     186             : class DDFuncDiff : public DDSumFunc
     187             : {
     188             : public:
     189             :   DDFuncDiff ( FuncSignature fsig,const casacore::String &corr1,const casacore::String &corr2 );
     190           0 :   virtual ~DDFuncDiff() {};
     191             :   
     192             :   virtual casacore::Float map   ( const casacore::Cube<casacore::Complex> &vis,casacore::uInt ich,casacore::uInt irow ) const;
     193             : };
     194             : 
     195             : // <summary>
     196             : // DDDiffFunc: maps two correlations A and B into func(A)-func(B)
     197             : // </summary>
     198             : // <use visibility=local>
     199             : class DDDiffFunc : public DDSumFunc
     200             : {
     201             : public:
     202             :   DDDiffFunc ( FuncSignature fsig,const casacore::String &corr1,const casacore::String &corr2 );
     203           0 :   virtual ~DDDiffFunc() {};
     204             :   
     205             :   virtual casacore::Float map   ( const casacore::Cube<casacore::Complex> &vis,casacore::uInt ich,casacore::uInt irow ) const;
     206             : };
     207             : 
     208             : // helper function to split an expression into elements
     209             : casacore::Vector<casacore::String> splitExpression( const casacore::Vector<casacore::String> &expr0 );
     210             : 
     211             : 
     212             : } //# NAMESPACE CASA - END
     213             : 
     214             : #endif

Generated by: LCOV version 1.16