CCfits 2.7

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

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

Public Member Functions | Protected Member Functions
CCfits::PHDU Class Reference

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

`#include <PHDU.h>`

Inheritance diagram for CCfits::PHDU:

List of all members.

## Public Member Functions

virtual | ~PHDU ()
| destructor
virtual PHDU * | clone (FITS *p) const =0
| virtual copy constructor for Primary HDUs.
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.
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.
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
virtual void | readData (bool readFlag=false, const std::vector< String > &keys=std::vector< String >())=0
| read primary HDU data
virtual void | scale (double value)
| set the BSCALE keyword value for images (see warning for images of int type)
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.
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::vector< long > &stride, const std::valarray< S > &data)
| write a subset (generalize slice) of data to the image
virtual void | zero (double value)
| set the BZERO keyword value for images (see warning for images of int type)
virtual double | zero () const
| return the BZERO keyword value

## Protected Member Functions

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

## 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 | ( |  | ) | `[protected, virtual]`

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:

  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::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:

  first | a 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:

  readFlag | read the image data if true
  key | a 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:

  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::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:

  firstVertex | The coordinates specifying lower and upper vertices of the n-dimensional slice
  lastVertex |
  stride | Pixels 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.
  data | The 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:

- PHDU.h
- PHDU.cxx
- PHDUT.h