CCfits  2.6
Public Member Functions | Protected Member Functions | List of all members
CCfits::PHDU Class Referenceabstract

class representing the primary HDU for a FITS file. More...

#include <PHDU.h>

Inheritance diagram for CCfits::PHDU:
Inheritance diagram CCfits::HDU

Public Member Functions

virtual ~PHDU ()
 destructor More...
 
virtual PHDUclone (FITS *p) const =0
 virtual copy constructor for Primary HDUs. More...
 
bool extend () const
 Returns the value of the Primary's EXTEND keyword.
 
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, 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)
 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 > &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, 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 primary HDU data More...
 
virtual void scale (double value)
 set the BSCALE keyword value for images (see warning for images of int type) More...
 
virtual double scale () const
 return the BSCALE keyword value
 
bool simple () const
 Returns the value of the Primary's SIMPLE keyword.
 
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::vector< long > &stride, const std::valarray< S > &data)
 write a subset (generalize slice) of data to the image More...
 
virtual void zero (double value)
 set the BZERO keyword value for images (see warning for images of int type) More...
 
virtual double zero () const
 return the BZERO keyword value
 
- 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, bool isLongStr=false)
 create a new keyword in the HDU with specified value and comment fields More...
 
KeywordaddKey (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.
 
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
 
virtual void makeThisCurrent () const
 move the fitsfile pointer to this current HDU. More...
 
bool operator!= (const HDU &right) const
 inequality operator
 
bool operator== (const HDU &right) const
 equality operator
 
FITSparent () 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...
 
KeywordreadNextKey (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 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...
 

Protected Member Functions

 PHDU (const PHDU &right)
 copy constructor More...
 
 PHDU (FITS *p, int bpix, int naxis, const std::vector< long > &axes)
 Writing Primary HDU constructor, called by PrimaryHDU<T> class. More...
 
 PHDU (FITS *p=0)
 Reading Primary HDU constructor. More...
 
virtual void initRead ()
 
- 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.
 

Additional Inherited Members

- Static Public Member Functions inherited from CCfits::HDU
static std::vector< int > keywordCategories ()
 Return the default enumerated keyword categories used by copyAllKeys() More...
 

Detailed Description

class representing the primary HDU for a FITS file.

A PHDU object is automatically instantiated and added to a FITS object when a FITS file is accessed in any way. If a new file is created without specifying the data type for the header, CCfits assumes that the file is to be used for table extensions and creates a dummy header. PHDU instances are only created by FITS ctors. In the first release of CCfits, the Primary cannot be changed once declared.

PHDU and ExtHDU provide the same interface to writing images: multiple overloads of the templated PHDU::read and PHDU::write operations provide for (a) writing image data specified in a number of ways [C-array, std::vector, std::valarray] and with input location specified by initial pixel, by n-tuple, and by rectangular subset [generalized slice]; (b) reading image data specified similarly to the write options into a std::valarray.

Todo:
Implement functions that allow replacement of the primary image

Constructor & Destructor Documentation

CCfits::PHDU::~PHDU ( )
virtual

destructor

Destructor

CCfits::PHDU::PHDU ( const PHDU right)
protected

copy constructor

required for cloning primary HDUs when copying FITS files.

CCfits::PHDU::PHDU ( FITS p,
int  bpix,
int  naxis,
const std::vector< long > &  axes 
)
protected

Writing Primary HDU constructor, called by PrimaryHDU<T> class.

Constructor used for creating new PHDU (i.e. for writing data to FITS). also doubles as default constructor since all arguments have default values, which are passed to the HDU constructor

CCfits::PHDU::PHDU ( FITS p = 0)
protected

Reading Primary HDU constructor.

Constructor used when reading the primary HDU from an existing file. Does nothing except initialize, with the real work done by the subclass PrimaryHDU<T>.

Member Function Documentation

CCfits::PHDU::clone ( FITS p) const
pure virtual

virtual copy constructor for Primary HDUs.

The operation is used when creating a copy of a FITS object.

Implements CCfits::HDU.

void CCfits::PHDU::initRead ( )
protectedvirtual

Read image header and update fits pointer accordingly.

Private: called by ctor.

Implements CCfits::HDU.

template<typename S >
void CCfits::PHDU::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
imageThe receiving container, a std::valarray reference
firstThe first pixel from the array to read [a long value]
nElementsThe number of values to read
nullValueA pointer containing the value in the table to be considered as undefined. See cfitsio for details
template<typename S >
void CCfits::PHDU::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
firsta vector<long> representing an n-tuple giving the coordinates in the image of the first pixel.
template<typename S >
void CCfits::PHDU::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.

void CCfits::PHDU::readData ( bool  readFlag = false,
const std::vector< String > &  keys = std::vector<String>() 
)
pure virtual

read primary HDU data

Called by FITS ctor, not intended for general use. parameters control how much gets read on initialization. An abstract function, implemented in the subclasses.

Parameters
readFlagread the image data if true
keya vector of strings of keyword names to be read from the primary HDU
void CCfits::PHDU::scale ( double  value)
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 from CCfits::HDU.

template<typename S >
void CCfits::PHDU::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 PHDU::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
firstan n-tuple of dimension equal to the image dimension specifying the first pixel in the range to be written
nElementsnumber of pixels to be written
dataarray of data to be written
nullValuepointer to null value (data with this value written as undefined; needs the BLANK keyword to have been specified).
template<typename S >
void CCfits::PHDU::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::PHDU::write ( const std::vector< long > &  firstVertex,
const std::vector< long > &  lastVertex,
const std::vector< long > &  stride,
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
firstVertexThe coordinates specifying lower and upper vertices of the n-dimensional slice
lastVertex
stridePixels to skip in each to dimension, e.g. stride = (1,1,1,...) means picking every pixel in every dimension, whearas stride = (2,2,2,...) means picking every other value in each dimension.
dataThe data to be written
void CCfits::PHDU::zero ( double  value)
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 from CCfits::HDU.


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