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