#include <HDU.h>
Public Member Functions | |
HDU (const HDU &right) | |
copy constructor | |
bool | operator== (const HDU &right) const |
equality operator | |
bool | operator!= (const HDU &right) const |
inequality operator | |
virtual HDU * | clone (FITSBase *p) const =0 |
virtual copy constructor, to be implemented in subclasses. | |
fitsfile * | fitsPointer () const |
return the fitsfile pointer for the FITS object containing the HDU | |
FITSBase * | parent () const |
return reference to the pointer representing the FITSBase object containing the HDU | |
virtual void | makeThisCurrent () const |
move the fitsfile pointer to this current HDU. | |
const String & | getComments () |
read the comments from the HDU and add it to the FITS object. | |
const string & | comment () const |
return the comment string previously read by getComment() | |
void | writeComment (const String &comment="Generic Comment") |
write a comment string. | |
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 | writeHistory (const String &history="Generic History String") |
write a history string. | |
void | writeDate () |
write a date string to *this. | |
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]. | |
void | index (int value) |
set the HDU number | |
int | index () const |
return the HDU number | |
long | bitpix () const |
return the data type keyword. | |
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) | |
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) | |
void | suppressScaling (bool toggle=true) |
turn off image scaling regardless of the BSCALE and BZERO keyword values | |
void | writeChecksum () |
compute and write the DATASUM and CHECKSUM 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 | |
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. | |
void | deleteKey (const String &doomed) |
delete a keyword from the header | |
void | readAllKeys () |
read all of the keys in the header | |
void | copyAllKeys (const HDU *inHdu) |
copy all keys from another header | |
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 | |
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 | |
template<typename T> | |
Keyword & | addKey (const String &name, T val, const String &comment) |
create a new keyword in the HDU with specified value and comment fields | |
Keyword * | addKey (const Keyword *inKeyword) |
create a copy of an existing Keyword and add to HDU | |
Static Public Member Functions | |
static std::vector< int > | keywordCategories () |
return the enumerated keyword categories used by readAllKeys() and copyAllKeys() | |
Protected Member Functions | |
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. | |
Classes | |
class | InvalidExtensionType |
exception to be thrown if user requests extension type that can not be understood as ImageExt, AsciiTable or BinTable. More... | |
class | InvalidImageDataType |
exception to be thrown if user requests creation of an image of type not supported by cfitsio. More... | |
class | NoNullValue |
exception to be thrown on seek errors for keywords. More... | |
class | NoSuchKeyword |
exception to be thrown on seek errors for keywords. More... |
HDU objects in CCfits are either PHDU (Primary HDU objects) or ExtHDU (Extension HDU) objects. Following the behavior. ExtHDUs are further subclassed into ImageExt or Table objects, which are finally AsciiTable or BinTable objects.
HDU's public interface gives access to properties that are common to all HDUs, largely required keywords, and functions that are common to all HDUs, principally the manipulation of keywords and their values.
HDUs must be constructed by HDUCreator objects which are called by FITS methods. Each HDU has an embedded pointer to a FITSBase object, which is private to FITS [FITSBase is a pointer encapsulating the resources of FITS. For details of this coding idiom see Exceptional C++ by Herb Sutter (2000) and references therein].
void CCfits::HDU::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 in CCfits::ExtHDU.
References fitsPointer().
Referenced by addKey(), CCfits::FITS::copy(), copyAllKeys(), CCfits::FITS::FITS(), getChecksum(), CCfits::ExtHDU::makeThisCurrent(), CCfits::PHDU::read(), readAllKeys(), readKey(), CCfits::PHDU::scale(), suppressScaling(), updateChecksum(), verifyChecksum(), CCfits::PHDU::write(), CCfits::Keyword::write(), writeChecksum(), writeComment(), writeDate(), writeHistory(), and CCfits::PHDU::zero().
const String & CCfits::HDU::getComments | ( | ) |
read the comments from the HDU and add it to the FITS object.
The comment string found in the header is concatenated and returned to the calling function
Referenced by readAllKeys().
void CCfits::HDU::writeComment | ( | const String & | comment = "Generic Comment" |
) |
write a comment string.
A default value for the string is given ("Generic Comment String") so users can put a placeholder call to this function in their code.
References fitsPointer(), and makeThisCurrent().
const String & CCfits::HDU::getHistory | ( | ) |
read the history information from the HDU and add it to the FITS object.
The history string found in the header is concatenated and returned to the calling function
Referenced by readAllKeys().
void CCfits::HDU::writeHistory | ( | const String & | history = "Generic History String" |
) |
write a history string.
A default value for the string is given ("Generic History String") so users can put a placeholder call to this function in their code.
References fitsPointer(), and makeThisCurrent().
long CCfits::HDU::axis | ( | size_t | index | ) | const [inline] |
return the size of axis numbered index [zero based].
return the length of HDU data axis i.
Referenced by CCfits::Table::rows().
long CCfits::HDU::bitpix | ( | ) | const [inline] |
return the data type keyword.
Takes values denoting the image data type for images, and takes the fixed value 8 for tables.
Referenced by CCfits::PHDU::initRead(), CCfits::PHDU::read(), CCfits::ExtHDU::read(), CCfits::PHDU::write(), and CCfits::ExtHDU::write().
void CCfits::HDU::scale | ( | double | value | ) | [inline, virtual] |
set the BSCALE keyword value for images (see warning for images of int type)
For primary HDUs and image extensions, this will add (or update) the BSCALE keyword in the header. The new setting will affect future image array read/writes as described in section 4.7 Data Scaling of the CFITSIO manual. For table extensions this function does nothing.
WARNING: If the image contains integer-type data (as indicated by the bitpix() return value), the new scale and zero value combination must not be such that the scaled data would require a floating-point type (this uses the CFITSIO function fits_get_img_equivtype to make the determination). If this situation occurs, the function will throw a FitsException.
Reimplemented in CCfits::ImageExt< T >, and CCfits::PHDU.
void CCfits::HDU::zero | ( | double | value | ) | [inline, virtual] |
set the BZERO keyword value for images (see warning for images of int type)
For primary HDUs and image extensions, this will add (or update) the BZERO keyword in the header. The new setting will affect future image array read/writes as described in section 4.7 Data Scaling of the CFITSIO manual. For table extensions this function does nothing.
WARNING: If the image contains integer-type data (as indicated by the bitpix() return value), the new scale and zero value combination must not be such that the scaled data would require a floating-point type (this uses the CFITSIO function fits_get_img_equivtype to make the determination). If this situation occurs, the function will throw a FitsException.
Reimplemented in CCfits::ImageExt< T >, and CCfits::PHDU.
void CCfits::HDU::suppressScaling | ( | bool | toggle = true |
) |
turn off image scaling regardless of the BSCALE and BZERO keyword values
For toggle = true, this turns off image scaling for future read/writes by resetting the scale and zero to 1.0 and 0.0 respectively. It does NOT modify the BSCALE and BZERO keywords. If toggle = false, the scale and zero values will be restored to the keyword values.
References makeThisCurrent().
void CCfits::HDU::writeChecksum | ( | ) |
compute and write the DATASUM and CHECKSUM keyword values
Wrapper for the CFITSIO function fits_write_chksum: This performs the datasum and checksum calculations for this HDU, as described in the CFITSIO manual. If either the DATASUM or CHECKSUM keywords already exist, their values will be updated.
References makeThisCurrent().
void CCfits::HDU::updateChecksum | ( | ) |
update the CHECKSUM keyword value, assuming DATASUM exists and is correct
Wrapper for the CFITSIO function fits_update_chksum: This recomputes and writes the CHECKSUM value with the assumption that the DATASUM value is correct. If the DATASUM keyword doesn't yet exist or is not up-to-date, use the HDU::writeChecksum function instead. This will throw a FitsError exception if called when there is no DATASUM keyword in the header.
References makeThisCurrent().
std::pair< int, int > CCfits::HDU::verifyChecksum | ( | ) | const |
verify the HDU by computing the checksums and comparing them with the CHECKSUM/DATASUM keywords
Wrapper for the CFITSIO function fits_verify_chksum: The data unit is verified correctly if the computed checksum equals the DATASUM keyword value, and the HDU is verified if the entire checksum equals zero (see the CFITSIO manual for further details).
This returns a std::pair<int,int> where the pair's first data member = DATAOK and second = HDUOK. DATAOK and HDUOK values will be = 1 if verified correctly, 0 if the keyword is missing, and -1 if the computed checksum is not correct.
References makeThisCurrent().
std::pair< unsigned long, unsigned long > CCfits::HDU::getChecksum | ( | ) | const |
compute and return the checksum values for the HDU without creating or modifying the CHECKSUM/DATASUM keywords.
Wrapper for the CFITSIO function fits_get_chksum: This returns a std::pair<unsigned long, unsigned long> where the pair's first data member holds the datasum value and second holds the hdusum value.
References makeThisCurrent().
void CCfits::HDU::deleteKey | ( | const String & | doomed | ) |
delete a keyword from the header
removes doomed from the FITS file and from the FITS object
References fitsPointer(), keyWord(), and CCfits::Keyword::name().
void CCfits::HDU::readAllKeys | ( | ) |
read all of the keys in the header
This member function reads keys that are not meta data for columns or image information, [which are considered to be part of the column or image objects]. Also, history and comment keys are read and returned by getHistory() and getComment(). The exact list of keyword classes this will read is returned by the function keywordCategories().
Note that readAllKeys can only construct keys of type string, double, complex<float>, integer, and bool because the FITS header records do not encode exact type information.
References fitsPointer(), getComments(), getHistory(), and makeThisCurrent().
void CCfits::HDU::copyAllKeys | ( | const HDU * | inHdu | ) |
copy all keys from another header
Parameters:
inHdu | (const HDU*) An existing HDU whose keys will be copied. |
References addKey(), keyWord(), and makeThisCurrent().
static std::vector< int > CCfits::HDU::keywordCategories | ( | ) | [static] |
return the enumerated keyword categories used by readAllKeys() and copyAllKeys()
This returns a vector of integers indicating which categories of keywords apply for the readAllKeys and copyAllKeys functions. The list of categories currently hardcoded is: TYP_CMPRS_KEY (20), TYP_CKSUM_KEY (100), TYP_WCS_KEY (110), TYP_REFSYS_KEY (120), and TYP_USER_KEY (150).
For the list of ALL keyword categories, see the CFITSIO documentation at: http://heasarc.gsfc.nasa.gov/docs/software/fitsio/c/c_user/node50.html
void CCfits::HDU::readKey | ( | const String & | keyName, | |
T & | val | |||
) | [inline] |
read a keyword of specified type from the header of a disk FITS file and return its value.
T is one of the types String, double, float, int, std::complex<float>, and bool. If a Keyword object with the name keyName already exists in this HDU due to a previous read call, then this will re-read from the file and create a new Keyword object to replace the existing one.
References makeThisCurrent(), and CCfits::Keyword::value().
Referenced by CCfits::PHDU::write(), and CCfits::ExtHDU::write().
void CCfits::HDU::readKeys | ( | std::vector< String > & | keyNames, | |
std::vector< T > & | vals | |||
) | [inline] |
read a set of specified keywords of the same data type from the header of a disk FITS file and return their values
T is one of the types String, double, float, int, std::complex<float>, and bool.
Keyword & CCfits::HDU::addKey | ( | const String & | name, | |
T | value, | |||
const String & | comment | |||
) | [inline] |
create a new keyword in the HDU with specified value and comment fields
The function returns a reference to keyword object just created. If a keyword with this name already exists, it will be overwritten. Note that this is mostly intended for adding user-defined keywords. It should not be used to add keywords for which there are already specific HDU functions, such as scaling or checksum. Nor should it be used for image or column structural keywords, such as BITPIX, NAXIS, TFORMn, etc. As a general rule, it is best to use this for keywords belonging to the same categories listed in the keywordCategories() function.
Parameters:
name | (String) The keyword name | |
value | (Recommended T = String, double, std::complex<float>, int, or bool | |
comment | (String) the keyword value |
References makeThisCurrent().
Referenced by copyAllKeys().
create a copy of an existing Keyword and add to HDU
This is particularly useful for copying Keywords from one HDU to another. For example the inKeyword pointer might come from a different HDU's std::map<string,Keyword*>. If a keyword with this name already exists, it will be overwritten. The return value is a pointer to the newly created Keyword inserted into this HDU. Also see copyAllKeys().
References CCfits::Keyword::clone(), makeThisCurrent(), CCfits::Keyword::name(), CCfits::Keyword::setParent(), and CCfits::Keyword::write().