LCOV - code coverage report
Current view: top level - calanalysis/CalAnalysis - CalStatsDerived.h (source / functions) Hit Total Coverage
Test: casa_coverage.info Lines: 0 9 0.0 %
Date: 2023-10-25 08:47:59 Functions: 0 1 0.0 %

          Line data    Source code
       1             : 
       2             : // -----------------------------------------------------------------------------
       3             : 
       4             : /*
       5             : 
       6             : CalStatsDerived.h
       7             : 
       8             : Description:
       9             : ------------
      10             : This header file contains definitions for the classes derived from CalStats.
      11             : 
      12             : Classes:
      13             : --------
      14             : CalStatsReal  - This class feeds real data to the CalStats base class.
      15             : CalStatsAmp   - This class converts complex data to amplitudes and initializes
      16             :                 the CalStats base class.
      17             : CalStatsPhase - This class converts complex data to phases and initializes the
      18             :                 CalStats base class.
      19             : 
      20             : Inhertited classes:
      21             : -------------------
      22             : CalStats - This class calculates statistics on CASA caltables.
      23             : 
      24             : Modification history:
      25             : ---------------------
      26             : 2011 Nov 15 - Nick Elias, NRAO
      27             :               Initial version.
      28             : 2012 Jan 25 - Nick Elias, NRAO
      29             :               Logging capability added.  Error checking added.
      30             : 
      31             : */
      32             : 
      33             : // -----------------------------------------------------------------------------
      34             : // Start of define macro to prevent multiple loading
      35             : // -----------------------------------------------------------------------------
      36             : 
      37             : #ifndef CAL_STATS_DERIVED_H
      38             : #define CAL_STATS_DERIVED_H
      39             : 
      40             : // -----------------------------------------------------------------------------
      41             : // Includes
      42             : // -----------------------------------------------------------------------------
      43             : 
      44             : #define _USE_MATH_DEFINES
      45             : #include <cmath>
      46             : 
      47             : #include <casacore/casa/Arrays/ArrayMath.h>
      48             : #include <casacore/casa/Arrays/MaskedArray.h>
      49             : 
      50             : #include <calanalysis/CalAnalysis/CalStats.h>
      51             : 
      52             : // -----------------------------------------------------------------------------
      53             : // Start of casa namespace definitions
      54             : // -----------------------------------------------------------------------------
      55             : 
      56             : namespace casa {
      57             : 
      58             : // -----------------------------------------------------------------------------
      59             : // Start of CalStatsReal class definition
      60             : // -----------------------------------------------------------------------------
      61             : 
      62             : /*
      63             : 
      64             : CalStatsReal
      65             : 
      66             : Description:
      67             : ------------
      68             : This class feeds real data to the CalStats base class.
      69             : 
      70             : Class public member functions:
      71             : ------------------------------
      72             : CalStatsReal  - This class feeds real data to the CalStats base class.  It is
      73             :                 primarily used for initial testing.
      74             : ~CalStatsReal - This destructor deallocates the internal memory of an instance.
      75             : 
      76             : Modification history:
      77             : ---------------------
      78             : 2011 Dec 11 - Nick Elias, NRAO
      79             :               Initial version.  The public member functions are CalStatsReal()
      80             :               (generic) and ~CalStatsReal().
      81             : 
      82             : */
      83             : 
      84             : // -----------------------------------------------------------------------------
      85             : 
      86             : class CalStatsReal : public CalStats {
      87             : 
      88             :   public:
      89             : 
      90             :     // Generic constructor
      91             :     CalStatsReal( const casacore::Cube<casacore::Double>& oValue, const casacore::Cube<casacore::Double>& oValueErr,
      92             :         const casacore::Cube<casacore::Bool>& oFlag, const casacore::Vector<casacore::String>& oFeed,
      93             :         const casacore::Vector<casacore::Double>& oFrequency, const casacore::Vector<casacore::Double>& oTime,
      94             :         const CalStats::AXIS& eAxisIterUserID );
      95             : 
      96             :     // Destructor
      97             :     ~CalStatsReal( void );
      98             : 
      99             : };
     100             : 
     101             : // -----------------------------------------------------------------------------
     102             : // End of CalStatsReal class definition
     103             : // -----------------------------------------------------------------------------
     104             : 
     105             : // -----------------------------------------------------------------------------
     106             : // Start of CalStatsAmp class definition
     107             : // -----------------------------------------------------------------------------
     108             : 
     109             : /*
     110             : 
     111             : CalStatsAmp
     112             : 
     113             : Description:
     114             : ------------
     115             : This class converts complex data to amplitudes and initializes the CalStats base
     116             : class.
     117             : 
     118             : Class public member functions:
     119             : ------------------------------
     120             : CalStatsAmp  - This generic constructor converts complex data to amplitudes and
     121             :                initializes the CalStats base class.  It is primarily used for
     122             :                initial testing.
     123             : ~CalStatsAmp - This destructor deallocates the internal memory of an instance.
     124             : 
     125             : Class public static member functions:
     126             : -------------------------------------
     127             : norm - This member function normalizes the amplitudes and their errors.
     128             : 
     129             : Modification history:
     130             : ---------------------
     131             : 2011 Nov 15 - Nick Elias, NRAO
     132             :               Initial version.  The public member functions are CalStatsAmp()
     133             :               (generic) and ~CalStatsAmp().  The static member function is
     134             :               norm().
     135             : 
     136             : */
     137             : 
     138             : // -----------------------------------------------------------------------------
     139             : 
     140             : class CalStatsAmp : public CalStats {
     141             : 
     142             :   public:
     143             : 
     144             :     // Generic constructor
     145             :     CalStatsAmp( const casacore::Cube<casacore::DComplex>& oValue, const casacore::Cube<casacore::Double>& oValueErr,
     146             :         const casacore::Cube<casacore::Bool>& oFlag, const casacore::Vector<casacore::String>& oFeed,
     147             :         const casacore::Vector<casacore::Double>& oFrequency, const casacore::Vector<casacore::Double>& oTime,
     148             :         const CalStats::AXIS& eAxisIterUserID, const casacore::Bool& bNorm );
     149             : 
     150             :     // Destructor
     151             :     ~CalStatsAmp( void );
     152             : 
     153             :     // Normalize member function
     154             :     static void norm( casacore::Vector<casacore::Double>& oAmp, casacore::Vector<casacore::Double>& oAmpErr,
     155             :         casacore::Vector<casacore::Bool>& oFlag );
     156             : 
     157             : };
     158             : 
     159             : // -----------------------------------------------------------------------------
     160             : // End of CalStatsAmp class definition
     161             : // -----------------------------------------------------------------------------
     162             : 
     163             : // -----------------------------------------------------------------------------
     164             : // Start of CalStatsPhase class definition
     165             : // -----------------------------------------------------------------------------
     166             : 
     167             : /*
     168             : 
     169             : CalStatsPhase
     170             : 
     171             : Description:
     172             : ------------
     173             : This class converts complex data to phases and initializes the CalStats base
     174             : class.
     175             : 
     176             : Inhertited classes:
     177             : -------------------
     178             : CalStats - This class calculates statistics of new CASA caltables.
     179             : 
     180             : Class public member functions:
     181             : ------------------------------
     182             : CalStatsPhase  - This generic constructor converts complex data to amplitudes
     183             :                  and initializes the CalStats base class.
     184             : ~CalStatsPhase - This destructor deallocates the internal memory of an instance.
     185             : 
     186             : CalStatsPhase public static member functions:
     187             : ---------------------------------------------
     188             : unwrapGD     - This member function unwraps the phases along the frequency axis
     189             :                with respect to the group delay.
     190             : unwrapSimple - This member function performs a simple unwrapping procedure for
     191             :                both frequency and temporal abscissae.
     192             : 
     193             : CalStatsPhase private static member functions:
     194             : ----------------------------------------------
     195             : fringePacket2 - This member function forms the squared-amplitude fringe packet.
     196             : 
     197             : CalStatsPhase templated private static member functions:
     198             : --------------------------------------------------------
     199             : maxLocation - This member function finds the abscissa corresponding to the peak
     200             :               value of an ordinate vector.
     201             : 
     202             : Modification history:
     203             : ---------------------
     204             : 2011 Nov 15 - Nick Elias, NRAO
     205             :               Initial version created with public member functions are
     206             :               CalStatsPhase() and ~CalStatsPhase(); and public static member
     207             :               function is unwrap().
     208             : 2012 Mar 27 - Nick Elias, NRAO
     209             :               Private static member functions fringePacket2() and maxLocation()
     210             :               added. Private static member variables NUM_ITER_UNWRAP and
     211             :               NEW_RANGE_FACTOR added.
     212             : 2012 Mar 30 - Nick Elias, NRAO
     213             :               Public static member function unwrap() renamed to unwrapGD().
     214             :               Public static member function unwrapSimple() added.
     215             : 
     216             : */
     217             : 
     218             : // -----------------------------------------------------------------------------
     219             : 
     220             : class CalStatsPhase : public CalStats {
     221             : 
     222             :   public:
     223             : 
     224             :     // Generic constructor
     225             :     CalStatsPhase( const casacore::Cube<casacore::DComplex>& oValue, const casacore::Cube<casacore::Double>& oValueErr,
     226             :         const casacore::Cube<casacore::Bool>& oFlag, const casacore::Vector<casacore::String>& oFeed,
     227             :         const casacore::Vector<casacore::Double>& oFrequency, const casacore::Vector<casacore::Double>& oTime,
     228             :         const CalStats::AXIS& eAxisIterUserID, const casacore::Bool& bUnwrap,
     229             :         const casacore::Double& dJumpMax );
     230             : 
     231             :     // Destructor
     232             :     ~CalStatsPhase( void );
     233             : 
     234             :     // Group-delay unwrapping member function
     235             :     static void unwrapGD( casacore::Vector<casacore::Double>& oPhase,
     236             :         const casacore::Vector<casacore::Double>& oFrequency, const casacore::Vector<casacore::Bool>& oFlag );
     237             : 
     238             :     // Simple phase unwrapping member function
     239             :     static void unwrapSimple( casacore::Vector<casacore::Double>& oPhase, const casacore::Double& dJumpMax,
     240             :         const casacore::Vector<casacore::Bool>& oFlag );
     241             : 
     242             :   private:
     243             : 
     244             :     // Form the squared-amplitude fringe packet
     245             :     static casacore::Vector<casacore::Double>& fringePacket2( const casacore::Vector<casacore::Double>& oPhase,
     246             :         const casacore::Vector<casacore::Double>& oFrequency, const casacore::Vector<casacore::Double>& oTime );
     247             : 
     248             :     // Find the abscissa corresponding to the peak value of an ordinate vector
     249             :     template <typename T> static casacore::Double& maxLocation( const casacore::Vector<T>& oAbs,
     250             :         const casacore::Vector<T>& oValue );
     251             : 
     252             :     // The maximum number of iterations for unwrapping
     253             :     static const casacore::uInt NUM_ITER_UNWRAP;
     254             : 
     255             :     // The new time range per unwrapping iteration is this factor times the
     256             :     // present time increment
     257             :     static const casacore::Double NEW_RANGE_FACTOR;
     258             : 
     259             : };
     260             : 
     261             : // -----------------------------------------------------------------------------
     262             : // End of CalStatsPhase class definition
     263             : // -----------------------------------------------------------------------------
     264             : 
     265             : // -----------------------------------------------------------------------------
     266             : // Start of CalStatsDerived::maxLocation<T> template private statistics member
     267             : // function
     268             : // -----------------------------------------------------------------------------
     269             : 
     270             : /*
     271             : 
     272             : CalStatsPhase::maxLocation<T>
     273             : 
     274             : Description:
     275             : ------------
     276             : This member function finds the abscissa corresponding to the peak value of an
     277             : ordinate vector.
     278             : 
     279             : Inputs:
     280             : -------
     281             : oAbs   - This casacore::Vector<T>() instance contains the abscissae.
     282             : oValue - This casacore::Vector<T>() instance contains the ordinates.
     283             : 
     284             : Outputs:
     285             : --------
     286             : The reference to the casacore::Double variable containing the abscissa corresponding to
     287             : the peak value of the ordinate vector, returned via the function value.
     288             : 
     289             : Modification history:
     290             : ---------------------
     291             : 2012 Mar 27 - Nick Elias, NRAO
     292             :               Initial version.
     293             : 
     294             : */
     295             : 
     296             : // -----------------------------------------------------------------------------
     297             : 
     298             : template <typename T>
     299           0 : casacore::Double& CalStatsPhase::maxLocation( const casacore::Vector<T>& oAbs,
     300             :     const casacore::Vector<T>& oValue ) {
     301             : 
     302             :   // Call the minMax() function and return the position of the maximum value
     303             : 
     304           0 :   casacore::Double dValMin = 0.0;
     305           0 :   casacore::Double dValMax = 0.0;
     306             : 
     307           0 :   casacore::IPosition oPosMin( 1, 0 );
     308           0 :   casacore::IPosition oPosMax( 1, 0 );
     309             : 
     310           0 :   minMax( dValMin, dValMax, oPosMin, oPosMax, oValue );
     311             : 
     312           0 :   casacore::Double* pdAbsMax = new casacore::Double;
     313           0 :   *pdAbsMax = oAbs(oPosMax);
     314             : 
     315           0 :   return( *pdAbsMax );
     316             : 
     317             : }
     318             : 
     319             : // -----------------------------------------------------------------------------
     320             : // End of CalStatsDerived::maxLocation<T> template private statistics member
     321             : // function
     322             : // -----------------------------------------------------------------------------
     323             : 
     324             : };
     325             : 
     326             : // -----------------------------------------------------------------------------
     327             : // End of casa namespace
     328             : // -----------------------------------------------------------------------------
     329             : 
     330             : #endif
     331             : 
     332             : // -----------------------------------------------------------------------------
     333             : // End of define macro to prevent multiple loading
     334             : // -----------------------------------------------------------------------------

Generated by: LCOV version 1.16