#include <fitshandle.h>
File-level access and manipulation. | |
fitshandle () | |
~fitshandle () | |
void | open (const std::string &fname) |
void | create (const std::string &fname) |
void | close () |
std::string | fileName () const |
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 (PDT type, const std::vector< int64 > &Axes) |
template<typename T> | |
void | insert_image (PDT type, 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 | |
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 |
PDT | coltype (int i) const |
int | ncols () const |
int64 | nrows () const |
int64 | nelems (int i) const |
int64 | efficientChunkSize (int i) const |
Keyword-handling methods | |
void | get_all_keys (std::vector< std::string > &keys) const |
void | set_key_void (const std::string &key, const void *value, PDT type, const std::string &comment="") |
template<typename T> | |
void | set_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) |
void | get_key_void (const std::string &key, void *value, PDT type) const |
template<typename T> | |
void | get_key (const std::string &name, T &value) const |
template<typename T> | |
T | get_key (const std::string &name) const |
bool | key_present (const std::string &name) const |
Methods for table data I/O | |
void | read_column_raw_void (int colnum, void *data, PDT 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, std::vector< 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 |
template<typename T> | |
void | read_entire_column (int colnum, std::vector< T > &data) const |
void | write_column_raw_void (int colnum, const void *data, PDT 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 std::vector< 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 |
void | read_subimage_void (void *data, PDT type, tsize ndata, int64 offset=0) const |
template<typename T> | |
void | read_subimage (arr< T > &data, int64 offset=0) const |
void | write_image2D_void (const void *data, PDT type, tsize s1, tsize s2) |
template<typename T> | |
void | write_image (const arr2< T > &data) |
void | write_subimage_void (const void *data, PDT type, tsize sz, int64 offset) |
template<typename T> | |
void | write_subimage (const arr< T > &data, int64 offset=0) |
Definition at line 70 of file fitshandle.h.
the list of modes in which a fitshandle can be opened.
Definition at line 105 of file fitshandle.h.
fitshandle::fitshandle | ( | ) |
Creates an unconnected fitshandle.
Definition at line 297 of file fitshandle.cc.
fitshandle::~fitshandle | ( | ) |
Performs all necessary cleanups.
Definition at line 300 of file fitshandle.cc.
void fitshandle::open | ( | const std::string & | fname | ) |
Connects to the file fname.
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 122 of file fitshandle.h.
static void fitshandle::delete_file | ( | const std::string & | name | ) | [static] |
Deletes the file with name name.
string fitshandle::fileName | ( | ) | const |
Returns the name of the connected file.
Definition at line 341 of file fitshandle.cc.
void fitshandle::goto_hdu | ( | int | hdu | ) |
Jumps to the HDU with the absolute number hdu.
Definition at line 352 of file fitshandle.cc.
int fitshandle::num_hdus | ( | ) | const |
Returns the number of HDUs in the file.
Definition at line 364 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 | ( | PDT | type, | |
const std::vector< int64 > & | Axes | |||
) |
Inserts a FITS image with the type given by type and dimensions given by Axes.
Inserts a 2D FITS image with the type given by type, whose contents are given in data.
Definition at line 433 of file fitshandle.cc.
void fitshandle::write_checksum | ( | ) |
Computes the checksum for the current HDU and writes it into the header.
Definition at line 449 of file fitshandle.cc.
const vector< int64 > & fitshandle::axes | ( | ) | const |
Returns the dimensions of the current image.
Definition at line 456 of file fitshandle.cc.
const string & fitshandle::colname | ( | int | i | ) | const |
Returns the name of column i.
Definition at line 461 of file fitshandle.cc.
const string & fitshandle::colunit | ( | int | i | ) | const |
Returns the unit of column i.
Definition at line 466 of file fitshandle.cc.
int64 fitshandle::repcount | ( | int | i | ) | const |
Returns repetition count of column i.
Definition at line 471 of file fitshandle.cc.
PDT fitshandle::coltype | ( | int | i | ) | const |
Returns the Planck type for column i.
Definition at line 476 of file fitshandle.cc.
int fitshandle::ncols | ( | ) | const |
Returns the number of columns in the current table.
Definition at line 481 of file fitshandle.cc.
int64 fitshandle::nrows | ( | ) | const |
Returns the number of rows in the current table.
Definition at line 486 of file fitshandle.cc.
int64 fitshandle::nelems | ( | int | i | ) | const |
Returns the total number of elements (nrows*repcount) in column i.
Definition at line 491 of file fitshandle.cc.
int64 fitshandle::efficientChunkSize | ( | int | i | ) | const |
Returns the number of elements that should be read/written in a single call for optimum performance. This depends on the current HDU.
Definition at line 497 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.
void fitshandle::set_key | ( | const std::string & | name, | |
const T & | value, | |||
const std::string & | comment = "" | |||
) | [inline] |
Updates key with value and comment.
Definition at line 192 of file fitshandle.h.
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.
void fitshandle::get_key | ( | const std::string & | name, | |
T & | value | |||
) | const [inline] |
Reads the value belonging to key and returns it in value.
Definition at line 201 of file fitshandle.h.
T fitshandle::get_key | ( | const std::string & | name | ) | const [inline] |
Returms the value belonging to key.
Definition at line 204 of file fitshandle.h.
bool fitshandle::key_present | ( | const std::string & | name | ) | const |
Returns true if key is present, else false.
void fitshandle::read_column_raw_void | ( | int | colnum, | |
void * | data, | |||
PDT | type, | |||
int64 | num, | |||
int64 | offset = 0 | |||
) | const |
Definition at line 648 of file fitshandle.cc.
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 219 of file fitshandle.h.
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 224 of file fitshandle.h.
void fitshandle::read_column | ( | int | colnum, | |
std::vector< T > & | data, | |||
int64 | offset = 0 | |||
) | const [inline] |
Fills data with elements from column colnum, starting at offset offset in the column.
Definition at line 229 of file fitshandle.h.
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 233 of file fitshandle.h.
void fitshandle::read_entire_column | ( | int | colnum, | |
arr< T > & | data | |||
) | const [inline] |
Reads the whole column colnum into data (which is resized accordingly).
Definition at line 238 of file fitshandle.h.
void fitshandle::read_entire_column | ( | int | colnum, | |
std::vector< T > & | data | |||
) | const [inline] |
Reads the whole column colnum into data (which is resized accordingly).
Definition at line 246 of file fitshandle.h.
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 257 of file fitshandle.h.
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 262 of file fitshandle.h.
void fitshandle::write_column | ( | int | colnum, | |
const std::vector< 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 267 of file fitshandle.h.
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 271 of file fitshandle.h.
void fitshandle::read_image | ( | arr2< T > & | data | ) | const [inline] |
Reads the current image into data, which is resized accordingly.
Definition at line 741 of file fitshandle.cc.
void fitshandle::read_image | ( | arr3< T > & | data | ) | const [inline] |
Reads the current image into data, which is resized accordingly.
Definition at line 754 of file fitshandle.cc.
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 769 of file fitshandle.cc.
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 293 of file fitshandle.h.
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 301 of file fitshandle.h.
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 312 of file fitshandle.h.