NASA - Jet Propulsion Laboratory
    + View the NASA Portal
Search JPL
Jet Propulsion Laboratory Home Earth Solar System Stars & Galaxies Technology
Introduction Background Software Links

fitshandle Class Reference
[FITS-related functionality]

#include <fitshandle.h>

List of all members.

File-level access and manipulation.



 fitshandle ()
 fitshandle (const std::string &fname, openmethod mode=OPEN, int rwmode=READONLY)
 fitshandle (const std::string &fname, int hdunum, int rwmode=READONLY)
 ~fitshandle ()
void open (const std::string &fname, int rwmode=READONLY)
void create (const std::string &fname)
void close ()
void goto_hdu (int hdu)
int num_hdus () const
void assert_pdmtype (const std::string &pdmtype) const
void insert_bintab (const std::vector< fitscolumn > &cols, const std::string &extname="xtension")
void insert_asctab (const std::vector< fitscolumn > &cols, const std::string &extname="xtension")
void insert_image (int btpx, const std::vector< int64 > &Axes)
template<typename T>
void insert_image (int btpx, const arr2< T > &data)
void write_checksum ()
static void delete_file (const std::string &name)

Public Types

enum  openmethod { CREATE, OPEN }

Public Member Functions

Information about the current HDU


int bitpix () const
int hdutype () const
const std::vector< int64 > & axes () const
const std::string & colname (int i) const
const std::string & colunit (int i) const
int64 repcount (int i) const
int coltype (int i) const
int ncols () const
int64 nrows () const
int64 nelems (int i) const
Keyword-handling methods


void copy_header (const fitshandle &orig)
void copy_historified_header (const fitshandle &orig)
void get_all_keys (std::vector< std::string > &keys) const
template<typename T>
void add_key (const std::string &name, const T &value, const std::string &comment="")
template<typename T>
void update_key (const std::string &name, const T &value, const std::string &comment="")
void delete_key (const std::string &name)
void add_comment (const std::string &comment)
template<typename T>
void get_key (const std::string &name, T &value) const
template<typename T>
get_key (const std::string &name) const
bool key_present (const std::string &name) const
int get_key_type (const std::string &name) const
Methods for table data I/O


void read_column_raw_void (int colnum, void *data, int type, int64 num, int64 offset=0) const
template<typename T>
void read_column_raw (int colnum, T *data, int64 num, int64 offset=0) const
template<typename T>
void read_column (int colnum, arr< T > &data, int64 offset=0) const
template<typename T>
void read_column (int colnum, T &data, int64 offset=0) const
template<typename T>
void read_entire_column (int colnum, arr< T > &data) const
void write_column_raw_void (int colnum, const void *data, int type, int64 num, int64 offset=0)
template<typename T>
void write_column_raw (int colnum, const T *data, int64 num, int64 offset=0)
template<typename T>
void write_column (int colnum, const arr< T > &data, int64 offset=0)
template<typename T>
void write_column (int colnum, const T &data, int64 offset=0)
Methods for image data I/O


template<typename T>
void read_image (arr2< T > &data) const
template<typename T>
void read_image (arr3< T > &data) const
template<typename T>
void read_subimage (arr2< T > &data, int xl, int yl) const
template<typename T>
void read_subimage (arr< T > &data, int64 offset=0) const
template<typename T>
void write_image (const arr2< T > &data)
template<typename T>
void write_subimage (const arr< T > &data, int64 offset=0)


Detailed Description

Class for performing I/O from/to FITS files.

Definition at line 127 of file fitshandle.h.


Member Enumeration Documentation

the list of modes in which a fitshandle can be opened.

Enumerator:
CREATE  the file must not yet exist
OPEN  the file must already exist

Definition at line 175 of file fitshandle.h.


Constructor & Destructor Documentation

fitshandle::fitshandle (  )  [inline]

Creates an unconnected fitshandle.

Definition at line 183 of file fitshandle.h.

fitshandle::fitshandle ( const std::string &  fname,
openmethod  mode = OPEN,
int  rwmode = READONLY 
) [inline]

Creates a fitshandle connected to file fname. If rwmode == READONLY, no writing access is permitted; if it is READWRITE, reading and writing can be performed.

Definition at line 188 of file fitshandle.h.

fitshandle::fitshandle ( const std::string &  fname,
int  hdunum,
int  rwmode = READONLY 
) [inline]

Creates a fitshandle connected to file fname and jumps directly to the HDU with the number hdunum. If rwmode == READONLY, no writing access is permitted; if it is READWRITE, reading and writing can be performed.

Definition at line 201 of file fitshandle.h.

fitshandle::~fitshandle (  )  [inline]

Performs all necessary cleanups.

Definition at line 209 of file fitshandle.h.


Member Function Documentation

void fitshandle::open ( const std::string &  fname,
int  rwmode = READONLY 
)

Connects to the file fname. If rwmode == READONLY, no writing access is permitted; if it is READWRITE, reading and writing can be performed.

void fitshandle::create ( const std::string &  fname  ) 

Creates the file fname and connects to it.

void fitshandle::close (  )  [inline]

Closes the current file.

Definition at line 218 of file fitshandle.h.

static void fitshandle::delete_file ( const std::string &  name  )  [static]

Deletes the file with name name.

void fitshandle::goto_hdu ( int  hdu  ) 

Jumps to the HDU with the absolute number hdu.

Definition at line 247 of file fitshandle.cc.

int fitshandle::num_hdus (  )  const

Returns the number of HDUs in the file.

Definition at line 259 of file fitshandle.cc.

void fitshandle::assert_pdmtype ( const std::string &  pdmtype  )  const

Asserts that the PDMTYPE of the current HDU is pdmtype.

void fitshandle::insert_bintab ( const std::vector< fitscolumn > &  cols,
const std::string &  extname = "xtension" 
)

Inserts a binary table described by cols. The HDU has the name extname.

void fitshandle::insert_asctab ( const std::vector< fitscolumn > &  cols,
const std::string &  extname = "xtension" 
)

Inserts an ASCII table described by cols. The width of the columns is chosen automatically, in a way that avoids truncation. The HDU has the name extname.

void fitshandle::insert_image ( int  btpx,
const std::vector< int64 > &  Axes 
)

Inserts a FITS image with the type given by btpx and dimensions given by Axes.

template<typename T>
void fitshandle::insert_image ( int  btpx,
const arr2< T > &  data 
) [inline]

Inserts a 2D FITS image with the type given by btpx, whose contents are given in data.

Definition at line 328 of file fitshandle.cc.

void fitshandle::write_checksum (  ) 

Computes the checksum for the current HDU and writes it into the header.

Definition at line 345 of file fitshandle.cc.

int fitshandle::bitpix (  )  const [inline]

If the current HDU is an image, returns the BITPIX parameter of that image, else throws an exception.

Definition at line 255 of file fitshandle.h.

int fitshandle::hdutype (  )  const [inline]

Returns the FITS type code for the current HDU.

Definition at line 261 of file fitshandle.h.

const std::vector<int64>& fitshandle::axes (  )  const [inline]

Returns the dimensions of the current image.

Definition at line 263 of file fitshandle.h.

const std::string& fitshandle::colname ( int  i  )  const [inline]

Returns the name of column i.

Definition at line 269 of file fitshandle.h.

const std::string& fitshandle::colunit ( int  i  )  const [inline]

Returns the unit of column i.

Definition at line 275 of file fitshandle.h.

int64 fitshandle::repcount ( int  i  )  const [inline]

Returns repetition count of column i.

Definition at line 281 of file fitshandle.h.

int fitshandle::coltype ( int  i  )  const [inline]

Returns the FITS type code for column i.

Definition at line 287 of file fitshandle.h.

int fitshandle::ncols (  )  const [inline]

Returns the number of columns in the current table.

Definition at line 293 of file fitshandle.h.

int64 fitshandle::nrows (  )  const [inline]

Returns the number of rows in the current table.

Definition at line 299 of file fitshandle.h.

int64 fitshandle::nelems ( int  i  )  const [inline]

Returns the total number of elements (nrows*repcount) in column i.

Definition at line 306 of file fitshandle.h.

void fitshandle::copy_header ( const fitshandle orig  ) 

Copies all header keywords from the current HDU of orig to the current HDU of *this.

Definition at line 394 of file fitshandle.cc.

void fitshandle::copy_historified_header ( const fitshandle orig  ) 

Copies all header keywords from the current HDU of orig to the current HDU of *this, prepending a HISTORY keyword to every line.

Definition at line 352 of file fitshandle.cc.

void fitshandle::get_all_keys ( std::vector< std::string > &  keys  )  const

Returns a list of all user-defined keys in the current HDU in keys.

template<typename T>
void fitshandle::add_key ( const std::string &  name,
const T &  value,
const std::string &  comment = "" 
) [inline]

Adds a new header line consisting of key, value and comment.

template<typename T>
void fitshandle::update_key ( const std::string &  name,
const T &  value,
const std::string &  comment = "" 
) [inline]

Updates key with value and comment.

void fitshandle::delete_key ( const std::string &  name  ) 

Deletes key from the header.

void fitshandle::add_comment ( const std::string &  comment  ) 

Adds comment as a comment line.

template<typename T>
void fitshandle::get_key ( const std::string &  name,
T &  value 
) const [inline]

Reads the value belonging to key and returns it in value.

template<typename T>
T fitshandle::get_key ( const std::string &  name  )  const [inline]

Returms the value belonging to key.

Definition at line 344 of file fitshandle.h.

bool fitshandle::key_present ( const std::string &  name  )  const

Returns true if key is present, else false.

int fitshandle::get_key_type ( const std::string &  name  )  const

Returns the Planck type code for the key name.

void fitshandle::read_column_raw_void ( int  colnum,
void *  data,
int  type,
int64  num,
int64  offset = 0 
) const

Definition at line 649 of file fitshandle.cc.

template<typename T>
void fitshandle::read_column_raw ( int  colnum,
T *  data,
int64  num,
int64  offset = 0 
) const [inline]

Copies num elements from column colnum to the memory pointed to by data, starting at offset offset in the column.

Definition at line 361 of file fitshandle.h.

template<typename T>
void fitshandle::read_column ( int  colnum,
arr< T > &  data,
int64  offset = 0 
) const [inline]

Fills data with elements from column colnum, starting at offset offset in the column.

Definition at line 366 of file fitshandle.h.

template<typename T>
void fitshandle::read_column ( int  colnum,
T &  data,
int64  offset = 0 
) const [inline]

Reads the element offset from column colnum into data.

Definition at line 370 of file fitshandle.h.

template<typename T>
void fitshandle::write_column_raw ( int  colnum,
const T *  data,
int64  num,
int64  offset = 0 
) [inline]

Copies num elements from the memory pointed to by data to the column colnum, starting at offset offset in the column.

Definition at line 384 of file fitshandle.h.

template<typename T>
void fitshandle::write_column ( int  colnum,
const arr< T > &  data,
int64  offset = 0 
) [inline]

Copies all elements from data to the column colnum, starting at offset offset in the column.

Definition at line 389 of file fitshandle.h.

template<typename T>
void fitshandle::write_column ( int  colnum,
const T &  data,
int64  offset = 0 
) [inline]

Copies data to the column colnum, at the position offset.

Definition at line 393 of file fitshandle.h.

template<typename T>
void fitshandle::read_image ( arr2< T > &  data  )  const [inline]

Reads the current image into data, which is resized accordingly.

Definition at line 756 of file fitshandle.cc.

template<typename T>
void fitshandle::read_image ( arr3< T > &  data  )  const [inline]

Reads the current image into data, which is resized accordingly.

Definition at line 770 of file fitshandle.cc.

template<typename T>
void fitshandle::read_subimage ( arr2< T > &  data,
int  xl,
int  yl 
) const [inline]

Reads a partial image, whose dimensions are given by the dimensions of data, into data. The starting pixel indices are given by xl and yl.

Definition at line 785 of file fitshandle.cc.

template<typename T>
void fitshandle::read_subimage ( arr< T > &  data,
int64  offset = 0 
) const [inline]

Fills data with values from the image, starting at the offset offset in the image. The image is treated as a one-dimensional array.

Definition at line 803 of file fitshandle.cc.

template<typename T>
void fitshandle::write_image ( const arr2< T > &  data  )  [inline]

Writes data into the current image. data must have the same dimensions as specified in the HDU.

Definition at line 726 of file fitshandle.cc.

template<typename T>
void fitshandle::write_subimage ( const arr< T > &  data,
int64  offset = 0 
) [inline]

Copies data to the image, starting at the offset offset in the image. The image is treated as a one-dimensional array.

Definition at line 743 of file fitshandle.cc.


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

Generated on Fri Jun 18 16:12:29 2010 for LevelS C++ support library
Privacy / Copyright
FIRST GOV Contact: NASA Home Page Site Manager:
Webmaster:

CL 03-2650