mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
|
Class to manage a complete fits header.
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.
Definition at line 51 of file fitsHeader.hpp.
#include <ioutils/fits/fitsHeader.hpp>
Public Types | |
typedef std::list< fitsHeaderCard >::iterator | headerIterator |
The iterator type for the cards list. More... | |
typedef std::unordered_multimap< std::string, headerIterator >::iterator | mapIterator |
The iterator type for the card map. More... | |
Public Member Functions | |
fitsHeader () | |
Default c'tor. More... | |
fitsHeader (const fitsHeader &head) | |
Copy constructor. More... | |
~fitsHeader () | |
Destructor. More... | |
fitsHeader & | operator= (const fitsHeader &head) |
Assignment. More... | |
headerIterator | begin () |
Get iterator to the beginning of the cards list. More... | |
headerIterator | end () |
Get iterator to the end of the cards list. More... | |
headerIterator | iterator (const std::string &keyword) |
Get iterator pointing to a specific element. More... | |
bool | empty () |
Test whether the header is empty. More... | |
size_t | size () |
Get number of cards currently stored in the header. More... | |
void | clear () |
Clear all cards from the header. More... | |
size_t | count (const std::string &keyword) |
Get number of cards with a given keyword. More... | |
void | erase (const std::string &keyword) |
Erase card by keyword. More... | |
void | erase (headerIterator it) |
Erase card by iterator. More... | |
void | eraseStandardTop () |
Erase the standard entries at the top of the header. More... | |
void | append (fitsHeaderCard card) |
Append a fitsHeaderCard to the end of the header. More... | |
template<typename typeT > | |
void | 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. More... | |
template<typename typeT > | |
void | 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. More... | |
void | append (const std::string &k) |
Append a card to the end of the header, with just a keyword. More... | |
void | append (fitsHeader &head) |
Append a fitsHeader to the end of the header. More... | |
void | insert_before (headerIterator it, fitsHeaderCard card) |
Insert a card before another card. More... | |
template<typename typeT > | |
void | insert_before (headerIterator it, const std::string &k, typeT v, const std::string &c) |
Insert a card before another card, specifying the card by its components. More... | |
template<typename typeT > | |
void | insert_before (headerIterator it, const std::string &k, typeT v) |
Insert a card before another card, specifying the card by its components. More... | |
void | insert_after (headerIterator it, fitsHeaderCard card) |
Insert a card after another card. More... | |
template<typename typeT > | |
void | insert_after (headerIterator it, const std::string &k, typeT v, const std::string &c) |
Insert a card after another card, specifying the card by its components. More... | |
template<typename typeT > | |
void | insert_after (headerIterator it, const std::string &k, typeT v) |
Insert a card after another card, specifying the card by its components. More... | |
fitsHeaderCard & | operator[] (const std::string &keyword) |
Card access by keyword operator. More... | |
const fitsHeaderCard & | operator[] (const std::string &keyword) const |
Card access by keyword operator (const version) More... | |
Protected Attributes | |
std::list< fitsHeaderCard > | cards |
The storage for the FITS header cards. More... | |
std::unordered_multimap< std::string, headerIterator > | cardMap |
This multimap allows for fast lookup by keyword. More... | |
typedef std::list<fitsHeaderCard>::iterator mx::fits::fitsHeader::headerIterator |
The iterator type for the cards list.
Definition at line 57 of file fitsHeader.hpp.
typedef std::unordered_multimap<std::string, headerIterator>::iterator mx::fits::fitsHeader::mapIterator |
The iterator type for the card map.
Definition at line 60 of file fitsHeader.hpp.
mx::fits::fitsHeader::fitsHeader | ( | ) |
Default c'tor.
Definition at line 34 of file fitsHeader.cpp.
mx::fits::fitsHeader::fitsHeader | ( | const fitsHeader & | head | ) |
Copy constructor.
Must be explicitly defined to handle creation of new iterators in the cardMap
head | The fitsHeader to copy |
Definition at line 38 of file fitsHeader.cpp.
References operator=().
mx::fits::fitsHeader::~fitsHeader | ( | ) |
void mx::fits::fitsHeader::append | ( | const std::string & | k | ) |
Append a card to the end of the header, with just a keyword.
Appens a headerCard with unknownType
k | is the keyword string |
Definition at line 188 of file fitsHeader.cpp.
References append(), and mx::astro::constants::k().
void mx::fits::fitsHeader::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 |
k | is the keyword string |
v | is the value of typeT |
Definition at line 280 of file fitsHeader.hpp.
References append(), and mx::astro::constants::k().
void mx::fits::fitsHeader::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 |
k | is the keyword string |
v | is the value of typeT |
c | is the comment string |
Definition at line 270 of file fitsHeader.hpp.
References append(), mx::astro::constants::c(), and mx::astro::constants::k().
void mx::fits::fitsHeader::append | ( | fitsHeader & | head | ) |
Append a fitsHeader to the end of the header.
head | is a populated fitsHeader |
Definition at line 178 of file fitsHeader.cpp.
void mx::fits::fitsHeader::append | ( | fitsHeaderCard | card | ) |
Append a fitsHeaderCard to the end of the header.
card | is a fitsHeaderCard already populated |
Definition at line 156 of file fitsHeader.cpp.
References cardMap, mx::fits::fitsHeaderCard::keyword(), and mx::fits::fitsHeaderCard::type().
Referenced by append(), mx::AO::circularPupil(), mx::fits::fitsHeaderGitStatus(), mx::AO::influenceFunctionsGaussian(), operator[](), mx::improc::HCIobservation< _realT >::outputPSFSub(), mx::improc::HCIobservation< _realT >::readFiles(), mx::fits::fitsFile< dataT >::readHeader(), mx::improc::HCIobservation< _realT >::readPSFSub(), mx::improc::HCIobservation< _realT >::readRDIFiles(), mx::AO::sim::directPhaseReconstructor< realT >::saveRMat(), mx::improc::HCIobservation< _realT >::stdFitsHeader(), and mx::improc::HCIobservation< _realT >::writeFinim().
fitsHeader::headerIterator mx::fits::fitsHeader::begin | ( | ) |
Get iterator to the beginning of the cards list.
Definition at line 66 of file fitsHeader.cpp.
References cards.
Referenced by append(), eraseStandardTop(), mx::fits::fitsFile< dataT >::readHeader(), and mx::fits::fitsFile< dataT >::write().
void mx::fits::fitsHeader::clear | ( | ) |
Clear all cards from the header.
Definition at line 91 of file fitsHeader.cpp.
References cardMap, and cards.
Referenced by ~fitsHeader().
size_t mx::fits::fitsHeader::count | ( | const std::string & | keyword | ) |
Get number of cards with a given keyword.
Reeturns the result of the count() method of the header map.
the | number of cards with keyword. |
[in] | keyword | the keyword to loop up |
Definition at line 97 of file fitsHeader.cpp.
References cardMap.
Referenced by mx::improc::HCIobservation< _realT >::readFiles(), mx::improc::ADIobservation< _realT, _derotFunctObj >::readPSFSub(), and mx::improc::HCIobservation< _realT >::readPSFSub().
bool mx::fits::fitsHeader::empty | ( | ) |
fitsHeader::headerIterator mx::fits::fitsHeader::end | ( | ) |
Get iterator to the end of the cards list.
Definition at line 71 of file fitsHeader.cpp.
References cards.
Referenced by append(), eraseStandardTop(), mx::fits::fitsFile< dataT >::readHeader(), and mx::fits::fitsFile< dataT >::write().
void mx::fits::fitsHeader::erase | ( | const std::string & | keyword | ) |
Erase card by keyword.
This can not be used to erase COMMENT or HISTORY cards.
keyword | the keyword of the card to delete |
Definition at line 102 of file fitsHeader.cpp.
References cardMap, and cards.
Referenced by eraseStandardTop(), and mx::fits::fitsFile< dataT >::readHeader().
void mx::fits::fitsHeader::erase | ( | headerIterator | it | ) |
Erase card by iterator.
This handles COMMENT and HISTORY cards, deleting only the one pointed to by it
it | is a headerIterator pointing to the card to delete. |
Definition at line 114 of file fitsHeader.cpp.
void mx::fits::fitsHeader::eraseStandardTop | ( | ) |
Erase the standard entries at the top of the header.
Erases each entry down to BSCALE. This is useful for appending a header to a newly created file.
Definition at line 126 of file fitsHeader.cpp.
void mx::fits::fitsHeader::insert_after | ( | headerIterator | 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 |
it | points to the element after which to insert |
k | is the keyword |
v | is the value |
Definition at line 319 of file fitsHeader.hpp.
References insert_after(), and mx::astro::constants::k().
void mx::fits::fitsHeader::insert_after | ( | headerIterator | 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 |
it | points to the element after which to insert |
k | is the keyword |
v | is the value |
c | is the comment |
Definition at line 308 of file fitsHeader.hpp.
References mx::astro::constants::c(), insert_after(), and mx::astro::constants::k().
void mx::fits::fitsHeader::insert_after | ( | headerIterator | it, |
fitsHeaderCard | card | ||
) |
Insert a card after another card.
it | points to the element after which to insert |
card | contains the card to insert |
Definition at line 215 of file fitsHeader.cpp.
References cardMap, mx::fits::fitsHeaderCard::keyword(), and mx::fits::fitsHeaderCard::type().
Referenced by insert_after().
void mx::fits::fitsHeader::insert_before | ( | headerIterator | 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 |
it | points to the element before which to insert |
k | is the keyword |
v | is the value |
Definition at line 299 of file fitsHeader.hpp.
References insert_before(), and mx::astro::constants::k().
void mx::fits::fitsHeader::insert_before | ( | headerIterator | 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 |
it | points to the element before which to insert |
k | is the keyword |
v | is the value |
c | is the comment |
Definition at line 288 of file fitsHeader.hpp.
References mx::astro::constants::c(), insert_before(), and mx::astro::constants::k().
void mx::fits::fitsHeader::insert_before | ( | headerIterator | it, |
fitsHeaderCard | card | ||
) |
Insert a card before another card.
it | points to the element before which to insert |
card | contains the card to insert |
Definition at line 193 of file fitsHeader.cpp.
References cardMap, mx::fits::fitsHeaderCard::keyword(), and mx::fits::fitsHeaderCard::type().
Referenced by insert_before().
fitsHeader::headerIterator mx::fits::fitsHeader::iterator | ( | const std::string & | keyword | ) |
Get iterator pointing to a specific element.
keyword | The keyword to look up |
Definition at line 76 of file fitsHeader.cpp.
References cardMap.
fitsHeader & mx::fits::fitsHeader::operator= | ( | const fitsHeader & | head | ) |
Assignment.
Must be explicitly defined to handle creation of new iterators in the cardMap
head | The fitsHeader to copy |
Definition at line 49 of file fitsHeader.cpp.
References cardMap, and cards.
Referenced by fitsHeader().
fitsHeaderCard & mx::fits::fitsHeader::operator[] | ( | const std::string & | keyword | ) |
Card access by keyword operator.
Looks up the card by its keyword, and returns a reference to it.
keyword | is the header keyword to look up |
fitsHeaderCard& | reference to the fitsHeaderCard |
Definition at line 238 of file fitsHeader.cpp.
const fitsHeaderCard & mx::fits::fitsHeader::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.
keyword | is the header keyword to look up |
fitsHeaderCard& | const reference to the fitsHeaderCard |
Definition at line 254 of file fitsHeader.cpp.
References cardMap.
size_t mx::fits::fitsHeader::size | ( | ) |
Get number of cards currently stored in the header.
Definition at line 86 of file fitsHeader.cpp.
References cards.
Referenced by mx::fits::fitsFile< dataT >::readHeader().
|
protected |
This multimap allows for fast lookup by keyword.
Use unordered_multimap to handle HISTORY and COMMENT properly, and be as efficient as possible.
Definition at line 73 of file fitsHeader.hpp.
Referenced by append(), clear(), count(), erase(), insert_after(), insert_before(), iterator(), operator=(), and operator[]().
|
protected |
The storage for the FITS header cards.
We use a list, rather than forward_list, so that append (insert at end) is constant time.
Definition at line 68 of file fitsHeader.hpp.
Referenced by begin(), clear(), empty(), end(), erase(), operator=(), and size().