LevelS C++ support library  3.83
Public Types | List of all members
fitshandle Class Reference

#include <fitshandle.h>

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

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)
 

Detailed Description

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

Definition at line 70 of file fitshandle.h.

Member Enumeration Documentation

◆ openmethod

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 105 of file fitshandle.h.

Constructor & Destructor Documentation

◆ fitshandle()

fitshandle::fitshandle ( )

Creates an unconnected fitshandle.

Definition at line 297 of file fitshandle.cc.

◆ ~fitshandle()

fitshandle::~fitshandle ( )

Performs all necessary cleanups.

Definition at line 300 of file fitshandle.cc.

Member Function Documentation

◆ open()

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

Connects to the file fname.

Definition at line 303 of file fitshandle.cc.

◆ create()

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

Creates the file fname and connects to it.

Definition at line 313 of file fitshandle.cc.

◆ close()

void fitshandle::close ( )
inline

Closes the current file.

Definition at line 122 of file fitshandle.h.

◆ delete_file()

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

Deletes the file with name name.

Definition at line 326 of file fitshandle.cc.

◆ fileName()

string fitshandle::fileName ( ) const

Returns the name of the connected file.

Definition at line 341 of file fitshandle.cc.

◆ goto_hdu()

void fitshandle::goto_hdu ( int  hdu)

Jumps to the HDU with the absolute number hdu.

Definition at line 352 of file fitshandle.cc.

◆ num_hdus()

int fitshandle::num_hdus ( ) const

Returns the number of HDUs in the file.

Definition at line 364 of file fitshandle.cc.

◆ assert_pdmtype()

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

Asserts that the PDMTYPE of the current HDU is pdmtype.

Definition at line 639 of file fitshandle.cc.

◆ insert_bintab()

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.

Definition at line 372 of file fitshandle.cc.

◆ insert_asctab()

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.

Definition at line 393 of file fitshandle.cc.

◆ insert_image() [1/2]

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.

◆ insert_image() [2/2]

template<typename T >
void fitshandle::insert_image ( PDT  type,
const arr2< T > &  data 
)

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.

◆ write_checksum()

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.

◆ axes()

const vector< int64 > & fitshandle::axes ( ) const

Returns the dimensions of the current image.

Definition at line 456 of file fitshandle.cc.

◆ colname()

const string & fitshandle::colname ( int  i) const

Returns the name of column #i.

Definition at line 461 of file fitshandle.cc.

◆ colunit()

const string & fitshandle::colunit ( int  i) const

Returns the unit of column #i.

Definition at line 466 of file fitshandle.cc.

◆ repcount()

int64 fitshandle::repcount ( int  i) const

Returns repetition count of column #i.

Definition at line 471 of file fitshandle.cc.

◆ coltype()

PDT fitshandle::coltype ( int  i) const

Returns the Planck type for column #i.

Definition at line 476 of file fitshandle.cc.

◆ ncols()

int fitshandle::ncols ( ) const

Returns the number of columns in the current table.

Definition at line 481 of file fitshandle.cc.

◆ nrows()

int64 fitshandle::nrows ( ) const

Returns the number of rows in the current table.

Definition at line 486 of file fitshandle.cc.

◆ nelems()

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.

◆ efficientChunkSize()

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.

◆ get_all_keys()

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.

Definition at line 507 of file fitshandle.cc.

◆ set_key()

template<typename T >
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.

◆ delete_key()

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

Deletes key from the header.

Definition at line 614 of file fitshandle.cc.

◆ add_comment()

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

Adds comment as a comment line.

Definition at line 621 of file fitshandle.cc.

◆ get_key() [1/2]

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.

Definition at line 201 of file fitshandle.h.

◆ get_key() [2/2]

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

Returms the value belonging to key.

Definition at line 204 of file fitshandle.h.

◆ key_present()

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

Returns true if key is present, else false.

Definition at line 628 of file fitshandle.cc.

◆ read_column_raw()

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 219 of file fitshandle.h.

◆ read_column() [1/3]

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 224 of file fitshandle.h.

◆ read_column() [2/3]

template<typename T >
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.

◆ read_column() [3/3]

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 233 of file fitshandle.h.

◆ read_entire_column() [1/2]

template<typename T >
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.

◆ read_entire_column() [2/2]

template<typename T >
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.

◆ write_column_raw()

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 257 of file fitshandle.h.

◆ write_column() [1/3]

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 262 of file fitshandle.h.

◆ write_column() [2/3]

template<typename T >
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.

◆ write_column() [3/3]

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 271 of file fitshandle.h.

◆ read_image() [1/2]

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

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

Definition at line 741 of file fitshandle.cc.

◆ read_image() [2/2]

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

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

Definition at line 754 of file fitshandle.cc.

◆ read_subimage() [1/2]

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

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.

◆ read_subimage() [2/2]

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 293 of file fitshandle.h.

◆ write_image()

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 301 of file fitshandle.h.

◆ write_subimage()

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 312 of file fitshandle.h.


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

Generated on Wed Nov 13 2024 12:18:16 for LevelS C++ support library