CCfits  2.4
Classes | Public Member Functions | Protected Member Functions | List of all members
CCfits::Table Class Reference

#include <Table.h>

Inheritance diagram for CCfits::Table:
CCfits::ExtHDU CCfits::HDU CCfits::AsciiTable CCfits::BinTable

Classes

class  NoSuchColumn
 Exception to be thrown on a failure to retrieve a column specified either by name or index number. More...

Public Member Functions

 Table (const Table &right)
 copy constructor
virtual ~Table ()
 destructor
virtual Columncolumn (const String &colName, bool caseSensitive=true) const
 return a reference to a Table column specified by name.
virtual Columncolumn (int colIndex) const
 return a reference to the column identified by colIndex
virtual const std::map< string,
Column * > & 
column () const
 return a reference to the array containing the columns.
virtual std::map< string,
Column * > & 
column ()
 return a reference to the array containing the columns.
virtual void deleteColumn (const String &columnName)
 delete a column in a Table extension by name.
void deleteRows (long first, long number=1)
 delete a range of rows in a table.
void deleteRows (const std::vector< long > &rowList)
 delete a set of rows in the table specified by an input array.
virtual long getRowsize () const
 return the optimal number of rows to read or write at a time
void insertRows (long first, long number=1)
 insert empty rows into the table
virtual int numCols () const
 return the number of Columns in the Table (the TFIELDS keyword).
virtual long rows () const
 return the number of rows in the table (NAXIS2).
void rows (long numRows)
 set the number of rows in the Table.
void updateRows ()
 update the number of rows in the table
- Public Member Functions inherited from CCfits::ExtHDU
 ExtHDU (const ExtHDU &right)
 copy constructor
virtual ~ExtHDU ()
 destructor
virtual void addColumn (ValueType type, const String &columnName, long repeatWidth, const String &colUnit=String(""), long decimals=-1, size_t columnNumber=0)
 add a new column to an existing table HDU.
virtual HDUclone (FITSBase *p) const =0
 virtual copy constructor
bool isCompressed () const
 return true if image is stored using compression.
virtual void makeThisCurrent () const
 move the fitsfile pointer to this current HDU.
const String & name () const
 return the name of the extension.
template<typename S >
void read (std::valarray< S > &image)
 Read image data into container.
template<typename S >
void read (std::valarray< S > &image, long first, long nElements, S *nullValue)
 read part of an image array, processing null values.
template<typename S >
void read (std::valarray< S > &image, const std::vector< long > &first, long nElements, S *nullValue)
 read part of an image array, processing null values.
template<typename S >
void read (std::valarray< S > &image, const std::vector< long > &firstVertex, const std::vector< long > &lastVertex, const std::vector< long > &stride)
 read an image subset
template<typename S >
void read (std::valarray< S > &image, long first, long nElements)
 read an image section starting at a specified pixel
template<typename S >
void read (std::valarray< S > &image, const std::vector< long > &first, long nElements)
 read an image section starting at a location specified by an n-tuple
template<typename S >
void read (std::valarray< S > &image, const std::vector< long > &firstVertex, const std::vector< long > &lastVertex, const std::vector< long > &stride, S *nullValue)
 read an image subset into valarray image, processing null values
virtual void readData (bool readFlag=false, const std::vector< String > &keys=std::vector< String >())=0
 read data from HDU depending on readFlag and keys.
int version () const
 return the extension version number.
void version (int value)
 set the extension version number
template<typename S >
void write (const std::vector< long > &first, long nElements, const std::valarray< S > &data, S *nullValue)
 Write a set of pixels to an image extension with the first pixel specified by an n-tuple, processing undefined data.
template<typename S >
void write (long first, long nElements, const std::valarray< S > &data, S *nullValue)
 write array to image starting with a specified pixel and allowing undefined data to be processed
template<typename S >
void write (const std::vector< long > &first, long nElements, const std::valarray< S > &data)
 write array starting from specified n-tuple, without undefined data processing
template<typename S >
void write (long first, long nElements, const std::valarray< S > &data)
 write array starting from specified pixel number, without undefined data processing
template<typename S >
void write (const std::vector< long > &firstVertex, const std::vector< long > &lastVertex, const std::valarray< S > &data)
 write a subset (generalize slice) of data to the image
- Public Member Functions inherited from CCfits::HDU
 HDU (const HDU &right)
 copy constructor
template<typename T >
KeywordaddKey (const String &name, T val, const String &comment)
 create a new keyword in the HDU with specified value and comment fields
KeywordaddKey (const Keyword *inKeyword)
 create a copy of an existing Keyword and add to HDU
long axes () const
 return the number of axes in the HDU data section (always 2 for tables).
long axis (size_t index) const
 return the size of axis numbered index [zero based].
long bitpix () const
 return the data type keyword.
const string & comment () const
 return the comment string previously read by getComment()
void copyAllKeys (const HDU *inHdu)
 copy all keys from another header
void deleteKey (const String &doomed)
 delete a keyword from the header
fitsfile * fitsPointer () const
 return the fitsfile pointer for the FITS object containing the HDU
std::pair< unsigned long,
unsigned long > 
getChecksum () const
 compute and return the checksum values for the HDU without creating or modifying the CHECKSUM/DATASUM keywords.
const String & getComments ()
 read the comments from the HDU and add it to the FITS object.
const String & getHistory ()
 read the history information from the HDU and add it to the FITS object.
const string & history () const
 return the history string previously read by getHistory()
void index (int value)
 set the HDU number
int index () const
 return the HDU number
std::map< String, Keyword * > & keyWord ()
 return the associative array containing the HDU keywords so far read.
KeywordkeyWord (const String &keyName)
 return a (previously read) keyword from the HDU object.
const std::map< string,
Keyword * > & 
keyWord () const
 return the associative array containing the HDU Keywords that have been read so far.
const KeywordkeyWord (const string &keyname) const
 return a (previously read) keyword from the HDU object. const version
bool operator!= (const HDU &right) const
 inequality operator
bool operator== (const HDU &right) const
 equality operator
FITSBase * parent () const
 return reference to the pointer representing the FITSBase object containing the HDU
void readAllKeys ()
 read all of the keys in the header
template<typename T >
void readKey (const String &keyName, T &val)
 read a keyword of specified type from the header of a disk FITS file and return its value.
template<typename T >
void readKeys (std::vector< String > &keyNames, std::vector< T > &vals)
 read a set of specified keywords of the same data type from the header of a disk FITS file and return their values
virtual double scale () const
 return the BSCALE keyword value
virtual void scale (double value)
 set the BSCALE keyword value for images (see warning for images of int type)
void suppressScaling (bool toggle=true)
 turn off image scaling regardless of the BSCALE and BZERO keyword values
void updateChecksum ()
 update the CHECKSUM keyword value, assuming DATASUM exists and is correct
std::pair< int, int > verifyChecksum () const
 verify the HDU by computing the checksums and comparing them with the CHECKSUM/DATASUM keywords
void writeChecksum ()
 compute and write the DATASUM and CHECKSUM keyword values
void writeComment (const String &comment="Generic Comment")
 write a comment string.
void writeDate ()
 write a date string to *this.
void writeHistory (const String &history="Generic History String")
 write a history string.
virtual double zero () const
 return the BZERO keyword value
virtual void zero (double value)
 set the BZERO keyword value for images (see warning for images of int type)

Protected Member Functions

 Table (FITSBase *p, HduType xtype, const String &hduName, int rows, const std::vector< String > &columnName, const std::vector< String > &columnFmt, const std::vector< String > &columnUnit=std::vector< String >(), int version=1)
 Constructor to be used for creating new HDUs.
 Table (FITSBase *p, HduType xtype, const String &hduName=String(""), int version=1)
 Constructor to be called by operations that read Table specified by hduName and version.
 Table (FITSBase *p, HduType xtype, int number)
 Table constructor for getting Tables by number.
void init (bool readFlag=false, const std::vector< String > &keys=std::vector< String >())
void numCols (int value)
 set the number of Columns in the Table
virtual void setColumn (const String &colname, Column *value)
 set the column with name colname to the input value.
- Protected Member Functions inherited from CCfits::ExtHDU
 ExtHDU (FITSBase *p, HduType xtype, const String &hduName, int version)
 default constructor, required as Standard Library Container content.
 ExtHDU (FITSBase *p, HduType xtype, const String &hduName, int bitpix, int naxis, const std::vector< long > &axes, int version)
 writing constructor.
 ExtHDU (FITSBase *p, HduType xtype, int number)
 ExtHDU constructor for getting ExtHDUs by number.
long gcount () const
 return required gcount keyword value
void gcount (long value)
 set required gcount keyword value
long pcount () const
 return required pcount keyword value
void pcount (long value)
 set required pcount keyword value
HduType xtension () const
 return the extension type
void xtension (HduType value)
 set the extension type
- Protected Member Functions inherited from CCfits::HDU
 HDU (FITSBase *p=0)
 default constructor, called by HDU subclasses that read from FITS files.
 HDU (FITSBase *p, int bitpix, int naxis, const std::vector< long > &axes)
 constructor for creating new HDU objects, called by HDU subclasses writing to FITS files.
virtual ~HDU ()
 destructor
std::vector< long > & naxes ()
 return the HDU data axis array.

Additional Inherited Members

- Static Public Member Functions inherited from CCfits::ExtHDU
static void readHduName (const fitsfile *fptr, int hduIndex, String &hduName, int &hduVersion)
 read extension name.

Detailed Description

Table is the abstract common interface to Binary and Ascii Table HDUs.

Table is a subclass of ExtHDU that contains an associative array of Column objects. It implements methods for reading and writing columns

Constructor & Destructor Documentation

CCfits::Table::Table ( FITSBase *  p,
HduType  xtype,
const String &  hduName,
int  rows,
const std::vector< String > &  columnName,
const std::vector< String > &  columnFmt,
const std::vector< String > &  columnUnit = std::vector<String>(),
int  version = 1 
)
protected

Constructor to be used for creating new HDUs.

Parameters
pThe FITS file in which to place the new HDU
xtypeAn HduType enumerator defined in CCfits.h for type of table (AsciiTbl or BinaryTbl)
hduNameThe name of this HDU extension
rowsThe number of rows in the new HDU (the value of the NAXIS2 keyword).
columnNamea vector of names for the columns.
columnFmtthe format strings for the columns
columnUnitthe units for the columns.
versiona version number
CCfits::Table::Table ( FITSBase *  p,
HduType  xtype,
int  number 
)
protected

Table constructor for getting Tables by number.

Necessary since EXTNAME is a reserved not required keyword, and users may thus read FITS files without an extension name. Since an HDU is completely specified by extension number, this is part of the public interface.

Member Function Documentation

Column & CCfits::Table::column ( const String &  colName,
bool  caseSensitive = true 
) const
virtual

return a reference to a Table column specified by name.

If the caseSensitive parameter is set to false, the search will be case-insensitive. The overridden base class implementation ExtHDU::column throws an exception, which is thus the action to be taken if self is an image extension

Exceptions
WrongExtensionTypesee above

Reimplemented from CCfits::ExtHDU.

Column & CCfits::Table::column ( int  colIndex) const
virtual

return a reference to the column identified by colIndex

Throws NoSuchColumn if the index is out of range -index must satisfy (1 <= index <= numCols() ).

N.B. the column number is assigned as 1-based, as in FORTRAN rather than 0-based as in C.

Exceptions
Table::NoSuchColumnpasses colIndex to the diagnostic message printed when the exception is thrown

Reimplemented from CCfits::ExtHDU.

const std::map< string, Column * > & CCfits::Table::column ( ) const
inlinevirtual

return a reference to the array containing the columns.

This public version might be used to query the size of the column container in a routine that manipulates column table data.

Reimplemented from CCfits::ExtHDU.

std::map< string, Column * > & CCfits::Table::column ( )
inlinevirtual

return a reference to the array containing the columns.

To be used in the implementation of subclasses.

void CCfits::Table::deleteColumn ( const String &  columnName)
virtual

delete a column in a Table extension by name.

Parameters
columnNameThe name of the column to be deleted.
Exceptions
WrongExtensionTypeif extension is an image.

Reimplemented from CCfits::ExtHDU.

void CCfits::Table::deleteRows ( long  first,
long  number = 1 
)

delete a range of rows in a table.

In both this and the overloaded version which allows a selection of rows to be deleted, the cfitsio library is called first to perform the operation on the disk file, and then the FITS object is updated.

Parameters
firstthe start row of the range
numberthe number of rows to delete; defaults to 1.
Exceptions
FitsErrorthrown if the cfitsio call fails to return without error.
void CCfits::Table::deleteRows ( const std::vector< long > &  rowlist)

delete a set of rows in the table specified by an input array.

Parameters
rowlistThe vector of row numbers to be deleted.
Exceptions
FitsErrorthrown if the underlying cfitsio call fails to return without error.
long CCfits::Table::getRowsize ( ) const
virtual

return the optimal number of rows to read or write at a time

A wrapper for the CFITSIO function fits_get_rowsize, useful for obtaining maximum I/O efficiency. This will throw if it is not called for a Table extension.

Reimplemented from CCfits::ExtHDU.

void CCfits::Table::init ( bool  readFlag = false,
const std::vector< String > &  keys = std::vector<String>() 
)
protected

"Late Constructor." wrap-up of calls needed to construct a table. Reads header information and sets up the array of column objects in the table.

Protected function, provided to allow the implementation of extensions of the library.

void CCfits::Table::insertRows ( long  first,
long  number = 1 
)

insert empty rows into the table

Parameters
firstthe start row of the range
numberthe number of rows to insert.
Exceptions
FitsErrorthrown if the underlying cfitsio call fails to return without error.
void CCfits::Table::updateRows ( )

update the number of rows in the table

Called to force the Table to reset its internal "rows" attribute. public, but is called when needed internally.


The documentation for this class was generated from the following files: