LCOV - code coverage report
Current view: top level - calanalysis/CalAnalysis - CalStats.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 54 154 35.1 %
Date: 2024-11-06 17:42:47 Functions: 5 20 25.0 %

          Line data    Source code
       1             : 
       2             : // -----------------------------------------------------------------------------
       3             : 
       4             : /*
       5             : 
       6             : CalStats.cc
       7             : 
       8             : Description:
       9             : ------------
      10             : This file contains member functions for the CalStats class.
      11             : 
      12             : Classes:
      13             : --------
      14             : CalStats - This class calculates statistics of new CASA caltables.
      15             : 
      16             : Modification history:
      17             : ---------------------
      18             : 2011 Nov 11 - Nick Elias, NRAO
      19             :               Initial version.
      20             : 2012 Jan 25 - Nick Elias, NRAO
      21             :               Logging capability added.  Error checking added.
      22             : 
      23             : */
      24             : 
      25             : // -----------------------------------------------------------------------------
      26             : // Includes
      27             : // -----------------------------------------------------------------------------
      28             : 
      29             : #include <calanalysis/CalAnalysis/CalStats.h>
      30             : 
      31             : // -----------------------------------------------------------------------------
      32             : // Start of casa namespace
      33             : // -----------------------------------------------------------------------------
      34             : 
      35             : using namespace casacore;
      36             : namespace casa {
      37             : 
      38             : // -----------------------------------------------------------------------------
      39             : // Start of CalStats class
      40             : // -----------------------------------------------------------------------------
      41             : 
      42             : /*
      43             : 
      44             : CalStats
      45             : 
      46             : Description:
      47             : ------------
      48             : This class calculates statistics of new CASA caltables.
      49             : 
      50             : NB: At present this class gets data and calculates fit statistics, but other
      51             : things such as histogram statistics will be added later.
      52             : 
      53             : In a nutshell:
      54             : --------------
      55             : * This class can get data (no statistics calculated) and calculate fit
      56             :   statistics from these data.
      57             : * Hooks are present in the code for calculating histogram statistics in the
      58             :   future.
      59             : * This class employs internal iterators to move uniformly through the data
      60             :   cubes.  This process is invisible to the user.
      61             : * The input data are cubes whose axes are feed, frequency, and time.  The other
      62             :   axes, such as antenna 1, antenna 2, etc. are handled in another class.  There
      63             :   are two iteration axes and one non-iteration axis, which means that this class
      64             :   returns ONE-dimensional quantities (data, fits, or histograms) for each
      65             :   iteration.  This class does not deal with multi-dimensional fits and
      66             :   histograms.
      67             : * The feed axis is always an iteration axis (fits cannot be calculated along
      68             :   it).  The user-defined iteration axis is either frequency or time, which means
      69             :   that the other axis is either time or frequency.
      70             : * The input data are obtained from the NewCalTable and NewCalTabIter classes
      71             :   that iterate along antenna1, antenna2, spw, etc.
      72             : * Once an instance is created, the stats<T> member function is the main user
      73             :   interface to calculate statistics.  The choice of T determines which function
      74             :   is used (getting data, fit statistics, histogram statistics).
      75             : * To minimize the amount of duplicated code, some of the member functions are
      76             :   templated and some of the templated member functions are specialized.  The
      77             :   class is not templated.
      78             : 
      79             : Nested classes:
      80             : ---------------
      81             : AXES   - This nested class contains the axes for the CalStats class.
      82             : DATA   - This nested class contains the data for the CalStats class.
      83             : ARG<T> - This nested template class contains the arguments for the
      84             :          CalStats::stats<T>() template member function.
      85             : OUT<T> - This nested template class contains the outputs for the
      86             :          CalStats::stats<T>() template member function.
      87             : 
      88             : Class public member functions:
      89             : ------------------------------
      90             : CalStats  - This constructor saves input abscissae and data cubes to internal
      91             :             copies so that statistics can be calculated.
      92             : CalStats  - This copy constructor is unused by this class and unavailable when
      93             :             an instance is created.
      94             : operator= - This operator= function is unused by this class and unavailable when
      95             :             an instance is created.
      96             : ~CalStats - This destructor deallocates the internal memory of an instance.
      97             : 
      98             : Class public state member functions:
      99             : ------------------------------------
     100             : axisIterID    - This member function returns the iteration axis IDs.
     101             : axisNonIterID - This member function returns the non-iteration axis ID.
     102             : axisIterFeed  - This member function returns the feed iteration axis values.
     103             : axisIterUser  - This member function returns the user-defined iteration axis
     104             :                 values.
     105             : axisNonIter   - This member function returns the non-iteration axis values.
     106             : statsShape    - This member function returns the shape of the output statistics
     107             :                 cube.
     108             : value         - This member function returns the input value.
     109             : valueErr      - This member function returns the input value errors.
     110             : flag          - This member function returns the input flags.
     111             : 
     112             : Class static public member functions:
     113             : -------------------------------------
     114             : axisName - This function returns the string corresponding to the CalStats::AXIS
     115             :            enum.
     116             : 
     117             : Class template public stats member functions:
     118             : ---------------------------------------------
     119             : stats<T> - This member function is the main user interface for calculating the
     120             :            the statistics for all iterations.  Allowed T: CalStats::NONE only
     121             :            returns the input data, CalStatsFitter::FIT calculates fit
     122             :            statistics, and CalStatsHist::HIST calculates histogram statistics.
     123             : 
     124             : Class specialized template public stats member functions:
     125             : ---------------------------------------------------------
     126             : statsWrap<T> - This member function wraps statistics functions and provides a
     127             :                uniform interface to stats<T>().  Allowed T: CalStats::NONE only
     128             :                returns the input data, CalStatsFitter::FIT calculates fit
     129             :                statistics, and CalStatsHist::HIST calculates histogram
     130             :                statistics.
     131             : 
     132             : Class protected member functions:
     133             : ---------------------------------
     134             : CalStats - This default constructor is unused by this class and unavailable when
     135             :            an instance is created.
     136             : next     - This member function simultaneously iterates all of the internal
     137             :            copies of the input data cubes.
     138             : reset    - This member function simultaneously resets the iterators of all of
     139             :            the internal copies of the input data cubes.
     140             : 
     141             : Modification history:
     142             : ---------------------
     143             : 2011 Nov 11 - Nick Elias, NRAO
     144             :               Initial version created with public member functions CalStats()
     145             :               (generic) and ~CalStats(); protected member functions CalStats()
     146             :               (default), CalStats() (copy), operator=(), next() and reset().
     147             : 2011 Nov 15 - Nick Elias, NRAO
     148             :               Moved the CalTypes namespace and its members, originally defined
     149             :               in this file, to the CalStatsFitter class.  Also, the
     150             :               CalTypes::AXIS typedef was replaced by CalStats::AXIS.
     151             : 2011 Dec 08 - Nick Elias, NRAO
     152             :               Added the fit axis vector to the internal variables.
     153             : 2011 Dec 11 - Nick Elias, NRAO
     154             :               The structure CalStats::FIT was added and replaces the
     155             :               CalStatsFitter::FIT structure output of the calcFit() public stats
     156             :               member function (the latter is now part of the former).  Added
     157             :               init() and dealloc() public member functions.
     158             : 2011 Dec 14 - Nick Elias, NRAO
     159             :               The structures CalStats::AXES, CalStats::DATA, and CalStats::NONE
     160             :               added.  The nested class CalStats::OUT<T> added (C++ does not
     161             :               allow templated typedefs, so a nested class is used instead).
     162             :               Public member function getData() added.  Public static member
     163             :               functions initAxes(), initGet(), initResultNone(),
     164             :               initResultFit(), and dealloc() added (overloaded for
     165             :               CalStats::DATA and CalStats::OUT<CalStatsFitter::FIT>).  Removed
     166             :               public member functions init() and dealloc() (non-overloaded
     167             :               version).
     168             : 2011 Dec 15 - Nick Elias, NRAO
     169             :               Private member functions next() and reset() now protected member
     170             :               functions.  State public member functions axisIterID(),
     171             :               axisNonIterID(), axisIterFeed(), axisIterUser(), axisNonIter(),
     172             :               statsShape(), value(), valueErr(), and flag() added.
     173             : 2011 Dec 16 - Nick Elias, NRAO
     174             :               Public member functions getData() and calcFit() replaced by
     175             :               stats<T>() template public member function.  Specialized template
     176             :               public member function statsWrap<T>() added.  Public static member
     177             :               functions initAxes(), initData(), initResultNone(), and
     178             :               initResultFit() replaced by template public static member function
     179             :               init<T>().
     180             : 2011 Dec 21 - Nick Elias, NRAO
     181             :               Template public static member functions init<T>() and dealloc<T>
     182             :               removed because all of their duties are subsumed by the nested
     183             :               classes AXES, DATA, ARG, and OUT (they were previously
     184             :               structures).
     185             : 2012 Jan 25 - Nick Elias, NRAO
     186             :               Created working versions of CalStats() (copy) and operator=() and
     187             :               turned them into public member functions.
     188             : 2012 Mar 05 - Nick Elias, NRAO
     189             :               Static public member function axisName() added.
     190             : 
     191             : */
     192             : 
     193             : // -----------------------------------------------------------------------------
     194             : // Start of CalStats public member functions
     195             : // -----------------------------------------------------------------------------
     196             : 
     197             : /*
     198             : 
     199             : CalStats::CalStats
     200             : 
     201             : Description:
     202             : ------------
     203             : This constructor saves input abscissae and data cubes to internal copies so that
     204             : statistics can be calculated.
     205             : 
     206             : NB: There must always be two iteration axes because statistics are performed
     207             : only on the third.  The FEED axis is always included as an iteration axis by
     208             : default because one cannot perform a fit along it.  The other axis is defined
     209             : by the user as an input parameter.
     210             : 
     211             : Inputs:
     212             : -------
     213             : oValue          - This reference to a Cube<Double> instance contains the values.
     214             : oValueErr       - This reference to a Cube<Double> instance contains the value
     215             :                   errors.
     216             : oFlag           - This reference to a Cube<Bool> instance contains the flags.
     217             : oFeed           - This reference to a Vector<String> instance is the feed
     218             :                   abscissae.
     219             : oFrequency      - This reference to a Vector<Double> instance is the frequency
     220             :                   abscissae.
     221             : oTime           - This reference to a Vector<Double> instance is the time
     222             :                   abscissae.
     223             : eAxisIterUserID - This CalStats::AXIS enum contains either the FREQUENCY or TIME
     224             :                   iteration axes (user defined).
     225             : 
     226             : Outputs:
     227             : --------
     228             : None.
     229             : 
     230             : Modification history:
     231             : ---------------------
     232             : 2011 Nov 11 - Nick Elias, NRAO
     233             :               Initial version.
     234             : 2011 Nov 15 - Nick Elias, NRAO
     235             :               The CalTypes::AXIS enum has been replaced with CalStats::AXIS.
     236             : 2011 Dec 19 - Nick Elias, NRAO
     237             :               To avoid data referencing issues, I invoked the copy() method of
     238             :               classes with the Array<T> base class.  To save memory, I may go
     239             :               back to the original way if I'm confident that it's OK.
     240             : 2011 Jan 25 - Nick Elias, NRAO
     241             :               Error checking added.
     242             : 
     243             : */
     244             : 
     245             : // -----------------------------------------------------------------------------
     246             : 
     247           1 : CalStats::CalStats( const Cube<Double>& oValue, const Cube<Double>& oValueErr,
     248             :     const Cube<Bool>& oFlag, const Vector<String>& oFeed,
     249             :     const Vector<Double>& oFrequency, const Vector<Double>& oTime,
     250           1 :     const CalStats::AXIS& eAxisIterUserID ) {
     251             : 
     252             :   // Check the inputs
     253             : 
     254           1 :   IPosition oShapeValue( oValue.shape() );
     255           1 :   IPosition oShapeValueErr( oValueErr.shape() );
     256           1 :   IPosition oShapeFlag( oFlag.shape() );
     257             : 
     258           1 :   if ( oShapeValue != oShapeValueErr || oShapeValue != oShapeFlag ) {
     259           0 :     throw( AipsError( "Input cubes have different shapes" ) );
     260             :   }
     261             : 
     262           1 :   if ( (uInt) oShapeValue[1] != oFrequency.nelements() ) {
     263           0 :     throw( AipsError( "Inconsistent frequency axis" ) );
     264             :   }
     265             : 
     266           1 :   if ( (uInt) oShapeValue[2] != oTime.nelements() ) {
     267           0 :     throw( AipsError( "Inconsistent time axis" ) );
     268             :   }
     269             : 
     270           1 :   if ( eAxisIterUserID != CalStats::FREQUENCY &&
     271           1 :        eAxisIterUserID != CalStats::TIME ) {
     272           0 :     throw( AipsError( "User-defined iteration axis must be frequency/time" ) );
     273             :   }
     274             : 
     275             : 
     276             :   // Initialize the internal copies of the iteration and fit axes
     277             : 
     278           1 :   switch ((uInt) eAxisIterUserID) {
     279             :   
     280           1 :     case (uInt) CalStats::TIME:
     281           1 :       oAxisIterID = IPosition( 2, CalStats::FEED, CalStats::TIME );
     282           1 :       oAxisIterFeed = Vector<String>( oFeed.copy() );
     283           1 :       oAxisIterUser = Vector<Double>( oTime.copy() );
     284           1 :       eAxisNonIterID = CalStats::AXIS( CalStats::FREQUENCY );
     285           1 :       oAxisNonIter = Vector<Double>( oFrequency.copy() );
     286           1 :       break;
     287             : 
     288           0 :     case (uInt) CalStats::FREQUENCY:
     289           0 :       oAxisIterID = IPosition( 2, CalStats::FEED, CalStats::FREQUENCY );
     290           0 :       oAxisIterFeed = Vector<String>( oFeed.copy() );
     291           0 :       oAxisIterUser = Vector<Double>( oFrequency.copy() );
     292           0 :       eAxisNonIterID = CalStats::AXIS( CalStats::TIME );
     293           0 :       oAxisNonIter = Vector<Double>( oTime.copy() );
     294           0 :       break;
     295             : 
     296           0 :     default:
     297           0 :       break;
     298             : 
     299             :   }
     300             : 
     301             : 
     302             :   // Form the shape of the statistics cube.  To appease the ArrayIterator<T>
     303             :   // template used elsewhere in this class, the fit (non-iteration) axis is
     304             :   // included as a degenerate axis (length=1).
     305             : 
     306           1 :   oStatsShape = IPosition( 3, 1 );
     307             : 
     308           3 :   for ( uInt a=0; a<2; a++ ) {
     309           2 :     uInt uiAxisIter = (uInt) oAxisIterID[a];
     310           2 :     oStatsShape[uiAxisIter] = oValue.shape()[uiAxisIter];
     311             :   }
     312             : 
     313             : 
     314             :   // Initialize the internal copies of the input parameter cubes
     315             : 
     316           1 :   poValue = new Cube<Double>( oValue.copy() );
     317           1 :   poValueErr = new Cube<Double>( oValueErr.copy() );
     318           1 :   poFlag = new Cube<Bool>( oFlag.copy() );
     319             : 
     320             : 
     321             :   // Initialize the input parameter cube iterators and reset them
     322             : 
     323           1 :   poValueIter = new ArrayIterator<Double>( *poValue, oAxisIterID, false );
     324           1 :   poValueIter->reset();
     325             : 
     326           1 :   poValueErrIter = new ArrayIterator<Double>( *poValueErr, oAxisIterID, false );
     327           1 :   poValueErrIter->reset();
     328             : 
     329           1 :   poFlagIter = new ArrayIterator<Bool>( *poFlag, oAxisIterID, false );
     330           1 :   poFlagIter->reset();
     331             : 
     332             : 
     333             :   // Return
     334             : 
     335           2 :   return;
     336             : 
     337           1 : }
     338             : 
     339             : // -----------------------------------------------------------------------------
     340             : 
     341             : /*
     342             : 
     343             : CalStats::CalStats (copy)
     344             : 
     345             : Description:
     346             : ------------
     347             : This constructor copies the internal parameters from the input instance to the
     348             : present instance.
     349             : 
     350             : Inputs:
     351             : -------
     352             : oCalStats - A reference to a CalStats instance.
     353             : 
     354             : Outputs:
     355             : --------
     356             : None.
     357             : 
     358             : Modification history:
     359             : ---------------------
     360             : 2011 Nov 11 - Nick Elias, NRAO
     361             :               Initial version.
     362             : 2012 Jan 25 - Nick Elias, NRAO
     363             :               Added working code.
     364             : 
     365             : */
     366             : 
     367             : // -----------------------------------------------------------------------------
     368             : 
     369           0 : CalStats::CalStats( const CalStats& oCalStats ) {
     370             : 
     371             :   // Copy all internal parameters from the input instance
     372             : 
     373           0 :   oAxisIterID = oCalStats.axisIterID();
     374           0 :   eAxisNonIterID = oCalStats.axisNonIterID();
     375             : 
     376           0 :   oAxisIterFeed = oCalStats.axisIterFeed();
     377           0 :   oAxisIterUser = oCalStats.axisIterUser();
     378           0 :   oAxisNonIter = oCalStats.axisNonIter();
     379             : 
     380           0 :   oStatsShape = oCalStats.statsShape();
     381             : 
     382           0 :   poValue = new Cube<Double>( oCalStats.value().copy() );
     383           0 :   poValueErr = new Cube<Double>( oCalStats.valueErr().copy() );
     384           0 :   poFlag = new Cube<Bool>( oCalStats.flag().copy() );
     385             : 
     386           0 :   poValueIter = new ArrayIterator<Double>( *poValue, oAxisIterID, false );
     387           0 :   poValueIter->reset();
     388             : 
     389           0 :   poValueErrIter = new ArrayIterator<Double>( *poValueErr, oAxisIterID, false );
     390           0 :   poValueErrIter->reset();
     391             : 
     392           0 :   poFlagIter = new ArrayIterator<Bool>( *poFlag, oAxisIterID, false );
     393           0 :   poFlagIter->reset();
     394             : 
     395             : 
     396             :   // Return
     397             : 
     398           0 :   return;
     399             : 
     400           0 : }
     401             : 
     402             : // -----------------------------------------------------------------------------
     403             : 
     404             : /*
     405             : 
     406             : CalStats::operator=
     407             : 
     408             : Description:
     409             : ------------
     410             : This constructor copies the internal parameters from the input instance to the
     411             : present instance.
     412             : 
     413             : Inputs:
     414             : -------
     415             : oCalStats - A reference to a CalStats instance.
     416             : 
     417             : Outputs:
     418             : --------
     419             : None.
     420             : 
     421             : Modification history:
     422             : ---------------------
     423             : 2011 Nov 11 - Nick Elias, NRAO
     424             :               Initial version.
     425             : 2012 Jan 25 - Nick Elias, NRAO
     426             :               Added working code.
     427             : 
     428             : */
     429             : 
     430             : // -----------------------------------------------------------------------------
     431             : 
     432           0 : CalStats& CalStats::operator=( const CalStats& oCalStats ) {
     433             : 
     434             :   // If the input instance is the same as this instance, return
     435             : 
     436           0 :   if ( this == &oCalStats ) return( *this );
     437             : 
     438             : 
     439             :   // Copy all internal parameters from the input instance
     440             : 
     441           0 :   oAxisIterID = oCalStats.axisIterID();
     442           0 :   eAxisNonIterID = oCalStats.axisNonIterID();
     443             : 
     444           0 :   oAxisIterFeed = oCalStats.axisIterFeed();
     445           0 :   oAxisIterUser = oCalStats.axisIterUser();
     446           0 :   oAxisNonIter = oCalStats.axisNonIter();
     447             : 
     448           0 :   oStatsShape = oCalStats.statsShape();
     449             : 
     450           0 :   delete poValue;
     451           0 :   poValue = new Cube<Double>( oCalStats.value().copy() );
     452             : 
     453           0 :   delete poValueErr;
     454           0 :   poValueErr = new Cube<Double>( oCalStats.valueErr().copy() );
     455             : 
     456           0 :   delete poFlag;
     457           0 :   poFlag = new Cube<Bool>( oCalStats.flag().copy() );
     458             : 
     459           0 :   delete poValueIter;
     460           0 :   poValueIter = new ArrayIterator<Double>( *poValue, oAxisIterID, false );
     461           0 :   poValueIter->reset();
     462             : 
     463           0 :   delete poValueErrIter;
     464           0 :   poValueErrIter = new ArrayIterator<Double>( *poValueErr, oAxisIterID, false );
     465           0 :   poValueErrIter->reset();
     466             : 
     467           0 :   delete poFlagIter;
     468           0 :   poFlagIter = new ArrayIterator<Bool>( *poFlag, oAxisIterID, false );
     469           0 :   poFlagIter->reset();
     470             : 
     471             : 
     472             :   // Return the reference to this instance
     473             : 
     474           0 :   return( *this );
     475             : 
     476             : }
     477             : 
     478             : // -----------------------------------------------------------------------------
     479             : 
     480             : /*
     481             : 
     482             : CalStats::~CalStats
     483             : 
     484             : Description:
     485             : ------------
     486             : This destructor deallocates the internal memory of an instance.
     487             : 
     488             : Inputs:
     489             : -------
     490             : None.
     491             : 
     492             : Outputs:
     493             : --------
     494             : None.
     495             : 
     496             : Modification history:
     497             : ---------------------
     498             : 2011 Nov 11 - Nick Elias, NRAO
     499             :               Initial version.
     500             : 
     501             : */
     502             : 
     503             : // -----------------------------------------------------------------------------
     504             : 
     505           1 : CalStats::~CalStats( void ) {
     506             : 
     507             :   // Deallocate the internal copies of the input parameter cubes
     508             : 
     509           1 :   delete poValue;
     510           1 :   delete poValueErr;
     511           1 :   delete poFlag;
     512             : 
     513             : 
     514             :   // Deallocate the input parameter cube iterators
     515             : 
     516           1 :   delete poValueIter;
     517           1 :   delete poValueErrIter;
     518           1 :   delete poFlagIter;
     519             : 
     520             : 
     521             :   // Return
     522             : 
     523           1 :   return;
     524             : 
     525           1 : }
     526             : 
     527             : // -----------------------------------------------------------------------------
     528             : // End of CalStats public member functions
     529             : // -----------------------------------------------------------------------------
     530             : 
     531             : // -----------------------------------------------------------------------------
     532             : // Start of CalStats public state member functions
     533             : // -----------------------------------------------------------------------------
     534             : 
     535             : /*
     536             : 
     537             : CalStats::axisIterID
     538             : 
     539             : Description:
     540             : ------------
     541             : This member function returns the iteration axis IDs..
     542             : 
     543             : Inputs:
     544             : -------
     545             : None.
     546             : 
     547             : Outputs:
     548             : --------
     549             : The IPosition instance containing the iteration axis IDs,
     550             : returned via the function value.
     551             : 
     552             : Modification history:
     553             : ---------------------
     554             : 2011 Dec 15 - Nick Elias, NRAO
     555             :               Initial version.
     556             : 
     557             : */
     558             : 
     559             : // -----------------------------------------------------------------------------
     560             : 
     561           0 : IPosition CalStats::axisIterID( void ) const {
     562             : 
     563             :   // Return the IPosition instance containing the iteration
     564             :   // axis IDs
     565             : 
     566           0 :   return oAxisIterID;
     567             : 
     568             : }
     569             : 
     570             : // -----------------------------------------------------------------------------
     571             : 
     572             : /*
     573             : 
     574             : CalStats::axisNonIterID
     575             : 
     576             : Description:
     577             : ------------
     578             : This member function returns the non-iteration axis IDs.
     579             : 
     580             : Inputs:
     581             : -------
     582             : None.
     583             : 
     584             : Outputs:
     585             : --------
     586             : The CalStats::AXIS instance containing the non-iteration axis
     587             : IDs, returned via the function value.
     588             : 
     589             : Modification history:
     590             : ---------------------
     591             : 2011 Dec 15 - Nick Elias, NRAO
     592             :               Initial version.
     593             : 
     594             : */
     595             : 
     596             : // -----------------------------------------------------------------------------
     597             : 
     598           0 : CalStats::AXIS CalStats::axisNonIterID( void ) const {
     599             : 
     600             :   // Return the CalStats::AXIS instance containing the non-iteration
     601             :   // axis IDs
     602             : 
     603           0 :   CalStats::AXIS axisNonIterID( eAxisNonIterID );
     604             : 
     605           0 :   return axisNonIterID;
     606             : 
     607             : }
     608             : 
     609             : // -----------------------------------------------------------------------------
     610             : 
     611             : /*
     612             : 
     613             : CalStats::axisIterFeed
     614             : 
     615             : Description:
     616             : ------------
     617             : This member function returns the feed iteration axis values.
     618             : 
     619             : Inputs:
     620             : -------
     621             : None.
     622             : 
     623             : Outputs:
     624             : --------
     625             : The  Vector<String> instance containing the feed iteration axis
     626             : values, returned via the function value.
     627             : 
     628             : Modification history:
     629             : ---------------------
     630             : 2011 Dec 15 - Nick Elias, NRAO
     631             :               Initial version.
     632             : 
     633             : */
     634             : 
     635             : // -----------------------------------------------------------------------------
     636             : 
     637           0 : Vector<String> CalStats::axisIterFeed( void ) const {
     638             : 
     639             :   // Return the Vector<String> instance containing the feed
     640             :   // iteration axis values
     641             : 
     642           0 :   return oAxisIterFeed;
     643             : 
     644             : }
     645             : 
     646             : // -----------------------------------------------------------------------------
     647             : 
     648             : /*
     649             : 
     650             : CalStats::axisIterUser
     651             : 
     652             : Description:
     653             : ------------
     654             : This member function returns the user-defined iteration axis values.
     655             : 
     656             : Inputs:
     657             : -------
     658             : None.
     659             : 
     660             : Outputs:
     661             : --------
     662             : The Vector<Double> instance containing the user-defined
     663             : iteration axis values, returned via the function value.
     664             : 
     665             : Modification history:
     666             : ---------------------
     667             : 2011 Dec 15 - Nick Elias, NRAO
     668             :               Initial version.
     669             : 
     670             : */
     671             : 
     672             : // -----------------------------------------------------------------------------
     673             : 
     674           0 : Vector<Double> CalStats::axisIterUser( void ) const {
     675             : 
     676             :   // Return the Vector<Double> instance containing the
     677             :   // user-defined iteration axis values
     678             : 
     679           0 :   return oAxisIterUser;
     680             : 
     681             : }
     682             : 
     683             : // -----------------------------------------------------------------------------
     684             : 
     685             : /*
     686             : 
     687             : CalStats::axisNonIter
     688             : 
     689             : Description:
     690             : ------------
     691             : This member function returns the non-iteration axis values.
     692             : 
     693             : Inputs:
     694             : -------
     695             : None.
     696             : 
     697             : Outputs:
     698             : --------
     699             : The Vector<Double> instance containing the non-iteration axis
     700             : values, returned via the function value.
     701             : 
     702             : Modification history:
     703             : ---------------------
     704             : 2011 Dec 15 - Nick Elias, NRAO
     705             :               Initial version.
     706             : 
     707             : */
     708             : 
     709             : // -----------------------------------------------------------------------------
     710             : 
     711           0 : Vector<Double> CalStats::axisNonIter( void ) const {
     712             : 
     713             :   // Return the Vector<Double> instance containing the
     714             :   // non-iteration axis values
     715             : 
     716           0 :   return oAxisNonIter;
     717             : 
     718             : }
     719             : 
     720             : // -----------------------------------------------------------------------------
     721             : 
     722             : /*
     723             : 
     724             : CalStats::statsShape
     725             : 
     726             : Description:
     727             : ------------
     728             : This member function returns the shape of the output statistics cube.
     729             : 
     730             : Inputs:
     731             : -------
     732             : None.
     733             : 
     734             : Outputs:
     735             : --------
     736             : The IPosition instance containing the shape of the output
     737             : statistics cube, returned via the function value.
     738             : 
     739             : Modification history:
     740             : ---------------------
     741             : 2011 Dec 15 - Nick Elias, NRAO
     742             :               Initial version.
     743             : 
     744             : */
     745             : 
     746             : // -----------------------------------------------------------------------------
     747             : 
     748           0 : IPosition CalStats::statsShape( void ) const {
     749             : 
     750             :   // Return the IPosition instance containing the shape of the
     751             :   // output statistics cube
     752             : 
     753           0 :   return oStatsShape;
     754             : 
     755             : }
     756             : 
     757             : // -----------------------------------------------------------------------------
     758             : 
     759             : /*
     760             : 
     761             : CalStats::value
     762             : 
     763             : Description:
     764             : ------------
     765             : This member function returns the input values.
     766             : 
     767             : Inputs:
     768             : -------
     769             : None.
     770             : 
     771             : Outputs:
     772             : --------
     773             : The reference to the Cube<Double> instance containing the input values, returned
     774             : via the function value.
     775             : 
     776             : Modification history:
     777             : ---------------------
     778             : 2011 Dec 15 - Nick Elias, NRAO
     779             :               Initial version.
     780             : 
     781             : */
     782             : 
     783             : // -----------------------------------------------------------------------------
     784             : 
     785           0 : Cube<Double>& CalStats::value( void ) const {
     786             : 
     787             :   // Return the reference to the Cube<Double> instance containing the input
     788             :   // values
     789             : 
     790           0 :   return( *poValue );
     791             : 
     792             : }
     793             : 
     794             : // -----------------------------------------------------------------------------
     795             : 
     796             : /*
     797             : 
     798             : CalStats::valueErr
     799             : 
     800             : Description:
     801             : ------------
     802             : This member function returns the input value errors.
     803             : 
     804             : Inputs:
     805             : -------
     806             : None.
     807             : 
     808             : Outputs:
     809             : --------
     810             : The reference to the Cube<Double> instance containing the input value errors,
     811             : returned via the function value.
     812             : 
     813             : Modification history:
     814             : ---------------------
     815             : 2011 Dec 15 - Nick Elias, NRAO
     816             :               Initial version.
     817             : 
     818             : */
     819             : 
     820             : // -----------------------------------------------------------------------------
     821             : 
     822           0 : Cube<Double>& CalStats::valueErr( void ) const {
     823             : 
     824             :   // Return the reference to the Cube<Double> instance containing the input
     825             :   // values errors
     826             : 
     827           0 :   return( *poValueErr );
     828             : 
     829             : }
     830             : 
     831             : // -----------------------------------------------------------------------------
     832             : 
     833             : /*
     834             : 
     835             : CalStats::flag
     836             : 
     837             : Description:
     838             : ------------
     839             : This member function returns the input flags.
     840             : 
     841             : Inputs:
     842             : -------
     843             : None.
     844             : 
     845             : Outputs:
     846             : --------
     847             : The reference to the Cube<Bool> instance containing the input flags, returned
     848             : via the function value.
     849             : 
     850             : Modification history:
     851             : ---------------------
     852             : 2011 Dec 15 - Nick Elias, NRAO
     853             :               Initial version.
     854             : 
     855             : */
     856             : 
     857             : // -----------------------------------------------------------------------------
     858             : 
     859           0 : Cube<Bool>& CalStats::flag( void ) const {
     860             : 
     861             :   // Return the reference to the Cube<Bool> instance containing the input flags
     862             : 
     863           0 :   return( *poFlag );
     864             : 
     865             : }
     866             : 
     867             : // -----------------------------------------------------------------------------
     868             : // End of CalStats public state member functions
     869             : // -----------------------------------------------------------------------------
     870             : 
     871             : // -----------------------------------------------------------------------------
     872             : // Start of public static member functions
     873             : // -----------------------------------------------------------------------------
     874             : 
     875             : /*
     876             : 
     877             : CalStats::axisName
     878             : 
     879             : Description:
     880             : ------------
     881             : This function returns the string corresponding to the CalStats::AXIS enum.
     882             : 
     883             : Inputs:
     884             : -------
     885             : eAxis - This reference to the CalStats::AXIS enum.
     886             : 
     887             : Outputs:
     888             : --------
     889             : The axis string, returned via the function value.
     890             : 
     891             : Modification history:
     892             : ---------------------
     893             : 2012 Mar 05 - Nick Elias, NRAO
     894             :               Initial version.
     895             : 
     896             : */
     897             : 
     898             : // -----------------------------------------------------------------------------
     899             : 
     900           0 : String CalStats::axisName( const CalStats::AXIS& eAxis ) {
     901             : 
     902             :   // Return the string corresponding to the CalStats::AXIS enum
     903             : 
     904           0 :   String axisName;
     905             : 
     906           0 :   switch ((uInt) eAxis) {
     907           0 :     case (uInt) CalStats::FEED:
     908           0 :       axisName =  "FEED";
     909           0 :       break;
     910           0 :     case (uInt) CalStats::FREQUENCY:
     911           0 :       axisName = "FREQUENCY";
     912           0 :       break;
     913           0 :     case (uInt) CalStats::TIME:
     914           0 :       axisName = "TIME";
     915           0 :       break;
     916           0 :     default:
     917           0 :       throw( AipsError( "Invalid axis" ) );
     918             :       break;
     919             :   }
     920             : 
     921           0 :   return axisName;
     922             : 
     923           0 : }
     924             : 
     925             : // -----------------------------------------------------------------------------
     926             : // End of public static member functions
     927             : // -----------------------------------------------------------------------------
     928             : 
     929             : // -----------------------------------------------------------------------------
     930             : // Start of CalStats::statsWrap<T> specialized template public fit member
     931             : // functions
     932             : // -----------------------------------------------------------------------------
     933             : 
     934             : /*
     935             : 
     936             : CalStats::statsWrap<CalStats::NONE>
     937             : 
     938             : Description:
     939             : ------------
     940             : This member function wraps statistics functions and provides a uniform interface
     941             : to stats<T>().  This 
     942             : 
     943             : Inputs:
     944             : -------
     945             : oDummy1 - This reference to a Vector<Double> instance is a dummy.
     946             : oDummy2 - This reference to a Vector<Double> instance is a dummy.
     947             : oDummy3 - This reference to a Vector<Double> instance is a dummy.
     948             : oDummy4 - This reference to a Vector<Bool> instance is a dummy.
     949             : oDummy5 - This reference to a CalStats::ARG<CalStats::NONE> instance is a dummy.
     950             : 
     951             : Outputs:
     952             : --------
     953             : The CalStats::NONE instance, returned via the function value.
     954             : 
     955             : Modification history:
     956             : ---------------------
     957             : 2011 Dec 16 - Nick Elias, NRAO
     958             :               Initial version.
     959             : 
     960             : */
     961             : 
     962             : // -----------------------------------------------------------------------------
     963             : 
     964         200 : template <> CalStats::NONE CalStats::statsWrap<CalStats::NONE>(
     965             :     const Vector<Double>& /*oDummy1*/, const Vector<Double>& /*oDummy2*/,
     966             :     const Vector<Double>& /*oDummy3*/, Vector<Bool>& /*oDummy4*/,
     967             :     const CalStats::ARG<CalStats::NONE>& /*oDummy5*/ ) {
     968             : 
     969             :   // Return a CalStats::NONE instance
     970             : 
     971         200 :   return CalStats::NONE();
     972             : }
     973             : 
     974             : // -----------------------------------------------------------------------------
     975             : 
     976             : /*
     977             : 
     978             : CalStats::statsWrap<CalStatsFitter::FIT>
     979             : 
     980             : Description:
     981             : ------------
     982             : This member function wraps statistics functions and provides a uniform interface
     983             : to stats<T>().
     984             : 
     985             : Inputs:
     986             : -------
     987             : oAbs      - This reference to a Vector<Double> instance contains the
     988             :             non-iteration axis abscissae.
     989             : oValue    - This reference to a Vector<Double> instance contains the values.
     990             : oValueErr - This reference to a Vector<Double> instance contains the value
     991             :             errors.
     992             : oFlag     - This reference to a Vector<Bool> instance contains the flags.
     993             : oArg      - This reference to a CalStats::ARG<CalStats::NONE> instance contains
     994             :             the extra arguments.
     995             : 
     996             : Outputs:
     997             : --------
     998             : oFlag - This reference to  Vector<Bool> instance contains the flags.
     999             : The reference to the CalStatsFitter::FIT instance, returned via the function
    1000             : value.
    1001             : 
    1002             : Modification history:
    1003             : ---------------------
    1004             : 2011 Dec 16 - Nick Elias, NRAO
    1005             :               Initial version.
    1006             : 2012 Jan 25 - Nick Elias, NRAO
    1007             :               Error checking added.
    1008             : 
    1009             : */
    1010             : 
    1011             : // -----------------------------------------------------------------------------
    1012             : 
    1013           0 : template <> CalStatsFitter::FIT CalStats::statsWrap<CalStatsFitter::FIT>(
    1014             :     const Vector<Double>& oAbs, const Vector<Double>& oValue,
    1015             :     const Vector<Double>& oValueErr, Vector<Bool>& oFlag,
    1016             :     const CalStats::ARG<CalStatsFitter::FIT>& oArg ) {
    1017             : 
    1018             :   // Perform the fit and return the CalStatsFitter::FIT instance
    1019             : 
    1020           0 :   CalStatsFitter::FIT fit;
    1021             : 
    1022             :   try {
    1023           0 :     fit = CalStatsFitter::fit( oAbs, oValue, oValueErr, oFlag, oArg.eOrder,
    1024           0 :                                oArg.eType, oArg.eWeight );
    1025             :   }
    1026           0 :   catch ( AipsError oAE ) {
    1027           0 :     throw( oAE );
    1028           0 :   }
    1029             : 
    1030           0 :   return fit;
    1031             : 
    1032           0 : }
    1033             : 
    1034             : // -----------------------------------------------------------------------------
    1035             : // Start of CalStats::statsWrap<T> specialized template public fit member
    1036             : // functions
    1037             : // -----------------------------------------------------------------------------
    1038             : 
    1039             : // -----------------------------------------------------------------------------
    1040             : // Start of CalStats protected member functions
    1041             : // -----------------------------------------------------------------------------
    1042             : 
    1043             : /*
    1044             : 
    1045             : CalStats::CalStats (default)
    1046             : 
    1047             : Description:
    1048             : ------------
    1049             : This default constructor is unused by this class and unavailable when an
    1050             : instance is created.
    1051             : 
    1052             : Inputs:
    1053             : -------
    1054             : None.
    1055             : 
    1056             : Outputs:
    1057             : --------
    1058             : None.
    1059             : 
    1060             : Modification history:
    1061             : ---------------------
    1062             : 2011 Nov 11 - Nick Elias, NRAO
    1063             :               Initial version.
    1064             : 
    1065             : */
    1066             : 
    1067             : // -----------------------------------------------------------------------------
    1068             : 
    1069           0 : CalStats::CalStats( void ) {}
    1070             : 
    1071             : // -----------------------------------------------------------------------------
    1072             : 
    1073             : /*
    1074             : 
    1075             : CalStats::next
    1076             : 
    1077             : Description:
    1078             : ------------
    1079             : This member function simultaneously iterates all of the internal copies of the
    1080             : input data cubes.
    1081             : 
    1082             : Inputs:
    1083             : -------
    1084             : None.
    1085             : 
    1086             : Outputs:
    1087             : --------
    1088             : None.
    1089             : 
    1090             : Modification history:
    1091             : ---------------------
    1092             : 2011 Nov 11 - Nick Elias, NRAO
    1093             :               Initial version.
    1094             : 
    1095             : */
    1096             : 
    1097             : // -----------------------------------------------------------------------------
    1098             : 
    1099         200 : void CalStats::next( void ) {
    1100             : 
    1101             :   // Iterate the input data cube iterators
    1102             : 
    1103         200 :   poValueIter->next();
    1104         200 :   poValueErrIter->next();
    1105         200 :   poFlagIter->next();
    1106             : 
    1107             : 
    1108             :   // Return
    1109             : 
    1110         200 :   return;
    1111             : 
    1112             : }
    1113             : 
    1114             : // -----------------------------------------------------------------------------
    1115             : 
    1116             : /*
    1117             : 
    1118             : CalStats::reset
    1119             : 
    1120             : Description:
    1121             : ------------
    1122             : This member function simultaneously resets the iterators of all of the internal
    1123             : copies of the input data cubes.
    1124             : 
    1125             : Inputs:
    1126             : -------
    1127             : None.
    1128             : 
    1129             : Outputs:
    1130             : --------
    1131             : None.
    1132             : 
    1133             : Modification history:
    1134             : ---------------------
    1135             : 2011 Nov 11 - Nick Elias, NRAO
    1136             :               Initial version.
    1137             : 
    1138             : */
    1139             : 
    1140             : // -----------------------------------------------------------------------------
    1141             : 
    1142           1 : void CalStats::reset( void ) {
    1143             : 
    1144             :   // Reset the input data cube iterators
    1145             : 
    1146           1 :   poValueIter->reset();
    1147           1 :   poValueErrIter->reset();
    1148           1 :   poFlagIter->reset();
    1149             : 
    1150             : 
    1151             :   // Return
    1152             : 
    1153           1 :   return;
    1154             : 
    1155             : }
    1156             : 
    1157             : // -----------------------------------------------------------------------------
    1158             : // End of CalStats protected member functions
    1159             : // -----------------------------------------------------------------------------
    1160             : 
    1161             : // -----------------------------------------------------------------------------
    1162             : // End of CalStats class
    1163             : // -----------------------------------------------------------------------------
    1164             : 
    1165             : };
    1166             : 
    1167             : // -----------------------------------------------------------------------------
    1168             : // End of casa namespace
    1169             : // -----------------------------------------------------------------------------

Generated by: LCOV version 1.16