casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
CalTable2.h
Go to the documentation of this file.
00001 //# CalTable.h: Calibration table access and creation
00002 //# Copyright (C) 1996,1997,1998,1999,2001,2002,2003
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be adressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //#
00027 //# $Id$
00028 
00029 #ifndef CALIBRATION_CALTABLE2_H
00030 #define CALIBRATION_CALTABLE2_H
00031 
00032 #include <casa/aips.h>
00033 #include <tables/Tables/Table.h>
00034 #include <tables/Tables/ExprNode.h>
00035 #include <casa/Containers/Record.h>
00036 #include <casa/Utilities/Sort.h>
00037 #include <synthesis/CalTables/CalTableDesc2.h>
00038 #include <synthesis/CalTables/CalMainRecord.h>
00039 #include <synthesis/CalTables/CalDescRecord.h>
00040 #include <synthesis/CalTables/CalHistRecord.h>
00041 
00042 namespace casa { //# NAMESPACE CASA - BEGIN
00043   
00044   // <summary> 
00045   // CalTable: Calibration table access and creation
00046   // </summary>
00047   
00048   // <use visibility=export>
00049   
00050   // <reviewed reviewer="" date="" tests="" demos="">
00051   
00052   // <prerequisite>
00053   //   <li> <linkto class="CalTableDesc">CalTableDesc</linkto> module
00054   // </prerequisite>
00055   //
00056   // <etymology>
00057   // From "calibration" and "table".
00058   // </etymology>
00059   //
00060   // <synopsis>
00061   // The CalTable classes provide basic access to calibration tables. This 
00062   // includes the creation of calibration tables, sorting and selection
00063   // capabilities, and basic data access. Specializations for baseline-based,
00064   // time-variable and solvable VisJones types, and sub-types, are provided 
00065   // through inheritance.
00066   // </etymology>
00067   //
00068   // <example>
00069   // <srcblock>
00070   // </srcblock>
00071   // </example>
00072   //
00073   // <motivation>
00074   // This class is used by other calibration table accessors and iterators.
00075   // </motivation>
00076   //
00077   // <todo asof="98/01/01">
00078   // (i) Generic synthesis selection
00079   // </todo>
00080   
00081   class CalTable2
00082   {
00083   public:
00084     // Default null constructor, and destructor
00085     CalTable2();
00086     virtual ~CalTable2();
00087     
00088     // Construct from a specified table name, calibration table descriptor 
00089     // and table access option. Used for creating new tables.
00090     CalTable2(const String& tableName, CalTableDesc2& ctableDesc,
00091               Table::TableOption access = Table::New);
00092     
00093     // Construct from a specified table name, and access option. Used
00094     // for accessing existing tables.
00095     CalTable2(const String& tableName, Table::TableOption access = Table::Old);
00096     
00097     // Construct from an existing table object
00098     CalTable2(const Table& table);
00099     
00100     // Copy constructor
00101     CalTable2(const CalTable2& other);
00102     
00103     //
00104     const Int parType() {return parType_;};
00105     // Assignment operator
00106     CalTable2& operator= (const CalTable2& other);
00107     
00108     // Sort (cal_main)
00109     CalTable2 sort (const Block <String>& columnNames, 
00110                     Sort::Order order = Sort::Ascending,
00111                     Sort::Option option = Sort::HeapSort); 
00112     
00113     // Sort (cal_main) IN PLACE
00114     void sort2 (const Block <String>& columnNames, 
00115                 Sort::Order order = Sort::Ascending,
00116                 Sort::Option option = Sort::HeapSort); 
00117     
00118     // Apply selection to the calibration table 
00119     CalTable2 select (const String& calSelect);
00120     
00121     // Apply selection to the calibration table  IN PLACE
00122     void select2 (const String& calSelect);
00123     
00124     // Return number of rows in cal_main, cal_desc or cal_history
00125     Int nRowMain() const;
00126     Int nRowDesc() const;
00127     Int nRowHistory() const;
00128     
00129     // Add rows to cal_main, cal_desc or cal_history
00130     void addRowMain (uInt nrrow = 1, Bool initialize = False) 
00131     {itsMainTable->addRow(nrrow, initialize);};
00132     void addRowDesc (uInt nrrow = 1, Bool initialize = False)
00133     {itsDescTable->addRow(nrrow, initialize);};
00134     void addRowHistory (uInt nrrow = 1, Bool initialize = False)
00135     {itsHistoryTable->addRow(nrrow, initialize);};
00136     
00137     // Get a row from cal_main, cal_desc or cal_history
00138     Record getRowMain (const Int& jrow);
00139     Record getRowDesc (const Int& jrow);
00140     Record getRowHistory (const Int& jrow);
00141     
00142     // Put a row to cal_main, cal_desc or cal_history
00143     void putRowMain (const Int& jrow, CalMainRecord& tableRec);
00144     void putRowDesc (const Int& jrow, CalDescRecord& tableRec);
00145     void putRowHistory (const Int& jrow, CalHistoryRecord& tableRec);
00146     
00147     // Return the maximum antenna number in the table
00148     virtual Int maxAntenna();
00149     
00150     // Return the number of unique time slots in the table
00151     Int numberTimeSlots (const Double& fracError);
00152     
00153     // Create a new table
00154     void createCalTable(const String& tableName, CalTableDesc2& ctableDesc,
00155                         Table::TableOption access = Table::New);
00156     
00157     // Open an existing table
00158     void openCalTable(const String& tableName, 
00159                       Table::TableOption access = Table::Old);
00160     
00161     // Return cal_main and sub-tables as Table references
00162     Table& calMainAsTable() {return *itsMainTable;};
00163     Table& calDescAsTable() {return *itsDescTable;};
00164     Table& calHistoryAsTable() {return *itsHistoryTable;};
00165     const Table& calMainAsTable() const {return *itsMainTable;};
00166     const Table& calDescAsTable() const {return *itsDescTable;};
00167     const Table& calHistoryAsTable() const {return *itsHistoryTable;};
00168   protected:
00169     
00170     // Friend class access from the ROCalMainColumns, ROCalDescColumns
00171     // and ROCalHistoryColumns class hierarchies
00172 //    friend class ROCalMainColumns2;
00173 //    friend class CalMainColumns2;
00174 //    friend class ROCalDescColumns2;
00175 //    friend class CalDescColumns2;
00176     friend class ROCalHistoryColumns;
00177     friend class CalHistoryColumns;
00178     
00179   private:
00180     // Pointer to underlying cal_main Table object
00181     Table* itsMainTable;
00182     
00183     // Pointers to the cal_desc and cal_history sub-tables
00184     Table* itsDescTable;
00185     Table* itsHistoryTable;
00186     Int parType_;
00187   };
00188 
00189 } //# NAMESPACE CASA - END
00190 
00191 #endif
00192