|
mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
|
Class to manage a FITS file metadata header and provide fast access to the cards by keyword.
Manages tasks such as insertion (avoiding duplicates), and keyword lookup.
The cards are stored in a std::list to preserve order, but a std::unordered_multimap is used to provide fast keyword lookup into the list.
| verboseT | sets the error reporting verbosity |
Definition at line 53 of file fitsHeader.hpp.
#include <ioutils/fits/fitsHeader.hpp>
Public Types | |
| typedef std::list< fitsHeaderCard< verboseT > > | cardListT |
| The list type. | |
| typedef cardListT::iterator | headerIteratorT |
| The iterator type for the cards list. | |
| typedef std::unordered_multimap< std::string, headerIteratorT > | cardMapT |
| The map type. | |
| typedef cardMapT::value_type | cardMapValueT |
| The value type for the card map. | |
| typedef cardMapT::iterator | mapIteratorT |
| The iterator type for the card map. | |
Public Member Functions | |
| fitsHeader () | |
| Default c'tor. | |
| fitsHeader (const fitsHeader &head) | |
| Copy constructor. | |
| ~fitsHeader () | |
| Destructor. | |
| fitsHeader & | operator= (const fitsHeader &head) |
| Assignment operator. | |
| headerIteratorT | begin () |
| Get iterator to the beginning of the cards list. | |
| headerIteratorT | end () |
| Get iterator to the end of the cards list. | |
| headerIteratorT | iterator (const std::string &keyword) |
| Get iterator pointing to a specific element. | |
| bool | empty () |
| Test whether the header is empty. | |
| size_t | size () |
| Get number of cards currently stored in the header. | |
| error_t | clear () |
| Clear all cards from the header. | |
| size_t | count (const std::string &keyword) |
| Get number of cards with a given keyword. | |
| error_t | erase (const std::string &keyword) |
| Erase card by keyword. | |
| error_t | erase (headerIteratorT it) |
| Erase card by iterator. | |
| error_t | eraseStandardTop () |
| Erase the standard entries at the top of the header. | |
| error_t | append (const fitsHeaderCard< verboseT > &card) |
| Append a fitsHeaderCard to the end of the header. | |
| error_t | append (const std::string &k, const char *v, const std::string &c) |
| Append a string card to the end of the header, from the three components of a card. | |
| template<typename typeT > | |
| error_t | append (const std::string &k, const typeT &v, const std::string &c) |
| Append a card to the end of the header, from the three components of a card. | |
| template<typename typeT > | |
| error_t | append (const std::string &k, const typeT &v) |
| Append a card to the end of the header, from the components of a card with no comment. | |
| error_t | append (const std::string &k) |
| Append a card to the end of the header, with just a keyword. | |
| error_t | append (fitsHeader &head) |
| Append a fitsHeader to the end of the header. | |
| error_t | insert_before (headerIteratorT it, fitsHeaderCard< verboseT > card) |
| Insert a card before another card. | |
| template<typename typeT > | |
| error_t | insert_before (headerIteratorT it, const std::string &k, typeT v, const std::string &c) |
| Insert a card before another card, specifying the card by its components. | |
| template<typename typeT > | |
| error_t | insert_before (headerIteratorT it, const std::string &k, typeT v) |
| Insert a card before another card, specifying the card by its components. | |
| error_t | insert_after (headerIteratorT it, fitsHeaderCard< verboseT > card) |
| Insert a card after another card. | |
| template<typename typeT > | |
| error_t | insert_after (headerIteratorT it, const std::string &k, typeT v, const std::string &c) |
| Insert a card after another card, specifying the card by its components. | |
| template<typename typeT > | |
| error_t | insert_after (headerIteratorT it, const std::string &k, typeT v) |
| Insert a card after another card, specifying the card by its components. | |
| fitsHeaderCard< verboseT > & | operator[] (const std::string &keyword) |
| Card access by keyword operator. | |
| const fitsHeaderCard< verboseT > & | operator[] (const std::string &keyword) const |
| Card access by keyword operator (const version) | |
Protected Attributes | |
| cardListT | m_cardList |
| The storage for the FITS header cards. | |
| cardMapT | m_cardMap |
| This multimap allows for fast lookup by keyword. | |
| fitsHeaderCard< verboseT > | m_emptyCard |
| Card with empty keyword used as an error sentinel. | |
| typedef std::list<fitsHeaderCard<verboseT> > mx::fits::fitsHeader< verboseT >::cardListT |
The list type.
We use a list, rather than forward_list, so that append (insert at end) is constant time.
Definition at line 60 of file fitsHeader.hpp.
| typedef std::unordered_multimap<std::string, headerIteratorT> mx::fits::fitsHeader< verboseT >::cardMapT |
The map type.
Use unordered_multimap to allow multiple HISTORY and COMMENT properly, but be as efficient as possible.
Definition at line 68 of file fitsHeader.hpp.
| typedef cardMapT::value_type mx::fits::fitsHeader< verboseT >::cardMapValueT |
The value type for the card map.
Definition at line 71 of file fitsHeader.hpp.
| typedef cardListT::iterator mx::fits::fitsHeader< verboseT >::headerIteratorT |
The iterator type for the cards list.
Definition at line 63 of file fitsHeader.hpp.
| typedef cardMapT::iterator mx::fits::fitsHeader< verboseT >::mapIteratorT |
The iterator type for the card map.
Definition at line 74 of file fitsHeader.hpp.
| mx::fits::fitsHeader< verboseT >::fitsHeader | ( | ) |
Default c'tor.
Definition at line 270 of file fitsHeader.hpp.
| mx::fits::fitsHeader< verboseT >::fitsHeader | ( | const fitsHeader< verboseT > & | head | ) |
Copy constructor.
| head | The fitsHeader to copy |
Definition at line 275 of file fitsHeader.hpp.
| mx::fits::fitsHeader< verboseT >::~fitsHeader | ( | ) |
Destructor.
Definition at line 281 of file fitsHeader.hpp.
| error_t mx::fits::fitsHeader< verboseT >::append | ( | const fitsHeaderCard< verboseT > & | card | ) |
Append a fitsHeaderCard to the end of the header.
| [in] | card | the card to append |
Definition at line 515 of file fitsHeader.hpp.
References mx::error, mx::invalidarg, mx::fits::fitsHeaderCard< verboseT >::keyword(), mx::noerror, mx::std_bad_alloc, mx::std_exception, and mx::fits::fitsHeaderCard< verboseT >::type().
Referenced by mx::AO::circularApodizedPupil(), mx::AO::circularPupil(), mx::AO::analysis::fourierCovarMap(), mx::AO::ifPInv(), mx::AO::influenceFunctionsGaussian(), mx::wfp::lyotCoronagraph< _realT, _fpmaskFloatT >::optimizeAPLCMC(), mx::wfp::lyotCoronagraph< _realT, _fpmaskFloatT >::optimizeAPLCMC(), mx::fits::fitsFile< dataT, verboseT >::readHeader(), mx::AO::sim::directPhaseReconstructor< realT >::saveRMat(), mx::unitTest::fitsTest::fitsFileTest::TEST_CASE(), mx::unitTest::fitsTest::fitsFileTest::TEST_CASE(), and mx::unitTest::fitsTest::fitsFileTest::TEST_CASE().
| error_t mx::fits::fitsHeader< verboseT >::append | ( | const std::string & | k | ) |
Append a card to the end of the header, with just a keyword.
Appends a headerCard with unknownType
| [in] | k | the keyword of the new card |
Definition at line 620 of file fitsHeader.hpp.
References mxlib_error_return.
| error_t mx::fits::fitsHeader< verboseT >::append | ( | const std::string & | k, |
| const char * | v, | ||
| const std::string & | c | ||
| ) |
Append a string card to the end of the header, from the three components of a card.
| [in] | k | the keyword of the new card |
| [in] | v | the value of the new card |
| [in] | c | the comment of the new card |
Definition at line 626 of file fitsHeader.hpp.
References mxlib_error_return.
| error_t mx::fits::fitsHeader< verboseT >::append | ( | const std::string & | k, |
| const typeT & | v | ||
| ) |
Append a card to the end of the header, from the components of a card with no comment.
| typeT | is the data type of the value |
| [in] | k | the keyword of the new card |
| [in] | v | the value of the new card |
Definition at line 640 of file fitsHeader.hpp.
References mxlib_error_return.
| error_t mx::fits::fitsHeader< verboseT >::append | ( | const std::string & | k, |
| const typeT & | v, | ||
| const std::string & | c | ||
| ) |
Append a card to the end of the header, from the three components of a card.
| typeT | is the data type of the value |
| [in] | k | the keyword of the new card |
| [in] | v | the value of the new card |
| [in] | c | the comment of the new card |
Definition at line 633 of file fitsHeader.hpp.
References mxlib_error_return.
| error_t mx::fits::fitsHeader< verboseT >::append | ( | fitsHeader< verboseT > & | head | ) |
Append a fitsHeader to the end of the header.
| [in] | head | the fitsHeader to append |
Definition at line 607 of file fitsHeader.hpp.
References mx::fits::fitsHeader< verboseT >::begin(), mx::fits::fitsHeader< verboseT >::end(), mxlib_error_check, and mx::noerror.
| fitsHeader< verboseT >::headerIteratorT mx::fits::fitsHeader< verboseT >::begin | ( | ) |
Get iterator to the beginning of the cards list.
Definition at line 304 of file fitsHeader.hpp.
Referenced by mx::fits::fitsHeader< verboseT >::append(), mx::fits::fitsFile< dataT, verboseT >::readHeader(), and mx::fits::fitsFile< dataT, verboseT >::write().
| error_t mx::fits::fitsHeader< verboseT >::clear | ( | ) |
Clear all cards from the header.
Definition at line 334 of file fitsHeader.hpp.
References mx::noerror.
| size_t mx::fits::fitsHeader< verboseT >::count | ( | const std::string & | keyword | ) |
Get number of cards with a given keyword.
Returns the result of the count() method of the header map.
| the | number of cards with keyword. |
| [in] | keyword | the keyword to look up |
Definition at line 343 of file fitsHeader.hpp.
| bool mx::fits::fitsHeader< verboseT >::empty | ( | ) |
Test whether the header is empty.
Definition at line 322 of file fitsHeader.hpp.
| fitsHeader< verboseT >::headerIteratorT mx::fits::fitsHeader< verboseT >::end | ( | ) |
Get iterator to the end of the cards list.
Definition at line 310 of file fitsHeader.hpp.
Referenced by mx::fits::fitsHeader< verboseT >::append(), mx::fits::fitsFile< dataT, verboseT >::readHeader(), and mx::fits::fitsFile< dataT, verboseT >::write().
| error_t mx::fits::fitsHeader< verboseT >::erase | ( | const std::string & | keyword | ) |
Erase card by keyword.
This can not be used to erase COMMENT or HISTORY cards.
| [in] | keyword | the keyword of the card to delete |
Definition at line 349 of file fitsHeader.hpp.
References mx::invalidarg, mx::noerror, mx::notfound, and mx::std_exception.
Referenced by mx::fits::fitsFile< dataT, verboseT >::readHeader().
| error_t mx::fits::fitsHeader< verboseT >::erase | ( | headerIteratorT | it | ) |
Erase card by iterator.
This handles COMMENT and HISTORY cards, deleting only the one pointed to by it using all the contents of the card (not just the keyword)
| [in] | it | iterator pointing to the card to delete. |
Definition at line 419 of file fitsHeader.hpp.
References mx::invalidarg, mx::noerror, mx::notfound, and mx::std_exception.
| error_t mx::fits::fitsHeader< verboseT >::eraseStandardTop | ( | ) |
Erase the standard entries at the top of the header.
Erases each entry down to BSCALE. This is useful for appending a header from a previous image to a newly created file. Also erases boilerplate comments, such as for long string.
Definition at line 473 of file fitsHeader.hpp.
References mxlib_error_check, and mx::noerror.
| error_t mx::fits::fitsHeader< verboseT >::insert_after | ( | headerIteratorT | it, |
| const std::string & | k, | ||
| typeT | v | ||
| ) |
Insert a card after another card, specifying the card by its components.
| typeT | is the type of the value, which is converted to string for insertion |
| [in] | it | interator pointing to the element after which to insert |
| [in] | k | the keyword of the new card |
| [in] | v | the value of the new card |
Definition at line 824 of file fitsHeader.hpp.
References mxlib_error_return.
| error_t mx::fits::fitsHeader< verboseT >::insert_after | ( | headerIteratorT | it, |
| const std::string & | k, | ||
| typeT | v, | ||
| const std::string & | c | ||
| ) |
Insert a card after another card, specifying the card by its components.
| typeT | is the type of the value, which is converted to string for insertion |
| [in] | it | iterator pointing to the element after which to insert |
| [in] | k | the keyword of the new card |
| [in] | v | the value of the new card |
| [in] | c | the comment of the new card |
Definition at line 739 of file fitsHeader.hpp.
References mxlib_error_return.
| error_t mx::fits::fitsHeader< verboseT >::insert_after | ( | headerIteratorT | it, |
| fitsHeaderCard< verboseT > | card | ||
| ) |
Insert a card after another card.
| [in] | it | iterator pointing to the element after which to insert |
| [in] | card | the card to insert |
Definition at line 745 of file fitsHeader.hpp.
References mx::invalidarg, mx::fits::fitsHeaderCard< verboseT >::keyword(), mx::noerror, mx::std_bad_alloc, mx::std_exception, and mx::fits::fitsHeaderCard< verboseT >::type().
| error_t mx::fits::fitsHeader< verboseT >::insert_before | ( | headerIteratorT | it, |
| const std::string & | k, | ||
| typeT | v | ||
| ) |
Insert a card before another card, specifying the card by its components.
| typeT | is the type of the value, which is converted to string for insertion |
| [in] | it | iterator pointing to the element before which to insert |
| [in] | k | the keyword of the new card |
| [in] | v | the value of the new card |
Definition at line 732 of file fitsHeader.hpp.
References mxlib_error_return.
| error_t mx::fits::fitsHeader< verboseT >::insert_before | ( | headerIteratorT | it, |
| const std::string & | k, | ||
| typeT | v, | ||
| const std::string & | c | ||
| ) |
Insert a card before another card, specifying the card by its components.
| typeT | is the type of the value, which is converted to string for insertion |
| [in] | it | iterator pointing to the element before which to insert |
| [in] | k | the keyword of the new card |
| [in] | v | the value of the new card |
| [in] | c | the comment of the new card |
Definition at line 725 of file fitsHeader.hpp.
References mxlib_error_return.
| error_t mx::fits::fitsHeader< verboseT >::insert_before | ( | headerIteratorT | it, |
| fitsHeaderCard< verboseT > | card | ||
| ) |
Insert a card before another card.
| [in] | it | iterator pointing to the element before which to insert |
| [in] | card | the card to insert |
Definition at line 646 of file fitsHeader.hpp.
References mx::invalidarg, mx::fits::fitsHeaderCard< verboseT >::keyword(), mx::noerror, mx::std_bad_alloc, mx::std_exception, and mx::fits::fitsHeaderCard< verboseT >::type().
| fitsHeader< verboseT >::headerIteratorT mx::fits::fitsHeader< verboseT >::iterator | ( | const std::string & | keyword | ) |
Get iterator pointing to a specific element.
| keyword | The keyword to look up |
Definition at line 316 of file fitsHeader.hpp.
| fitsHeader< verboseT > & mx::fits::fitsHeader< verboseT >::operator= | ( | const fitsHeader< verboseT > & | head | ) |
Assignment operator.
| head | The fitsHeader to copy |
Definition at line 287 of file fitsHeader.hpp.
References mx::fits::fitsHeader< verboseT >::m_cardList.
| fitsHeaderCard< verboseT > & mx::fits::fitsHeader< verboseT >::operator[] | ( | const std::string & | keyword | ) |
Card access by keyword operator.
Looks up the card by its keyword, and returns a reference to it.
| [in] | keyword | the header keyword to look up |
Definition at line 830 of file fitsHeader.hpp.
References mx::noerror, and mx::notfound.
| const fitsHeaderCard< verboseT > & mx::fits::fitsHeader< verboseT >::operator[] | ( | const std::string & | keyword | ) | const |
Card access by keyword operator (const version)
Looks up the card by its keyword, and returns a reference to it.
| [in] | keyword | the header keyword to look up |
Definition at line 862 of file fitsHeader.hpp.
References mx::notfound.
| size_t mx::fits::fitsHeader< verboseT >::size | ( | ) |
Get number of cards currently stored in the header.
Definition at line 328 of file fitsHeader.hpp.
Referenced by mx::fits::fitsFile< dataT, verboseT >::readHeader().
|
protected |
The storage for the FITS header cards.
Definition at line 78 of file fitsHeader.hpp.
Referenced by mx::fits::fitsHeader< verboseT >::operator=().
|
protected |
This multimap allows for fast lookup by keyword.
Definition at line 81 of file fitsHeader.hpp.
|
mutableprotected |
Card with empty keyword used as an error sentinel.
Definition at line 84 of file fitsHeader.hpp.