casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
CalTable.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_CALTABLE_H
00030 #define CALIBRATION_CALTABLE_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/CalTableDesc.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 CalTable
00082 {
00083  public:
00084    // Default null constructor, and destructor
00085    CalTable();
00086    virtual ~CalTable();
00087 
00088    // Construct from a specified table name, calibration table descriptor 
00089    // and table access option. Used for creating new tables.
00090    CalTable (const String& tableName, CalTableDesc& 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    CalTable (const String& tableName, Table::TableOption access = Table::Old);
00096 
00097    // Construct from an existing table object
00098    CalTable (const Table& table);
00099 
00100    // Copy constructor
00101    CalTable (const CalTable& other);
00102 
00103    // Assignment operator
00104    CalTable& operator= (const CalTable& other);
00105 
00106    // Sort (cal_main)
00107    CalTable sort (const Block <String>& columnNames, 
00108                   Sort::Order order = Sort::Ascending,
00109                   Sort::Option option = Sort::HeapSort); 
00110 
00111    // Sort (cal_main) IN PLACE
00112    void sort2 (const Block <String>& columnNames, 
00113               Sort::Order order = Sort::Ascending,
00114               Sort::Option option = Sort::HeapSort); 
00115 
00116    // Apply selection to the calibration table 
00117    CalTable select (const String& calSelect);
00118 
00119    // Apply selection to the calibration table  IN PLACE
00120    void select2 (const String& calSelect);
00121 
00122    // Return number of rows in cal_main, cal_desc or cal_history
00123    Int nRowMain() const;
00124    Int nRowDesc() const;
00125    Int nRowHistory() const;
00126 
00127    // Add rows to cal_main, cal_desc or cal_history
00128    void addRowMain (uInt nrrow = 1, Bool initialize = False) 
00129      {itsMainTable->addRow(nrrow, initialize);};
00130    void addRowDesc (uInt nrrow = 1, Bool initialize = False)
00131      {itsDescTable->addRow(nrrow, initialize);};
00132    void addRowHistory (uInt nrrow = 1, Bool initialize = False)
00133      {itsHistoryTable->addRow(nrrow, initialize);};
00134 
00135    // Get a row from cal_main, cal_desc or cal_history
00136    Record getRowMain (const Int& jrow);
00137    Record getRowDesc (const Int& jrow);
00138    Record getRowHistory (const Int& jrow);
00139 
00140    // Put a row to cal_main, cal_desc or cal_history
00141    void putRowMain (const Int& jrow, CalMainRecord& tableRec);
00142    void putRowDesc (const Int& jrow, CalDescRecord& tableRec);
00143    void putRowHistory (const Int& jrow, CalHistoryRecord& tableRec);
00144 
00145    // Return the maximum antenna number in the table
00146    virtual Int maxAntenna();
00147 
00148    // Return the number of unique time slots in the table
00149    Int numberTimeSlots (const Double& fracError);
00150 
00151    // Return the number of rows per CalDescId
00152    void rowsPerCalDescId(Vector<Int>& rowspercdi);
00153 
00154  protected:
00155    // Create a new table
00156    void createCalTable (const String& tableName, CalTableDesc& ctableDesc,
00157                         Table::TableOption access = Table::New);
00158 
00159    // Open an existing table
00160    void openCalTable (const String& tableName, 
00161                       Table::TableOption access = Table::Old);
00162 
00163    // Return cal_main and sub-tables as Table references
00164    Table& calMainAsTable() {return *itsMainTable;};
00165    Table& calDescAsTable() {return *itsDescTable;};
00166    Table& calHistoryAsTable() {return *itsHistoryTable;};
00167    const Table& calMainAsTable() const {return *itsMainTable;};
00168    const Table& calDescAsTable() const {return *itsDescTable;};
00169    const Table& calHistoryAsTable() const {return *itsHistoryTable;};
00170 
00171    // Friend class access from the ROCalMainColumns, ROCalDescColumns
00172    // and ROCalHistoryColumns class hierarchies
00173    friend class ROCalMainColumns;
00174    friend class CalMainColumns;
00175    friend class ROCalDescColumns;
00176    friend class CalDescColumns;
00177    friend class ROCalHistoryColumns;
00178    friend class CalHistoryColumns;
00179 
00180  private:
00181    // Pointer to underlying cal_main Table object
00182    Table* itsMainTable;
00183 
00184    // Pointers to the cal_desc and cal_history sub-tables
00185    Table* itsDescTable;
00186    Table* itsHistoryTable;
00187  };
00188 
00189 
00190 } //# NAMESPACE CASA - END
00191 
00192 #endif
00193