CCfits  2.4
Classes | Public Member Functions | Protected Member Functions
CCfits::Column Class Reference

Abstract base class for Column objects. More...

#include <Column.h>

Inherited by CCfits::ColumnData< T >, and CCfits::ColumnVectorData< T >.

List of all members.

Classes

class  InsufficientElements
 Exception thrown if the data supplied for a write operation is less than declared. More...
class  InvalidDataType
 Exception thrown for invalid data type inputs. More...
class  InvalidNumberOfRows
 Exception thrown if user enters a non-positive number for the number of rows to write. More...
class  InvalidRowNumber
 Exception thrown on attempting to read a row number beyond the end of a table. More...
class  InvalidRowParameter
 Exception thrown on incorrect row writing request. More...
class  NoNullValue
 Exception thrown if a null value is specified without support from existing column header. More...
class  RangeError
 exception to be thrown for inputs that cause range errors in column read operations. More...
class  WrongColumnType
 Exception thrown on attempting to access a scalar column as vector data. More...

Public Member Functions

 Column (const Column &right)
 copy constructor, used in copying Columns to standard library containers.
virtual ~Column ()
 destructor.
template<typename T >
void addNullValue (T nullVal)
 Set the TNULLn keyword for the column.
const String & dimen () const
 return TDIMn keyword
const String & display () const
 return TDISPn keyword
const String & format () const
 return TFORMn keyword
template<typename T >
bool getNullValue (T *nullVal) const
 Get the value of the TNULLn keyword for the column.
int index () const
 get the Column index (the n in TTYPEn etc).
bool isRead () const
 flag set to true if the entire column data has been read from disk
const String & name () const
 return name of Column (TTYPEn keyword)
Tableparent () const
 return a pointer to the Table which owns this Column
template<typename S >
void read (std::vector< S > &vals, long first, long last)
 Retrieve data from a scalar column into a std::vector.
template<typename S >
void read (std::valarray< S > &vals, long first, long last)
 Retrieve data from a scalar column into a std::valarray.
template<typename S >
void read (std::valarray< S > &vals, long rows)
 return a single row of a vector column into a std::valarray
template<typename S >
void read (std::vector< S > &vals, long first, long last, S *nullValue)
 Retrieve data from a scalar column into a std::vector>, applying nullValue when relevant.
template<typename S >
void read (std::valarray< S > &vals, long first, long last, S *nullValue)
 Retrieve data from a scalar column into a std::valarray, applying nullValue when relevant.
template<typename S >
void read (std::valarray< S > &vals, long rows, S *nullValue)
 return a single row of a vector column into a std::valarray, setting undefined values
template<typename S >
void readArrays (std::vector< std::valarray< S > > &vals, long first, long last)
 return a set of rows of a vector column into a vector of valarrays
template<typename S >
void readArrays (std::vector< std::valarray< S > > &vals, long first, long last, S *nullValue)
 return a set of rows of a vector column into a container, setting undefined values
virtual void readData (long firstRow, long nelements, long firstElem=1)=0
 Read (or reread) data from the disk into the Column object's internal arrays.
size_t repeat () const
 get the repeat count for the rows
void resetRead ()
 reset the Column's isRead flag to false
int rows () const
 return the number of rows in the table.
double scale () const
 get TSCALn value
virtual void setDimen ()
 set the TDIMn keyword.
void setDisplay ()
 set the TDISPn keyword
ValueType type () const
 returns the data type of the column
const String & unit () const
 get units of data in Column (TUNITn keyword)
bool varLength () const
 boolean, set to true if Column has variable length vector rows.
long width () const
 return column data width
template<typename S >
void write (const std::vector< S > &indata, long firstRow)
 write a vector of values into a scalar column starting with firstRow
template<typename S >
void write (const std::valarray< S > &indata, long firstRow)
 write a valarray of values into a scalar column starting with firstRow
template<typename S >
void write (S *indata, long nRows, long firstRow)
 write a C array of size nRows into a scalar Column starting with row firstRow.
template<typename S >
void write (const std::vector< S > &indata, long firstRow, S *nullValue)
 write a vector of values into a scalar column starting with firstRow, replacing elements equal to nullValue with the FITS null value.
template<typename S >
void write (const std::valarray< S > &indata, long firstRow, S *nullValue)
 write a valarray of values into a scalar column starting with firstRow, replacing elements equal to nullValue with the FITS null value.
template<typename S >
void write (S *indata, long nRows, long firstRow, S *nullValue)
 write a C array into a scalar Column, processing undefined values.
template<typename S >
void write (const std::valarray< S > &indata, long nRows, long firstRow)
 write a valarray of values into a range of rows of a vector column.
template<typename S >
void write (const std::vector< S > &indata, long nRows, long firstRow)
 write a vector of values into a range of rows of a vector column
template<typename S >
void write (S *indata, long nElements, long nRows, long firstRow)
 write a C array of values into a range of rows of a vector column
template<typename S >
void write (const std::valarray< S > &indata, long nRows, long firstRow, S *nullValue)
 write a valarray of values into a range of rows of a vector column.
template<typename S >
void write (const std::vector< S > &indata, long nRows, long firstRow, S *nullValue)
 write a vector of values into a range of rows of a vector column, processing undefined values
template<typename S >
void write (S *indata, long nElements, long nRows, long firstRow, S *nullValue)
 write a C array of values into a range of rows of a vector column, processing undefined values.
template<typename S >
void write (const std::valarray< S > &indata, const std::vector< long > &vectorLengths, long firstRow)
 write a valarray of values into a column with specified number of entries written per row.
template<typename S >
void write (const std::vector< S > &indata, const std::vector< long > &vectorLengths, long firstRow)
 write a vector of values into a column with specified number of entries written per row.
template<typename S >
void write (S *indata, long nElements, const std::vector< long > &vectorLengths, long firstRow)
 write a C-array of values of size nElements into a vector column with specified number of entries written per row.
template<typename S >
void writeArrays (const std::vector< std::valarray< S > > &indata, long firstRow)
 write a vector of valarray objects to the column, starting at row firstRow >= 1
template<typename S >
void writeArrays (const std::vector< std::valarray< S > > &indata, long firstRow, S *nullValue)
 write a vector of valarray objects to the column, starting at row firstRow >= 1, processing undefined values
double zero () const
 get TZEROn value

Protected Member Functions

 Column (int columnIndex, const String &columnName, ValueType type, const String &format, const String &unit, Table *p, int rpt=1, long w=1, const String &comment="")
 new column creation constructor
 Column (Table *p=0)
 Simple constructor to be called by subclass reading ctors.
const String & comment () const
 retrieve comment for Column
fitsfile * fitsPointer ()
 fits pointer corresponding to fits file containing column data.
void makeHDUCurrent ()
 make HDU containing this the current HDU of the fits file.
virtual std::ostream & put (std::ostream &s) const
 internal implementation of << operator.

Detailed Description

Abstract base class for Column objects.

Columns are the data containers used in FITS tables. Columns of scalar type (one entry per cell) are implemented by the template subclass ColumnData<T>. Columns of vector type (vector and variable rows) are implemented with the template subclass ColumnVectorData<T>. AsciiTables may only contain Columns of type ColumnData<T>, where T is an implemented FITS data type (see the CCfits.h header for a complete list. This requirement is enforced by ensuring that AsciiTable's addColumn method may only create an AsciiTable compatible column. The ColumnData<T> class stores its data in a std::vector<T> object.

BinTables may contain either ColumnData<T> or ColumnVectorData<T>. For ColumnVectorData, T must be a numeric type: string vectors are handled by ColumnData<T>; string arrays are not supported. The internal representation of the data is a std::vector<std::valarray<T> > object. The std::valarray class is designed for efficient numeric processing and has many vectorized numeric and transcendental functions defined on it.

Member template functions for read/write operations are provided in multiple overloads as the interface to data operations. Implicit data type conversions are supported but where they are required make the operations less efficient. Reading numeric column data as character arrays, supported by cfitsio, is not supported by CCfits.

As a base class, Column provides protected accessor/mutator inline functions to allow only its subclasses to access data members.


Constructor & Destructor Documentation

CCfits::Column::Column ( const Column right)

copy constructor, used in copying Columns to standard library containers.

The copy constructor is for internal use only: it does not affect the disk fits file associated with the object.

CCfits::Column::Column ( int  columnIndex,
const String &  columnName,
ValueType  type,
const String &  format,
const String &  unit,
Table p,
int  rpt = 1,
long  w = 1,
const String &  comment = "" 
) [protected]

new column creation constructor

This constructor allows the specification of:

Parameters:
columnIndexThe column number
columnNameThe column name, keyword TTYPEn
typeused for determining class of T in ColumnData<T>, ColumnVectorData<T>
formatthe column data format, TFORMn keyword
unitthe column data unit, TUNITn keyword
pthe Table pointer
rpt(optional) repeat count for the row ( == 1 for AsciiTables)
wthe row width
commentcomment to be added to the header.

Member Function Documentation

template<typename T >
void CCfits::Column::addNullValue ( nullVal)

Set the TNULLn keyword for the column.

Only relevant for integer valued columns, TNULLn is the value used by cfitsio in undefined processing. All entries in the table equal to an input "null value" are set equal to the value of TNULLn. (For floating point columns a system NaN value is used).

const String & CCfits::Column::dimen ( ) const [inline]

return TDIMn keyword

represents dimensions of data arrays in vector columns. for scalar columns, returns a default value.

const String & CCfits::Column::display ( ) const [inline]

return TDISPn keyword

TDISPn is suggested format for output of column data.

const String & CCfits::Column::format ( ) const [inline]

return TFORMn keyword

TFORMn specifies data format stored in disk file.

template<typename T >
bool CCfits::Column::getNullValue ( T *  nullVal) const

Get the value of the TNULLn keyword for the column.

Only relevant for integer valued columns. If the TNULLn keyword is present, its value will be written to *nullVal and the function returns true. If the keyword is not found or its value is undefined, the function returns false and *nullVal is not modified.

Parameters:
nullValA pointer to the variable for storing the TNULLn value.
template<typename S >
void CCfits::Column::read ( std::vector< S > &  vals,
long  first,
long  last 
)

Retrieve data from a scalar column into a std::vector.

This and the following functions perform implicit data conversions. An exception will be thrown if no conversion exists.

Parameters:
valsThe output container. The function will resize this as necessary
first,lastthe span of row numbers to read.
template<typename S >
void CCfits::Column::read ( std::valarray< S > &  vals,
long  first,
long  last 
)

Retrieve data from a scalar column into a std::valarray.

Parameters:
valsThe output container. The function will resize this as necessary
first,lastthe span of row numbers to read.
template<typename S >
void CCfits::Column::read ( std::valarray< S > &  vals,
long  rows 
)

return a single row of a vector column into a std::valarray

Parameters:
valsThe output valarray object
rowsThe row number to be retrieved (starting at 1).
template<typename S >
void CCfits::Column::read ( std::vector< S > &  vals,
long  first,
long  last,
S *  nullValue 
)

Retrieve data from a scalar column into a std::vector>, applying nullValue when relevant.

If both nullValue and *nullValue are not 0, then any undefined values in the file will be converted to *nullValue when copied into the vals vector. See cfitsio documentation for further details

Parameters:
valsThe output container. The function will resize this as necessary
first,lastthe span of row numbers to read.
nullValuepointer to value to be applied to undefined elements.
template<typename S >
void CCfits::Column::read ( std::valarray< S > &  vals,
long  first,
long  last,
S *  nullValue 
)

Retrieve data from a scalar column into a std::valarray, applying nullValue when relevant.

If both nullValue and *nullValue are not 0, then any undefined values in the file will be converted to *nullValue when copied into the vals valarray. See cfitsio documentation for further details

Parameters:
valsThe output container. The function will resize this as necessary
first,lastthe span of row numbers to read.
nullValuepointer to value to be applied to undefined elements.
template<typename S >
void CCfits::Column::readArrays ( std::vector< std::valarray< S > > &  vals,
long  first,
long  last 
)

return a set of rows of a vector column into a vector of valarrays

Parameters:
valsThe output container. The function will resize this as necessary
first,lastthe span of row numbers to read.
template<typename S >
void CCfits::Column::readArrays ( std::vector< std::valarray< S > > &  vals,
long  first,
long  last,
S *  nullValue 
)

return a set of rows of a vector column into a container, setting undefined values

Parameters:
valsThe output container. The function will resize this as necessary
first,lastthe span of row numbers to read.
nullValuepointer to integer value regarded as undefined
void CCfits::Column::readData ( long  firstRow = 1,
long  nelements = 1,
long  firstElem = 1 
) [pure virtual]

Read (or reread) data from the disk into the Column object's internal arrays.

This function normally does not need to be called. See the resetRead function for an alternative way of performing a reread from disk.

Parameters:
firstRowThe first row to be read
nelementsThe number of elements to read
firstElemThe number of the element on the first row to start at (ignored for scalar columns)
void CCfits::Column::resetRead ( ) [inline]

reset the Column's isRead flag to false

This forces the data to be reread from the disk the next time a read command is called on the Column, rather than simply retrieving the data already stored in the Column object's internal arrays. This may be useful for example if trying to reread a Column using a different nullValue argument than for an earlier read.

int CCfits::Column::rows ( ) const

return the number of rows in the table.

return number of rows in the Column

double CCfits::Column::scale ( ) const [inline]

get TSCALn value

TSCALn is used to convert a data array represented on disk in integer format as floating. Useful for compact storage of digitized data.

template<typename S >
void CCfits::Column::write ( const std::vector< S > &  indata,
long  firstRow 
)

write a vector of values into a scalar column starting with firstRow

Parameters:
indataThe data to be written.
firstRowThe first row to be written
template<typename S >
void CCfits::Column::write ( const std::valarray< S > &  indata,
long  firstRow 
)

write a valarray of values into a scalar column starting with firstRow

Parameters:
indataThe data to be written.
firstRowThe first row to be written
template<typename S >
void CCfits::Column::write ( S *  indata,
long  nRows,
long  firstRow 
)

write a C array of size nRows into a scalar Column starting with row firstRow.

Parameters:
indataThe data to be written.
nRowsThe size of the data array to be written
firstRowThe first row to be written
template<typename S >
void CCfits::Column::write ( const std::vector< S > &  indata,
long  firstRow,
S *  nullValue 
)

write a vector of values into a scalar column starting with firstRow, replacing elements equal to nullValue with the FITS null value.

If nullValue is not 0, the appropriate FITS null value will be substituted for all elements of indata equal to *nullValue. For integer type columns there must be a pre-existing TNULLn keyword to define the FITS null value, otherwise a FitsError exception is thrown. For floating point columns, the FITS null is the IEEE NaN (Not-a-Number) value. See the cfitsio fits_write_colnull function documentation for more details.

Parameters:
indataThe data to be written.
firstRowThe first row to be written
nullValuePointer to the value for which equivalent indata elements will be replaced in the file with the appropriate FITS null value.
template<typename S >
void CCfits::Column::write ( const std::valarray< S > &  indata,
long  firstRow,
S *  nullValue 
)

write a valarray of values into a scalar column starting with firstRow, replacing elements equal to nullValue with the FITS null value.

If nullValue is not 0, the appropriate FITS null value will be substituted for all elements of indata equal to *nullValue. For integer type columns there must be a pre-existing TNULLn keyword to define the FITS null value, otherwise a FitsError exception is thrown. For floating point columns, the FITS null is the IEEE NaN (Not-a-Number) value. See the cfitsio fits_write_colnull function documentation for more details.

Parameters:
indataThe data to be written.
firstRowThe first row to be written
nullValuePointer to the value for which equivalent indata elements will be replaced in the file with the appropriate FITS null value.
template<typename S >
void CCfits::Column::write ( S *  indata,
long  nRows,
long  firstRow,
S *  nullValue 
)

write a C array into a scalar Column, processing undefined values.

Parameters:
indataThe data to be written.
nRowsThe size of the data array to be written
firstRowThe first row to be written
nullValuePointer to the value in the input array to be set to undefined values
template<typename S >
void CCfits::Column::write ( const std::valarray< S > &  indata,
long  nRows,
long  firstRow 
)

write a valarray of values into a range of rows of a vector column.

The primary use of this is for fixed width columns, in which case Column's repeat attribute is used to determine how many elements are written to each row; if indata.size() is too small an exception will be thrown. If the column is variable width, the call will write indata.size()/nRows elements to each row.

Parameters:
indataThe data to be written.
nRowsthe number of rows to which to write the data.
firstRowThe first row to be written
template<typename S >
void CCfits::Column::write ( const std::vector< S > &  indata,
long  nRows,
long  firstRow 
)

write a vector of values into a range of rows of a vector column

The primary use of this is for fixed width columns, in which case Column's repeat attribute is used to determine how many elements are written to each row; if indata.size() is too small an exception will be thrown. If the column is variable width, the call will write indata.size()/nRows elements to each row.

Parameters:
indataThe data to be written.
nRowsthe number of rows to which to write the data.
firstRowThe first row to be written
template<typename S >
void CCfits::Column::write ( S *  indata,
long  nElements,
long  nRows,
long  firstRow 
)

write a C array of values into a range of rows of a vector column

Details are as for vector input; only difference is the need to supply the size of the C-array.

Parameters:
indataThe data to be written.
nElementsThe size of indata
nRowsthe number of rows to which to write the data.
firstRowThe first row to be written
template<typename S >
void CCfits::Column::write ( const std::valarray< S > &  indata,
long  nRows,
long  firstRow,
S *  nullValue 
)

write a valarray of values into a range of rows of a vector column.

see version without undefined processing for details.

template<typename S >
void CCfits::Column::write ( const std::vector< S > &  indata,
long  nRows,
long  firstRow,
S *  nullValue 
)

write a vector of values into a range of rows of a vector column, processing undefined values

see version without undefined processing for details.

template<typename S >
void CCfits::Column::write ( S *  indata,
long  nElements,
long  nRows,
long  firstRow,
S *  nullValue 
)

write a C array of values into a range of rows of a vector column, processing undefined values.

see version without undefined processing for details.

template<typename S >
void CCfits::Column::write ( const std::valarray< S > &  indata,
const std::vector< long > &  vectorLengths,
long  firstRow 
)

write a valarray of values into a column with specified number of entries written per row.

Data are written into vectorLengths.size() rows, with vectorLength[n] elements written to row n+firstRow -1. Although primarily intended for wrapping calls to multiple variable-width vector column rows, it may also be used to write a variable number of elements to fixed-width column rows.

When writing to fixed-width column rows, if the number of elements sent to a particular row are fewer than the column's repeat value, the remaining elements in the row will not be modified.

Since cfitsio does not support null value processing for variable width columns this function and its variants do not have version which process undefined values

Parameters:
indataThe data to be written
vectorLengthsthe number of elements to write to each successive row.
firstRowthe first row to be written.
template<typename S >
void CCfits::Column::write ( const std::vector< S > &  indata,
const std::vector< long > &  vectorLengths,
long  firstRow 
)

write a vector of values into a column with specified number of entries written per row.

Intended for writing a varying number of elements to multiple rows in a vector column, this may be used for either variable or fixed-width columns. See the indata valarray version of this function for a complete description.

template<typename S >
void CCfits::Column::write ( S *  indata,
long  nElements,
const std::vector< long > &  vectorLengths,
long  firstRow 
)

write a C-array of values of size nElements into a vector column with specified number of entries written per row.

Intended for writing a varying number of elements to multiple rows in a vector column, this may be used for either variable or fixed-width columns. See the indata valarray version of this function for a complete description.

template<typename S >
void CCfits::Column::writeArrays ( const std::vector< std::valarray< S > > &  indata,
long  firstRow 
)

write a vector of valarray objects to the column, starting at row firstRow >= 1

Intended for writing a varying number of elements to multiple rows in a vector column, this may be used for either variable or fixed-width columns. When writing to fixed-width column rows, if the number of elements sent to a particular row are fewer than the column's repeat value, the remaining elements in the row will not be modified.

Parameters:
indataThe data to be written
firstRowthe first row to be written.
template<typename S >
void CCfits::Column::writeArrays ( const std::vector< std::valarray< S > > &  indata,
long  firstRow,
S *  nullValue 
)

write a vector of valarray objects to the column, starting at row firstRow >= 1, processing undefined values

see version without undefined processing for details.

double CCfits::Column::zero ( ) const [inline]

get TZEROn value

TZEROn is an integer offset used in the implementation of unsigned data


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