21#include "NewKeyword.h"
728 NoNullValue (
const string& diag,
bool silent =
true);
751 const string&
comment ()
const;
757 const string&
history ()
const;
764 friend std::ostream& operator << (std::ostream& s,
const CCfits::HDU& right);
767 void index (
int value);
770 virtual double scale ()
const;
771 virtual void scale (
double value);
772 virtual double zero ()
const;
773 virtual void zero (
double value);
779 std::pair<unsigned long,unsigned long>
getChecksum ()
const;
781 void readAllKeys (
const std::vector<int> & keyCategories = std::vector<int>());
782 void copyAllKeys (
const HDU* inHdu,
const std::vector<int> & keyCategories = std::vector<int>());
783 std::map<String, Keyword*>&
keyWord ();
786 const std::map<string,Keyword*>&
keyWord ()
const;
789 const std::vector<String>& excList,
790 bool searchFromBeginning =
false);
796 template <
typename T>
797 void readKey(
const String& keyName, T& val);
799 template <
typename T>
800 void readKeys(std::vector<String>& keyNames, std::vector<T>& vals);
802 template <
typename T>
810 Keyword&
addKey(
const String& name,
const char* charString,
const String&
comment,
bool isLongStr =
false);
814#ifdef TEMPLATE_AMBIG_DEFECT
815 inline void readKeyMS(
const String& keyName,
int & val);
816 inline void readKeys(std::vector<String>& keyNames, std::vector<String>& vals);
829 Keyword& readKeyword (
const String &keyname);
830 void readKeywords (std::list<String>& keynames);
831 virtual std::ostream & put (std::ostream &s)
const = 0;
833 bool checkImgDataTypeChange (
double zero,
double scale)
const;
835 void naxis (
const long& value);
839 void anynul (
const bool& value);
842 std::vector< long >&
naxes ();
854 virtual void initRead () = 0;
857 virtual bool compare (
const HDU &right)
const;
860 void copyKeys (
const HDU& right);
861 String getNamedLines (
const String& name);
864 void saveReadKeyword (
Keyword* newKey);
865 void zeroInit (
double value);
866 void scaleInit (
double value);
885 std::map<string,Keyword*> m_keyWord;
887 std::vector< long > m_naxes;
890 static const size_t s_nCategories;
891 static const int s_iKeywordCategories[];
893 friend class HDUCreator;
894 friend Keyword* KeywordCreator::getKeyword(
const String& keyname,
HDU* p);
895 friend Keyword* KeywordCreator::getKeyword(
const String& keyname,
ValueType keyType,
HDU* p);
900 template <
typename T>
904 NewKeyword<T> keyCreator(
this,value);
905 Keyword& newKey = *(addKeyword(keyCreator.createKeyword(name,
comment,isLongStr)));
909 template <
typename T>
913 Keyword& key = readKeyword(keyName);
917 template <
typename T>
920 size_t nRead = keyNames.size();
922 std::list<String> valKeys;
923 std::list<T> valList;
924 for (
size_t i = 0; i < nRead; i++) valKeys.push_back(keyNames[i]);
927 readKeywords(valKeys);
933 std::list<String>::iterator it = valKeys.begin();
934 while (it != valKeys.end())
938 m_keyWord[*it]->value(current);
939 valList.push_back(current);
942 catch ( Keyword::WrongKeywordValueType )
944 it = valKeys.erase(it);
948 keyNames.erase(keyNames.begin(),keyNames.end());
950 if (!valList.empty())
952 if (valList.size() != vals.size()) vals.resize(valList.size());
955 for (
typename std::list<T>::const_iterator it1
956 = valList.begin(); it1 != valList.end(); ++it1,++i)
960 for (std::list<String>::const_iterator it1= valKeys.begin(); it1 != valKeys.end(); ++it1)
962 keyNames.push_back(*it1);
1000 return m_naxes[
index];
1047 inline void HDU::saveReadKeyword (
Keyword* newKey)
1049 m_keyWord.insert(std::map<String,Keyword*>::value_type(newKey->
name(),newKey->
clone()));
1059 std::map<String,Keyword*>::iterator key = m_keyWord.find(keyName);
1061 return *((*key).second);
1064 inline long& HDU::naxis ()
1069 inline void HDU::naxis (
const long& value)
1074 inline bool& HDU::anynul ()
1079 inline void HDU::anynul (
const bool& value)
1091 std::map<String,Keyword*>::const_iterator key = m_keyWord.find(keyname);
1093 return *((*key).second);
1108 return m_naxes[
index];
1111 inline void HDU::naxes (
size_t index,
const long& value)
1113 m_naxes[
index] = value;
1118#ifdef SPEC_TEMPLATE_IMP_DEFECT
1121 inline void HDU::readKeyMS(
const String& keyName,
int & val)
1124 Keyword& key = readKeyword(keyName);
1128 inline void HDU::readKeys(std::vector<String>& keyNames, std::vector<String>& vals)
1130 size_t nRead = keyNames.size();
1132 std::list<String> valKeys;
1133 std::list<String> valList;
1134 for (
size_t i = 0; i < nRead; i++) valKeys.push_back(keyNames[i]);
1137 readKeywords(valKeys);
1143 std::list<String>::iterator it = valKeys.begin();
1144 while (it != valKeys.end())
1148 m_keyWord[*it]->value(current);
1149 valList.push_back(current);
1152 catch ( Keyword::WrongKeywordValueType )
1154 it = valKeys.erase(it);
1158 keyNames.erase(keyNames.begin(),keyNames.end());
1160 if (!valList.empty())
1162 if (valList.size() != vals.size()) vals.resize(valList.size());
1165 std::list<String>::const_iterator it1 = valList.begin();
1166 for ( ; it1 != valList.end(); ++it1,++i)
1170 for ( it1= valKeys.begin(); it1 != valKeys.end(); ++it1)
1172 keyNames.push_back(*it1);
Memory object representation of a disk FITS file.
Definition FITS.h:629
FitsException is the base class for all exceptions thrown by this library.
Definition FitsError.h:94
exception to be thrown if user requests extension type that can not be understood as ImageExt,...
Definition HDU.h:704
exception to be thrown if user requests creation of an image of type not supported by cfitsio.
Definition HDU.h:693
exception to be thrown on seek errors for keywords.
Definition HDU.h:726
exception to be thrown on seek errors for keywords.
Definition HDU.h:715
Base class for all HDU [Header-Data Unit] objects.
Definition HDU.h:687
std::map< String, Keyword * > & keyWord()
return the associative array containing the HDU keywords so far read.
Definition HDU.h:1052
Keyword & addKey(const String &name, T val, const String &comment, bool isLongStr=false)
create a new keyword in the HDU with specified value and comment fields
Definition HDU.h:901
void writeComment(const String &comment="Generic Comment")
write a comment string.
Definition HDU.cxx:403
const String & getHistory()
read the history information from the HDU and add it to the FITS object.
Definition HDU.cxx:425
fitsfile * fitsPointer() const
return the fitsfile pointer for the FITS object containing the HDU
Definition HDU.cxx:308
virtual HDU * clone(FITS *p) const =0
virtual copy constructor, to be implemented in subclasses.
void readKeys(std::vector< String > &keyNames, std::vector< T > &vals)
read a set of specified keywords of the same data type from the header of a disk FITS file and return...
Definition HDU.h:918
Keyword & readNextKey(const std::vector< String > &incList, const std::vector< String > &excList, bool searchFromBeginning=false)
Read the next key in the HDU which matches a string in incList, and does not match string in excList.
Definition HDU.cxx:783
std::vector< long > & naxes()
return the HDU data axis array.
Definition HDU.h:1101
void writeChecksum()
compute and write the DATASUM and CHECKSUM keyword values
Definition HDU.cxx:500
std::pair< int, int > verifyChecksum() const
verify the HDU by computing the checksums and comparing them with the CHECKSUM/DATASUM keywords
Definition HDU.cxx:518
std::pair< unsigned long, unsigned long > getChecksum() const
compute and return the checksum values for the HDU without creating or modifying the CHECKSUM/DATASUM...
Definition HDU.cxx:532
void writeDate()
write a date string to *this.
Definition HDU.cxx:460
void updateChecksum()
update the CHECKSUM keyword value, assuming DATASUM exists and is correct
Definition HDU.cxx:509
Keyword & addKeyNull(const String &name, const String &comment, bool isLongStr=false)
create a new keyword in the HDU with a null (ie. undefined) value.
Definition HDU.cxx:896
int index() const
return the HDU number
Definition HDU.h:1008
const String & getComments()
read the comments from the HDU and add it to the FITS object.
Definition HDU.cxx:391
static std::vector< int > keywordCategories()
Return the default enumerated keyword categories used by copyAllKeys()
Definition HDU.cxx:660
virtual double scale() const
return the BSCALE keyword value
Definition HDU.h:1023
virtual void suppressScaling(bool toggle=true)
turn off image scaling regardless of the BSCALE and BZERO keyword values
Definition HDU.cxx:483
bool operator!=(const HDU &right) const
inequality operator
Definition HDU.cxx:150
long axis(size_t index) const
return the size of axis numbered index [zero based].
Definition HDU.h:998
void copyAllKeys(const HDU *inHdu, const std::vector< int > &keyCategories=std::vector< int >())
copy all keys from another header
Definition HDU.cxx:617
void readKey(const String &keyName, T &val)
read a keyword of specified type from the header of a disk FITS file and return its value.
Definition HDU.h:910
void readAllKeys(const std::vector< int > &keyCategories=std::vector< int >())
read all of the keys in the header
Definition HDU.cxx:553
virtual void resetImageRead()
force next image reading operation to read from file instead of object cache.
Definition HDU.h:1043
virtual void makeThisCurrent() const
move the fitsfile pointer to this current HDU.
Definition HDU.cxx:318
FITS * parent() const
return reference to the pointer representing the FITS object containing the HDU
Definition HDU.cxx:313
long bitpix() const
return the data type keyword.
Definition HDU.h:1013
bool operator==(const HDU &right) const
equality operator
Definition HDU.cxx:145
const string & comment() const
return the comment string previously read by getComment()
Definition HDU.h:978
const string & history() const
return the history string previously read by getHistory()
Definition HDU.h:983
virtual ~HDU()
destructor
Definition HDU.cxx:138
long axes() const
return the number of axes in the HDU data section (always 2 for tables).
Definition HDU.h:993
void writeHistory(const String &history="Generic History String")
write a history string.
Definition HDU.cxx:438
void deleteKey(const String &doomed)
delete a keyword from the header
Definition HDU.cxx:543
virtual double zero() const
return the BZERO keyword value
Definition HDU.h:1033
Abstract base class defining the interface for Keyword objects.
Definition Keyword.h:199
T & value(T &val) const
get the keyword value
Definition KeywordT.h:29
const String & name() const
return the name of a keyword
Definition Keyword.h:322
virtual Keyword * clone() const =0
virtual copy constructor
Namespace enclosing all CCfits classes and globals definitions.
Definition AsciiTable.cxx:26
std::ostream & operator<<(std::ostream &s, const Column &right)
output operator for Column objects.
Definition Column.h:1337
ValueType
CCfits value types and their CFITSIO equivalents (in caps)
Definition CCfits.h:81