CCfits 2.6

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
CCfits::ExtHDU Class Referenceabstract

base class for all FITS extension HDUs, i.e. Image Extensions and Tables. More...

`#include <ExtHDU.h>`

Inheritance diagram for CCfits::ExtHDU:

## Classes
class | WrongExtensionType
| Exception to be thrown on unmatched extension types. More...

## Public Member Functions
| 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. More...
virtual HDU * | clone (FITS *p) const =0
| virtual copy constructor
virtual Column & | column (const String &colName, bool caseSensitive=true) const
| return a reference to a Table column specified by name. More...
virtual Column & | column (int colIndex) const
| return a reference to a Table column specified by column index. More...
virtual const ColMap & | column () const
| return a reference to the multimap containing the columns. More...
virtual void | copyColumn (const Column &inColumn, int colIndx, bool insertNewCol=true)
| copy a column (from different or same HDU and file) into an existing table HDU. More...
virtual void | deleteColumn (const String &columnName)
| delete a column in a Table extension by name. More...
virtual long | getRowsize () const
| return the optimal number of rows to read or write at a time More...
bool | isCompressed () const
| return true if image is stored using compression. More...
virtual void | makeThisCurrent () const
| move the fitsfile pointer to this current HDU. More...
const String & | name () const
| return the name of the extension.
virtual int | numCols () const
| return the number of Columns in the Table (the TFIELDS keyword). More...
template<typename S >
void | read (std::valarray< S > &image)
| Read image data into container. More...
template<typename S >
void | read (std::valarray< S > &image, long first, long nElements, S *nullValue)
| read part of an image array, processing null values. More...
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. More...
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 More...
virtual void | readData (bool readFlag=false, const std::vector< String > &keys=std::vector< String >())=0
| read data from HDU depending on readFlag and keys.
virtual long | rows () const
| return the number of rows in the extension. More...
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. More...
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 More...
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 More...
Public Member Functions inherited from CCfits::HDU
| HDU (const HDU &right)
| copy constructor
template<typename T >
Keyword & | addKey (const String &name, T val, const String &comment, bool isLongStr=false)
| create a new keyword in the HDU with specified value and comment fields More...
Keyword * | addKey (const Keyword *inKeyword)
| create a copy of an existing Keyword and add to HDU More...
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]. More...
long | bitpix () const
| return the data type keyword. More...
const string & | comment () const
| return the comment string previously read by getComment()
void | copyAllKeys (const HDU *inHdu, const std::vector< int > &keyCategories=std::vector< int >())
| copy all keys from another header More...
void | deleteKey (const String &doomed)
| delete a keyword from the header More...
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. More...
const String & | getComments ()
| read the comments from the HDU and add it to the FITS object. More...
const String & | getHistory ()
| read the history information from the HDU and add it to the FITS object. More...
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.
Keyword & | keyWord (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 Keyword & | keyWord (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
FITS * | parent () const
| return reference to the pointer representing the FITS object containing the HDU
void | readAllKeys (const std::vector< int > &keyCategories=std::vector< int >())
| read all of the keys in the header More...
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. More...
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 More...
Keyword & | readNextKey (const std::vector< String > &incList, const std::vector< String > &excList, bool searchFromBeginning=false)
| Read the next key in the HDU which matches a string in incList, and does not match string in excList. More...
virtual void | resetImageRead ()
| force next image reading operation to read from file instead of object cache. More...
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) More...
virtual void | suppressScaling (bool toggle=true)
| turn off image scaling regardless of the BSCALE and BZERO keyword values More...
void | updateChecksum ()
| update the CHECKSUM keyword value, assuming DATASUM exists and is correct More...
std::pair< int, int > | verifyChecksum () const
| verify the HDU by computing the checksums and comparing them with the CHECKSUM/DATASUM keywords More...
void | writeChecksum ()
| compute and write the DATASUM and CHECKSUM keyword values More...
void | writeComment (const String &comment="Generic Comment")
| write a comment string. More...
void | writeDate ()
| write a date string to *this.
void | writeHistory (const String &history="Generic History String")
| write a history string. More...
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) More...

## Static Public Member Functions
static void | readHduName (const fitsfile *fptr, int hduIndex, String &hduName, int &hduVersion)
| read extension name. More...
Static Public Member Functions inherited from CCfits::HDU
static std::vector< int > | keywordCategories ()
| Return the default enumerated keyword categories used by copyAllKeys() More...

## Protected Member Functions
| ExtHDU (FITS *p, HduType xtype, const String &hduName, int version)
| default constructor, required as Standard Library Container content.
| ExtHDU (FITS *p, HduType xtype, const String &hduName, int bitpix, int naxis, const std::vector< long > &axes, int version)
| writing constructor. More...
| ExtHDU (FITS *p, HduType xtype, int number)
| ExtHDU constructor for getting ExtHDUs by number. More...
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 More...
void | xtension (HduType value)
| set the extension type
Protected Member Functions inherited from CCfits::HDU
| HDU (FITS *p=0)
| default constructor, called by HDU subclasses that read from FITS files.
| HDU (FITS *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.

## Detailed Description

base class for all FITS extension HDUs, i.e. Image Extensions and Tables.

ExtHDU needs to have the combined public interface of Table objects and images. It achieves this by providing the same set of read and write operations as PHDU, and also providing the same operations for extracting columns from the extension as does Table [after which the column interface is accessible]. Differentiation between extension types operates by exception handling: .i.e. attempting to access image data structures on a Table object through the ExtHDU interface will or trying to return a Column reference from an Image extension will both throw an exception

## Constructor & Destructor Documentation

CCfits::ExtHDU::ExtHDU | ( | FITS * | p,
|  | HduType | xtype,
|  | const String & | hduName,
|  | int | bitpix,
|  | int | naxis,
|  | const std::vector< long > & | axes,
|  | int | version
| ) |  |
| protected

writing constructor.

The writing constructor forces the user to supply a name for the HDU. The bitpix, naxes and naxis data required by this constructor are required FITS keywords for any HDUs.

CCfits::ExtHDU::ExtHDU | ( | FITS * | p,
|  | HduType | xtype,
|  | int | number
| ) |  |
| protected

ExtHDU constructor for getting ExtHDUs by number.

Necessary since EXTNAME is a reserved, not required, keyword. But a synthetic name is supplied by static ExtHDU::readHduName which is called by this constructor.

## Member Function Documentation

void CCfits::ExtHDU::addColumn | ( | ValueType | type,
|  | const String & | columnName,
|  | long | repeatWidth,
|  | const String & | colUnit = `String("")`,
|  | long | decimals = `-1`,
|  | size_t | columnNumber = `0`
| ) |  |
| virtual

add a new column to an existing table HDU.

Parameters

  type | The data type of the column to be added
  columnName | The name of the column to be added
  repeatWidth | for a string valued, this is the width of a string. For a numeric column it supplies the vector length of the rows. It is ignored for ascii table numeric data.
  colUnit | an optional field specifying the units of the data (TUNITn)
  decimals | optional parameter specifying the number of decimals for an ascii numeric column
  columnNumber | optional parameter specifying column number to be created. If not specified the column is added to the end. If specified, the column is inserted and the columns already read are reindexed. This parameter is provided as a convenience to support existing code rather than recommended.

Reimplemented in CCfits::AsciiTable, and CCfits::BinTable.

Column & CCfits::ExtHDU::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

  WrongExtensionType | see above

Reimplemented in CCfits::Table.

Column & CCfits::ExtHDU::column | ( | int | colIndex | ) | const
| virtual

return a reference to a Table column specified by column index.

This version is provided for convenience; the 'return by name' version is more efficient because columns are stored in an associative array sorted by name.

Exceptions

  WrongExtensionType | thrown if *this is an image extension.

Reimplemented in CCfits::Table.

const ColMap & CCfits::ExtHDU::column | ( |  | ) | const
| virtual

return a reference to the multimap containing the columns.

Exceptions

  WrongExtensionType | thrown if *this is an image extension.

Reimplemented in CCfits::Table.

void CCfits::ExtHDU::copyColumn | ( | const Column & | inColumn,
|  | int | colIndx,
|  | bool | insertNewCol = `true`
| ) |  |
| virtual

copy a column (from different or same HDU and file) into an existing table HDU.

This is meant to provide the same functionality as CFITSIO's fits_copy_col, and therefore does not work with columns with variable length fields. Copying a column from an AsciiTable to a BinTable is prohibited. colIndx range should be from 1 to nCurrentCols+1 if inserting, or 1 to nCurrentCols if replacing.

Parameters

  inColumn | The Column object which is to be copied
  colIndx | The position for which the copied Column will be placed (first colIndx = 1).
  insertNewCol | If 'true', new Column will be inserted in or appended to table. If 'false', Column will replace current Column at position = colIndx.

Reimplemented in CCfits::Table.

void CCfits::ExtHDU::deleteColumn | ( | const String & | columnName | ) |
| virtual

delete a column in a Table extension by name.

Parameters

  columnName | The name of the column to be deleted.

Exceptions

  WrongExtensionType | if extension is an image.

Reimplemented in CCfits::Table.

long CCfits::ExtHDU::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 in CCfits::Table.

bool CCfits::ExtHDU::isCompressed | ( |  | ) | const

return true if image is stored using compression.

This is simply a wrapper around the CFITSIO fits_is_compressed_image function. It will throw if this is not an Image extension.

void CCfits::ExtHDU::makeThisCurrent | ( |  | ) | const
| virtual

move the fitsfile pointer to this current HDU.

This function should never need to be called by the user since it is called internally whenever required.

Reimplemented from CCfits::HDU.

int CCfits::ExtHDU::numCols | ( |  | ) | const
| virtual

return the number of Columns in the Table (the TFIELDS keyword).

Exceptions

  WrongExtensionType | thrown if *this is an image extension.

Reimplemented in CCfits::Table.

template<typename S >

void CCfits::ExtHDU::read | ( | std::valarray< S > & | image | ) |

Read image data into container.

The container image contains the entire image array after the call. This and all the other variants of read() throw a WrongExtensionType exception if called for a Table object.

template<typename S >

void CCfits::ExtHDU::read | ( | std::valarray< S > & | image,
|  | long | first,
|  | long | nElements,
|  | S * | nullValue
| ) |  |

read part of an image array, processing null values.

Implicit data conversion is supported (i.e. user does not need to know the type of the data stored. A WrongExtensionType extension is thrown if *this is not an image.

Parameters

  image | The receiving container, a std::valarray reference
  first | The first pixel from the array to read [a long value]
  nElements | The number of values to read
  nullValue | A pointer containing the value in the table to be considered as undefined. See cfitsio for details

template<typename S >

void CCfits::ExtHDU::read | ( | std::valarray< S > & | image,
|  | const std::vector< long > & | first,
|  | long | nElements,
|  | S * | nullValue
| ) |  |

read part of an image array, processing null values.

As above except for

Parameters

  first | a vector<long> representing an n-tuple giving the coordinates in the image of the first pixel.

template<typename S >

void CCfits::ExtHDU::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

The image subset is defined by two vertices and a stride indicating the 'denseness' of the values to be picked in each dimension (a stride = (1,1,1,...) means picking every pixel in every dimension, whereas stride = (2,2,2,...) means picking every other value in each dimension.

static void CCfits::ExtHDU::readHduName | ( | const fitsfile * | fptr,
|  | int | hduIndex,
|  | String & | hduName,
|  | int & | hduVersion
| ) |  |
| static

read extension name.

Used primarily to allow extensions to be specified by HDU number and provide their name for the associative array that contains them. Alternatively, if there is no name keyword in the extension, one is synthesized from the index.

long CCfits::ExtHDU::rows | ( |  | ) | const
| virtual

return the number of rows in the extension.

Exceptions

  WrongExtensionType | thrown if *this is an image extension.

Reimplemented in CCfits::Table.

template<typename S >

void CCfits::ExtHDU::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.

All the overloaded versions of ExtHDU::write perform operations on *this if it is an image and throw a WrongExtensionType exception if not. Where appropriate, alternate versions allow undefined data to be processed

Parameters

  first | an n-tuple of dimension equal to the image dimension specifying the first pixel in the range to be written
  nElements | number of pixels to be written
  data | array of data to be written
  nullValue | pointer to null value (data with this value written as undefined; needs the BLANK keyword to have been specified).

template<typename S >

void CCfits::ExtHDU::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

parameters after the first are as for version with n-tuple specifying first element. these two version are equivalent, except that it is possible for the first pixel number to exceed the range of 32-bit integers, which is how long datatype is commonly implemented.

template<typename S >

void CCfits::ExtHDU::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

A generalized slice/subset is a subset of the image (e.g. one plane of a data cube of size <= the dimension of the cube). It is specified by two opposite vertices. The equivalent cfitsio call does not support undefined data processing so there is no version that allows a null value to be specified.

Parameters

  firstVertex | the coordinates specifying lower and upper vertices of the n-dimensional slice
  lastVertex |
  data | The data to be written

HduType CCfits::ExtHDU::xtension | ( |  | ) | const
| inline protected

return the extension type

allowed values are ImageHDU, AsciiTbl, and BinaryTbl

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

- ExtHDU.h
- ExtHDU.cxx
- ExtHDUT.h