casacore
Loading...
Searching...
No Matches
BinTable.h
Go to the documentation of this file.
1//# BinTable.h: The class BinaryTable converts a FITS binary table into a Casacore Table.
2//# Copyright (C) 1995,1996,1999
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 addressed as follows:
20//# Internet email: casa-feedback@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#ifndef FITS_BINTABLE_H
27#define FITS_BINTABLE_H
28
29
30//# Includes
31
32#include <casacore/casa/aips.h>
33#include <casacore/fits/FITS/hdu.h>
34#include <casacore/tables/Tables/Table.h>
35#include <casacore/tables/Tables/TableRecord.h>
36#include <map>
37
38namespace casacore { //# NAMESPACE CASACORE - BEGIN
39
40// <summary>
41// BinaryTable is used to translate a FITS binary table to a Casacore Table.
42// </summary>
43
44// <use visibility=export>
45
46// <reviewed reviewer="" date="" tests="tBinTable">
47
48// <prerequisite>
49//# Classes you should understand before using this one.
50// <li> FitsInput
51// <li> HeaderDataUnit
52// <li> BinaryTableExtension
53// <li> Tables module
54// </prerequisite>
55//
56// <etymology>
57// BinaryTable inherits from the FITS BinaryTableExtension class and its
58// primary use is to convert that class to a Casacore Table. This explains
59// it's use but not its name. A better name should be found.
60// </etymology>
61//
62// <synopsis>
63// The class starts with an already existing FitsInput object, which should
64// be set at a BinaryTableExtension HDU. Member functions provide a TableDesc
65// appropriate for the FITS data (to help in constructing a Casacore Table
66// compatible with the BinaryTableExtension), a Table containing the
67// current row of FITS data and a Table containing the next row of FITS data
68// (which can be used to step through the FitsInput, copying each row
69// using the RowCopier class), and a Table containin the entire FITS binary
70// table from the current row to the end of the table.
71// </synopsis>
72//
73// <motivation>
74// We need a way to get FITS data into Casacore Tables.
75// </motivation>
76//
77// <example>
78// open a FitsInput from a disk file, if the HDU is a BinaryTableExtension,
79// then instantiate a BinTable object and get the entire table. A fair
80// amount of error checking has been eliminated from this example.
81// <srcblock>
82// FitsInput infits("myFITSFile", FITS::Disk);
83// switch (infits.hdutype()) {
84// case FITS::BinaryTableHDU:
85// BinaryTable bintab(infits);
86// Table tab = bintable.fullTable("myTable");
87// break;
88// }
89// </srcblock>
90// There would obviously be other cases to the switch to deal with any
91// other HDUs (e.g. skip them via infits.skip_hdu()). The Table destructor
92// would write "myTable" to disk.
93// </example>
94//
95//
96// <todo asof="1995/04/10">
97//# A List of bugs, limitations, extensions or planned refinements.
98// <li> It would be nice to construct this directly from the BinaryTableExtension.
99// <li> When random access FITS becomes available, this needs to be able to deal with that.
100// <li> A corresponding class is needed for conversion from Casacore Tables to FITS.
101// <li> Throw exceptions rather than send messages to cout : however the entire FITS
102// module behaves this way, so it should all remain consistent.
103// <li> The following types of columns are not dealt with very well or at all
104// (Bit, Byte, 0-length columns).
105// <li> No attempt use any TDIM columns or keywords to shape arrays.
106// </todo>
107
109{
110public:
111
112 // The only constructor is from a FitsInput, you can also optionally
113 // provide a FITS error handler. If useMiriadSM is True, use
114 // the Miriad storage manager for all columns, otherwise AipsIO.
115 // If sdfits is True, all non-reserved and some reserved keyword
116 // are treated as if they were columns with constant values
117 // "virtual columns" in the sdfits convention.
120 Bool useMiriadSM = False, Bool sdfits = False);
121
123
124 // Get the full table, using the supplied arguments to construct the table.
125 // The table will contain all data from the current row to the end of the
126 // BinarTableExtension.If useMiriadSM is True, use the Miriad storage
127 // manager for all columns, otherwise AipsIO.
128 Table fullTable(const String& tabName,
130 Bool useMiriadSM = False);
131
132 // This version of the fullTable return a Memory based table
133 // Its recommended if its being used as a temporary
134
136
137 // Get an appropriate TableDesc (this is the same TableDesc used to
138 // construct any Table objects returned by this class.
140
141 // Return the Table keywords (this is the same TableRecord used
142 // in any Table objects returned by this class.
144
145 // Get a Table with a single row, the current row of the FITS table.
146 // The returned Table is a Scratch table.
147 // The standard BinaryTableExtension manipulation functions are
148 // available to position the FITS input at the desired location.
149 const Table &thisRow();
150
151 // Get a Table with a single row, the next row of the FITS table.
152 // The returned Table is a Scratch table.
153 // The FITS input is positioned to the next row and the values translated
154 // and returned in a Table object.
155 const Table &nextRow();
156
157
158private:
159
160 //# Data Members
161 // This is the Scratch table containing the current row
163 // The number of elements for each column of the BinaryTableExtension
165 // This is a map from column number to column name
166 std::map<Int, String> *colNames;
167
169
170 // These are used by any VADesc columns
172 void **vaptr_p;
175
176 // this is the function that fills each row in as needed
177 void fillRow();
178};
179
180
181} //# NAMESPACE CASACORE - END
182
183#endif
BINTABLE extension
Definition hdu.h:1033
Table fullTable()
This version of the fullTable return a Memory based table Its recommended if its being used as a temp...
TableRecord kwSet
Definition BinTable.h:168
FITS::ValueType * vatypes_p
These are used by any VADesc columns.
Definition BinTable.h:171
const Table & thisRow()
Get a Table with a single row, the current row of the FITS table.
const Table & nextRow()
Get a Table with a single row, the next row of the FITS table.
Int * nelem
The number of elements for each column of the BinaryTableExtension.
Definition BinTable.h:164
BinaryTable(FitsInput &, FITSErrorHandler errhandler=FITSError::defaultHandler, Bool useMiriadSM=False, Bool sdfits=False)
The only constructor is from a FitsInput, you can also optionally provide a FITS error handler.
void fillRow()
this is the function that fills each row in as needed
Table * currRowTab
This is the Scratch table containing the current row.
Definition BinTable.h:162
Table fullTable(const String &tabName, const Table::TableOption=Table::NewNoReplace, Bool useMiriadSM=False)
Get the full table, using the supplied arguments to construct the table.
const TableDesc & getDescriptor()
Get an appropriate TableDesc (this is the same TableDesc used to construct any Table objects returned...
VADescFitsField * va_p
Definition BinTable.h:173
std::map< Int, String > * colNames
This is a map from column number to column name.
Definition BinTable.h:166
TableRecord & getKeywords()
Return the Table keywords (this is the same TableRecord used in any Table objects returned by this cl...
static void defaultHandler(const char *errMessage, ErrorLevel severity)
The default error handler.
ValueType
FITS I/O Error message types.
Definition fits.h:165
fixed-length sequential blocked FITS input
Definition fitsio.h:154
String: the storage and methods of handling collections of characters.
Definition String.h:223
TableOption
Define the possible options how a table can be opened.
Definition Table.h:171
@ NewNoReplace
create table (may not exist)
Definition Table.h:177
void(* FITSErrorHandler)(const char *errMessage, FITSError::ErrorLevel severity)
Define a typedef for the handler function signature for convenience.
Definition FITSError.h:108
this file contains all the compiler specific defines
Definition mainpage.dox:28
const Bool False
Definition aipstype.h:42
FitsField< FitsVADesc > VADescFitsField
Definition hdu.h:966
int Int
Definition aipstype.h:48
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40