#include <FitsFile.h>
Inheritance diagram for FitsFile:
Encapsulates the low level C interface to a higher level C++ interface. Does not currently handle everything, only those that were needed in some simple applications. This version handles arrays with the Standard Template Library (STL).
Definition at line 39 of file FitsFile.h.
Public Types | |
enum | DataType { ByteU = TBYTE, Short = TSHORT, ShortU = TUSHORT, Int = TINT, IntU = TUINT, Long = TLONG, LongU = TULONG, LongLong = TLONGLONG, Float = TFLOAT, Double = TDOUBLE } |
The data types supported by cfitsio. More... | |
enum | HduType { Image = IMAGE_HDU, Atable = ASCII_TBL, Btable = BINARY_TBL, Any = ANY_HDU } |
The type of HDU. More... | |
enum | ImageType { ByteImg = BYTE_IMG, ShortImg = SHORT_IMG, LongImg = LONG_IMG, FloatImg = FLOAT_IMG, DoubleImg = DOUBLE_IMG, NoImg = 0 } |
The type of image in HDU. More... | |
Public Member Functions | |
void | clearErrorMessageStack (void) |
Clear the entire error message stack. | |
int | fillAxisSizes (std::vector< long > &vec) const |
Clears and fills the vector vec with the size of each dimension of an image. | |
int | fillColumnNames (std::vector< std::string > &labels) |
Clears and fills the vector with the column labels of the current HDU table. | |
int | fillDoubleVectorFromColumn (std::vector< double > &vec, int column) |
Read elements from an ASCII or binary table column (in the CDU) and fill the vector with its contents. | |
void | fillHDUNames (std::vector< std::string > &names) |
Clears and fills the vector with the HDU names. | |
void | fillImageDeltas (std::vector< double > &deltas) const |
Clears and fills the vector with the delta values of an image. | |
void | fillRefPixelIndices (std::vector< int > &indices) const |
Clears and fills the vector with the reference pixel's indexes. | |
void | fillRefPixelValues (std::vector< double > &values) const |
Clears and fills the vector with the reference pixel's values. | |
void | fillShape (std::vector< intptr_t > &shape, int column) |
Fills the vector with the shape of the column. | |
FitsFile (const std::string &filename, bool write=false) | |
Public construction taking a filename as argument. | |
int | getHDUNumber () const |
Returns the current HDU number. | |
HduType | getHduType () const |
Returns the type of HDU. | |
long | getNumberOfRows () const |
Returns the number of rows in the table. | |
bool | isHammerAitoff () const |
Returns true if coordinate system of the axis is should undergo Hammer-Aitoff transformation. | |
int | moveToHDU (const std::string &name) |
Move to a specified absolute HDU with name name in the FITS file and return the cfitsio status. | |
int | moveToHDU (int hdunum) |
Move to a specified absolute HDU number in the FITS file and return the cfitsio status. | |
bool | pixCenter () const |
int | status () const |
Returns the cfitsio status code for the last operation. | |
void | writeCloseFile () |
void | writeColumn (int c, const std::vector< double > &data) |
Writes the vector to FITS table. | |
void | writeHDU (long rows, int columns, const std::vector< std::string > &names, const std::vector< std::vector< int > > &shapes, const std::string &extname) |
void | writeImageHDU (long x, long y) |
void | writePix (long x, long y, const std::vector< double > &data) |
void | writeRefPixelValues (double value1, double value2) |
Protected Member Functions | |
double | doubleValueForKey (const char *key) const |
Read a specified keyword value and return it as a double. | |
int | getImageDimensions () const |
Returns the number of dimensions (axes) of an image. | |
ImageType | getImageType () const |
Returns the image type. | |
int | getNumberOfColumns () const |
Returns the number of columns in a table. | |
int | getNumberOfHDU () const |
Returns the number of HDU in the file. | |
bool | hasKey (const char *key) const |
Returns true if the keyword key exists, otherwise returns false . | |
int | intValueForKey (const char *key) const |
Read a specified keyword value and returns it as a int. | |
std::string | stringValueForKey (const char *key) const |
Read a specified keyword value and returns it as a string. | |
Protected Attributes | |
fitsfile * | m_fptr |
Pointer to the fits file data structure. | |
int | m_status |
The status return code from the last cfitsio operation. | |
Private Member Functions | |
int | fillColumnNamesFromImage (std::vector< std::string > &labels) |
Clears and fills the vector with the column labels of a image. | |
int | fillColumnNamesFromTable (std::vector< std::string > &labels) |
Clears and fills the vector with the column labels of binary or ASCII table. | |
int | fillFromImage (std::vector< double > &vec, unsigned int axis) |
Fills the vector vec from an image HDU. | |
int | fillFromTableColumn (std::vector< double > &v, int column) |
Fills the vector v from a table column. | |
int | fillIntVectorFromColumn (std::vector< int > &vec, int column) |
Read elements from an ASCII or binary table column (in the CDU) and fill STL vector<int> with its contents. |
enum DataType [inherited] |
The data types supported by cfitsio.
Definition at line 58 of file FitsFileBase.h.
enum HduType [inherited] |
The type of HDU.
Image | Image. |
Atable | ASCII table. |
Btable | Binary table. |
Any | Matchs any. |
Definition at line 38 of file FitsFileBase.h.
enum ImageType [inherited] |
The type of image in HDU.
Definition at line 47 of file FitsFileBase.h.
FitsFile | ( | const std::string & | filename, | |
bool | write = false | |||
) |
void clearErrorMessageStack | ( | void | ) | [inherited] |
double doubleValueForKey | ( | const char * | key | ) | const [protected, inherited] |
Read a specified keyword value and return it as a double.
Data type conversion will be performed for numeric values if the keyword value does not have the type double. If the value of the keyword is undefined (i.e., the value field is blank) then an undefined value will be returned.
Definition at line 164 of file FitsFileBase.cxx.
References FitsFileBase::m_fptr, and FitsFileBase::m_status.
Referenced by FitsFile::fillImageDeltas(), and FitsFile::fillRefPixelValues().
int fillAxisSizes | ( | std::vector< long > & | vec | ) | const |
Clears and fills the vector vec with the size of each dimension of an image.
The size of the returned vector gives the number of dimensions.
Definition at line 190 of file FitsFile.cxx.
References FitsFileBase::getImageDimensions(), FitsFileBase::m_fptr, and FitsFileBase::m_status.
Referenced by FitsFile::fillFromImage().
int fillColumnNames | ( | std::vector< std::string > & | labels | ) |
Clears and fills the vector with the column labels of the current HDU table.
Definition at line 58 of file FitsFile.cxx.
References FitsFile::fillColumnNamesFromImage(), FitsFile::fillColumnNamesFromTable(), FitsFileBase::getHduType(), FitsFileBase::m_status, and num_util::type().
int fillColumnNamesFromImage | ( | std::vector< std::string > & | labels | ) | [private] |
Clears and fills the vector with the column labels of a image.
Definition at line 98 of file FitsFile.cxx.
References hippodraw::String::convert(), FitsFileBase::getImageDimensions(), FitsFileBase::hasKey(), FitsFileBase::intValueForKey(), FitsFileBase::m_status, FitsFileBase::stringValueForKey(), and num_util::type().
Referenced by FitsFile::fillColumnNames().
int fillColumnNamesFromTable | ( | std::vector< std::string > & | labels | ) | [private] |
Clears and fills the vector with the column labels of binary or ASCII table.
Definition at line 73 of file FitsFile.cxx.
References FitsFileBase::getNumberOfColumns(), FitsFileBase::m_fptr, and FitsFileBase::m_status.
Referenced by FitsFile::fillColumnNames().
int fillDoubleVectorFromColumn | ( | std::vector< double > & | vec, | |
int | column | |||
) |
Read elements from an ASCII or binary table column (in the CDU) and fill the vector with its contents.
vec | The vector of doubles provided by the caller. | |
column | The index to the column number starting at 0. |
Definition at line 123 of file FitsFile.cxx.
References FitsFileBase::Atable, FitsFileBase::Btable, FitsFile::fillFromImage(), FitsFile::fillFromTableColumn(), FitsFileBase::getHduType(), and num_util::type().
int fillFromImage | ( | std::vector< double > & | vec, | |
unsigned int | axis | |||
) | [private] |
Fills the vector vec from an image HDU.
Fills the vector vec from an image HDU. If the image is three dimensional, then selects only the axis for the third dimension.
Definition at line 307 of file FitsFile.cxx.
References FitsFileBase::Double, FitsFile::fillAxisSizes(), FitsFile::fillIntVectorFromColumn(), FitsFileBase::m_fptr, and FitsFileBase::m_status.
Referenced by FitsFile::fillDoubleVectorFromColumn().
int fillFromTableColumn | ( | std::vector< double > & | v, | |
int | column | |||
) | [private] |
Fills the vector v from a table column.
The first column index is 0, unlike CFITSIO
Definition at line 141 of file FitsFile.cxx.
References FitsFileBase::m_fptr, and FitsFileBase::m_status.
Referenced by FitsFile::fillDoubleVectorFromColumn().
void fillHDUNames | ( | std::vector< std::string > & | names | ) |
Clears and fills the vector with the HDU names.
If an HDU doesn't have a name, one is generated for it.
Definition at line 33 of file FitsFile.cxx.
References FitsFileBase::getNumberOfHDU(), FitsFileBase::intValueForKey(), FitsFileBase::moveToHDU(), and FitsFileBase::stringValueForKey().
void fillImageDeltas | ( | std::vector< double > & | deltas | ) | const |
Clears and fills the vector with the delta values of an image.
If the delta parameter is not give in the image's header, then use the value 1.0.
Definition at line 207 of file FitsFile.cxx.
References FitsFileBase::doubleValueForKey(), FitsFileBase::getImageDimensions(), FitsFileBase::hasKey(), and FitsFileBase::m_status.
int fillIntVectorFromColumn | ( | std::vector< int > & | vec, | |
int | column | |||
) | [private] |
Read elements from an ASCII or binary table column (in the CDU) and fill STL vector<int> with its contents.
vec | The STL vector of doubles provided by the caller. | |
column | The column index which starts a 1. |
Definition at line 335 of file FitsFile.cxx.
References FitsFileBase::m_fptr, FitsFileBase::m_status, and FitsFileBase::status().
Referenced by FitsFile::fillFromImage().
void fillRefPixelIndices | ( | std::vector< int > & | indices | ) | const |
Clears and fills the vector with the reference pixel's indexes.
Definition at line 232 of file FitsFile.cxx.
References FitsFileBase::getImageDimensions(), FitsFileBase::hasKey(), FitsFileBase::intValueForKey(), and FitsFileBase::m_status.
void fillRefPixelValues | ( | std::vector< double > & | values | ) | const |
Clears and fills the vector with the reference pixel's values.
Definition at line 257 of file FitsFile.cxx.
References FitsFileBase::doubleValueForKey(), FitsFileBase::getImageDimensions(), FitsFileBase::hasKey(), and FitsFileBase::m_status.
void fillShape | ( | std::vector< intptr_t > & | shape, | |
int | column | |||
) |
Fills the vector with the shape of the column.
Fills the vector v with the shape of the column c of a binary table. If the column contains an array, the first member of the shape vector is the number of rows of the Binary table.
Definition at line 158 of file FitsFile.cxx.
References hippodraw::String::convert(), FitsFileBase::getNumberOfRows(), FitsFileBase::m_fptr, and FitsFileBase::m_status.
int getHDUNumber | ( | ) | const [inherited] |
Returns the current HDU number.
The first (primary) HDU has number value = 1.
Definition at line 144 of file FitsFileBase.cxx.
References FitsFileBase::m_fptr, and FitsFileBase::m_status.
FitsFileBase::HduType getHduType | ( | ) | const [inherited] |
Returns the type of HDU.
Definition at line 69 of file FitsFileBase.cxx.
References FitsFileBase::convert(), FitsFileBase::m_fptr, and FitsFileBase::m_status.
Referenced by FitsFile::fillColumnNames(), and FitsFile::fillDoubleVectorFromColumn().
int getImageDimensions | ( | ) | const [protected, inherited] |
Returns the number of dimensions (axes) of an image.
Definition at line 98 of file FitsFileBase.cxx.
References FitsFileBase::m_fptr, and FitsFileBase::m_status.
Referenced by FitsFile::fillAxisSizes(), FitsFile::fillColumnNamesFromImage(), FitsFile::fillImageDeltas(), FitsFile::fillRefPixelIndices(), and FitsFile::fillRefPixelValues().
FitsFileBase::ImageType getImageType | ( | ) | const [protected, inherited] |
Returns the image type.
Definition at line 80 of file FitsFileBase.cxx.
References FitsFileBase::ByteImg, FitsFileBase::DoubleImg, FitsFileBase::FloatImg, FitsFileBase::LongImg, FitsFileBase::m_fptr, FitsFileBase::m_status, FitsFileBase::NoImg, FitsFileBase::ShortImg, and num_util::type().
int getNumberOfColumns | ( | ) | const [protected, inherited] |
Returns the number of columns in a table.
Definition at line 241 of file FitsFileBase.cxx.
References FitsFileBase::m_fptr, and FitsFileBase::m_status.
Referenced by FitsFile::fillColumnNamesFromTable().
int getNumberOfHDU | ( | ) | const [protected, inherited] |
Returns the number of HDU in the file.
Definition at line 110 of file FitsFileBase.cxx.
References FitsFileBase::m_fptr, and FitsFileBase::m_status.
Referenced by FitsFile::fillHDUNames().
long getNumberOfRows | ( | ) | const [inherited] |
Returns the number of rows in the table.
Definition at line 218 of file FitsFileBase.cxx.
References FitsFileBase::intValueForKey(), FitsFileBase::m_fptr, and FitsFileBase::m_status.
Referenced by FitsFile::fillShape().
bool hasKey | ( | const char * | key | ) | const [protected, inherited] |
Returns true
if the keyword key exists, otherwise returns false
.
Definition at line 175 of file FitsFileBase.cxx.
References FitsFileBase::m_fptr, and FitsFileBase::m_status.
Referenced by FitsFile::fillColumnNamesFromImage(), FitsFile::fillImageDeltas(), FitsFile::fillRefPixelIndices(), FitsFile::fillRefPixelValues(), FitsFile::isHammerAitoff(), and FitsFile::pixCenter().
int intValueForKey | ( | const char * | key | ) | const [protected, inherited] |
Read a specified keyword value and returns it as a int.
Data type conversion will be performed for numeric values if the keyword value does not have the type int. If the value of the keyword is undefined (i.e., the value field is blank) then an undefined value will be returned.
Definition at line 187 of file FitsFileBase.cxx.
References FitsFileBase::m_fptr, and FitsFileBase::m_status.
Referenced by FitsFile::fillColumnNamesFromImage(), FitsFile::fillHDUNames(), FitsFile::fillRefPixelIndices(), and FitsFileBase::getNumberOfRows().
bool isHammerAitoff | ( | ) | const |
Returns true
if coordinate system of the axis is should undergo Hammer-Aitoff transformation.
Definition at line 282 of file FitsFile.cxx.
References FitsFileBase::hasKey(), FitsFileBase::m_status, and FitsFileBase::stringValueForKey().
int moveToHDU | ( | const std::string & | name | ) | [inherited] |
Move to a specified absolute HDU with name name in the FITS file and return the cfitsio status.
When a FITS file is first opened or created it is automatically positioned to the first HDU (the primary array) in the file which has hdunum = 1.
Definition at line 133 of file FitsFileBase.cxx.
References FitsFileBase::m_fptr, and FitsFileBase::m_status.
int moveToHDU | ( | int | hdunum | ) | [inherited] |
Move to a specified absolute HDU number in the FITS file and return the cfitsio status.
When a FITS file is first opened or created it is automatically positioned to the first HDU (the primary array) in the file which has hdunum = 0 ( = 1 in cfitsio call) . The hdutype parameter of the underlying call to cfitsio function `fits_movabs_hdu()' is ignored.
Definition at line 121 of file FitsFileBase.cxx.
References FitsFileBase::m_fptr, and FitsFileBase::m_status.
Referenced by FitsFile::fillHDUNames().
bool pixCenter | ( | ) | const |
Definition at line 446 of file FitsFile.cxx.
References FitsFileBase::hasKey(), and FitsFileBase::stringValueForKey().
int status | ( | ) | const [inherited] |
Returns the cfitsio status code for the last operation.
Definition at line 211 of file FitsFileBase.cxx.
References FitsFileBase::m_status.
Referenced by FitsFile::fillIntVectorFromColumn().
string stringValueForKey | ( | const char * | key | ) | const [protected, inherited] |
Read a specified keyword value and returns it as a string.
Data type conversion will be performed for numeric values if the keyword value does not have the type int. If the value of the keyword is undefined (i.e., the value field is blank) then an undefined value will be returned.
Definition at line 199 of file FitsFileBase.cxx.
References FitsFileBase::m_fptr, and FitsFileBase::m_status.
Referenced by FitsFile::fillColumnNamesFromImage(), FitsFile::fillHDUNames(), FitsFile::isHammerAitoff(), and FitsFile::pixCenter().
void writeCloseFile | ( | ) |
Definition at line 438 of file FitsFile.cxx.
References FitsFileBase::m_fptr, and FitsFileBase::m_status.
void writeColumn | ( | int | c, | |
const std::vector< double > & | data | |||
) |
Writes the vector to FITS table.
Writes the contents of the vector data to a FITS table at column c.
Definition at line 417 of file FitsFile.cxx.
References FitsFileBase::m_fptr, and FitsFileBase::m_status.
void writeHDU | ( | long | rows, | |
int | columns, | |||
const std::vector< std::string > & | names, | |||
const std::vector< std::vector< int > > & | shapes, | |||
const std::string & | extname | |||
) |
Definition at line 353 of file FitsFile.cxx.
References hippodraw::String::convert(), FitsFileBase::m_fptr, FitsFileBase::m_status, num_util::rank(), num_util::shape(), num_util::size(), and hippodraw::Symbol::types.
void writeImageHDU | ( | long | x, | |
long | y | |||
) |
Definition at line 408 of file FitsFile.cxx.
References FitsFileBase::m_fptr, and FitsFileBase::m_status.
void writePix | ( | long | x, | |
long | y, | |||
const std::vector< double > & | data | |||
) |
Definition at line 428 of file FitsFile.cxx.
References FitsFileBase::m_fptr, and FitsFileBase::m_status.
void writeRefPixelValues | ( | double | value1, | |
double | value2 | |||
) |
Definition at line 462 of file FitsFile.cxx.
References FitsFileBase::m_fptr, and FitsFileBase::m_status.
Pointer to the fits file data structure.
Definition at line 90 of file FitsFileBase.h.
Referenced by FitsFileBase::doubleValueForKey(), FitsFile::fillAxisSizes(), FitsFile::fillColumnNamesFromTable(), FitsFile::fillFromImage(), FitsFile::fillFromTableColumn(), FitsFile::fillIntVectorFromColumn(), FitsFile::fillShape(), FitsFileBase::FitsFileBase(), FitsFileBase::getHDUNumber(), FitsFileBase::getHduType(), FitsFileBase::getImageDimensions(), FitsFileBase::getImageType(), FitsFileBase::getNumberOfColumns(), FitsFileBase::getNumberOfHDU(), FitsFileBase::getNumberOfRows(), FitsFileBase::hasKey(), FitsFileBase::intValueForKey(), FitsFileBase::moveToHDU(), FitsFileBase::numKeywords(), FitsFileBase::stringValueForKey(), FitsFile::writeCloseFile(), FitsFile::writeColumn(), FitsFile::writeHDU(), FitsFile::writeImageHDU(), FitsFile::writePix(), FitsFile::writeRefPixelValues(), and FitsFileBase::~FitsFileBase().
int m_status [mutable, protected, inherited] |
The status return code from the last cfitsio operation.
Definition at line 87 of file FitsFileBase.h.
Referenced by FitsFileBase::doubleValueForKey(), FitsFile::fillAxisSizes(), FitsFile::fillColumnNames(), FitsFile::fillColumnNamesFromImage(), FitsFile::fillColumnNamesFromTable(), FitsFile::fillFromImage(), FitsFile::fillFromTableColumn(), FitsFile::fillImageDeltas(), FitsFile::fillIntVectorFromColumn(), FitsFile::fillRefPixelIndices(), FitsFile::fillRefPixelValues(), FitsFile::fillShape(), FitsFileBase::FitsFileBase(), FitsFileBase::getHDUNumber(), FitsFileBase::getHduType(), FitsFileBase::getImageDimensions(), FitsFileBase::getImageType(), FitsFileBase::getNumberOfColumns(), FitsFileBase::getNumberOfHDU(), FitsFileBase::getNumberOfRows(), FitsFileBase::hasKey(), FitsFileBase::intValueForKey(), FitsFile::isHammerAitoff(), FitsFileBase::moveToHDU(), FitsFileBase::numKeywords(), FitsFileBase::status(), FitsFileBase::stringValueForKey(), FitsFile::writeCloseFile(), FitsFile::writeColumn(), FitsFile::writeHDU(), FitsFile::writeImageHDU(), FitsFile::writePix(), FitsFile::writeRefPixelValues(), and FitsFileBase::~FitsFileBase().