casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CalTable.h
Go to the documentation of this file.
1 //# CalTable.h: Calibration table access and creation
2 //# Copyright (C) 1996,1997,1998,1999,2001,2002,2003
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be adressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //#
27 //# $Id$
28 
29 #ifndef CALIBRATION_CALTABLE_H
30 #define CALIBRATION_CALTABLE_H
31 
32 #include <casa/aips.h>
33 #include <tables/Tables/Table.h>
34 #include <tables/TaQL/ExprNode.h>
36 #include <casa/Containers/Record.h>
37 #include <casa/Utilities/Sort.h>
42 
43 namespace casa { //# NAMESPACE CASA - BEGIN
44 
45 // <summary>
46 // CalTable: Calibration table access and creation
47 // </summary>
48 
49 // <use visibility=export>
50 
51 // <reviewed reviewer="" date="" tests="" demos="">
52 
53 // <prerequisite>
54 // <li> <linkto class="CalTableDesc">CalTableDesc</linkto> module
55 // </prerequisite>
56 //
57 // <etymology>
58 // From "calibration" and "table".
59 // </etymology>
60 //
61 // <synopsis>
62 // The CalTable classes provide basic access to calibration tables. This
63 // includes the creation of calibration tables, sorting and selection
64 // capabilities, and basic data access. Specializations for baseline-based,
65 // time-variable and solvable VisJones types, and sub-types, are provided
66 // through inheritance.
67 // </etymology>
68 //
69 // <example>
70 // <srcblock>
71 // </srcblock>
72 // </example>
73 //
74 // <motivation>
75 // This class is used by other calibration table accessors and iterators.
76 // </motivation>
77 //
78 // <todo asof="98/01/01">
79 // (i) Generic synthesis selection
80 // </todo>
81 
82 class CalTable
83 {
84  public:
85  // Default null constructor, and destructor
86  CalTable();
87  virtual ~CalTable();
88 
89  // Construct from a specified table name, calibration table descriptor
90  // and table access option. Used for creating new tables.
91  CalTable (const casacore::String& tableName, CalTableDesc& ctableDesc,
93 
94  // Construct from a specified table name, and access option. Used
95  // for accessing existing tables.
97 
98  // Construct from an existing table object
99  CalTable (const casacore::Table& table);
100 
101  // Copy constructor
102  CalTable (const CalTable& other);
103 
104  // Assignment operator
105  CalTable& operator= (const CalTable& other);
106 
107  // casacore::Sort (cal_main)
108  CalTable sort (const casacore::Block <casacore::String>& columnNames,
111 
112  // casacore::Sort (cal_main) IN PLACE
113  void sort2 (const casacore::Block <casacore::String>& columnNames,
116 
117  // Apply selection to the calibration table
118  CalTable select (const casacore::String& calSelect);
119 
120  // Apply selection to the calibration table IN PLACE
121  void select2 (const casacore::String& calSelect);
122 
123  // Return number of rows in cal_main, cal_desc or cal_history
124  casacore::Int nRowMain() const;
125  casacore::Int nRowDesc() const;
126  casacore::Int nRowHistory() const;
128 
129  // Add rows to cal_main, cal_desc or cal_history
130  void addRowMain (casacore::uInt nrrow = 1, casacore::Bool initialize = false)
131  {itsMainTable->addRow(nrrow, initialize);};
132  void addRowDesc (casacore::uInt nrrow = 1, casacore::Bool initialize = false)
133  {itsDescTable->addRow(nrrow, initialize);};
134  void addRowHistory (casacore::uInt nrrow = 1, casacore::Bool initialize = false)
135  {itsHistoryTable->addRow(nrrow, initialize);};
136 
137  // Get a row from cal_main, cal_desc or cal_history
142 
143  // Put a row to cal_main, cal_desc or cal_history
144  void putRowMain (const casacore::Int& jrow, CalMainRecord& tableRec);
145  void putRowDesc (const casacore::Int& jrow, CalDescRecord& tableRec);
146  void putRowHistory (const casacore::Int& jrow, CalHistoryRecord& tableRec);
147 
148  // Return the maximum antenna number in the table
149  virtual casacore::Int maxAntenna();
150 
151  // Return the number of unique time slots in the table
153 
154  // Return the number of rows per CalDescId
156 
158 
160 
161  protected:
162  // Create a new table
163  void createCalTable (const casacore::String& tableName, CalTableDesc& ctableDesc,
165 
166  // Open an existing table
167  void openCalTable (const casacore::String& tableName,
169 
170  // Return cal_main and sub-tables as casacore::Table references
175  const casacore::Table& calMainAsTable() const {return *itsMainTable;};
176  const casacore::Table& calDescAsTable() const {return *itsDescTable;};
179 
180  // Friend class access from the ROCalMainColumns, ROCalDescColumns
181  // and ROCalHistoryColumns class hierarchies
182  friend class ROCalMainColumns;
183  friend class CalMainColumns;
184  friend class ROCalDescColumns;
185  friend class CalDescColumns;
186  friend class ROCalHistoryColumns;
187  friend class CalHistoryColumns;
188 
189  private:
190  // Pointer to underlying cal_main casacore::Table object
192 
193  // Pointers to the cal_desc and cal_history sub-tables
197 
198  // Check if has optional OBSERVATION Table
199  bool hasObsTable() const {
200  return (itsMainTable->keywordSet().fieldNumber("OBSERVATION") != -1); }
201  };
202 
203 
204 } //# NAMESPACE CASA - END
205 
206 #endif
207 
void addRow(uInt nrrow=1, Bool initialize=False)
Add one or more rows at the end of the table.
Definition: Table.h:1235
virtual casacore::Int maxAntenna()
Return the maximum antenna number in the table.
int Int
Definition: aipstype.h:50
void rowsPerCalDescId(casacore::Vector< casacore::Int > &rowspercdi)
Return the number of rows per CalDescId.
virtual ~CalTable()
casacore::Int nRowMain() const
Return number of rows in cal_main, cal_desc or cal_history.
const casacore::Table & calDescAsTable() const
Definition: CalTable.h:176
casacore::Table & calHistoryAsTable()
Definition: CalTable.h:173
const casacore::String type()
Definition: CalTable.h:159
Main interface class to a read/write table.
Definition: Table.h:153
ROCalDescColumns: Read-only cal_desc calibration table column access.
casacore::Int numberTimeSlots(const casacore::Double &fracError)
Return the number of unique time slots in the table.
ROCalMainColumns: Read-only cal_main calibration table column access.
casacore::Int nRowObservation() const
ROCalHistoryColumns: Read-only cal_history calibration table column access.
Order
Enumerate the sort order:
Definition: Sort.h:260
casacore::Table * itsObservationTable
Definition: CalTable.h:196
casacore::Table & calDescAsTable()
Definition: CalTable.h:172
virtual Int fieldNumber(const String &fieldName) const
Get the field number from the field name.
CalTableDesc: Define the format of calibration tables.
Definition: CalTableDesc.h:84
void putRowDesc(const casacore::Int &jrow, CalDescRecord &tableRec)
void addRowHistory(casacore::uInt nrrow=1, casacore::Bool initialize=false)
Definition: CalTable.h:134
casacore::Int nRowHistory() const
CalDescRecord: Cal_desc table record access and creation.
Definition: CalDescRecord.h:72
const casacore::String tableName()
Definition: CalTable.h:157
casacore::Record getRowHistory(const casacore::Int &jrow)
const String & tableName() const
Get the table name.
Definition: Table.h:1219
const String & subType() const
Definition: TableInfo.h:233
CalTable: Calibration table access and creation.
Definition: CalTable.h:82
void sort2(const casacore::Block< casacore::String > &columnNames, casacore::Sort::Order order=casacore::Sort::Ascending, casacore::Sort::Option option=casacore::Sort::HeapSort)
casacore::Sort (cal_main) IN PLACE
void putRowHistory(const casacore::Int &jrow, CalHistoryRecord &tableRec)
CalHistoryRecord: Cal_ table record access and creation.
Definition: CalHistRecord.h:71
CalTable()
Default null constructor, and destructor.
casacore::Record getRowObservation(const casacore::Int &jrow)
CalMainColumns: Read-write cal_main calibration table column access.
static TableInfo tableInfo(const String &tableName)
Get the table info of the table with the given name.
Definition: Table.h:1210
casacore::Table * itsDescTable
Pointers to the cal_desc and cal_history sub-tables.
Definition: CalTable.h:194
existing table
Definition: Table.h:170
double Double
Definition: aipstype.h:55
void addRowDesc(casacore::uInt nrrow=1, casacore::Bool initialize=false)
Definition: CalTable.h:132
Option
Enumerate the sort options:
Definition: Sort.h:252
A hierarchical collection of named fields of various types.
Definition: Record.h:180
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
CalMainRecord: Calibration table record access and creation.
Definition: CalMainRecord.h:74
void addRowMain(casacore::uInt nrrow=1, casacore::Bool initialize=false)
Add rows to cal_main, cal_desc or cal_history.
Definition: CalTable.h:130
casacore::Record getRowMain(const casacore::Int &jrow)
Get a row from cal_main, cal_desc or cal_history.
casacore::Record getRowDesc(const casacore::Int &jrow)
casacore::Table & calMainAsTable()
Return cal_main and sub-tables as casacore::Table references.
Definition: CalTable.h:171
casacore::Table * itsHistoryTable
Definition: CalTable.h:195
CalDescColumns: Read-write cal_desc calibration table column access.
CalTable & operator=(const CalTable &other)
Assignment operator.
void putRowMain(const casacore::Int &jrow, CalMainRecord &tableRec)
Put a row to cal_main, cal_desc or cal_history.
const TableRecord & keywordSet() const
Get readonly access to the table keyword set.
Definition: Table.h:1207
void createCalTable(const casacore::String &tableName, CalTableDesc &ctableDesc, casacore::Table::TableOption access=casacore::Table::New)
Create a new table.
bool hasObsTable() const
Check if has optional OBSERVATION Table.
Definition: CalTable.h:199
CalTable sort(const casacore::Block< casacore::String > &columnNames, casacore::Sort::Order order=casacore::Sort::Ascending, casacore::Sort::Option option=casacore::Sort::HeapSort)
casacore::Sort (cal_main)
const casacore::Table & calHistoryAsTable() const
Definition: CalTable.h:177
const casacore::Table & calMainAsTable() const
Definition: CalTable.h:175
String: the storage and methods of handling collections of characters.
Definition: String.h:223
CalTable select(const casacore::String &calSelect)
Apply selection to the calibration table.
CalHistoryColumns: Read-write cal_history calibration table column access.
create table
Definition: Table.h:172
casacore::Table * itsMainTable
Pointer to underlying cal_main casacore::Table object.
Definition: CalTable.h:191
void select2(const casacore::String &calSelect)
Apply selection to the calibration table IN PLACE.
casacore::Int nRowDesc() const
void openCalTable(const casacore::String &tableName, casacore::Table::TableOption access=casacore::Table::Old)
Open an existing table.
unsigned int uInt
Definition: aipstype.h:51
TableOption
Define the possible options how a table can be opened.
Definition: Table.h:168
casacore::Table & calObservationAsTable()
Definition: CalTable.h:174