LCOV - code coverage report
Current view: top level - calanalysis/CalAnalysis - CalAnalysis.cc (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 659 0.0 %
Date: 2024-12-11 20:54:31 Functions: 0 57 0.0 %

          Line data    Source code
       1             : 
       2             : // -----------------------------------------------------------------------------
       3             : 
       4             : /*
       5             : 
       6             : CalAnalysis.cc
       7             : 
       8             : Description:
       9             : ------------
      10             : This file contains member functions for the CalAnalysis class.
      11             : 
      12             : Classes:
      13             : --------
      14             : CalAnalysis - This class acts as the interface between the ROCTIter and CalStats
      15             :               classes.
      16             : 
      17             : Modification history:
      18             : ---------------------
      19             : 2012 Jan 20 - Nick Elias, NRAO
      20             :               Initial version.
      21             : 2012 Jan 25 - Nick Elias, NRAO
      22             :               Logging capability added.  Error checking added.
      23             : 2012 Feb 14 - Nick Elias, NRAO
      24             :               Updated this code to reflect changes in NewCalTabIter (now
      25             :               ROCTIter) and other classes.
      26             : 
      27             : */
      28             : 
      29             : // -----------------------------------------------------------------------------
      30             : // Includes
      31             : // -----------------------------------------------------------------------------
      32             : 
      33             : #include <calanalysis/CalAnalysis/CalAnalysis.h>
      34             : 
      35             : // -----------------------------------------------------------------------------
      36             : // Start of casa namespace
      37             : // -----------------------------------------------------------------------------
      38             : 
      39             : using namespace casacore;
      40             : namespace casa {
      41             : 
      42             : // -----------------------------------------------------------------------------
      43             : // Start of CalAnalysis class
      44             : // -----------------------------------------------------------------------------
      45             : 
      46             : /*
      47             : 
      48             : CalAnalysis
      49             : 
      50             : Description:
      51             : ------------
      52             : This class acts as the interface between the ROCTIter and CalAnalysis classes.
      53             : 
      54             : In a nutshell:
      55             : --------------
      56             : * The constructor gets the information from the new format calibration table
      57             :   and initializes the class.
      58             : * The stats<T>() function calculates statistics (the type depends on T) and
      59             :   returns the results.
      60             :   - The user can specify the field(s), antenna 1s, antenna 2s, time range,
      61             :     feeds, spectral windows, channels, the second iteration axis for the 
      62             :     CalStats class (time or frequency), normalization, and unwrapping.
      63             :   - The inputs are checked and fixed, if possible.
      64             :   - The data are grouped according to unique (field,antenna1,antenna2).
      65             :   - The resulting group-based information is fed to the CalStats class and its
      66             :     stats<T>() function calculates the desired statistics which are stored in a
      67             :     vector of OUTPUT<T>() instances.  Each OUTPUT<T>() element corresponds to a
      68             :     group.
      69             : 
      70             : NB: There are a lot of get/set member functions.  Unfortunately, they could not
      71             :     be overloaded with the same names because of conflicts with corresponding
      72             :     member functions without get/set in their names.  Plus, some get functions
      73             :     need to call other get functions.
      74             : 
      75             : NB: When an instance of this class is created from the python binding, input
      76             :     parameters are mostly checked there.  There is checking in this class as
      77             :     well, just in case that the class is not called from the python binding.
      78             :     There does not appear to be a significant speed penalty.
      79             : 
      80             : Nested classes:
      81             : ---------------
      82             : OUTPUT<T> - This nested class contains the outputs for the
      83             :             CalAnalysis::stats<T>() template member function.
      84             : 
      85             : Class public member functions:
      86             : ------------------------------
      87             : CalAnalysis  - This constructor gets information from the new format calibration
      88             :                table for further processing by the stats<T>() function.
      89             : ~CalAnalysis - This destructor deallocates the internal memory of an instance.
      90             : calName      - This member function returns the new format calibration table
      91             :                name.
      92             : msName       - This member function returns the associated MS name.
      93             : visCal       - This member function returns the visibility calibration type.
      94             : parType      - This member function returns the parameter type ("Complex" or
      95             :                "Float").
      96             : polBasis     - This member function returns the polarization basis ("L" or "C").
      97             : field        - This member function returns the field numbers.
      98             : antenna      - This member function returns the antenna numbers.
      99             : antenna1     - This member function returns the antenna 1 numbers.
     100             : antenna2     - This member function returns the antenna 2 numbers.
     101             : time         - This member function returns the times.
     102             : feed         - This member function returns the feeds.
     103             : numspw       - This member function returns the number of spectral windows.
     104             : spw          - This member function returns the spectral windows.
     105             : numChannel   - This member function returns the number of channels for each
     106             :                spectral window.
     107             : freq         - This member function returns the frequencies for each spectral
     108             :                window.
     109             : 
     110             : Class template public member functions:
     111             : ---------------------------------------
     112             : stats<T> - This member function is the main user interface for calculating the
     113             :            statistics for all iterations.  Allowed T: CalStats::NONE only
     114             :            returns the input data, CalStatsFitter::FIT calculates fit
     115             :            statistics, and CalStatsHist::HIST calculates histogram statistics.
     116             : 
     117             : Class template static public member functions:
     118             : ----------------------------------------------
     119             : exists<T> - This member function determines whether a value appears in a vector.
     120             : where<T>  - This member function returns the index of a search value in a
     121             :             vector.
     122             : unique<T> - This member function returns a unique vector from an input vector.
     123             : 
     124             : Class private member functions:
     125             : -------------------------------
     126             : calNameGet      - This member function gets the new format calibration table
     127             :                   name from the new format calibration table.
     128             : calNameSet      - This member function sets the new format calibration table
     129             :                   name private variable.
     130             : msNameGet       - This member function gets the associated MS name from the new
     131             :                   format calibration table.
     132             : msNameSet       - This member function sets the associated MS name private
     133             :                   variable.
     134             : visCalGet       - This member function gets the visibility calibration type from
     135             :                   the new format calibration table.
     136             : visCalSet       - This member function sets the visibility calibration type
     137             :                   private variable.
     138             : parTypeGet      - This member function gets the parameter type ("Complex" or
     139             :                   "Float") from the new format calibration table.
     140             : parTypeSet      - This member function sets the parameter type ("Complex" or
     141             :                   "Float") private variable.
     142             : polBasisGet     - This member function gets the polarization basis ("L" or "C")
     143             :                   from the new format calibration table.
     144             : polBasisSet     - This member function sets the polarization basis ("L" or "C")
     145             :                   private variable.
     146             : fieldGet        - This member function gets the field numbers from the new
     147             :                   format calibration table.
     148             : fieldSet        - This member function sets the field numbers private variables.
     149             : fieldCheck      - This member function checks the input field vector and returns
     150             :                   the fixed field vector.
     151             : antennaGet      - This member function gets the antenna numbers from the new
     152             :                   format calibration table.
     153             : antennaSet      - This member function sets the antenna numbers private
     154             :                   variables.
     155             : antenna1Get     - This member function gets the antenna 1 numbers from the new
     156             :                   format calibration table.
     157             : antenna1Set     - This member function sets the antenna 1 numbers private
     158             :                   variables.
     159             : antenna1Check   - This member function checks the input antenna 1 vector and
     160             :                   returns the fixed antenna 1 vector.
     161             : antenna2Get     - This member function gets the antenna 2 numbers from the new
     162             :                   format calibration table.
     163             : antenna2Set     - This member function sets the antenna 2 numbers private
     164             :                   variables.
     165             : antenna2Check   - This member function checks the input antenna 2 vector and
     166             :                   returns the fixed antenna 2 vector.
     167             : timeGet         - This member function gets the times from the new format
     168             :                   calibration table.
     169             : timeSet         - This member function sets the times private variables.
     170             : timeCheck       - This member function checks the time range and returns the
     171             :                   corresponding time vector.
     172             : feedGet         - This member function gets the feeds from the new format
     173             :                   calibration table.
     174             : feedSet         - This member function sets the feeds private variables.
     175             : feedCheck       - This member function checks the input feed vector and returns
     176             :                   the fixed feed vector.
     177             : spwInfoGet      - This member function gets the spectral window information from
     178             :                   the new format calibration table.
     179             : spwInfoSet      - This member function sets the spectral window information
     180             :                   private variables.
     181             : statsCheckInput - This member function checks and fixes (if possible) the inputs
     182             :                   to the CalAnalysis::stats<T>() member function.
     183             : getGroup        - This member function gets input selected rows from a new
     184             :                   format calibration table and groups them according to unique
     185             :                   (field,antenna1,antenna2).
     186             : rowSelect       - This member function returns the rows selected by the input
     187             :                   parameters.
     188             : rowGroup        - This member function returns the row numbers, fields, antenna
     189             :                   1s, antenna 2s, spectral windows, unique spectral windows,
     190             :                   times, and unique times grouped according to selected rows and
     191             :                   input selection.
     192             : chanSPW         - This member function maps the spectral windows to the input
     193             :                   spectral windows (to get the correct channels) and forms the
     194             :                   start channels so that spectral windows can be concatenated.
     195             : freqGroup       - This member function concatenates the frequencies from
     196             :                   multiple spectral windows for each group.
     197             : cubeGroup       - This member function concatenates data from multiple rows into
     198             :                   groups according to unique (field,antenna1,antenna2).
     199             : 
     200             : Class protected member functions:
     201             : ---------------------------------
     202             : CalAnalysis - This default constructor is unused by this class and unavailable
     203             :               when an instance is created.
     204             : CalAnalysis - This copy constructor is unused by this class and unavailable when
     205             :               an instance is created.
     206             : operator=   - This operator= function is unused by this class and unavailable
     207             :               when an instance is created.
     208             : 
     209             : Modification history:
     210             : ---------------------
     211             : 2012 Jan 20 - Nick Elias, NRAO
     212             :               Initial version created with public member functions CalAnalysis()
     213             :               (generic), ~CalAnalysis(); template static public member function
     214             :               stats<T>(); template public member functions exists<T>() and
     215             :               unique<T>(); private member functions tableType(), polBasisGet(),
     216             :               feedCheck(), timeCheck(), spw_channel(), freq(); template private
     217             :               member functions parse<T>(), and select<T>(); and protected member
     218             :               functions CalAnalysis() (default), CalAnalysis() (copy), and
     219             :               operator=().
     220             : 2012 Feb 14 - Nick Elias, NRAO
     221             :               Updated this code to reflect changes in NewCalTabIter (now
     222             :               ROCTIter) and other classes.  Added the RAP enum.
     223             : 2012 Mar 13 - Nick Elias, NRAO
     224             :               Public member function tableType() renamed to parTypeGet().
     225             :               Private member functions msNameGet() and visCalGet() added.
     226             : 2012 Mar 14 - Nick Elias, NRAO
     227             :               Spectral window ID, start channel, and stop channel added to the
     228             :               nested OUTPUT<T> class.
     229             : 2012 Apr 03 - Nick Elias, NRAO
     230             :               Private member function calNameGet() added.  Public member
     231             :               functions calName(), msName(), visCal(), parType(), and polBasis()
     232             :               added.
     233             : 2012 Apr 04 - Nick Elias, NRAO
     234             :               Private member functions calNameSet(), msNameSet(), visCalSet(),
     235             :               parTypeSet(), polBasisSet(), feedGet(), feedSet(), timeGet(),
     236             :               timeSet(), spwGet(), and spwSet() added.  Public member functions
     237             :               feed(), time(), spw(), and numspw() added.
     238             : 2012 Apr 17 - Nick Elias, NRAO
     239             :               Nested class CalAnalysis::SPW_INFO() added.  Private member
     240             :               functions fieldGet(), fieldSet(), fieldCheck(), antennaGet(),
     241             :               antennaSet(), antennaCheck(), spwInfoGet(), and spwInfoSet()
     242             :               added.  Public member functions field(), antenna(), numChannel(),
     243             :               and freq() added.  Private member functions spwGet(), spwSet(),
     244             :               and spw_channel() removed.
     245             : 2012 Apr 25 - Nick Elias, NRAO
     246             :               Private member function antennaCheck() renamed to antenna1Check().
     247             :               private member function antenna2Check() added.  The start and stop
     248             :               channel lists versus spectral window are replaced with a channel
     249             :               list versus spectral window.
     250             : 2012 Apr 26 - Nick Elias, NRAO
     251             :               Nested class INPUT added (for the stats<T>() member function).
     252             :               Spectral window ID, start channel, and stop channel removed from
     253             :               the nested OUTPUT<T> class.
     254             : 2012 Apr 27 - Nick Elias, NRAO
     255             :               Private member function statsCheckInput() added.  The member
     256             :               functions of the nested class CalAnalysis::SPW_INFO() have been
     257             :               moved to a separate file CalAnalysisSPW_INFO.cc.
     258             : 2012 May 02 - Nick Elias, NRAO
     259             :               Private member functions antenna1Get(), antenna1Set(),
     260             :               antenna2Get(), and antenna2Set() added.
     261             : 2012 May 06 - Nick Elias, NRAO
     262             :               Template private member functions parse<T>() and select<T>()
     263             :               removed.  Template static public member function where<T>() added.
     264             :               Private member functions getGroup(), rowSelect(), rowGroup(),
     265             :               chanSPW(), freqGroup(), and cubeGroup() added.
     266             : 2012 May 07 - Nick Elias, NRAO
     267             :               Public member functions antenna1() and antenna2() added.
     268             : 
     269             : */
     270             : 
     271             : // -----------------------------------------------------------------------------
     272             : // Start of CalAnalysis public member functions
     273             : // -----------------------------------------------------------------------------
     274             : 
     275             : /*
     276             : 
     277             : CalAnalysis::CalAnalysis (generic)
     278             : 
     279             : Description:
     280             : ------------
     281             : This constructor gets information from the new format calibration table for
     282             : further processing by the stats<T>() function.
     283             : 
     284             : Inputs:
     285             : -------
     286             : oTableName - This reference to a String instance contains the new format
     287             :              calibration table name.
     288             : 
     289             : Outputs:
     290             : --------
     291             : None.
     292             : 
     293             : Modification history:
     294             : ---------------------
     295             : 2012 Jan 20 - Nick Elias, NRAO
     296             :               Initial version.
     297             : 2012 Jan 25 - Nick Elias, NRAO
     298             :               Error checking added.
     299             : 2012 Apr 17 - Nick Elias, NRAO
     300             :               Called new member functions to make this member function shorter.
     301             : 2012 May 02 - Nick Elias, NRAO
     302             :               New format calibration table iterator no longer initialized here.
     303             : 2012 May 06 - Nick Elias, NRAO
     304             :               Eliminated the call to the NewCalTable() instance.
     305             : 
     306             : */
     307             : 
     308             : // -----------------------------------------------------------------------------
     309             : 
     310           0 : CalAnalysis::CalAnalysis( const String& oTableName ) {
     311             : 
     312             :   // Set the private variables corresponding to the new format calibration
     313             :   // table name, MS name, visibility calibration type, parameter type, and
     314             :   // polarization basis
     315             : 
     316             :   // Used to check if the new format calibration table name is valid
     317             :   try {
     318           0 :     calNameSet( calNameGet(oTableName) );
     319             :   }
     320             : 
     321           0 :   catch ( AipsError oAipsError ) {
     322           0 :     throw( oAipsError );
     323           0 :   }
     324             : 
     325           0 :   msNameSet( msNameGet(oTableName) );
     326           0 :   visCalSet( visCalGet(oTableName) );
     327           0 :   parTypeSet( parTypeGet(oTableName) );
     328           0 :   polBasisSet( polBasisGet(oTableName) );
     329             : 
     330             : 
     331             :   // Set the private variables corresponding to the field vector, antenna
     332             :   // vectors, time vector, feed vector, and spectral window information
     333             : 
     334           0 :   fieldSet( fieldGet(oTableName) );
     335             : 
     336           0 :   antennaSet( antennaGet(oTableName) );
     337           0 :   antenna1Set( antenna1Get(oTableName) );
     338           0 :   antenna2Set( antenna2Get(oTableName) );
     339             : 
     340           0 :   timeSet( timeGet(oTableName) );
     341             : 
     342           0 :   feedSet( feedGet(oTableName) );
     343             : 
     344           0 :   spwInfoSet(CalAnalysis::SPW_INFO(oTableName));
     345             : 
     346             : 
     347             :   // Return
     348             : 
     349           0 :   return;
     350             : 
     351           0 : }
     352             : 
     353             : // -----------------------------------------------------------------------------
     354             : 
     355             : /*
     356             : 
     357             : CalAnalysis::~CalAnalysis
     358             : 
     359             : Description:
     360             : ------------
     361             : This destructor deallocates the internal memory of an instance.
     362             : 
     363             : Inputs:
     364             : -------
     365             : None.
     366             : 
     367             : Outputs:
     368             : --------
     369             : None.
     370             : 
     371             : Modification history:
     372             : ---------------------
     373             : 2012 Jan 20 - Nick Elias, NRAO
     374             :               Initial version.
     375             : 2012 May 02 - Nick Elias, NRAO
     376             :               The new format calibration table iterator pointer may be
     377             :               deallocated elsewhere, so it is checked for NULL first.
     378             : 2012 May 06 - Nick Elias, NRAO
     379             :               Removed references to NewCalTable() and CTIter().
     380             : 
     381             : */
     382             : 
     383             : // -----------------------------------------------------------------------------
     384             : 
     385           0 : CalAnalysis::~CalAnalysis( void ) {}
     386             : 
     387             : // -----------------------------------------------------------------------------
     388             : 
     389             : /*
     390             : 
     391             : CalAnalysis::calName
     392             : 
     393             : Description:
     394             : ------------
     395             : This member function returns the new format calibration table.
     396             : 
     397             : Inputs:
     398             : -------
     399             : None.
     400             : 
     401             : Outputs:
     402             : --------
     403             : The String instance containing the new format calibration table
     404             : name, returned via the function value.
     405             : 
     406             : Modification history:
     407             : ---------------------
     408             : 2012 Apr 03 - Nick Elias, NRAO
     409             :               Initial version.
     410             : 
     411             : */
     412             : 
     413             : // -----------------------------------------------------------------------------
     414             : 
     415           0 : String CalAnalysis::calName( void ) const {
     416             : 
     417             :   // return the variable containing the new format calibration table name
     418             : 
     419           0 :   return oCalName;
     420             : 
     421             : }
     422             : 
     423             : // -----------------------------------------------------------------------------
     424             : 
     425             : /*
     426             : 
     427             : CalAnalysis::msName
     428             : 
     429             : Description:
     430             : ------------
     431             : This member function returns the MS name.
     432             : 
     433             : Inputs:
     434             : -------
     435             : None.
     436             : 
     437             : Outputs:
     438             : --------
     439             : The String instance containing the MS name, returned via the
     440             : function value.
     441             : 
     442             : Modification history:
     443             : ---------------------
     444             : 2012 Apr 03 - Nick Elias, NRAO
     445             :               Initial version.
     446             : 
     447             : */
     448             : 
     449             : // -----------------------------------------------------------------------------
     450             : 
     451           0 : String CalAnalysis::msName( void ) const {
     452             : 
     453             :   // return the private variable containing the MS name
     454             : 
     455           0 :   return oMSName;
     456             : 
     457             : }
     458             : 
     459             : // -----------------------------------------------------------------------------
     460             : 
     461             : /*
     462             : 
     463             : CalAnalysis::visCal
     464             : 
     465             : Description:
     466             : ------------
     467             : This member function returns the visibility calibration type.
     468             : 
     469             : Inputs:
     470             : -------
     471             : None.
     472             : 
     473             : Outputs:
     474             : --------
     475             : The String instance containing the visibility calibration type,
     476             : returned via the function value.
     477             : 
     478             : Modification history:
     479             : ---------------------
     480             : 2012 Apr 03 - Nick Elias, NRAO
     481             :               Initial version.
     482             : 
     483             : */
     484             : 
     485             : // -----------------------------------------------------------------------------
     486             : 
     487           0 : String CalAnalysis::visCal( void ) const {
     488             : 
     489             :   // Return opy the private variable containing the visibility calibration type
     490             : 
     491           0 :   return oVisCal;
     492             : 
     493             : }
     494             : 
     495             : // -----------------------------------------------------------------------------
     496             : 
     497             : /*
     498             : 
     499             : CalAnalysis::parType
     500             : 
     501             : Description:
     502             : ------------
     503             : This member function returns the parameter type ("Complex" or "Float").
     504             : 
     505             : Inputs:
     506             : -------
     507             : None.
     508             : 
     509             : Outputs:
     510             : --------
     511             : The String instance containing the parameter type, returned via
     512             : the function value.
     513             : 
     514             : Modification history:
     515             : ---------------------
     516             : 2012 Apr 03 - Nick Elias, NRAO
     517             :               Initial version.
     518             : 
     519             : */
     520             : 
     521             : // -----------------------------------------------------------------------------
     522             : 
     523           0 : String CalAnalysis::parType( void ) const {
     524             : 
     525             :   // Return the private variable containing the parameter type
     526             : 
     527           0 :   return oParType;
     528             : 
     529             : }
     530             : 
     531             : // -----------------------------------------------------------------------------
     532             : 
     533             : /*
     534             : 
     535             : CalAnalysis::polBasis
     536             : 
     537             : Description:
     538             : ------------
     539             : This member function returns the polarization basis ("L" or "C").
     540             : 
     541             : Inputs:
     542             : -------
     543             : None.
     544             : 
     545             : Outputs:
     546             : --------
     547             : The reference to the String instance containing the polarization basis, returned
     548             : via the function value.
     549             : 
     550             : Modification history:
     551             : ---------------------
     552             : 2012 Apr 03 - Nick Elias, NRAO
     553             :               Initial version.
     554             : 
     555             : */
     556             : 
     557             : // -----------------------------------------------------------------------------
     558             : 
     559           0 : String CalAnalysis::polBasis( void ) const {
     560             : 
     561             :   // Return the variable containing the polarization basis
     562             : 
     563           0 :   return oPolBasis;
     564             : 
     565             : }
     566             : 
     567             : // -----------------------------------------------------------------------------
     568             : 
     569             : /*
     570             : 
     571             : CalAnalysis::field
     572             : 
     573             : Description:
     574             : ------------
     575             : This member function returns the field numbers.
     576             : 
     577             : Inputs:
     578             : -------
     579             : None.
     580             : 
     581             : Outputs:
     582             : --------
     583             : The Vector<uInt> instance containing the fields, returned via
     584             : the function value.
     585             : 
     586             : Modification history:
     587             : ---------------------
     588             : 2012 Apr 17 - Nick Elias, NRAO
     589             :               Initial version.
     590             : 
     591             : */
     592             : 
     593             : // -----------------------------------------------------------------------------
     594             : 
     595           0 : Vector<uInt> CalAnalysis::field( void ) const {
     596             : 
     597             :   // Copy the private variable containing the field numbers and return it
     598             : 
     599           0 :   return oField.copy();
     600             : 
     601             : }
     602             : 
     603             : // -----------------------------------------------------------------------------
     604             : 
     605             : /*
     606             : 
     607             : CalAnalysis::antenna
     608             : 
     609             : Description:
     610             : ------------
     611             : This member function returns the antenna numbers.
     612             : 
     613             : Inputs:
     614             : -------
     615             : None.
     616             : 
     617             : Outputs:
     618             : --------
     619             : The Vector<uInt> instance containing the antenna numbers,
     620             : returned via the function value.
     621             : 
     622             : Modification history:
     623             : ---------------------
     624             : 2012 Apr 17 - Nick Elias, NRAO
     625             :               Initial version.
     626             : 
     627             : */
     628             : 
     629             : // -----------------------------------------------------------------------------
     630             : 
     631           0 : Vector<uInt> CalAnalysis::antenna( void ) const {
     632             : 
     633             :   // Return a copy of the private variable containing the antenna numbers
     634             : 
     635           0 :   return oAntenna.copy();
     636             : 
     637             : }
     638             : 
     639             : // -----------------------------------------------------------------------------
     640             : 
     641             : /*
     642             : 
     643             : CalAnalysis::antenna1
     644             : 
     645             : Description:
     646             : ------------
     647             : This member function returns the antenna 1 numbers.
     648             : 
     649             : Inputs:
     650             : -------
     651             : None.
     652             : 
     653             : Outputs:
     654             : --------
     655             : The the Vector<uInt> instance containing the antenna 1 numbers,
     656             : returned via the function value.
     657             : 
     658             : Modification history:
     659             : ---------------------
     660             : 2012 May 07 - Nick Elias, NRAO
     661             :               Initial version.
     662             : 
     663             : */
     664             : 
     665             : // -----------------------------------------------------------------------------
     666             : 
     667           0 : Vector<uInt> CalAnalysis::antenna1( void ) const {
     668             : 
     669             :   // Copy the private variable containing the antenna 1 numbers and return it
     670             : 
     671           0 :   return oAntenna1.copy();
     672             : 
     673             : }
     674             : 
     675             : // -----------------------------------------------------------------------------
     676             : 
     677             : /*
     678             : 
     679             : CalAnalysis::antenna2
     680             : 
     681             : Description:
     682             : ------------
     683             : This member function returns the antenna 2 numbers.
     684             : 
     685             : Inputs:
     686             : -------
     687             : None.
     688             : 
     689             : Outputs:
     690             : --------
     691             : The Vector<Int> instance containing the antenna 2 numbers,
     692             : returned via the function value.
     693             : 
     694             : Modification history:
     695             : ---------------------
     696             : 2012 May 07 - Nick Elias, NRAO
     697             :               Initial version.
     698             : 
     699             : */
     700             : 
     701             : // -----------------------------------------------------------------------------
     702             : 
     703           0 : Vector<Int> CalAnalysis::antenna2( void ) const {
     704             : 
     705             :   // Copy the private variable containing the antenna 2 numbers and return it
     706             : 
     707           0 :   return oAntenna2.copy();
     708             : 
     709             : }
     710             : 
     711             : // -----------------------------------------------------------------------------
     712             : 
     713             : /*
     714             : 
     715             : CalAnalysis::time
     716             : 
     717             : Description:
     718             : ------------
     719             : This member function returns the times.
     720             : 
     721             : Inputs:
     722             : -------
     723             : None.
     724             : 
     725             : Outputs:
     726             : --------
     727             : The Vector<Double> instance containing the times, returned via
     728             : the function value.
     729             : 
     730             : Modification history:
     731             : ---------------------
     732             : 2012 Apr 04 - Nick Elias, NRAO
     733             :               Initial version.
     734             : 
     735             : */
     736             : 
     737             : // -----------------------------------------------------------------------------
     738             : 
     739           0 : Vector<Double> CalAnalysis::time( void ) const {
     740             : 
     741             :   // Copy the private variable containing the times and return it
     742             : 
     743           0 :   return oTime.copy();
     744             : 
     745             : }
     746             : 
     747             : // -----------------------------------------------------------------------------
     748             : 
     749             : /*
     750             : 
     751             : CalAnalysis::feed
     752             : 
     753             : Description:
     754             : ------------
     755             : This member function returns the feeds.
     756             : 
     757             : Inputs:
     758             : -------
     759             : None.
     760             : 
     761             : Outputs:
     762             : --------
     763             : The Vector<String> instance containing the feeds, returned via
     764             : the function value.
     765             : 
     766             : Modification history:
     767             : ---------------------
     768             : 2012 Apr 04 - Nick Elias, NRAO
     769             :               Initial version.
     770             : 
     771             : */
     772             : 
     773             : // -----------------------------------------------------------------------------
     774             : 
     775           0 : Vector<String> CalAnalysis::feed( void ) const {
     776             : 
     777             :   // Copy the private variable containing the feeds and return it
     778             : 
     779           0 :   return oFeed.copy();
     780             : 
     781             : }
     782             : 
     783             : // -----------------------------------------------------------------------------
     784             : 
     785             : /*
     786             : 
     787             : CalAnalysis::numspw
     788             : 
     789             : Description:
     790             : ------------
     791             : This member function returns the number of spectral windows.
     792             : 
     793             : Inputs:
     794             : -------
     795             : None.
     796             : 
     797             : Outputs:
     798             : --------
     799             : The uInt variable containing the spectral windows, returned via
     800             : the function value.
     801             : 
     802             : Modification history:
     803             : ---------------------
     804             : 2012 Apr 04 - Nick Elias, NRAO
     805             :               Initial version.
     806             : 2012 Apr 17 - Nick Elias, NRAO
     807             :               Modified to handle the SPW_INFO instance.
     808             : 
     809             : */
     810             : 
     811             : // -----------------------------------------------------------------------------
     812             : 
     813           0 : uInt CalAnalysis::numspw( void ) const {
     814             : 
     815             :   // Return the variable containing the number of spectral windows
     816             : 
     817           0 :   return oSPWInfo.uiNumSPW;
     818             : 
     819             : }
     820             : 
     821             : // -----------------------------------------------------------------------------
     822             : 
     823             : /*
     824             : 
     825             : CalAnalysis::spw
     826             : 
     827             : Description:
     828             : ------------
     829             : This member function returns the spectral windows.
     830             : 
     831             : Inputs:
     832             : -------
     833             : None.
     834             : 
     835             : Outputs:
     836             : --------
     837             : The Vector<uInt> instance containing the spectral windows,
     838             : returned via the function value.
     839             : 
     840             : Modification history:
     841             : ---------------------
     842             : 2012 Apr 04 - Nick Elias, NRAO
     843             :               Initial version.
     844             : 2012 Apr 17 - Nick Elias, NRAO
     845             :               Modified to handle the SPW_INFO instance.
     846             : 
     847             : */
     848             : 
     849             : // -----------------------------------------------------------------------------
     850             : 
     851           0 : Vector<uInt> CalAnalysis::spw( void ) const {
     852             : 
     853             :   // Copy the private variable containing the spectral windows and return it
     854             : 
     855           0 :   return oSPWInfo.oSPW.copy();
     856             : 
     857             : }
     858             : 
     859             : // -----------------------------------------------------------------------------
     860             : 
     861             : /*
     862             : 
     863             : CalAnalysis::numChannel
     864             : 
     865             : Description:
     866             : ------------
     867             : This member function returns the number of channels for each spectral window.
     868             : 
     869             : Inputs:
     870             : -------
     871             : None.
     872             : 
     873             : Outputs:
     874             : --------
     875             : The array of pointers to the Vector<uInt> instances containing the number of
     876             : channels for each spectral window, returned via the function value.
     877             : 
     878             : Modification history:
     879             : ---------------------
     880             : 2012 Apr 17 - Nick Elias, NRAO
     881             :               Initial version.
     882             : 
     883             : */
     884             : 
     885             : // -----------------------------------------------------------------------------
     886             : 
     887           0 : Vector<uInt> CalAnalysis::numChannel( void ) const {
     888             : 
     889             :   // Copy the private variable containing the number of channels for each
     890             :   // spectral window and return it
     891             : 
     892           0 :   return oSPWInfo.oNumChannel.copy();
     893             : 
     894             : }
     895             : 
     896             : // -----------------------------------------------------------------------------
     897             : 
     898             : /*
     899             : 
     900             : CalAnalysis::freq
     901             : 
     902             : Description:
     903             : -----------
     904             : This member function returns the frequencies for each spectral window.
     905             : 
     906             : Inputs:
     907             : -------
     908             : None.
     909             : 
     910             : Outputs:
     911             : --------
     912             : The reference to the Vector<Vector<uInt> > instance containing the frequencies
     913             : for each spectral window, returned via the function value.
     914             : 
     915             : Modification history:
     916             : ---------------------
     917             : 2012 Apr 17 - Nick Elias, NRAO
     918             :               Initial version.
     919             : 
     920             : */
     921             : 
     922             : // -----------------------------------------------------------------------------
     923             : 
     924           0 : Vector<Vector<Double> > CalAnalysis::freq( void ) const {
     925             : 
     926             :   // Copy the private variable containing the frequencies for each spectral
     927             :   // window and return it
     928             : 
     929           0 :   uInt uiNumSPW = oSPWInfo.uiNumSPW;
     930             : 
     931           0 :   Vector<Vector<Double> > freq( uiNumSPW );
     932             : 
     933           0 :   for ( uInt s=0; s<uiNumSPW; s++ ) {
     934           0 :     freq[s] = oSPWInfo.oFrequency[s].copy();
     935             :   }
     936             : 
     937           0 :   return freq;
     938             : 
     939           0 : }
     940             : 
     941             : // -----------------------------------------------------------------------------
     942             : // End of CalAnalysis public member functions
     943             : // -----------------------------------------------------------------------------
     944             : 
     945             : // -----------------------------------------------------------------------------
     946             : // Start of CalAnalysis private member functions
     947             : // -----------------------------------------------------------------------------
     948             : 
     949             : /*
     950             : 
     951             : CalAnalysis::calNameGet
     952             : 
     953             : Description:
     954             : ------------
     955             : This member function gets the new format calibration table name from the new
     956             : format calibration table.
     957             : 
     958             : NB: This function is somewhat trivial, but it is included because of the other
     959             : get member functions of this class.
     960             : 
     961             : Inputs:
     962             : -------
     963             : oTableName - This reference to a String instance contains the new format
     964             :              calibration table name.
     965             : 
     966             : Outputs:
     967             : --------
     968             : The reference to the String instance containing the new format calibration table
     969             : name, returned via the function value.
     970             : 
     971             : Modification history:
     972             : ---------------------
     973             : 2012 Apr 03 - Nick Elias, NRAO
     974             :               Initial version.
     975             : 
     976             : */
     977             : 
     978             : // -----------------------------------------------------------------------------
     979             : 
     980           0 : String CalAnalysis::calNameGet( const String& oTableName ) {
     981             : 
     982             :   // Get the new format calibration table name and return it
     983             : 
     984           0 :   String poTableName = oTableName;
     985             : 
     986           0 :   return poTableName;
     987             : 
     988             : }
     989             : 
     990             : // -----------------------------------------------------------------------------
     991             : 
     992             : /*
     993             : 
     994             : CalAnalysis::calNameSet
     995             : 
     996             : Description:
     997             : ------------
     998             : This member function sets the new format calibration table name private
     999             : variable.
    1000             : 
    1001             : Inputs:
    1002             : -------
    1003             : oCalNameIn - This reference to a String instance contains the new format
    1004             :              calibration table name.
    1005             : 
    1006             : Outputs:
    1007             : --------
    1008             : None.
    1009             : 
    1010             : Modification history:
    1011             : ---------------------
    1012             : 2012 Apr 04 - Nick Elias, NRAO
    1013             :               Initial version.
    1014             : 
    1015             : */
    1016             : 
    1017             : // -----------------------------------------------------------------------------
    1018             : 
    1019           0 : void CalAnalysis::calNameSet( const String& oCalNameIn ) {
    1020             : 
    1021             :   // Set the new format calibration table name and return
    1022             : 
    1023           0 :   oCalName = String( oCalNameIn );
    1024             : 
    1025           0 :   return;
    1026             : 
    1027             : }
    1028             : 
    1029             : // -----------------------------------------------------------------------------
    1030             : 
    1031             : /*
    1032             : 
    1033             : CalAnalysis::msNameGet
    1034             : 
    1035             : Description:
    1036             : ------------
    1037             : This member function gets the associated MS name from the new format calibration
    1038             : table.
    1039             : 
    1040             : Inputs:
    1041             : -------
    1042             : oTableName - This reference to a String instance contains the new format
    1043             :              calibration table name.
    1044             : 
    1045             : Outputs:
    1046             : --------
    1047             : The reference to the String instance containing the MS name, returned via the
    1048             : function value.
    1049             : 
    1050             : Modification history:
    1051             : ---------------------
    1052             : 2012 Mar 13 - Nick Elias, NRAO
    1053             :               Initial version.
    1054             : 
    1055             : */
    1056             : 
    1057             : // -----------------------------------------------------------------------------
    1058             : 
    1059           0 : String CalAnalysis::msNameGet( const String& oTableName ) {
    1060             : 
    1061             :   // Get the record containing the main table keywords
    1062             : 
    1063           0 :   Table oTable( oTableName );
    1064           0 :   TableProxy oTP( oTable );
    1065           0 :   Record oR( oTP.getKeywordSet( String("") ) );
    1066             : 
    1067             : 
    1068             :   // Get the associated MS name and return it
    1069             : 
    1070           0 :   uInt uiIndex = oR.fieldNumber( String( "MSName" ) );
    1071           0 :   String poMSName = RecordFieldPtr<String>(oR,uiIndex).get();
    1072             : 
    1073           0 :   return poMSName;
    1074             : 
    1075           0 : }
    1076             : 
    1077             : // -----------------------------------------------------------------------------
    1078             : 
    1079             : /*
    1080             : 
    1081             : CalAnalysis::msNameSet
    1082             : 
    1083             : Description:
    1084             : ------------
    1085             : This member function sets the associated MS name private variable.
    1086             : 
    1087             : Inputs:
    1088             : -------
    1089             : oMSNameIn - This reference to a String instance contains the assciated MS name.
    1090             : 
    1091             : Outputs:
    1092             : --------
    1093             : None.
    1094             : 
    1095             : Modification history:
    1096             : ---------------------
    1097             : 2012 Apr 04 - Nick Elias, NRAO
    1098             :               Initial version.
    1099             : 
    1100             : */
    1101             : 
    1102             : // -----------------------------------------------------------------------------
    1103             : 
    1104           0 : void CalAnalysis::msNameSet( const String& oMSNameIn ) {
    1105             : 
    1106             :   // Set the assciated MS name and return
    1107             : 
    1108           0 :   oMSName = String( oMSNameIn );
    1109             : 
    1110           0 :   return;
    1111             : 
    1112             : }
    1113             : 
    1114             : // -----------------------------------------------------------------------------
    1115             : 
    1116             : /*
    1117             : 
    1118             : CalAnalysis::visCalGet
    1119             : 
    1120             : Description:
    1121             : ------------
    1122             : This member function gets the visibility calibration type from the new format
    1123             : calibration table.
    1124             : 
    1125             : Inputs:
    1126             : -------
    1127             : oTableName - This reference to a String instance contains the new format
    1128             :              calibration table name.
    1129             : 
    1130             : Outputs:
    1131             : --------
    1132             : The reference to the String instance containing the visibility calibration type
    1133             : instance, returned via the function value.
    1134             : 
    1135             : Modification history:
    1136             : ---------------------
    1137             : 2012 Mar 13 - Nick Elias, NRAO
    1138             :               Initial version.
    1139             : 
    1140             : */
    1141             : 
    1142             : // -----------------------------------------------------------------------------
    1143             : 
    1144           0 : String CalAnalysis::visCalGet( const String& oTableName ) {
    1145             : 
    1146             :   // Get the record containing the main table keywords
    1147             : 
    1148           0 :   Table oTable( oTableName );
    1149           0 :   TableProxy oTP( oTable );
    1150           0 :   Record oR( oTP.getKeywordSet( String("") ) );
    1151             : 
    1152             : 
    1153             :   // Get the visibility calibration type and return it
    1154             : 
    1155           0 :   uInt uiIndex = oR.fieldNumber( String( "VisCal" ) );
    1156           0 :   String poVisCal = RecordFieldPtr<String>(oR,uiIndex).get();
    1157             : 
    1158           0 :   return poVisCal;
    1159             : 
    1160           0 : }
    1161             : 
    1162             : // -----------------------------------------------------------------------------
    1163             : 
    1164             : /*
    1165             : 
    1166             : CalAnalysis::visCalSet
    1167             : 
    1168             : Description:
    1169             : ------------
    1170             : This member function sets the visibility calibration type private variable.
    1171             : 
    1172             : Inputs:
    1173             : -------
    1174             : oVisCalIn - This reference to a String instance contains the visibility
    1175             :             calibration type.
    1176             : 
    1177             : Outputs:
    1178             : --------
    1179             : None.
    1180             : 
    1181             : Modification history:
    1182             : ---------------------
    1183             : 2012 Apr 04 - Nick Elias, NRAO
    1184             :               Initial version.
    1185             : 
    1186             : */
    1187             : 
    1188             : // -----------------------------------------------------------------------------
    1189             : 
    1190           0 : void CalAnalysis::visCalSet( const String& oVisCalIn ) {
    1191             : 
    1192             :   // Set the visibility calibration type and return
    1193             : 
    1194           0 :   oVisCal = String( oVisCalIn );
    1195             : 
    1196           0 :   return;
    1197             : 
    1198             : }
    1199             : 
    1200             : // -----------------------------------------------------------------------------
    1201             : 
    1202             : /*
    1203             : 
    1204             : CalAnalysis::parTypeGet
    1205             : 
    1206             : Description:
    1207             : ------------
    1208             : This member function gets the parameter column type ("Complex" or "Float") from
    1209             : the new format calibration table.
    1210             : 
    1211             : Inputs:
    1212             : -------
    1213             : oTableName - This reference to a String instance contains the new format
    1214             :              calibration table name.
    1215             : 
    1216             : Outputs:
    1217             : --------
    1218             : The reference to the String instance containing the parameter column type,
    1219             : returned via the function value.
    1220             : 
    1221             : Modification history:
    1222             : ---------------------
    1223             : 2012 Jan 20 - Nick Elias, NRAO
    1224             :               Initial version.
    1225             : 2012 Mar 13 - Nick Elias, NRAO
    1226             :               Function renamed to parType().
    1227             : 
    1228             : */
    1229             : 
    1230             : // -----------------------------------------------------------------------------
    1231             : 
    1232           0 : String CalAnalysis::parTypeGet( const String& oTableName ) {
    1233             : 
    1234             :   // Get the record containing the main table keywords
    1235             : 
    1236           0 :   Table oTable( oTableName );
    1237           0 :   TableProxy oTP( oTable );
    1238           0 :   Record oR( oTP.getKeywordSet( String("") ) );
    1239             : 
    1240             : 
    1241             :   // Get the parameter column type and return it
    1242             : 
    1243           0 :   uInt uiIndex = oR.fieldNumber( String( "ParType" ) );
    1244           0 :   String poParType = RecordFieldPtr<String>(oR,uiIndex).get();
    1245             : 
    1246           0 :   return poParType;
    1247             : 
    1248           0 : }
    1249             : 
    1250             : // -----------------------------------------------------------------------------
    1251             : 
    1252             : /*
    1253             : 
    1254             : CalAnalysis::parTypeSet
    1255             : 
    1256             : Description:
    1257             : ------------
    1258             : This member function sets the parameter column type ("Complex" or "Float")
    1259             : private variable.
    1260             : 
    1261             : Inputs:
    1262             : -------
    1263             : oParTypeIn - This reference to a String instance contains the parameter column
    1264             :              type.
    1265             : 
    1266             : Outputs:
    1267             : --------
    1268             : None.
    1269             : 
    1270             : Modification history:
    1271             : ---------------------
    1272             : 2012 Apr 04 - Nick Elias, NRAO
    1273             :               Initial version.
    1274             : 
    1275             : */
    1276             : 
    1277             : // -----------------------------------------------------------------------------
    1278             : 
    1279           0 : void CalAnalysis::parTypeSet( const String& oParTypeIn ) {
    1280             : 
    1281             :   // Set the parameter column type and return
    1282             : 
    1283           0 :   oParType = String( oParTypeIn );
    1284             : 
    1285           0 :   return;
    1286             : 
    1287             : }
    1288             : 
    1289             : // -----------------------------------------------------------------------------
    1290             : 
    1291             : /*
    1292             : 
    1293             : CalAnalysis::polBasisGet
    1294             : 
    1295             : Description:
    1296             : ------------
    1297             : This member function gets the polarization basis ("L" or "C") from the new
    1298             : format calibration table.
    1299             : 
    1300             : Inputs:
    1301             : -------
    1302             : oTableName - This reference to a String instance contains the new format
    1303             :              calibration table name.
    1304             : 
    1305             : Outputs:
    1306             : --------
    1307             : The reference to the String instance containing the polarization basis, returned
    1308             : via the function value.
    1309             : 
    1310             : Modification history:
    1311             : ---------------------
    1312             : 2012 Jan 20 - Nick Elias, NRAO
    1313             :               Initial version.
    1314             : 
    1315             : */
    1316             : 
    1317             : // -----------------------------------------------------------------------------
    1318             : 
    1319           0 : String CalAnalysis::polBasisGet( const String& oTableName ) {
    1320             : 
    1321             :   // Get the record containing the main table keywords
    1322             : 
    1323           0 :   Table oTable( oTableName );
    1324           0 :   TableProxy oTP( oTable );
    1325           0 :   Record oR( oTP.getKeywordSet( String("") ) );
    1326             : 
    1327             : 
    1328             :   // Get the polarization basis, make it upper case, keep only the initial
    1329             :   // letter, and return it
    1330             : 
    1331           0 :   uInt uiIndex = oR.fieldNumber( String( "PolBasis" ) );
    1332           0 :   String poPolBasis = RecordFieldPtr<String>(oR,uiIndex).get();
    1333             : 
    1334           0 :   poPolBasis.upcase();
    1335           0 :   poPolBasis.operator=( poPolBasis.operator[](0) );
    1336             : 
    1337           0 :   return poPolBasis;
    1338             : 
    1339           0 : }
    1340             : 
    1341             : // -----------------------------------------------------------------------------
    1342             : 
    1343             : /*
    1344             : 
    1345             : CalAnalysis::polBasisSet
    1346             : 
    1347             : Description:
    1348             : ------------
    1349             : This member function sets the polarization basis ("L" or "C") private variable.
    1350             : 
    1351             : Inputs:
    1352             : -------
    1353             : oPolBasisIn - This reference to a String instance contains the polarization
    1354             :               basis.
    1355             : 
    1356             : Outputs:
    1357             : --------
    1358             : None.
    1359             : 
    1360             : Modification history:
    1361             : ---------------------
    1362             : 2012 Apr 04 - Nick Elias, NRAO
    1363             :               Initial version.
    1364             : 
    1365             : */
    1366             : 
    1367             : // -----------------------------------------------------------------------------
    1368             : 
    1369           0 : void CalAnalysis::polBasisSet( const String& oPolBasisIn ) {
    1370             : 
    1371             :   // Set the polarization basis and return
    1372             : 
    1373           0 :   oPolBasis = String( oPolBasisIn );
    1374             : 
    1375           0 :   return;
    1376             : 
    1377             : }
    1378             : 
    1379             : // -----------------------------------------------------------------------------
    1380             : 
    1381             : /*
    1382             : 
    1383             : CalAnalysis::fieldGet
    1384             : 
    1385             : Description:
    1386             : ------------
    1387             : This member function gets the field numbers from the new format calibration
    1388             : table.
    1389             : 
    1390             : Inputs:
    1391             : -------
    1392             : oTableName - This reference to a String instance contains the new format
    1393             :              calibration table name.
    1394             : 
    1395             : Outputs:
    1396             : --------
    1397             : The Vector<uInt> instance containing the field numbers,
    1398             : returned via the function value.
    1399             : 
    1400             : Modification history:
    1401             : ---------------------
    1402             : 2012 Apr 17 - Nick Elias, NRAO
    1403             :               Initial version.
    1404             : 2012 May 02 - Nick Elias, NRAO
    1405             :               Fields are now obtained directly from the FIELD_ID column of the
    1406             :               main table.
    1407             : 
    1408             : */
    1409             : 
    1410             : // -----------------------------------------------------------------------------
    1411             : 
    1412           0 : Vector<uInt> CalAnalysis::fieldGet( const String& oTableName ) {
    1413             : 
    1414             :   // Get the field numbers from the new format calibration table
    1415             : 
    1416           0 :   Table oTable( oTableName, Table::Old );
    1417           0 :   ScalarColumn<Int> oROSC( oTable, String("FIELD_ID") );
    1418             : 
    1419           0 :   Vector<Int> oFieldInt;
    1420           0 :   oROSC.getColumn( oFieldInt, true );
    1421             : 
    1422           0 :   Vector<Int> oFieldUnique;
    1423           0 :   unique<Int>(oFieldInt, oFieldUnique);
    1424             : 
    1425           0 :   Vector<uInt> field( oFieldUnique.nelements() );
    1426           0 :   convertArray<uInt,Int>( field, oFieldUnique );
    1427             : 
    1428           0 :   return field;
    1429             : 
    1430           0 : }
    1431             : 
    1432             : // -----------------------------------------------------------------------------
    1433             : 
    1434             : /*
    1435             : 
    1436             : CalAnalysis::fieldSet
    1437             : 
    1438             : Description:
    1439             : ------------
    1440             : This member function sets the field numbers private variables.
    1441             : 
    1442             : Inputs:
    1443             : -------
    1444             : oFieldIn - This reference to a Vector<uInt> instance contains the field numbers.
    1445             : 
    1446             : Outputs:
    1447             : --------
    1448             : None.
    1449             : 
    1450             : Modification history:
    1451             : ---------------------
    1452             : 2012 Apr 17 - Nick Elias, NRAO
    1453             :               Initial version.
    1454             : 
    1455             : */
    1456             : 
    1457             : // -----------------------------------------------------------------------------
    1458             : 
    1459           0 : void CalAnalysis::fieldSet( const Vector<uInt>& oFieldIn ) {
    1460             : 
    1461             :   // Set the number of fields and fields and return
    1462             : 
    1463           0 :   uiNumField = oFieldIn.nelements();
    1464           0 :   oField = Vector<uInt>( oFieldIn.copy() );
    1465             : 
    1466           0 :   return;
    1467             : 
    1468             : }
    1469             : 
    1470             : // -----------------------------------------------------------------------------
    1471             : 
    1472             : /*
    1473             : 
    1474             : CalAnalysis::fieldCheck
    1475             : 
    1476             : Description:
    1477             : ------------
    1478             : This member function checks the input field vector and returns the fixed field
    1479             : vector.
    1480             : 
    1481             : Inputs:
    1482             : -------
    1483             : oFieldIn - This reference to a Vector<uInt> instance contains the field numbers.
    1484             : 
    1485             : Outputs:
    1486             : --------
    1487             : oFieldOut - This reference to the Vector<uInt> instance contains the checked and
    1488             :             fixed field numbers.
    1489             : The Bool variable containing the check boolean, returned via
    1490             : the function value.
    1491             : 
    1492             : Modification history:
    1493             : ---------------------
    1494             : 2012 Apr 17 - Nick Elias, NRAO
    1495             :               Initial version.
    1496             : 
    1497             : */
    1498             : 
    1499             : // -----------------------------------------------------------------------------
    1500             : 
    1501           0 : Bool CalAnalysis::fieldCheck( const Vector<uInt>& oFieldIn,
    1502             :     Vector<uInt>& oFieldOut ) const {
    1503             : 
    1504             :   // Declare the success boolean
    1505             : 
    1506           0 :   Bool success = false;
    1507             : 
    1508             : 
    1509             :   // Check the input field numbers and return the fixed field numbers
    1510             : 
    1511           0 :   if ( oFieldIn.nelements() == 0 ) {
    1512           0 :     success = false;
    1513           0 :     return success;
    1514             :   }
    1515             : 
    1516           0 :   uInt uiNumFieldOut = 0;
    1517           0 :   oFieldOut.resize();
    1518             : 
    1519           0 :   for ( uInt f=0; f<oFieldIn.nelements(); f++ ) {
    1520           0 :     if ( exists<uInt>( oFieldIn[f], oField ) ) {
    1521           0 :       uiNumFieldOut += 1;
    1522           0 :       oFieldOut.resize( uiNumFieldOut, true );
    1523           0 :       oFieldOut[uiNumFieldOut-1] = oFieldIn[f];
    1524             :     }
    1525             :   }
    1526             : 
    1527           0 :   if ( uiNumFieldOut == 0 ) {
    1528           0 :     success = false;
    1529           0 :     return success;
    1530             :   }
    1531             : 
    1532             : 
    1533             :   // Return true
    1534             : 
    1535           0 :   success = true;
    1536             : 
    1537           0 :   return success;
    1538             : 
    1539             : }
    1540             : 
    1541             : // -----------------------------------------------------------------------------
    1542             : 
    1543             : /*
    1544             : 
    1545             : CalAnalysis::antennaGet
    1546             : 
    1547             : Description:
    1548             : ------------
    1549             : This member function gets the antenna numbers from the new format calibration
    1550             : table.
    1551             : 
    1552             : Inputs:
    1553             : -------
    1554             : oTableName - This reference to a String instance contains the new format
    1555             :              calibration table name.
    1556             : 
    1557             : Outputs:
    1558             : --------
    1559             : The Vector<uInt> instance containing the antenna numbers,
    1560             : returned via the function value.
    1561             : 
    1562             : Modification history:
    1563             : ---------------------
    1564             : 2012 Apr 17 - Nick Elias, NRAO
    1565             :               Initial version.
    1566             : 
    1567             : */
    1568             : 
    1569             : // -----------------------------------------------------------------------------
    1570             : 
    1571           0 : Vector<uInt> CalAnalysis::antennaGet( const String& oTableName ) {
    1572             : 
    1573             :   // Create a temporary antenna subtable instance and get the number of antennas
    1574             :   // (the number of rows)
    1575             : 
    1576           0 :   Table oTableAntenna( oTableName+"/ANTENNA", Table::Old );
    1577           0 :   uInt uiNumRow = oTableAntenna.nrow();
    1578             : 
    1579             : 
    1580             :   // Create the vector containing the antenna numbers and return it
    1581             : 
    1582           0 :   Vector<uInt> antenna( uiNumRow );
    1583           0 :   indgen<uInt>( antenna, 0 );
    1584             : 
    1585           0 :   return antenna;
    1586             : 
    1587             : 
    1588           0 : }
    1589             : 
    1590             : // -----------------------------------------------------------------------------
    1591             : 
    1592             : /*
    1593             : 
    1594             : CalAnalysis::antennaSet
    1595             : 
    1596             : Description:
    1597             : ------------
    1598             : This member function sets the antenna numbers private variables.
    1599             : 
    1600             : Inputs:
    1601             : -------
    1602             : oAntennaIn - This reference to a Vector<uInt> instance contains the antenna
    1603             :              numbers.
    1604             : 
    1605             : Outputs:
    1606             : --------
    1607             : None.
    1608             : 
    1609             : Modification history:
    1610             : ---------------------
    1611             : 2012 Apr 17 - Nick Elias, NRAO
    1612             :               Initial version.
    1613             : 
    1614             : */
    1615             : 
    1616             : // -----------------------------------------------------------------------------
    1617             : 
    1618           0 : void CalAnalysis::antennaSet( const Vector<uInt>& oAntennaIn ) {
    1619             : 
    1620             :   // Set the number of antennas and antennas and return
    1621             : 
    1622           0 :   uiNumAntenna = oAntennaIn.nelements();
    1623           0 :   oAntenna = Vector<uInt>( oAntennaIn.copy() );
    1624             : 
    1625           0 :   return;
    1626             : 
    1627             : }
    1628             : 
    1629             : // -----------------------------------------------------------------------------
    1630             : 
    1631             : /*
    1632             : 
    1633             : CalAnalysis::antenna1Get
    1634             : 
    1635             : Description:
    1636             : ------------
    1637             : This member function gets the antenna 1 numbers from the new format calibration
    1638             : table.
    1639             : 
    1640             : Inputs:
    1641             : -------
    1642             : oTableName - This reference to a String instance contains the new format
    1643             :              calibration table name.
    1644             : 
    1645             : Outputs:
    1646             : --------
    1647             : The Vector<uInt> instance containing the antenna 1 numbers,
    1648             : returned via the function value.
    1649             : 
    1650             : Modification history:
    1651             : ---------------------
    1652             : 2012 May 02 - Nick Elias, NRAO
    1653             :               Initial version.
    1654             : 
    1655             : */
    1656             : 
    1657             : // -----------------------------------------------------------------------------
    1658             : 
    1659           0 : Vector<uInt> CalAnalysis::antenna1Get( const String& oTableName ) {
    1660             : 
    1661             :   // Get the antenna 1 numbers from the new format calibration table
    1662             : 
    1663           0 :   Table oTable( oTableName, Table::Old );
    1664           0 :   ScalarColumn<Int> oROSC( oTable, String("ANTENNA1") );
    1665             : 
    1666           0 :   Vector<Int> oAntenna1Int;
    1667           0 :   oROSC.getColumn( oAntenna1Int, true );
    1668             : 
    1669           0 :   Vector<Int> oAntenna1Unique;
    1670           0 :   unique<Int>(oAntenna1Int, oAntenna1Unique);
    1671             : 
    1672           0 :   Vector<uInt> antenna1( oAntenna1Unique.nelements() );
    1673           0 :   convertArray<uInt,Int>( antenna1, oAntenna1Unique );
    1674             : 
    1675           0 :   return antenna1;
    1676             : 
    1677           0 : }
    1678             : 
    1679             : // -----------------------------------------------------------------------------
    1680             : 
    1681             : /*
    1682             : 
    1683             : CalAnalysis::antenna1Set
    1684             : 
    1685             : Description:
    1686             : ------------
    1687             : This member function sets the antenna 1 numbers private variables.
    1688             : 
    1689             : Inputs:
    1690             : -------
    1691             : oAntenna1In - This reference to a Vector<uInt> instance contains the antenna 1
    1692             :               numbers.
    1693             : 
    1694             : Outputs:
    1695             : --------
    1696             : None.
    1697             : 
    1698             : Modification history:
    1699             : ---------------------
    1700             : 2012 May 02 - Nick Elias, NRAO
    1701             :               Initial version.
    1702             : 
    1703             : */
    1704             : 
    1705             : // -----------------------------------------------------------------------------
    1706             : 
    1707           0 : void CalAnalysis::antenna1Set( const Vector<uInt>& oAntenna1In ) {
    1708             : 
    1709             :   // Set the number of antenna 1 and antenna 1 numbers and return
    1710             : 
    1711           0 :   uiNumAntenna1 = oAntenna1In.nelements();
    1712           0 :   oAntenna1 = Vector<uInt>( oAntenna1In.copy() );
    1713             : 
    1714           0 :   return;
    1715             : 
    1716             : }
    1717             : 
    1718             : // -----------------------------------------------------------------------------
    1719             : 
    1720             : /*
    1721             : 
    1722             : CalAnalysis::antenna1Check
    1723             : 
    1724             : Description:
    1725             : ------------
    1726             : This member function checks the input antenna 1 vector and returns the fixed
    1727             : antenna 1 vector.
    1728             : 
    1729             : Inputs:
    1730             : -------
    1731             : oAntenna1In - This reference to a Vector<uInt> instance contains the antenna 1
    1732             :               numbers.
    1733             : 
    1734             : Outputs:
    1735             : --------
    1736             : oAntenna1Out - This reference to the Vector<uInt> instance contains the checked
    1737             :                and fixed antenna 1 numbers.
    1738             : The Bool variable containing the check boolean, returned via
    1739             : the function value.
    1740             : 
    1741             : Modification history:
    1742             : ---------------------
    1743             : 2012 Apr 17 - Nick Elias, NRAO
    1744             :               Initial version.
    1745             : 2012 Apr 25 - Nick Elias, NRAO
    1746             :               Member function antennaCheck() renamed to antenna1Check().
    1747             : 2012 May 02 - Nick Elias, NRAO
    1748             :               The comparison is now made to an internal list of antenna 2.
    1749             : 
    1750             : */
    1751             : 
    1752             : // -----------------------------------------------------------------------------
    1753             : 
    1754           0 : Bool CalAnalysis::antenna1Check( const Vector<uInt>& oAntenna1In,
    1755             :     Vector<uInt>& oAntenna1Out ) const {
    1756             : 
    1757             :   // Declare the success boolean
    1758             : 
    1759           0 :   Bool success(false);
    1760             : 
    1761             : 
    1762             :   // Check the input antenna 1 numbers and return the fixed antenna 1 numbers
    1763             : 
    1764           0 :   if ( oAntenna1In.nelements() == 0 ) {
    1765           0 :     success = false;
    1766           0 :     return success;
    1767             :   }
    1768             : 
    1769           0 :   uInt uiNumAntenna1Out = 0;
    1770           0 :   oAntenna1Out.resize();
    1771             : 
    1772           0 :   for ( uInt a=0; a<oAntenna1In.nelements(); a++ ) {
    1773           0 :     if ( exists<uInt>( oAntenna1In[a], oAntenna1 ) ) {
    1774           0 :       uiNumAntenna1Out += 1;
    1775           0 :       oAntenna1Out.resize( uiNumAntenna1Out, true );
    1776           0 :       oAntenna1Out[uiNumAntenna1Out-1] = oAntenna1In[a];
    1777             :     }
    1778             :   }
    1779             : 
    1780           0 :   if ( uiNumAntenna1Out == 0 ) {
    1781           0 :     success = false;
    1782           0 :     return success;
    1783             :   }
    1784             : 
    1785             : 
    1786             :   // Return true
    1787             : 
    1788           0 :   success = true;
    1789             : 
    1790           0 :   return success;
    1791             : 
    1792             : }
    1793             : 
    1794             : // -----------------------------------------------------------------------------
    1795             : 
    1796             : /*
    1797             : 
    1798             : CalAnalysis::antenna2Get
    1799             : 
    1800             : Description:
    1801             : ------------
    1802             : This member function gets the antenna 2 numbers from the new format calibration
    1803             : table.
    1804             : 
    1805             : Inputs:
    1806             : -------
    1807             : oTableName - This reference to a String instance contains the new format
    1808             :              calibration table name.
    1809             : 
    1810             : Outputs:
    1811             : --------
    1812             : The Vector<Int> instance containing the antenna 2 numbers,
    1813             : returned via the function value.
    1814             : 
    1815             : Modification history:
    1816             : ---------------------
    1817             : 2012 May 02 - Nick Elias, NRAO
    1818             :               Initial version.
    1819             : 
    1820             : */
    1821             : 
    1822             : // -----------------------------------------------------------------------------
    1823             : 
    1824           0 : Vector<Int> CalAnalysis::antenna2Get( const String& oTableName ) {
    1825             : 
    1826             :   // Get the antenna 2 numbers from the new format calibration table
    1827             : 
    1828           0 :   Table oTable( oTableName, Table::Old );
    1829           0 :   ScalarColumn<Int> oROSC( oTable, String("ANTENNA2") );
    1830             : 
    1831           0 :   Vector<Int> oAntenna2Int;
    1832           0 :   oROSC.getColumn( oAntenna2Int, true );
    1833             : 
    1834             : 
    1835           0 :   Vector<Int> uniqueA2;
    1836           0 :   unique<Int>(oAntenna2Int, uniqueA2);
    1837             : 
    1838           0 :   Vector<Int> antenna2( uniqueA2 );
    1839             : 
    1840           0 :   return antenna2;
    1841             : 
    1842           0 : }
    1843             : 
    1844             : // -----------------------------------------------------------------------------
    1845             : 
    1846             : /*
    1847             : 
    1848             : CalAnalysis::antenna2Set
    1849             : 
    1850             : Description:
    1851             : ------------
    1852             : This member function sets the antenna 2 numbers private variables.
    1853             : 
    1854             : Inputs:
    1855             : -------
    1856             : oAntenna2In - This reference to a Vector<uInt> instance contains the antenna 2
    1857             :               numbers.
    1858             : 
    1859             : Outputs:
    1860             : --------
    1861             : None.
    1862             : 
    1863             : Modification history:
    1864             : ---------------------
    1865             : 2012 May 02 - Nick Elias, NRAO
    1866             :               Initial version.
    1867             : 
    1868             : */
    1869             : 
    1870             : // -----------------------------------------------------------------------------
    1871             : 
    1872           0 : void CalAnalysis::antenna2Set( const Vector<Int>& oAntenna2In ) {
    1873             : 
    1874             :   // Set the number of antenna 2 and antenna 2 numbers and return
    1875             : 
    1876           0 :   uiNumAntenna2 = oAntenna2In.nelements();
    1877           0 :   oAntenna2 = Vector<Int>( oAntenna2In.copy() );
    1878             : 
    1879           0 :   return;
    1880             : 
    1881             : }
    1882             : 
    1883             : // -----------------------------------------------------------------------------
    1884             : 
    1885             : /*
    1886             : 
    1887             : CalAnalysis::antenna2Check
    1888             : 
    1889             : Description:
    1890             : ------------
    1891             : This member function checks the input antenna 2 vector and returns the fixed
    1892             : antenna 2 vector.
    1893             : 
    1894             : Inputs:
    1895             : -------
    1896             : oAntenna2In - This reference to a Vector<Int> instance contains the antenna 2
    1897             :               numbers.
    1898             : 
    1899             : Outputs:
    1900             : --------
    1901             : oAntenna2Out - This reference to the Vector<Int> instance contains the checked
    1902             :                and fixed antenna 2 numbers.
    1903             : The Bool variable containing the check boolean, returned via
    1904             : the function value.
    1905             : 
    1906             : Modification history:
    1907             : ---------------------
    1908             : 2012 Apr 25 - Nick Elias, NRAO
    1909             :               Initial version.
    1910             : 2012 May 02 - Nick Elias, NRAO
    1911             :               The comparison is now made to an internal list of antenna 2.
    1912             : 
    1913             : */
    1914             : 
    1915             : // -----------------------------------------------------------------------------
    1916             : 
    1917           0 : Bool CalAnalysis::antenna2Check( const Vector<Int>& oAntenna2In,
    1918             :     Vector<Int>& oAntenna2Out ) const {
    1919             : 
    1920             :   // Declare the success boolean
    1921             : 
    1922           0 :   Bool success( false );
    1923             : 
    1924             : 
    1925             :   // Check the input antenna 1 numbers and return the fixed antenna 1 numbers
    1926             : 
    1927           0 :   if ( oAntenna2In.nelements() == 0 ) {
    1928           0 :     success = false;
    1929           0 :     return success;
    1930             :   }
    1931             : 
    1932           0 :   uInt uiNumAntenna2Out = 0;
    1933           0 :   oAntenna2Out.resize();
    1934             : 
    1935           0 :   for ( uInt a=0; a<oAntenna2In.nelements(); a++ ) {
    1936           0 :     if ( oAntenna2In[a] == -1 || exists<Int>( oAntenna2In[a], oAntenna2 ) ) {
    1937           0 :       uiNumAntenna2Out += 1;
    1938           0 :       oAntenna2Out.resize( uiNumAntenna2Out, true );
    1939           0 :       oAntenna2Out[uiNumAntenna2Out-1] = oAntenna2In[a];
    1940             :     }
    1941             :   }
    1942             : 
    1943           0 :   if ( uiNumAntenna2Out == 0 ) {
    1944           0 :     success = false;
    1945           0 :     return success;
    1946             :   }
    1947             : 
    1948             : 
    1949             :   // Return true
    1950             : 
    1951           0 :   success = true;
    1952             : 
    1953           0 :   return success;
    1954             : 
    1955             : }
    1956             : 
    1957             : // -----------------------------------------------------------------------------
    1958             : 
    1959             : /*
    1960             : 
    1961             : CalAnalysis::timeGet
    1962             : 
    1963             : Description:
    1964             : ------------
    1965             : This member function gets the times from the new format calibration table.
    1966             : 
    1967             : Inputs:
    1968             : -------
    1969             : oTableName - This reference to a String instance contains the new format
    1970             :              calibration table name.
    1971             : 
    1972             : Outputs:
    1973             : --------
    1974             : The Vector<Double> instance containing the times, returned via
    1975             : the function value.
    1976             : 
    1977             : Modification history:
    1978             : ---------------------
    1979             : 2012 Apr 04 - Nick Elias, NRAO
    1980             :               Initial version.
    1981             : 
    1982             : */
    1983             : 
    1984             : // -----------------------------------------------------------------------------
    1985             : 
    1986           0 : Vector<Double> CalAnalysis::timeGet( const String& oTableName ) {
    1987             : 
    1988             :   // Create a temporary new format calibration table instance
    1989             : 
    1990           0 :   Table oTable( oTableName, Table::Old );
    1991           0 :   ScalarColumn<Double> oROSC( oTable, String("TIME") );
    1992             : 
    1993             : 
    1994             :   // Get the sorted and unique time stamps
    1995             : 
    1996           0 :   Vector<Double> oTimeTemp;
    1997           0 :   oROSC.getColumn( oTimeTemp, true );
    1998             : 
    1999           0 :   Vector<Double> timev( 0 );
    2000           0 :   unique<Double>( oTimeTemp, timev );
    2001             : 
    2002             : 
    2003             :   // Return the time stamps
    2004             : 
    2005           0 :   return timev;
    2006             : 
    2007           0 : }
    2008             : 
    2009             : // -----------------------------------------------------------------------------
    2010             : 
    2011             : /*
    2012             : 
    2013             : CalAnalysis::timeSet
    2014             : 
    2015             : Description:
    2016             : ------------
    2017             : This member function sets the times private variables.
    2018             : 
    2019             : Inputs:
    2020             : -------
    2021             : oTimeIn - This reference to a Vector<Double> instance contains the times.
    2022             : 
    2023             : Outputs:
    2024             : --------
    2025             : None.
    2026             : 
    2027             : Modification history:
    2028             : ---------------------
    2029             : 2012 Apr 04 - Nick Elias, NRAO
    2030             :               Initial version.
    2031             : 
    2032             : */
    2033             : 
    2034             : // -----------------------------------------------------------------------------
    2035             : 
    2036           0 : void CalAnalysis::timeSet( const Vector<Double>& oTimeIn ) {
    2037             : 
    2038             :   // Set the number of times and times and return
    2039             : 
    2040           0 :   uiNumTime = oTimeIn.nelements();
    2041           0 :   oTime = Vector<Double>( oTimeIn.copy() );
    2042             : 
    2043           0 :   return;
    2044             : 
    2045             : }
    2046             : 
    2047             : // -----------------------------------------------------------------------------
    2048             : 
    2049             : /*
    2050             : 
    2051             : CalAnalysis::timeCheck
    2052             : 
    2053             : Description:
    2054             : ------------
    2055             : This member function checks the time range and returns the corresponding time
    2056             : vector.
    2057             : 
    2058             : Inputs:
    2059             : -------
    2060             : dStartTimeIn - This reference to a Double variable contains the start time.
    2061             : dStopTimeIn  - This reference to a Double variable contains the stop time.
    2062             : 
    2063             : Outputs:
    2064             : --------
    2065             : dStartTimeOut - This reference to a Double variable contains the start time.
    2066             : dStopTimeOut  - This reference to a Double variable contains the stop time.
    2067             : oTimeOut      - This reference to the Vector<Double> instance containing the
    2068             :                 time stamps.
    2069             : The Bool variable containing the check boolean, returned via
    2070             : the function value.
    2071             : 
    2072             : Modification history:
    2073             : ---------------------
    2074             : 2012 Jan 20 - Nick Elias, NRAO
    2075             :               Initial version.
    2076             : 2012 May 06 - Nick Elias, NRAO
    2077             :               Output start and stop times added.
    2078             : 
    2079             : */
    2080             : 
    2081             : // -----------------------------------------------------------------------------
    2082             : 
    2083           0 : Bool CalAnalysis::timeCheck( const Double& dStartTimeIn,
    2084             :     const Double& dStopTimeIn, Double& dStartTimeOut, Double& dStopTimeOut,
    2085             :     Vector<Double>& oTimeOut ) const {
    2086             : 
    2087             :   // Declare the success boolean
    2088             : 
    2089           0 :   Bool success( false );
    2090             : 
    2091             : 
    2092             :   // Check the start and stop times
    2093             : 
    2094           0 :   if ( dStartTimeIn > dStopTimeIn ) {
    2095           0 :     success = false;
    2096           0 :     return success;
    2097             :   }
    2098             : 
    2099           0 :   if ( dStartTimeIn > oTime[uiNumTime-1] ) {
    2100           0 :     success = false;
    2101           0 :     return success;
    2102             :   }
    2103             : 
    2104           0 :   if ( dStopTimeIn < oTime[0] ) {
    2105           0 :     success = false;
    2106           0 :     return success;
    2107             :   }
    2108             : 
    2109             : 
    2110             :   // Get the unique time values and the new start and stop times
    2111             : 
    2112           0 :   uInt uiNumTimeOut = 0;
    2113           0 :   oTimeOut.resize();
    2114             : 
    2115           0 :   for ( uInt t=0; t<uiNumTime; t++ ) {
    2116           0 :     if ( oTime[t] >= dStartTimeIn && oTime[t] <= dStopTimeIn ) {
    2117           0 :       oTimeOut.resize( ++uiNumTimeOut, true );
    2118           0 :       oTimeOut[uiNumTimeOut-1] = oTime[t];
    2119             :     }
    2120             :   }
    2121             : 
    2122           0 :   if ( oTimeOut.nelements() == 0 ) {
    2123           0 :     success = false;
    2124           0 :     return success;
    2125             :   }
    2126             : 
    2127           0 :   dStartTimeOut = min( oTimeOut );
    2128           0 :   dStopTimeOut = max( oTimeOut );
    2129             : 
    2130             : 
    2131             :   // Return true
    2132             : 
    2133           0 :   success = true;
    2134             : 
    2135           0 :   return success;
    2136             : 
    2137             : }
    2138             : 
    2139             : // -----------------------------------------------------------------------------
    2140             : 
    2141             : /*
    2142             : 
    2143             : CalAnalysis::feedGet
    2144             : 
    2145             : Description:
    2146             : ------------
    2147             : This member function gets the feeds from the new format calibration table.
    2148             : 
    2149             : NB: If the number of feeds in the column is a function of row, this function
    2150             : will fail.
    2151             : 
    2152             : Inputs:
    2153             : -------
    2154             : oTableName - This reference to a String instance contains the new format
    2155             :              calibration table name.
    2156             : 
    2157             : Outputs:
    2158             : --------
    2159             : The Vector<String> instance containing the feeds, returned via
    2160             : the function value.
    2161             : 
    2162             : Modification history:
    2163             : ---------------------
    2164             : 2012 Apr 04 - Nick Elias, NRAO
    2165             :               Initial version.
    2166             : 2012 May 02 - Nick Elias, NRAO
    2167             :               The new format calibration table iterator is no longer used.  A
    2168             :               call to the main table is now used instead.
    2169             : 
    2170             : */
    2171             : 
    2172             : // -----------------------------------------------------------------------------
    2173             : 
    2174           0 : Vector<String> CalAnalysis::feedGet( const String& oTableName ) {
    2175             : 
    2176             :   // Get the number of feeds from the new format calibration table
    2177             : 
    2178           0 :   Table oTable( oTableName, Table::Old );
    2179             : 
    2180           0 :   Array<Float> oParamErrCell0;
    2181             : 
    2182             :   try {
    2183             : 
    2184           0 :     ArrayColumn<Float> oROAC( oTable, String("PARAMERR") );
    2185             : 
    2186           0 :     oParamErrCell0.resize( oROAC(0).shape() );
    2187           0 :     oParamErrCell0 = oROAC( 0 );
    2188             : 
    2189           0 :   }
    2190             : 
    2191           0 :   catch ( AipsError oAipsError ) {
    2192           0 :     throw( oAipsError );
    2193           0 :   }
    2194             : 
    2195             : 
    2196             :   // Set the feeds
    2197             : 
    2198           0 :   uInt uiNumFeedTemp = oParamErrCell0.shape()[0];
    2199           0 :   Vector<String> feed( uiNumFeedTemp, "" );
    2200             : 
    2201           0 :   if ( uiNumFeedTemp == 1 ) {
    2202           0 :     feed[0] = "S";
    2203             :   } else {
    2204           0 :     if ( polBasisGet(oTableName) == "L" ) {
    2205           0 :       feed[0] = "X";
    2206           0 :       feed[1] = "Y";
    2207           0 :     } else if ( polBasisGet(oTableName) == "R" ) {
    2208           0 :       feed[0] = "R";
    2209           0 :       feed[1] = "L";
    2210             :     } else {
    2211           0 :       feed[0] = "1";
    2212           0 :       feed[1] = "2";
    2213             :     }
    2214             :   }
    2215             : 
    2216             : 
    2217             :   // Return the feeds
    2218             : 
    2219           0 :   return feed;
    2220             : 
    2221           0 : }
    2222             : 
    2223             : // -----------------------------------------------------------------------------
    2224             : 
    2225             : /*
    2226             : 
    2227             : CalAnalysis::feedSet
    2228             : 
    2229             : Description:
    2230             : ------------
    2231             : This member function sets the feeds private variables.
    2232             : 
    2233             : Inputs:
    2234             : -------
    2235             : oFeedIn - This reference to a Vector<String> instance contains the feeds.
    2236             : 
    2237             : Outputs:
    2238             : --------
    2239             : None.
    2240             : 
    2241             : Modification history:
    2242             : ---------------------
    2243             : 2012 Apr 04 - Nick Elias, NRAO
    2244             :               Initial version.
    2245             : 
    2246             : */
    2247             : 
    2248             : // -----------------------------------------------------------------------------
    2249             : 
    2250           0 : void CalAnalysis::feedSet( const Vector<String>& oFeedIn ) {
    2251             : 
    2252             :   // Set the number of feeds and feeds and return
    2253             : 
    2254           0 :   uiNumFeed = oFeedIn.nelements();
    2255           0 :   oFeed = Vector<String>( oFeedIn.copy() );
    2256             : 
    2257           0 :   return;
    2258             : 
    2259             : }
    2260             : 
    2261             : // -----------------------------------------------------------------------------
    2262             : 
    2263             : /*
    2264             : 
    2265             : CalAnalysis::feedCheck
    2266             : 
    2267             : Description:
    2268             : ------------
    2269             : This member function checks the input feed vector and returns the fixed feed
    2270             : vector.
    2271             : 
    2272             : Inputs:
    2273             : -------
    2274             : oFeedIn - This reference to a Vector<String> instance contains the feeds ("R"
    2275             :           and "L" for circular, "X" and "Y" for linear).
    2276             : 
    2277             : Outputs:
    2278             : --------
    2279             : oFeedOut - This reference to the Vector<String> instance contains the checked
    2280             :            and fixed feeds.
    2281             : The Bool variable containing the check boolean, returned via
    2282             : the function value.
    2283             : 
    2284             : Modification history:
    2285             : ---------------------
    2286             : 2012 Jan 20 - Nick Elias, NRAO
    2287             :               Initial version.
    2288             : 2012 Mar 13 - Nick Elias, NRAO
    2289             :               Now checking for null.
    2290             : 
    2291             : */
    2292             : 
    2293             : // -----------------------------------------------------------------------------
    2294             : 
    2295           0 : Bool CalAnalysis::feedCheck( const Vector<String>& oFeedIn,
    2296             :     Vector<String>& oFeedOut ) const {
    2297             : 
    2298             :   // Declare the success boolean
    2299             : 
    2300           0 :   Bool success( false );
    2301             : 
    2302             : 
    2303             :   // Check the input feed values
    2304             : 
    2305           0 :   if ( oFeedIn.nelements() == 0 ) {
    2306           0 :     success = false;
    2307           0 :     return success;
    2308             :   }
    2309             : 
    2310           0 :   uInt uiNumFeedOut = 0;
    2311           0 :   oFeedOut.resize();
    2312             : 
    2313           0 :   for ( uInt f=0; f<oFeedIn.nelements(); f++ ) {
    2314           0 :     if ( exists<String>( oFeedIn[f], oFeed ) ) {
    2315           0 :       uiNumFeedOut += 1;
    2316           0 :       oFeedOut.resize( uiNumFeedOut, true );
    2317           0 :       oFeedOut[uiNumFeedOut-1] = oFeedIn[f];
    2318             :     }
    2319             :   }
    2320             : 
    2321           0 :   if ( uiNumFeedOut == 0 ) {
    2322           0 :     success = false;
    2323           0 :     return success;
    2324             :   }
    2325             : 
    2326             : 
    2327             :   // Get the unique feed vector
    2328             : 
    2329           0 :   oFeedOut.resize();
    2330           0 :   unique<String>( oFeedIn, oFeedOut );
    2331             : 
    2332           0 :   if ( oFeedOut.nelements() > 2 ) {
    2333           0 :     success = false;
    2334           0 :     return success;
    2335             :   }
    2336             : 
    2337           0 :   if ( oFeedOut.nelements() == 1 ) {
    2338           0 :     if ( oFeedOut[0] != "R" && oFeedOut[0] != "L" &&
    2339           0 :          oFeedOut[0] != "X" && oFeedOut[0] != "Y" &&
    2340           0 :          oFeedOut[0] != "1" && oFeedOut[0] != "2" && oFeedOut[0] != "S" ) {
    2341           0 :       success = false;
    2342           0 :       return success;
    2343             :     }
    2344             :   }
    2345             : 
    2346           0 :   if ( oFeedOut.nelements() == 2 ) {
    2347             : 
    2348           0 :     if ( oFeedOut[0] != "R" && oFeedOut[0] != "L" &&
    2349           0 :          oFeedOut[0] != "X" && oFeedOut[0] != "Y" &&
    2350           0 :          oFeedOut[0] != "1" && oFeedOut[0] != "2" ) {
    2351           0 :       success = false;
    2352           0 :       return success;
    2353             :     }
    2354             : 
    2355           0 :     if ( oFeedOut[1] != "R" && oFeedOut[1] != "L" &&
    2356           0 :          oFeedOut[1] != "X" && oFeedOut[1] != "Y" &&
    2357           0 :          oFeedOut[1] != "1" && oFeedOut[1] != "2" ) {
    2358           0 :       success = false;
    2359           0 :       return success;
    2360             :     }
    2361             : 
    2362           0 :     if ( oFeedOut[0] == "L" && oFeedOut[1] == "R" ) {
    2363           0 :       oFeedOut[0] = "R";
    2364           0 :       oFeedOut[1] = "L";
    2365             :     }
    2366             : 
    2367           0 :     if ( oFeedOut[0] == "Y" && oFeedOut[1] == "X" ) {
    2368           0 :       oFeedOut[0] = "X";
    2369           0 :       oFeedOut[1] = "Y";
    2370             :     }
    2371             : 
    2372           0 :     if ( oFeedOut[0] == "2" && oFeedOut[1] == "1" ) {
    2373           0 :       oFeedOut[0] = "1";
    2374           0 :       oFeedOut[1] = "2";
    2375             :     }
    2376             : 
    2377             :   }
    2378             : 
    2379             : 
    2380             :   // Return true
    2381             : 
    2382           0 :   success = true;
    2383             : 
    2384           0 :   return success;
    2385             : 
    2386             : }
    2387             : 
    2388             : // -----------------------------------------------------------------------------
    2389             : 
    2390             : /*
    2391             : 
    2392             : CalAnalysis::spwInfoGet
    2393             : 
    2394             : Description:
    2395             : ------------
    2396             : This member function gets the spectral window information from the new format
    2397             : calibration table.
    2398             : 
    2399             : Inputs:
    2400             : -------
    2401             : oTableName - This reference to a String instance contains the new format
    2402             :              calibration table name.
    2403             : 
    2404             : Outputs:
    2405             : --------
    2406             : The reference to the SPW_INFO instance containing the spws, returned via the
    2407             : function value.
    2408             : 
    2409             : Modification history:
    2410             : ---------------------
    2411             : 2012 Apr 17 - Nick Elias, NRAO
    2412             :               Initial version.
    2413             : 
    2414             : */
    2415             : 
    2416             : // -----------------------------------------------------------------------------
    2417             : 
    2418           0 : CalAnalysis::SPW_INFO& CalAnalysis::spwInfoGet( const String& oTableName ) {
    2419             : 
    2420             :   // Get the spectral window information and return it
    2421             : 
    2422             :   CalAnalysis::SPW_INFO* poSPWInfo;
    2423           0 :   poSPWInfo = new CalAnalysis::SPW_INFO( oTableName );
    2424             : 
    2425           0 :   return( *poSPWInfo );
    2426             : 
    2427             : }
    2428             : 
    2429             : // -----------------------------------------------------------------------------
    2430             : 
    2431             : /*
    2432             : 
    2433             : CalAnalysis::spwInfoSet
    2434             : 
    2435             : Description:
    2436             : ------------
    2437             : This member function sets the spectral window information private variables.
    2438             : 
    2439             : Inputs:
    2440             : -------
    2441             : oSPWInfoIn - This reference to the SPW_INFO instance contains the spectral
    2442             :              window information.
    2443             : 
    2444             : Outputs:
    2445             : --------
    2446             : None.
    2447             : 
    2448             : Modification history:
    2449             : ---------------------
    2450             : 2012 Apr 17 - Nick Elias, NRAO
    2451             :               Initial version.
    2452             : 
    2453             : */
    2454             : 
    2455             : // -----------------------------------------------------------------------------
    2456             : 
    2457           0 : void CalAnalysis::spwInfoSet( const CalAnalysis::SPW_INFO& oSPWInfoIn ) {
    2458             : 
    2459             :   // Set the spectral window information and return
    2460             : 
    2461           0 :   oSPWInfo = CalAnalysis::SPW_INFO( oSPWInfoIn );
    2462             : 
    2463           0 :   return;
    2464             : 
    2465             : }
    2466             : 
    2467             : // -----------------------------------------------------------------------------
    2468             : 
    2469             : /*
    2470             : 
    2471             : CalAnalysis::statsCheckInput
    2472             : 
    2473             : Description:
    2474             : ------------
    2475             : This member function checks and fixes (if possible) the inputs to the
    2476             : CalAnalysis::stats<T>() member function.
    2477             : 
    2478             : Inputs:
    2479             : -------
    2480             : oInputIn - This reference to an INPUT instance contains the inputs to the
    2481             : CalAnalysis::stats<T>() member function.
    2482             : 
    2483             : Outputs:
    2484             : --------
    2485             : oInputOut - This reference to an INPUT instance contains the checked and fixed
    2486             :             inputs to the CalAnalysis::stats<T>() member function.
    2487             : The Bool variable containing the check boolean, returned via
    2488             : the function value.
    2489             : 
    2490             : Modification history:
    2491             : ---------------------
    2492             : 2012 Apr 27 - Nick Elias, NRAO
    2493             :               Initial version.
    2494             : 
    2495             : */
    2496             : 
    2497             : // -----------------------------------------------------------------------------
    2498             : 
    2499           0 : Bool CalAnalysis::statsCheckInput( const CalAnalysis::INPUT& oInputIn,
    2500             :     CalAnalysis::INPUT& oInputOut ) {
    2501             : 
    2502             :   // Declare the success boolean
    2503             : 
    2504           0 :   Bool success( false );
    2505             : 
    2506             : 
    2507             :   // Check the fields and create a new field vector
    2508             : 
    2509           0 :   if ( !fieldCheck( oInputIn.oField, oInputOut.oField ) ) {
    2510           0 :     LogIO log( LogOrigin( "CalAnalysis", "statsCheckInput()", WHERE ) );
    2511           0 :     log << LogIO::WARN << "One or more invalid fields" << LogIO::POST;
    2512           0 :     success = false;
    2513           0 :     return success;
    2514           0 :   }
    2515             : 
    2516             : 
    2517             :   // Check the antennas and create the new antenna vectors
    2518             : 
    2519           0 :   if ( !antenna1Check( oInputIn.oAntenna1, oInputOut.oAntenna1 ) ) {
    2520           0 :     LogIO log( LogOrigin( "CalAnalysis", "statsCheckInput()", WHERE ) );
    2521           0 :     log << LogIO::WARN << "One or more invalid antenna 1" << LogIO::POST;
    2522           0 :     success = false;
    2523           0 :     return success;
    2524           0 :   }
    2525             : 
    2526           0 :   if ( !antenna2Check( oInputIn.oAntenna2, oInputOut.oAntenna2 ) ) {
    2527           0 :     LogIO log( LogOrigin( "CalAnalysis", "statsCheckInput<T>()", WHERE ) );
    2528           0 :     log << LogIO::WARN << "One or more invalid antenna 2" << LogIO::POST;
    2529           0 :     success = false;
    2530           0 :     return success;
    2531           0 :   }
    2532             : 
    2533             : 
    2534             :   // Check the time range and create the corresponding time vector
    2535             : 
    2536           0 :   Bool bTimeCheck = timeCheck( oInputIn.dStartTime, oInputIn.dStopTime,
    2537           0 :       oInputOut.dStartTime, oInputOut.dStopTime, oInputOut.oTime );
    2538             : 
    2539           0 :   if ( !bTimeCheck ) {
    2540           0 :     LogIO log( LogOrigin( "CalAnalysis", "statsCheckInput<T>()", WHERE ) );
    2541           0 :     log << LogIO::WARN << "Invalid start and/or stop times" << LogIO::POST;
    2542           0 :     success = false;
    2543           0 :     return success;
    2544           0 :   }
    2545             : 
    2546             : 
    2547             :   // Check the feeds and create the new feed vector
    2548             : 
    2549           0 :   if ( !feedCheck( oInputIn.oFeed, oInputOut.oFeed ) ) {
    2550           0 :     LogIO log( LogOrigin( "CalAnalysis", "statsCheckInput<T>()", WHERE ) );
    2551           0 :     log << LogIO::WARN << "Invalid feed(s)" << LogIO::POST;
    2552           0 :     success = false;
    2553           0 :     return success;
    2554           0 :   }
    2555             : 
    2556             : 
    2557             :   // Check the spectral window info and create the frequency vector
    2558             : 
    2559           0 :   Vector<uInt> oSPWOld( oInputIn.oSPW );
    2560           0 :   Vector<Vector<uInt> > oChannelOld( oInputIn.oChannel );
    2561             : 
    2562           0 :   Vector<uInt> oSPWNew;
    2563           0 :   Vector<Vector<uInt> > oChannelNew;
    2564             : 
    2565           0 :   Bool bSPWCheck = oSPWInfo.spwInfoCheck( oInputIn.oSPW, oInputIn.oChannel,
    2566           0 :       oInputOut.oSPW, oInputOut.oChannel );
    2567             : 
    2568           0 :   if ( !bSPWCheck ) {
    2569           0 :     LogIO log( LogOrigin( "CalAnalysis", "statsCheckInput<T>()", WHERE ) );
    2570           0 :     log << LogIO::WARN << "Invalid spectral window information" << LogIO::POST;
    2571           0 :     success = false;
    2572           0 :     return success;
    2573           0 :   }
    2574             : 
    2575             : 
    2576             :   // Check the user-defined iteration axis
    2577             : 
    2578           0 :   if ( oInputIn.eAxisIterUserID != CalStats::FREQUENCY &&
    2579           0 :        oInputIn.eAxisIterUserID != CalStats::TIME ) {
    2580           0 :     LogIO log( LogOrigin( "CalAnalysis", "statsCheckInput<T>()", WHERE ) );
    2581             :     log << LogIO::WARN << "User-defined iteration axis must be frequency/time"
    2582           0 :         << LogIO::POST;
    2583           0 :     success = false;
    2584           0 :     return success;
    2585           0 :   }
    2586             : 
    2587           0 :   oInputOut.eAxisIterUserID = oInputIn.eAxisIterUserID;
    2588             : 
    2589             : 
    2590             :   // Check the RAP (real, amplitude, phase) parameter
    2591             : 
    2592           0 :   if ( oInputIn.eRAP != CalAnalysis::REAL &&
    2593           0 :        oInputIn.eRAP != CalAnalysis::AMPLITUDE &&
    2594           0 :        oInputIn.eRAP != CalAnalysis::PHASE ) {
    2595           0 :     LogIO log( LogOrigin( "CalAnalysis", "statsCheckInput<T>()", WHERE ) );
    2596           0 :     log << LogIO::WARN << "Invalid RAP parameter" << LogIO::POST;
    2597           0 :     success = false;
    2598           0 :     return success;
    2599           0 :   }
    2600             : 
    2601           0 :   oInputOut.eRAP = oInputIn.eRAP;
    2602             : 
    2603             : 
    2604             :   // Set the normalization and unwrap booleans
    2605             : 
    2606           0 :   oInputOut.bNorm = oInputIn.bNorm;
    2607             : 
    2608           0 :   oInputOut.bUnwrap = oInputIn.bUnwrap;
    2609             : 
    2610             : 
    2611             :   // Check the maximum phase jump parameter
    2612             : 
    2613           0 :   if ( oInputIn.dJumpMax < 0.0 ) {
    2614           0 :     LogIO log( LogOrigin( "CalAnalysis", "statsCheckInput<T>()", WHERE ) );
    2615           0 :     log << LogIO::WARN << "Invalid maximum jump parameter" << LogIO::POST;
    2616           0 :     success = false;
    2617           0 :     return success;
    2618           0 :   }
    2619             : 
    2620           0 :   oInputOut.dJumpMax = oInputIn.dJumpMax;
    2621             : 
    2622             : 
    2623             :   // Return true
    2624             : 
    2625           0 :   success = true;
    2626             : 
    2627           0 :   return success;
    2628             : 
    2629           0 : }
    2630             : 
    2631             : // -----------------------------------------------------------------------------
    2632             : 
    2633             : /*
    2634             : 
    2635             : CalAnalysis::getGroup
    2636             : 
    2637             : Description:
    2638             : ------------
    2639             : This member function gets input selected rows from a new format calibration
    2640             : table and groups them according to unique (field,antenna1,antenna2).
    2641             : 
    2642             : NB: Each element of the output Vector<T>() instances corresponds to a group.
    2643             : 
    2644             : NB: Each group has a vector of unique times and frequencies (which are not
    2645             : necessarily unique).
    2646             : 
    2647             : NB: Each group has data cubes, which are dimensioned feed x frequency x time.
    2648             : Each cube can have data from multiple rows, depending on the input elections.
    2649             : E.g., channels from multiple spectral windows are concatenated in the data
    2650             : cubes.
    2651             : 
    2652             : NB: The float parameter cube is empty for a new format calibration table with
    2653             : complex gains.  Conversely, the complex parameter is empty for a new format
    2654             : calibration table wth real values.
    2655             : 
    2656             : NB: Sometimes the cubes cannot be completely filled because of the shape of the
    2657             : new format calibration table.  In this case, the empty cube elements are set to
    2658             : zero and the corresponding flags set to true.
    2659             : 
    2660             : Inputs:
    2661             : -------
    2662             : oNCT             - This NewCalTable instance contains the new format calibration
    2663             :                    table.
    2664             : oInput           - This INPUT instance contains the input selections.
    2665             : oFieldGroup      - This Vector<uInt> instance contains the fields for each
    2666             :                    group.
    2667             : oAntenna1Group   - This Vector<uInt> instance contains the antenna 1 for each
    2668             :                    group.
    2669             : oAntenna2Group   - This Vector<Int> instance contains the antenna 2 for each
    2670             :                    group.
    2671             : oTimeUniqueGroup - This Vector<Vector<Double> > instance contains the unique
    2672             :                    times for each group.
    2673             : oFreqGroup       - This Vector<Vector<Double> >instance contains the frequencies
    2674             :                    for each group.  They can come from multiple spectral windows
    2675             :                    (which are in different rows).
    2676             : 
    2677             : Outputs:
    2678             : --------
    2679             : oCParamGroup   - This Vector<Cube<DComplex> > instance contains the complex
    2680             :                  parameters.  This instance is empty for new format calibration
    2681             :                  tables with real parameters.
    2682             : oFParamGroup   - This Vector<Cube<Double> > instance contains the real
    2683             :                  parameters.  This instance is empty for new format calibration
    2684             :                  tables with complex parameters.
    2685             : oParamErrGroup - This Vector<Cube<Double> > instance contains the parameter
    2686             :                  errors.
    2687             : oFlagGroup     - This Vector<Cube<Bool> > instance contains the flags.
    2688             : The Bool variable containing the check boolean, returned via
    2689             : the function value.
    2690             : 
    2691             : Modification history:
    2692             : ---------------------
    2693             : 2012 May 06 - Nick Elias, NRAO
    2694             :               Initial version.
    2695             : 
    2696             : */
    2697             : 
    2698             : // -----------------------------------------------------------------------------
    2699             : 
    2700           0 : Bool CalAnalysis::getGroup( const NewCalTable& oNCT,
    2701             :     const CalAnalysis::INPUT& oInput, Vector<uInt>& oFieldGroup,
    2702             :     Vector<uInt>& oAntenna1Group, Vector<Int>& oAntenna2Group,
    2703             :     Vector<Vector<Double> >& oTimeUniqueGroup,
    2704             :     Vector<Vector<Double> >& oFreqGroup, Vector<Cube<DComplex> >& oCParamGroup,
    2705             :     Vector<Cube<Double> >& oFParamGroup, Vector<Cube<Double> >& oParamErrGroup,
    2706             :     Vector<Cube<Bool> >& oFlagGroup ) const {
    2707             : 
    2708             :   // Declare the success boolean
    2709             : 
    2710           0 :   Bool success( false );
    2711             : 
    2712             : 
    2713             :   // Get the selected rows
    2714             : 
    2715           0 :   Vector<uInt> oRowSelect;
    2716             : 
    2717           0 :   if ( !rowSelect( oNCT, oInput, oRowSelect ) ) {
    2718           0 :     LogIO log( LogOrigin( "CalAnalysis", "getGroup()", WHERE ) );
    2719           0 :     log << LogIO::WARN << "No matching rows selected" << LogIO::POST;
    2720           0 :     success = false;
    2721           0 :     return success;
    2722           0 :   }
    2723             : 
    2724             : 
    2725             :   // Group the selected rows according to unique combinations of field, antenna
    2726             :   // 1, and antenna 2
    2727             : 
    2728           0 :   Vector<Vector<uInt> > oRowGroup;
    2729             : 
    2730           0 :   Vector<Vector<uInt> > oSPWGroup;
    2731           0 :   Vector<Vector<uInt> > oSPWUniqueGroup;
    2732             : 
    2733           0 :   Vector<Vector<Double> > oTimeGroup;
    2734             : 
    2735           0 :   Bool bRowGroup = rowGroup( oNCT, oRowSelect, oRowGroup, oFieldGroup,
    2736             :     oAntenna1Group, oAntenna2Group, oSPWGroup, oSPWUniqueGroup, oTimeGroup,
    2737             :     oTimeUniqueGroup );
    2738             : 
    2739           0 :   if ( !bRowGroup ) {
    2740           0 :     LogIO log( LogOrigin( "CalAnalysis", "getGroup()", WHERE ) );
    2741           0 :     log << LogIO::WARN << "Cannot group the data" << LogIO::POST;
    2742           0 :     success = false;
    2743           0 :     return success;
    2744           0 :   }
    2745             : 
    2746             : 
    2747             :   // Get the frequency vector, start channel vector, and relative channel vector
    2748             :   // for each group
    2749             : 
    2750           0 :   Bool bFreqGroup = freqGroup( oInput, oSPWUniqueGroup, oFreqGroup );
    2751             : 
    2752           0 :   if ( !bFreqGroup ) {
    2753           0 :     LogIO log( LogOrigin( "CalAnalysis", "getGroup()", WHERE ) );
    2754           0 :     log << LogIO::WARN << "Cannot group frequencies" << LogIO::POST;
    2755           0 :     success = false;
    2756           0 :     return success;
    2757           0 :   }
    2758             : 
    2759             : 
    2760             :   // Get the cubes for each group
    2761             : 
    2762           0 :   Bool bCubeGroup = cubeGroup( oNCT, oInput, oRowGroup, oSPWGroup,
    2763             :       oSPWUniqueGroup, oTimeGroup, oTimeUniqueGroup, oFreqGroup, oCParamGroup,
    2764             :       oFParamGroup, oParamErrGroup, oFlagGroup );
    2765             : 
    2766           0 :   if ( !bCubeGroup ) {
    2767           0 :     LogIO log( LogOrigin( "CalAnalysis", "getGroup()", WHERE ) );
    2768           0 :     log << LogIO::WARN << "Cannot group cubes" << LogIO::POST;
    2769           0 :     success = false;
    2770           0 :     return success;
    2771           0 :   }
    2772             : 
    2773             : 
    2774             :   // Return true
    2775             : 
    2776           0 :   success = true;
    2777             : 
    2778           0 :   return success;
    2779             : 
    2780           0 : }
    2781             : 
    2782             : // -----------------------------------------------------------------------------
    2783             : 
    2784             : /*
    2785             : 
    2786             : CalAnalysis::rowSelect
    2787             : 
    2788             : Description:
    2789             : ------------
    2790             : This member function returns the rows selected by the input parameters.
    2791             : 
    2792             : Inputs:
    2793             : -------
    2794             : oNCT   - This NewCalTable instance contains the new format calibration table.
    2795             : oInput - This INPUT instance contains the input selections.
    2796             : 
    2797             : Outputs:
    2798             : --------
    2799             : oRowSelect - This Vector<uInt> instance contains the row numbers selected by the
    2800             :              inputs.
    2801             : The Bool variable containing the check boolean, returned via
    2802             : the function value.
    2803             : 
    2804             : Modification history:
    2805             : ---------------------
    2806             : 2012 May 06 - Nick Elias, NRAO
    2807             :               Initial version.
    2808             : 
    2809             : */
    2810             : 
    2811             : // -----------------------------------------------------------------------------
    2812             : 
    2813           0 : Bool CalAnalysis::rowSelect( const NewCalTable& oNCT,
    2814             :     const CalAnalysis::INPUT& oInput, Vector<uInt>& oRowSelect ) const {
    2815             : 
    2816             :   // Declare the success boolean
    2817             : 
    2818           0 :   Bool success( false );
    2819             : 
    2820             : 
    2821             :   // Create the column accessors
    2822             : 
    2823           0 :   ScalarColumn<Int> oFieldCol( oNCT, String("FIELD_ID") );
    2824           0 :   ScalarColumn<Int> oAntenna1Col( oNCT, String("ANTENNA1") );
    2825           0 :   ScalarColumn<Int> oAntenna2Col( oNCT, String("ANTENNA2") );
    2826           0 :   ScalarColumn<Int> oSPWCol( oNCT, String("SPECTRAL_WINDOW_ID") );
    2827           0 :   ScalarColumn<Double> oTimeCol( oNCT, String("TIME") );
    2828             : 
    2829             : 
    2830             :   // Initialize the number of rows in the new format calibration table, the
    2831             :   // number of selected rows, and the Vector<uInt> instance containing the
    2832             :   // selected rows
    2833             : 
    2834           0 :   uInt uiNumRow = oNCT.nrow();
    2835           0 :   uInt uiNumRowSelect = 0;
    2836             : 
    2837           0 :   oRowSelect.resize();
    2838             : 
    2839             : 
    2840             :   // Loop over rows and record the selected ones
    2841             : 
    2842           0 :   for ( uInt r=0; r<uiNumRow; r++ ) {
    2843             : 
    2844             :     // Get the information from each column for the present row
    2845           0 :     uInt uiField = (uInt) oFieldCol( r );
    2846           0 :     uInt uiAntenna1 = (uInt) oAntenna1Col( r );
    2847           0 :     Int iAntenna2 = oAntenna2Col( r );
    2848           0 :     uInt uiSPW = (uInt) oSPWCol( r );
    2849           0 :     Double dTime = (Double) oTimeCol( r );
    2850             : 
    2851             :     // Are all of the quantities in the present row present in the input
    2852             :     // parameters?  If not, don't do anything and increment the loop
    2853           0 :     if ( !exists<uInt>( uiField, oInput.oField ) ) continue;
    2854           0 :     if ( !exists<uInt>( uiAntenna1, oInput.oAntenna1 ) ) continue;
    2855           0 :     if ( !exists<Int>( iAntenna2, oInput.oAntenna2 ) ) continue;
    2856           0 :     if ( !exists<uInt>( uiSPW, oInput.oSPW ) ) continue;
    2857           0 :     if ( !exists<Double>( dTime, oInput.oTime ) ) continue;
    2858             : 
    2859             :     // Record the selected row
    2860           0 :     oRowSelect.resize( ++uiNumRowSelect, true );
    2861           0 :     oRowSelect[uiNumRowSelect-1] = r;
    2862             : 
    2863             :   }
    2864             : 
    2865             : 
    2866             :   // Were any rows found?  It not, return false
    2867             : 
    2868           0 :   if ( uiNumRowSelect == 0 ) {
    2869           0 :     success = false;
    2870           0 :     return success;
    2871             :   }
    2872             : 
    2873             : 
    2874             :   // Return true
    2875             : 
    2876           0 :   success = true;
    2877             : 
    2878           0 :   return success;
    2879             : 
    2880           0 : }
    2881             : 
    2882             : // -----------------------------------------------------------------------------
    2883             : 
    2884             : /*
    2885             : 
    2886             : CalAnalysis::rowGroup
    2887             : 
    2888             : Description:
    2889             : ------------
    2890             : This member function returns the row numbers, fields, antenna 1s, antenna 2s,
    2891             : spectral windows, unique spectral windows, times, and unique times grouped
    2892             : according to selected rows and input selection.
    2893             : 
    2894             : Inputs:
    2895             : -------
    2896             : oNCT       - This NewCalTable instance contains the new format calibration
    2897             :              table.
    2898             : oRowSelect - This Vector<uInt> instance contains the row numbers selected by the
    2899             :              inputs.
    2900             : 
    2901             : Outputs:
    2902             : --------
    2903             : oRowGroup        - This Vector<uInt> instance contains the row numbers for each
    2904             :                    group.
    2905             : oFieldGroup      - This Vector<uInt> instance contains the fields for each
    2906             :                    group.
    2907             : oAntenna1Group   - This Vector<uInt> instance contains the antenna 1 for each
    2908             :                    group.
    2909             : oAntenna2Group   - This Vector<Int> instance contains the antenna 2 for each
    2910             :                    group.
    2911             : oSPWGroup        - This Vector<Vector<uInt> > instance contains the spectral
    2912             :                    windows for each group.
    2913             : oSPWUniqueGroup  - This Vector<Vector<uInt> > instance contains the unique
    2914             :                    spectral windows for each group.
    2915             : oTimeGroup       - This Vector<Vector<Double> > instance contains the times for
    2916             :                    each group.
    2917             : oTimeUniqueGroup - This Vector<Vector<Double> > instance contains the unique
    2918             :                    times for each group.
    2919             : The Bool variable containing the check boolean, returned via
    2920             : the function value.
    2921             : 
    2922             : Modification history:
    2923             : ---------------------
    2924             : 2012 May 06 - Nick Elias, NRAO
    2925             :               Initial version.
    2926             : 
    2927             : */
    2928             : 
    2929             : // -----------------------------------------------------------------------------
    2930             : 
    2931           0 : Bool CalAnalysis::rowGroup( const NewCalTable& oNCT,
    2932             :     const Vector<uInt>& oRowSelect, Vector<Vector<uInt> >& oRowGroup,
    2933             :     Vector<uInt>& oFieldGroup, Vector<uInt>& oAntenna1Group,
    2934             :     Vector<Int>& oAntenna2Group, Vector<Vector<uInt> >& oSPWGroup,
    2935             :     Vector<Vector<uInt> >& oSPWUniqueGroup, Vector<Vector<Double> >& oTimeGroup,
    2936             :     Vector<Vector<Double> >& oTimeUniqueGroup ) const {
    2937             : 
    2938             :   // Declare the success boolean
    2939             : 
    2940           0 :   Bool success( false );
    2941             : 
    2942             : 
    2943             :   // If there are no rows, return false
    2944             : 
    2945           0 :   uInt uiNumRow = oRowSelect.nelements();
    2946             : 
    2947           0 :   if ( uiNumRow == 0 ) {
    2948           0 :     success = false;
    2949           0 :     return success;
    2950             :   }
    2951             : 
    2952             : 
    2953             :   // Create the column accessors
    2954             : 
    2955           0 :   ScalarColumn<Int> oFieldCol( oNCT, String("FIELD_ID") );
    2956           0 :   ScalarColumn<Int> oAntenna1Col( oNCT, String("ANTENNA1") );
    2957           0 :   ScalarColumn<Int> oAntenna2Col( oNCT, String("ANTENNA2") );
    2958           0 :   ScalarColumn<Int> oSPWCol( oNCT, String("SPECTRAL_WINDOW_ID") );
    2959           0 :   ScalarColumn<Double> oTimeCol( oNCT, String("TIME") );
    2960             : 
    2961             : 
    2962             :   // Initialize the number of groups according to unique values of
    2963             :   // (field,antenna1,antenna2) and the Vector<Vector<T> > instances containing
    2964             :   // the groups
    2965             : 
    2966           0 :   uInt uiNumGroup = 0;
    2967             : 
    2968           0 :   oRowGroup.resize( uiNumGroup, false );
    2969             : 
    2970           0 :   oFieldGroup.resize( uiNumGroup, false );
    2971           0 :   oAntenna1Group.resize( uiNumGroup, false );
    2972           0 :   oAntenna2Group.resize( uiNumGroup, false );
    2973             : 
    2974           0 :   oSPWGroup.resize( uiNumGroup, false );
    2975           0 :   oSPWUniqueGroup.resize( uiNumGroup, false );
    2976             : 
    2977           0 :   oTimeGroup.resize( uiNumGroup, false );
    2978           0 :   oTimeUniqueGroup.resize( uiNumGroup, false );
    2979             : 
    2980             : 
    2981             :   // Loop over the rows and form the groups
    2982             : 
    2983           0 :   for ( uInt r=0; r<uiNumRow; r++ ) {
    2984             : 
    2985             :     // Get the field, antenna 1, antenna2, spectral window, and time for the
    2986             :     // present row
    2987           0 :     uInt uiField = oFieldCol( oRowSelect[r] );
    2988           0 :     uInt uiAntenna1 = oAntenna1Col( oRowSelect[r] );
    2989           0 :     Int iAntenna2 = oAntenna2Col( oRowSelect[r] );
    2990           0 :     uInt uiSPW = oSPWCol( oRowSelect[r] );
    2991           0 :     Double dTime = oTimeCol( oRowSelect[r] );
    2992             : 
    2993             :     // Is this combination of field, antenna 1, and antenna 2 unique?  If so
    2994             :     // create a new group, otherwise record the existing group.
    2995             :     uInt g;
    2996           0 :     for ( g=0; g<uiNumGroup; g++ ) {
    2997           0 :       if ( uiField == oFieldGroup[g] && uiAntenna1 == oAntenna1Group[g] &&
    2998           0 :            iAntenna2 == oAntenna2Group[g] ) {
    2999           0 :         break;
    3000             :       }
    3001             :     }
    3002             : 
    3003           0 :     if ( uiNumGroup == 0 || g >= uiNumGroup ) { // New group
    3004             : 
    3005             :       // Increment the number of groups
    3006           0 :       uiNumGroup++;
    3007             : 
    3008             :       // Add the row to the new group
    3009           0 :       oRowGroup.resize( uiNumGroup, true );
    3010           0 :       oRowGroup[uiNumGroup-1].resize( 1, true );
    3011           0 :       oRowGroup[uiNumGroup-1][0] = oRowSelect[r];
    3012             : 
    3013             :       // Add the field to the new group
    3014           0 :       oFieldGroup.resize( uiNumGroup, true );
    3015           0 :       oFieldGroup[uiNumGroup-1] = uiField;
    3016             : 
    3017             :       // Add the antenna 1 to the new group
    3018           0 :       oAntenna1Group.resize( uiNumGroup, true );
    3019           0 :       oAntenna1Group[uiNumGroup-1] = uiAntenna1;
    3020             : 
    3021             :       // Add the antenna 2 to the new group
    3022           0 :       oAntenna2Group.resize( uiNumGroup, true );
    3023           0 :       oAntenna2Group[uiNumGroup-1] = iAntenna2;
    3024             : 
    3025             :       // Add the spectral window to the new group
    3026           0 :       oSPWGroup.resize( uiNumGroup, true );
    3027           0 :       oSPWGroup[uiNumGroup-1].resize( 1, true );
    3028           0 :       oSPWGroup[uiNumGroup-1][0] = uiSPW;
    3029             : 
    3030             :       // Add the time to the new group
    3031           0 :       oTimeGroup.resize( uiNumGroup, true );
    3032           0 :       oTimeGroup[uiNumGroup-1].resize( 1, true );
    3033           0 :       oTimeGroup[uiNumGroup-1][0] = dTime;
    3034             : 
    3035             :     } else { // Existing group
    3036             :  
    3037             :       // Increment the number of rows in the group
    3038           0 :       uInt uiNumRowGroup = oRowGroup[g].nelements() + 1;
    3039             : 
    3040             :       // Add the row to the group
    3041           0 :       oRowGroup[g].resize( uiNumRowGroup, true );
    3042           0 :       oRowGroup[g][uiNumRowGroup-1] = oRowSelect[r];
    3043             : 
    3044             :       // Add the spectral window to the group
    3045           0 :       oSPWGroup[g].resize( uiNumRowGroup, true );
    3046           0 :       oSPWGroup[g][uiNumRowGroup-1] = uiSPW;
    3047             : 
    3048             :       // Add the time to the group
    3049           0 :       oTimeGroup[g].resize( uiNumRowGroup, true );
    3050           0 :       oTimeGroup[g][uiNumRowGroup-1] = dTime;
    3051             : 
    3052             :     }
    3053             : 
    3054             :   }
    3055             : 
    3056             : 
    3057             :   // Create the unique sorted spectral window and time vectors for each group
    3058             : 
    3059           0 :   oSPWUniqueGroup.resize( uiNumGroup, false );
    3060           0 :   oTimeUniqueGroup.resize( uiNumGroup, false );
    3061             : 
    3062           0 :   for ( uInt g=0; g<uiNumGroup; g++ ) {
    3063           0 :     oSPWUniqueGroup[g].resize();
    3064           0 :     unique<uInt>( oSPWGroup[g], oSPWUniqueGroup[g] );
    3065           0 :     oTimeUniqueGroup[g].resize();
    3066           0 :     unique<Double>( oTimeGroup[g], oTimeUniqueGroup[g] );
    3067             :   }
    3068             : 
    3069             : 
    3070             :   // Return true
    3071             : 
    3072           0 :   success = true;
    3073             : 
    3074           0 :   return success;
    3075             : 
    3076           0 : }
    3077             : 
    3078             : // -----------------------------------------------------------------------------
    3079             : 
    3080             : /*
    3081             : 
    3082             : CalAnalysis::chanSPW
    3083             : 
    3084             : Description:
    3085             : ------------
    3086             : This member function maps the spectral windows to the input spectral windows (to
    3087             : get the correct channels) and forms the start channels so that spectral windows
    3088             : can be concatenated.
    3089             : 
    3090             : NB: The spectral windows must be unique and sorted.
    3091             : 
    3092             : Inputs:
    3093             : -------
    3094             : oSPW   - This Vector<uInt> instance contains the unique and sorted spectral
    3095             :          windows.
    3096             : oInput - This INPUT instance contains the input selections.
    3097             : 
    3098             : Outputs:
    3099             : --------
    3100             : oSPWMap    - This Vector<uInt> instance contains the mapped spectral windows.
    3101             : oChanStart - This Vector<uInt> instance contains the start channels.
    3102             : The Bool variable containing the check boolean, returned via
    3103             : the function value.
    3104             : 
    3105             : Modification history:
    3106             : ---------------------
    3107             : 2012 May 06 - Nick Elias, NRAO
    3108             :               Initial version.
    3109             : 
    3110             : */
    3111             : 
    3112             : // -----------------------------------------------------------------------------
    3113             : 
    3114           0 : Bool CalAnalysis::chanSPW( const Vector<uInt>& oSPW, const INPUT& oInput,
    3115             :     Vector<uInt>& oSPWMap, Vector<uInt>& oChanStart ) const {
    3116             : 
    3117             :   // Declare the success boolean
    3118             : 
    3119           0 :   Bool success( false );
    3120             : 
    3121             : 
    3122             :   // Initialize the number of spectral windows, the spectral window map and
    3123             :   // start instances
    3124             : 
    3125           0 :   uInt uiNumSPW = oSPW.nelements();
    3126             : 
    3127           0 :   oSPWMap.resize( uiNumSPW, false );
    3128           0 :   oChanStart.resize( uiNumSPW, false );
    3129             : 
    3130             : 
    3131             :   // Load the spectral window map
    3132             : 
    3133           0 :   for ( uInt s=0; s<uiNumSPW; s++ ) {
    3134           0 :     if ( !where( oSPW[s], oInput.oSPW, oSPWMap[s] ) ) {
    3135           0 :       success = false;
    3136           0 :       return success;
    3137             :     }
    3138             :   }
    3139             : 
    3140             : 
    3141             :   // Load the start channels
    3142             : 
    3143           0 :   oChanStart[0] = 0;
    3144           0 :   for ( uInt s=1; s<uiNumSPW; s++ ) {
    3145           0 :     oChanStart[s] = oChanStart[s-1];
    3146           0 :     oChanStart[s] += oInput.oChannel[oSPWMap[s-1]].nelements();
    3147             :   }
    3148             : 
    3149             : 
    3150             :   // Return true
    3151             : 
    3152           0 :   success = true;
    3153             : 
    3154           0 :   return success;
    3155             : 
    3156             : }
    3157             : 
    3158             : // -----------------------------------------------------------------------------
    3159             : 
    3160             : /*
    3161             : 
    3162             : CalAnalysis::freqGroup
    3163             : 
    3164             : Description:
    3165             : ------------
    3166             : This member function concatenates the frequencies from multiple spectral windows
    3167             : for each group.
    3168             : 
    3169             : Inputs:
    3170             : -------
    3171             : oInput          - This INPUT instance contains the input selections.
    3172             : oSPWUniqueGroup - This Vector<Vector<uInt> > instance contains the unique
    3173             :                   spectral windows for each group.
    3174             : 
    3175             : Outputs:
    3176             : --------
    3177             : oFreqGroup - This Vector<Vector<Double> >instance contains the frequencies (for
    3178             :              each group.  They can come from multiple spectral windows (which
    3179             :              are in different rows).
    3180             : The Bool variable containing the success boolean, returned via
    3181             : the function value.
    3182             : 
    3183             : Modification history:
    3184             : ---------------------
    3185             : 2012 May 06 - Nick Elias, NRAO
    3186             :               Initial version.
    3187             : 
    3188             : */
    3189             : 
    3190             : // -----------------------------------------------------------------------------
    3191             : 
    3192           0 : Bool CalAnalysis::freqGroup( const INPUT& oInput,
    3193             :     const Vector<Vector<uInt> >& oSPWUniqueGroup,
    3194             :     Vector<Vector<Double> >& oFreqGroup ) const {
    3195             : 
    3196             :   // Declare the success boolean
    3197             : 
    3198           0 :   Bool success = false;
    3199             : 
    3200             : 
    3201             :   // Create the instance for the spectral window subtable of the new format
    3202             :   // calibration table and the accessor instance for the CHAN_FREQ column
    3203             : 
    3204           0 :   Table oTableSPW( oCalName+String("/SPECTRAL_WINDOW"), Table::Old );
    3205             : 
    3206           0 :   ArrayColumn<Double> oChanFreqCol( oTableSPW, String("CHAN_FREQ") );
    3207             : 
    3208             : 
    3209             :   // Initialize the number of groups and the output instance
    3210             : 
    3211           0 :   uInt uiNumGroup = oSPWUniqueGroup.nelements();
    3212             : 
    3213           0 :   oFreqGroup.resize( uiNumGroup, false );
    3214             : 
    3215             : 
    3216             :   // Load the output instances
    3217             : 
    3218           0 :   for ( uInt g=0; g<uiNumGroup; g++ ) {
    3219             : 
    3220             :     // Get the start channels for all spectral windows in the group
    3221           0 :     Vector<uInt> oSPWMap;
    3222           0 :     Vector<uInt> oChanStart;
    3223           0 :     if ( !chanSPW( oSPWUniqueGroup[g], oInput, oSPWMap, oChanStart ) ) {
    3224           0 :       success = false;
    3225           0 :       return success;
    3226             :     }
    3227             : 
    3228           0 :     for ( uInt s=0; s<oSPWUniqueGroup[g].nelements(); s++ ) {
    3229             : 
    3230             :       // Get the number of channels for the mapped spectral window
    3231           0 :       uInt uiNumChannelInput = oInput.oChannel[oSPWMap[s]].nelements();
    3232             : 
    3233             :       // Resize the frequency vector for the group
    3234           0 :       oFreqGroup[g].resize( oChanStart[s]+uiNumChannelInput, true );
    3235             : 
    3236             :       // Get the channels for the group and spectral window from the spectral
    3237             :       // window subtable of the new format calibration table
    3238           0 :       Vector<Double> oFreqTemp( oChanFreqCol(oSPWUniqueGroup[g][s]) );
    3239             : 
    3240             :       // Load the frequency vector for the group
    3241           0 :       for ( uInt c=0; c<uiNumChannelInput; c++ ) {
    3242           0 :         uInt uiChanGroup = oChanStart[s] + c;
    3243           0 :         uInt uiChanTemp = oInput.oChannel[oSPWMap[s]][c];
    3244           0 :         oFreqGroup[g][uiChanGroup] = oFreqTemp[uiChanTemp];
    3245             :       }
    3246             : 
    3247           0 :     }
    3248             : 
    3249           0 :   }
    3250             : 
    3251             : 
    3252             :   // Return true
    3253             : 
    3254           0 :   success = true;
    3255             : 
    3256           0 :   return success;
    3257             : 
    3258           0 : }
    3259             : 
    3260             : // -----------------------------------------------------------------------------
    3261             : 
    3262             : /*
    3263             : 
    3264             : CalAnalysis::cubeGroup
    3265             : 
    3266             : Description:
    3267             : ------------
    3268             : This member function concatenates data from multiple rows into groups according
    3269             : to unique (field,antenna1,antenna2).
    3270             : 
    3271             : Inputs:
    3272             : -------
    3273             : oNCT             - This NewCalTable instance contains the new format calibration
    3274             :                    table.
    3275             : oInput           - This INPUT instance contains the input selections.
    3276             : oRowGroup        - This Vector<uInt> instance contains the row numbers for each
    3277             :                    group.
    3278             : oSPWGroup        - This Vector<Vector<uInt> > instance contains the spectral
    3279             :                    windows for each group.
    3280             : oSPWUniqueGroup  - This Vector<Vector<uInt> > instance contains the unique
    3281             :                    spectral windows for each group.
    3282             : oTimeGroup       - This Vector<Vector<Double> > instance contains the times for
    3283             :                    each group.
    3284             : oTimeUniqueGroup - This Vector<Vector<Double> > instance contains the unique
    3285             :                    times for each group.
    3286             : oFreqGroup       - This Vector<Vector<Double> >instance contains the frequencies
    3287             :                    for each group.  They can come from multiple spectral windows
    3288             :                    (which are in different rows).
    3289             : 
    3290             : Outputs:
    3291             : --------
    3292             : oCParamGroup   - This Vector<Cube<DComplex> > instance contains the complex
    3293             :                  parameters.  This instance is empty for new format calibration
    3294             :                  tables with real parameters.
    3295             : oFParamGroup   - This Vector<Cube<Double> > instance contains the real
    3296             :                  parameters.  This instance is empty for new format calibration
    3297             :                  tables with complex parameters.
    3298             : oParamErrGroup - This Vector<Cube<Double> > instance contains the parameter
    3299             :                  errors.
    3300             : oFlagGroup     - This Vector<Cube<Bool> > instance contains the flags.
    3301             : The Bool variable containing the check boolean, returned via
    3302             : the function value.
    3303             : 
    3304             : Modification history:
    3305             : ---------------------
    3306             : 2012 May 06 - Nick Elias, NRAO
    3307             :               Initial version.
    3308             : 
    3309             : */
    3310             : 
    3311             : // -----------------------------------------------------------------------------
    3312             : 
    3313           0 : Bool CalAnalysis::cubeGroup( const NewCalTable& oNCT, const INPUT& oInput,
    3314             :     const Vector<Vector<uInt> >& oRowGroup,
    3315             :     const Vector<Vector<uInt> >& oSPWGroup,
    3316             :     const Vector<Vector<uInt> >& oSPWUniqueGroup,
    3317             :     const Vector<Vector<Double> >& oTimeGroup,
    3318             :     const Vector<Vector<Double> >& oTimeUniqueGroup,
    3319             :     const Vector<Vector<Double> >& oFreqGroup,
    3320             :     Vector<Cube<DComplex> >& oCParamGroup, Vector<Cube<Double> >& oFParamGroup,
    3321             :     Vector<Cube<Double> >& oParamErrGroup,
    3322             :     Vector<Cube<Bool> >& oFlagGroup ) const {
    3323             : 
    3324             :   // Declare the success boolean
    3325             : 
    3326           0 :   Bool success( false );
    3327             : 
    3328             : 
    3329             :   // Create accessors for the CPARAM/FPARAM, PARAMERR, and FLAG columns
    3330             : 
    3331           0 :   ArrayColumn<Complex> poCParamCol;
    3332           0 :   ArrayColumn<Float> poFParamCol;
    3333             : 
    3334           0 :   if ( oParType == String("Complex") ) {
    3335           0 :     poCParamCol = ArrayColumn<Complex>( oNCT, String("CPARAM") );
    3336             :   } else {
    3337           0 :     poFParamCol = ArrayColumn<Float>( oNCT, String("FPARAM") );
    3338             :   }
    3339             : 
    3340           0 :   ArrayColumn<Float> oParamErrCol( oNCT, String("PARAMERR") );
    3341             : 
    3342           0 :   ArrayColumn<Bool> oFlagCol( oNCT, String("FLAG") );
    3343             : 
    3344             : 
    3345             :   // Initialize the number of groups and the output instances
    3346             : 
    3347           0 :   uInt uiNumGroup = oRowGroup.nelements();
    3348             : 
    3349           0 :   oCParamGroup.resize( uiNumGroup, false );
    3350           0 :   oFParamGroup.resize( uiNumGroup, false );
    3351           0 :   oParamErrGroup.resize( uiNumGroup, false );
    3352           0 :   oFlagGroup.resize( uiNumGroup, false );
    3353             : 
    3354             : 
    3355             :   // Load the output instances for each group
    3356             : 
    3357           0 :   for ( uInt g=0; g<uiNumGroup; g++ ) { // Loop over group
    3358             : 
    3359             :     // Get the spectral window maps and start channels for the group
    3360           0 :     Vector<uInt> oSPWMap;
    3361           0 :     Vector<uInt> oChanStart;
    3362           0 :     if ( !chanSPW( oSPWUniqueGroup[g], oInput, oSPWMap, oChanStart ) ) {
    3363           0 :       success = false;
    3364           0 :       return success;
    3365             :     }
    3366             : 
    3367             :     // Initialize the shape of the output instances for the group
    3368           0 :     uInt uiNumFreq = oFreqGroup[g].nelements();
    3369           0 :     uInt uiNumTimeUnique = oTimeUniqueGroup[g].nelements();
    3370           0 :     IPosition oShape( 3, uiNumFeed, uiNumFreq, uiNumTimeUnique );
    3371             : 
    3372             :     // Allocate the output instances for the group
    3373           0 :     oCParamGroup[g].resize( oShape, false );
    3374           0 :     oFParamGroup[g].resize( oShape, false );
    3375           0 :     oParamErrGroup[g].resize( oShape, false );
    3376           0 :     oFlagGroup[g].resize( oShape, false );
    3377             : 
    3378             :     // Initialize the output instances for the group
    3379           0 :     oCParamGroup[g] = DComplex( 0.0, 0.0 );
    3380           0 :     oFParamGroup[g] = 0.0;
    3381           0 :     oParamErrGroup[g] = 0.0;
    3382           0 :     oFlagGroup[g] = true;
    3383             : 
    3384             :     // Get the number of rows for the group
    3385           0 :     uInt uiNumRow = oRowGroup[g].nelements();
    3386             : 
    3387           0 :     for ( uInt r=0; r<uiNumRow; r++ ) { // Loop over rows for the group
    3388             : 
    3389             :       // Get the row number in the new format calibration table
    3390           0 :       uInt uiRow = oRowGroup[g][r];
    3391             : 
    3392             :       // Get the CPARAM or FPARAM cell from the new format calibration table
    3393           0 :       Array<Complex> oCParamCube;
    3394           0 :       Array<Float> oFParamCube;
    3395           0 :       if ( oParType == String("Complex") ) {
    3396           0 :         IPosition oShape( poCParamCol( uiRow ).shape() );
    3397           0 :         oCParamCube.resize( oShape, false );
    3398           0 :         oCParamCube = poCParamCol( uiRow );
    3399           0 :         oFParamCube = Array<Float>( oShape, 0.0F );
    3400           0 :       } else {
    3401           0 :         IPosition oShape( poFParamCol(uiRow).shape() );
    3402           0 :         oFParamCube.resize( oShape, false );
    3403           0 :         oFParamCube = poFParamCol( uiRow );
    3404           0 :         oCParamCube = Array<Complex>( oShape, Complex(0.0,0.0) );
    3405           0 :       }
    3406             : 
    3407             :       // Get the PARAMERR cell from the new format calibration table
    3408           0 :       Array<Float> oParamErrCube( oParamErrCol(uiRow).shape(), 0.0F );
    3409           0 :       oParamErrCube = oParamErrCol( uiRow );
    3410             : 
    3411             :       // Get the FLAG cell from the new format calibration table
    3412           0 :       Array<Bool> oFlagCube( oFlagCol(uiRow).shape(), false );
    3413           0 :       oFlagCube = oFlagCol( uiRow );
    3414             : 
    3415             :       // Map the spectral window
    3416           0 :       uInt s = 0;
    3417           0 :       if ( !where( oSPWGroup[g][r], oSPWUniqueGroup[g], s ) ) {
    3418           0 :         success = false;
    3419           0 :         return success;
    3420             :       }
    3421             : 
    3422             :       // Get the number of input channels and the channels for the mapped
    3423             :       // spectral window
    3424           0 :       uInt uiNumChannelC = oInput.oChannel[oSPWMap[s]].nelements();
    3425           0 :       Vector<uInt> oChannelC( oInput.oChannel[oSPWMap[s]] );
    3426             : 
    3427             :       // Map the time
    3428           0 :       uInt t = 0;
    3429           0 :       if ( !where( oTimeGroup[g][r], oTimeUniqueGroup[g], t ) ) {
    3430           0 :         success = false;
    3431           0 :         return success;
    3432             :       }
    3433             : 
    3434             :       // Map the cubes from the new format calibration tables to the output
    3435             :       // instances for each group
    3436           0 :       for ( uInt f=0; f<uiNumFeed; f++ ) { // Loop over feeds
    3437           0 :         for ( uInt c=0; c<uiNumChannelC; c++ ) { // Loop over channnels
    3438           0 :           IPosition oPosG( 3, f, oChanStart[s]+c, t );
    3439           0 :           IPosition oPosC( 2, f, oChannelC[c] );
    3440           0 :           oCParamGroup[g](oPosG) = (DComplex) oCParamCube(oPosC);
    3441           0 :           oFParamGroup[g](oPosG) = (Double) oFParamCube(oPosC);
    3442           0 :           oParamErrGroup[g](oPosG) = (Double) oParamErrCube(oPosC);
    3443           0 :           oFlagGroup[g](oPosG) = oFlagCube(oPosC);
    3444           0 :         }
    3445             :       }
    3446             : 
    3447           0 :     }
    3448             : 
    3449           0 :   }
    3450             : 
    3451             : 
    3452             :   // Return true
    3453             : 
    3454           0 :   success = true;
    3455             : 
    3456           0 :   return success;
    3457             : 
    3458           0 : }
    3459             : 
    3460             : // -----------------------------------------------------------------------------
    3461             : // End of CalAnalysis private member functions
    3462             : // -----------------------------------------------------------------------------
    3463             : 
    3464             : // -----------------------------------------------------------------------------
    3465             : // Start of CalAnalysis protected member functions
    3466             : // -----------------------------------------------------------------------------
    3467             : 
    3468             : /*
    3469             : 
    3470             : CalAnalysis::CalAnalysis (default)
    3471             : 
    3472             : Description:
    3473             : ------------
    3474             : This default constructor is unused by this class and unavailable when an
    3475             : instance is created.
    3476             : 
    3477             : Inputs:
    3478             : -------
    3479             : None.
    3480             : 
    3481             : Outputs:
    3482             : --------
    3483             : None.
    3484             : 
    3485             : Modification history:
    3486             : ---------------------
    3487             : 2012 Jan 20 - Nick Elias, NRAO
    3488             :               Initial version.
    3489             : 
    3490             : */
    3491             : 
    3492             : // -----------------------------------------------------------------------------
    3493             : 
    3494           0 : CalAnalysis::CalAnalysis( void ) {}
    3495             : 
    3496             : // -----------------------------------------------------------------------------
    3497             : 
    3498             : /*
    3499             : 
    3500             : CalAnalysis::CalAnalysis (copy)
    3501             : 
    3502             : Description:
    3503             : ------------
    3504             : This copy constructor is unused by this class and unavailable when an instance
    3505             : is created.
    3506             : 
    3507             : Inputs:
    3508             : -------
    3509             : oCalAnalysis - A reference to a CalAnalysis instance.
    3510             : 
    3511             : Outputs:
    3512             : --------
    3513             : None.
    3514             : 
    3515             : Modification history:
    3516             : ---------------------
    3517             : 2012 Jan 20 - Nick Elias, NRAO
    3518             :               Initial version.
    3519             : 
    3520             : */
    3521             : 
    3522             : // -----------------------------------------------------------------------------
    3523             : 
    3524           0 : CalAnalysis::CalAnalysis( const CalAnalysis& oCalAnalysis ) {
    3525             : 
    3526             :   // Overwrite this instance and return.  This code will bomb.  I have written
    3527             :   // it in this way to keep the compiler from spewing warning messages about
    3528             :   // unused variables.
    3529             : 
    3530           0 :   *this = oCalAnalysis;
    3531             : 
    3532           0 :   return;
    3533             : 
    3534           0 : }
    3535             : 
    3536             : // -----------------------------------------------------------------------------
    3537             : 
    3538             : /*
    3539             : 
    3540             : CalAnalysis::operator=
    3541             : 
    3542             : Description:
    3543             : ------------
    3544             : This operator= function is unused by this class and unavailable when an instance
    3545             : is created.
    3546             : 
    3547             : Inputs:
    3548             : -------
    3549             : oCalAnalysis - A reference to a CalAnalysis instance.
    3550             : 
    3551             : Outputs:
    3552             : --------
    3553             : None.
    3554             : 
    3555             : Modification history:
    3556             : ---------------------
    3557             : 2012 Jan 20 - Nick Elias, NRAO
    3558             :               Initial version.
    3559             : 
    3560             : */
    3561             : 
    3562             : // -----------------------------------------------------------------------------
    3563             : 
    3564           0 : CalAnalysis& CalAnalysis::operator=( const CalAnalysis& oCalAnalysis ) {
    3565             : 
    3566             :   // Copy the input instance and return it.  This code will bomb.  I have
    3567             :   // written it in this way to keep the compiler from spewing warning messages
    3568             :   // about unused variables.
    3569             : 
    3570           0 :   CalAnalysis* poCalAnalysis = new CalAnalysis( oCalAnalysis );
    3571             : 
    3572           0 :   return( *poCalAnalysis );
    3573             : 
    3574             : }
    3575             : 
    3576             : // -----------------------------------------------------------------------------
    3577             : // End of CalAnalysis protected member functions
    3578             : // -----------------------------------------------------------------------------
    3579             : 
    3580             : // -----------------------------------------------------------------------------
    3581             : // End of CalAnalysis class
    3582             : // -----------------------------------------------------------------------------
    3583             : 
    3584             : };
    3585             : 
    3586             : // -----------------------------------------------------------------------------
    3587             : // End of casa namespace
    3588             : // -----------------------------------------------------------------------------

Generated by: LCOV version 1.16