FitsFile Class Reference

#include <FitsFile.h>

Collaboration diagram for FitsFile:
Collaboration graph
[legend]

List of all members.

Public Types

enum  FitsHdr { Primary, Secondary, Catalogue }
enum  ExpectKeys {
  UTDATE, MJD, PROJECT, FILTER,
  FLATCOR, CIRCPM, SKYSUB, ARC_MFID,
  ARC_TIME, OBSNUM, XTENSION, ZNAXIS,
  ZNAXIS1, ZNAXIS2, NAXIS, NAXIS1,
  NAXIS2, CRVAL1, CRVAL2, CD11,
  CD12, CD21, CD22, CAMNUM,
  TEXPTIME, cAMSTART, cAMEND, cMAGZPT,
  cMAGZRR, cEXTINCT, cEXP_TIME, cCRVAL1,
  cCRVAL2, cCTYPE1, cCTYPE2, cCRPIX1,
  cCRPIX2, cCD11, cCD12, cCD21,
  cCD22, cPV21, cPV22, cPV23,
  cPV24, cPV25, NumKeys
}

Public Member Functions

 FitsFile ()
 Constructor - just initialises the expected keywords list.
 FitsFile (const std::string &filename)
 Constructor - opens the given FITS filename on disc.
 ~FitsFile ()
void openFile (const std::string &filename)
 Opens the given FITS filename on disc.
void closeFile ()
 Closes the opened FITS file.
const std::string & getFileName () const
 Returns the filename associated with the FitsFile object.
bool isTile () const
 Returns true if the file is a tile.
bool testExpectedKeys (const std::string &fitsType)
 Check if any of the essential keywords is missing.
int checkKeys (const std::string &aKeyname)
bool hasKey (const std::string &keyname) const
 Returns true if keyword exists in FITS header.
void readKey (const std::string &keyname, int &value) const
 Read value of given header keyword into integer argument.
void readKey (const std::string &keyname, float &value) const
 Read value of given header keyword into float argument.
void readKey (const std::string &keyname, double &value) const
 Read value of given header keyword into double argument.
void readKey (const std::string &keyname, std::string &value) const
 Read value of given header keyword into std::string argument.
template<typename AnyDataType >
void readKey (ExpectKeys keyname, AnyDataType &value) const
 Read value of given header keyword.
void readKeyUnit (const std::string &keyname, std::string &unit)
void readHistory (std::list< std::string > &values)
 Read all HISTORY cards and put their values in the list of std::strings.
int getNumCards ()
 Return the number of FITS header cards in this HDU.
void readCard (int keyNo, char *card)
 Get the card for the given key number.
std::string readKeyname (int keyNo)
 Get the keyword for this key number.
int getNumHdus () const
 Return the number of HDU blocks in the FITS file.
int getHduNum ()
int movabsHdu (int hdunum) const
 Move to the given absolute HDU number in the file.
int movrelHdu (int nmove)
 Move nmove HDU blocks from the currently positioned HDU.
int getHduType ()
bool isImageHdu ()
 Returns true if the current HDU correspond to image (pixel) data.
bool isAsciiTable ()
 Returns true if the current HDU corresponds to an ASCII table.
bool isBinaryTable ()
 Returns true if the current HDU corresponds to a binary table.
int getNumRows ()
 Returns number of rows in the table in the current HDU.
int getNumCols ()
 Returns the number of columns in the table in the current HDU.
int getColnum (const std::string &name)
void readColumn (const std::string &name, float *data)
void readColumn (const std::string &name, double *data)
void readColumn (const std::string &name, std::string *data)
std::string readColumnUnit (const std::string &name)
 Return the unit std::string associated with the given column name.

Private Types

typedef std::pair< std::string,
FitsHdr
FitsKeysPair
typedef std::vector< FitsKeysPairFitsKeysList

Private Member Functions

void initExpectedKeysList ()
 Initialises the list of expected keywords.
void handleError (int status, bool throwException=true) const
 Forms and throws a FitsIOException using the given CFITSIO status.

Private Attributes

std::string fileName
 Name of file currently open.
fitsfile * fptr
 Pointer to CFISTIO data structure.

Static Private Attributes

static FitsKeysList mExpectedKeys
 A list of the expected FITS keywords - common to all instances.

Detailed Description

Class to represent FITS files on disc. This acts as a wrapper to the cfitsio library. Each class object (ie instance) represents a FITS file opened on disc.


Member Typedef Documentation

typedef std::vector<FitsKeysPair> FitsFile::FitsKeysList [private]
typedef std::pair<std::string, FitsHdr> FitsFile::FitsKeysPair [private]

Member Enumeration Documentation

Enumerator:
UTDATE 
MJD 
PROJECT 
FILTER 
FLATCOR 
CIRCPM 
SKYSUB 
ARC_MFID 
ARC_TIME 
OBSNUM 
XTENSION 
ZNAXIS 
ZNAXIS1 
ZNAXIS2 
NAXIS 
NAXIS1 
NAXIS2 
CRVAL1 
CRVAL2 
CD11 
CD12 
CD21 
CD22 
CAMNUM 
TEXPTIME 
cAMSTART 
cAMEND 
cMAGZPT 
cMAGZRR 
cEXTINCT 
cEXP_TIME 
cCRVAL1 
cCRVAL2 
cCTYPE1 
cCTYPE2 
cCRPIX1 
cCRPIX2 
cCD11 
cCD12 
cCD21 
cCD22 
cPV21 
cPV22 
cPV23 
cPV24 
cPV25 
NumKeys 
Enumerator:
Primary 
Secondary 
Catalogue 

Constructor & Destructor Documentation

FitsFile::FitsFile (  ) 

Constructor - just initialises the expected keywords list.

References initExpectedKeysList().

FitsFile::FitsFile ( const std::string &  filename  ) 

Constructor - opens the given FITS filename on disc.

References initExpectedKeysList(), and openFile().

FitsFile::~FitsFile (  ) 

Destructor. Does nothing at the moment, but future versions should have it check for an open file in the object and close it.


Member Function Documentation

int FitsFile::checkKeys ( const std::string &  aKeyname  ) 

References fptr, and handleError().

Referenced by testExpectedKeys().

void FitsFile::closeFile (  ) 

Closes the opened FITS file.

References fptr, and handleError().

Referenced by IndirectFrameID< DataType >::doit(), extractMetadata(), and extractSources().

int FitsFile::getColnum ( const std::string &  name  ) 

Returns the column number in the table associated with the given name of the column

References fptr, and handleError().

Referenced by readColumn(), and readColumnUnit().

const std::string & FitsFile::getFileName (  )  const
int FitsFile::getHduNum (  ) 

Return HDU at which the object is currently positioned. Note the FITSIO convention where the primary header is HDU #1 and all extensions start at HDU #2

References fptr.

Referenced by insertKeywordValue().

int FitsFile::getHduType (  ) 

Return the CFISTIO constant that identifies the type of data (image, ascii table, binary table) in the current HDU

References fptr, and handleError().

Referenced by isAsciiTable(), isBinaryTable(), and isImageHdu().

int FitsFile::getNumCards (  ) 
int FitsFile::getNumCols (  ) 

Returns the number of columns in the table in the current HDU.

References fptr, and handleError().

int FitsFile::getNumHdus (  )  const
int FitsFile::getNumRows (  ) 

Returns number of rows in the table in the current HDU.

References fptr, and handleError().

Referenced by DataDumper::addDefaultRow(), insertExtNum(), insertFitsColumns(), TableData< Numeric >::loadFitsColumn(), and readColumn().

void FitsFile::handleError ( int  status,
bool  throwException = true 
) const [private]
bool FitsFile::hasKey ( const std::string &  keyname  )  const

Returns true if keyword exists in FITS header.

References fptr.

Referenced by QuantitiesByAst< DataType >::doit().

void FitsFile::initExpectedKeysList (  )  [private]
bool FitsFile::isAsciiTable (  ) 

Returns true if the current HDU corresponds to an ASCII table.

References getHduType().

bool FitsFile::isBinaryTable (  ) 

Returns true if the current HDU corresponds to a binary table.

References getHduType().

Referenced by insertExtNum(), and insertFitsExtensionHeader().

bool FitsFile::isImageHdu (  ) 

Returns true if the current HDU correspond to image (pixel) data.

References getHduType().

Referenced by insertExtNum(), and insertFitsExtensionHeader().

bool FitsFile::isTile (  )  const
int FitsFile::movabsHdu ( int  hdunum  )  const
int FitsFile::movrelHdu ( int  nmove  ) 

Move nmove HDU blocks from the currently positioned HDU.

References fptr, and handleError().

void FitsFile::openFile ( const std::string &  filename  ) 

Opens the given FITS filename on disc.

References fileName, fptr, and handleError().

Referenced by FitsFile().

void FitsFile::readCard ( int  keyNo,
char *  card 
)
void FitsFile::readColumn ( const std::string &  name,
std::string *  data 
) [inline]

Read all entries in the named column and place the results in the std::string data array which must point to enough memory. I seem to have deliberately coded it up so that it does nothing - I can't remember why

void FitsFile::readColumn ( const std::string &  name,
double *  data 
)

Read all entries in the named column and place the results in the double data array which must point to enough memory

References fptr, getColnum(), getNumRows(), and handleError().

void FitsFile::readColumn ( const std::string &  name,
float *  data 
)

Read all entries in the named column and place the results in the float data array which must point to enough memory

References fptr, getColnum(), getNumRows(), and handleError().

Referenced by TableData< Numeric >::loadFitsColumn().

std::string FitsFile::readColumnUnit ( const std::string &  name  ) 

Return the unit std::string associated with the given column name.

References getColnum(), StringOps::NumToString(), and readKey().

Referenced by insertFitsColumns().

void FitsFile::readHistory ( std::list< std::string > &  values  ) 

Read all HISTORY cards and put their values in the list of std::strings.

References fptr, and handleError().

template<typename AnyDataType >
void FitsFile::readKey ( ExpectKeys  keyname,
AnyDataType &  value 
) const [inline]

Read value of given header keyword.

References mExpectedKeys, and readKey().

void FitsFile::readKey ( const std::string &  keyname,
std::string &  value 
) const

Read value of given header keyword into std::string argument.

References fptr, and handleError().

void FitsFile::readKey ( const std::string &  keyname,
double &  value 
) const

Read value of given header keyword into double argument.

References fptr, and handleError().

void FitsFile::readKey ( const std::string &  keyname,
float &  value 
) const

Read value of given header keyword into float argument.

References fptr, and handleError().

void FitsFile::readKey ( const std::string &  keyname,
int &  value 
) const
std::string FitsFile::readKeyname ( int  keyNo  ) 

Get the keyword for this key number.

References fptr, and handleError().

Referenced by Provenance< DataType >::build().

void FitsFile::readKeyUnit ( const std::string &  keyname,
std::string &  unit 
)

Read the [] unit in the comment std::string associated with the given keyword name

References fptr, and handleError().

bool FitsFile::testExpectedKeys ( const std::string &  fitsType  ) 

Member Data Documentation

std::string FitsFile::fileName [private]

Name of file currently open.

Referenced by getFileName(), handleError(), and openFile().

fitsfile* FitsFile::fptr [private]

A list of the expected FITS keywords - common to all instances.

Referenced by initExpectedKeysList(), readKey(), and testExpectedKeys().


The documentation for this class was generated from the following files:
Generated on Mon Oct 4 10:39:30 2010 for WfcamSrc by  doxygen 1.6.3