21 #include "NewKeyword.h"
23 #include "FitsError.h"
617 NoNullValue (
const string& diag,
bool silent =
true);
628 virtual HDU *
clone (FITSBase* p)
const = 0;
630 FITSBase*
parent ()
const;
638 const string&
comment ()
const;
644 const string&
history ()
const;
651 friend std::ostream& operator << (std::ostream& s,
const CCfits::HDU& right);
654 void index (
int value);
657 virtual double scale ()
const;
658 virtual void scale (
double value);
659 virtual double zero ()
const;
660 virtual void zero (
double value);
666 std::pair<unsigned long,unsigned long>
getChecksum ()
const;
670 std::map<String, Keyword*>&
keyWord ();
673 const std::map<string,Keyword*>&
keyWord ()
const;
676 const std::vector<String>& excList,
677 bool searchFromBeginning =
false);
681 template <
typename T>
682 void readKey(
const String& keyName, T& val);
684 template <
typename T>
685 void readKeys(std::vector<String>& keyNames, std::vector<T>& vals);
687 template <
typename T>
697 #ifdef TEMPLATE_AMBIG_DEFECT
698 inline void readKeyMS(
const String& keyName,
int & val);
699 inline void readKeys(std::vector<String>& keyNames, std::vector<String>& vals);
705 HDU (FITSBase* p = 0);
706 HDU (FITSBase* p,
int bitpix,
int naxis,
const std::vector<long>&
axes);
709 Keyword& readKeyword (
const String &keyname);
710 void readKeywords (std::list<String>& keynames);
711 virtual std::ostream & put (std::ostream &s)
const = 0;
713 bool checkImgDataTypeChange (
double zero,
double scale)
const;
715 void naxis (
const long& value);
719 void anynul (
const bool& value);
721 std::vector< long >&
naxes ();
731 virtual void initRead () = 0;
734 virtual bool compare (
const HDU &right)
const;
737 void copyKeys (
const HDU& right);
738 String getNamedLines (
const String& name);
741 void saveReadKeyword (
Keyword* newKey);
742 void zeroInit (
double value);
743 void scaleInit (
double value);
761 std::map<string,Keyword*> m_keyWord;
763 std::vector< long > m_naxes;
766 static const size_t s_nCategories;
767 static const int s_iKeywordCategories[];
769 friend class HDUCreator;
770 friend Keyword* KeywordCreator::getKeyword(
const String& keyname,
HDU* p);
771 friend Keyword* KeywordCreator::getKeyword(
const String& keyname,
ValueType keyType,
HDU* p);
773 template <
typename T>
777 NewKeyword<T> keyCreator(
this,value);
778 Keyword& newKey = *(addKeyword(keyCreator.createKeyword(name,
comment)));
782 template <
typename T>
786 Keyword& key = readKeyword(keyName);
791 template <
typename T>
794 size_t nRead = keyNames.size();
796 std::list<String> valKeys;
797 std::list<T> valList;
798 for (
size_t i = 0; i < nRead; i++) valKeys.push_back(keyNames[i]);
801 readKeywords(valKeys);
807 std::list<String>::iterator it = valKeys.begin();
808 while (it != valKeys.end())
812 m_keyWord[*it]->value(current);
813 valList.push_back(current);
816 catch ( Keyword::WrongKeywordValueType )
818 it = valKeys.erase(it);
822 keyNames.erase(keyNames.begin(),keyNames.end());
824 if (!valList.empty())
826 if (valList.size() != vals.size()) vals.resize(valList.size());
829 for (
typename std::list<T>::const_iterator it1
830 = valList.begin(); it1 != valList.end(); ++it1,++i)
834 for (std::list<String>::const_iterator it1= valKeys.begin(); it1 != valKeys.end(); ++it1)
836 keyNames.push_back(*it1);
876 return m_naxes[
index];
924 inline void HDU::saveReadKeyword (
Keyword* newKey)
926 m_keyWord.insert(std::map<String,Keyword*>::value_type(newKey->
name(),newKey->
clone()));
937 std::map<String,Keyword*>::iterator key = m_keyWord.find(keyName);
939 return *((*key).second);
942 inline long& HDU::naxis ()
947 inline void HDU::naxis (
const long& value)
952 inline bool& HDU::anynul ()
957 inline void HDU::anynul (
const bool& value)
962 inline const std::map<string,Keyword*>&
HDU::keyWord ()
const
969 std::map<String,Keyword*>::const_iterator key = m_keyWord.find(keyname);
971 return *((*key).second);
986 return m_naxes[
index];
989 inline void HDU::naxes (
size_t index,
const long& value)
991 m_naxes[
index] = value;
995 #ifdef SPEC_TEMPLATE_IMP_DEFECT
998 inline void HDU::readKeyMS(
const String& keyName,
int & val)
1001 Keyword& key = readKeyword(keyName);
1005 inline void HDU::readKeys(std::vector<String>& keyNames, std::vector<String>& vals)
1007 size_t nRead = keyNames.size();
1009 std::list<String> valKeys;
1010 std::list<String> valList;
1011 for (
size_t i = 0; i < nRead; i++) valKeys.push_back(keyNames[i]);
1014 readKeywords(valKeys);
1020 std::list<String>::iterator it = valKeys.begin();
1021 while (it != valKeys.end())
1025 m_keyWord[*it]->value(current);
1026 valList.push_back(current);
1029 catch ( Keyword::WrongKeywordValueType )
1031 it = valKeys.erase(it);
1035 keyNames.erase(keyNames.begin(),keyNames.end());
1037 if (!valList.empty())
1039 if (valList.size() != vals.size()) vals.resize(valList.size());
1042 std::list<String>::const_iterator it1 = valList.begin();
1043 for ( ; it1 != valList.end(); ++it1,++i)
1047 for ( it1= valKeys.begin(); it1 != valKeys.end(); ++it1)
1049 keyNames.push_back(*it1);
fitsfile * fitsPointer() const
return the fitsfile pointer for the FITS object containing the HDU
Definition: HDU.cxx:310
const String & getHistory()
read the history information from the HDU and add it to the FITS object.
Definition: HDU.cxx:417
virtual void makeThisCurrent() const
move the fitsfile pointer to this current HDU.
Definition: HDU.cxx:322
NoNullValue(const string &diag, bool silent=true)
Exception ctor, prefixes the string "Fits Error: No Null Pixel Value specified for Image " before the...
Definition: HDU.cxx:78
const string & history() const
return the history string previously read by getHistory()
Definition: HDU.h:857
std::vector< long > & naxes()
return the HDU data axis array.
Definition: HDU.h:979
void writeDate()
write a date string to *this.
Definition: HDU.cxx:439
static std::vector< int > keywordCategories()
return the enumerated keyword categories used by readAllKeys() and copyAllKeys()
Definition: HDU.cxx:600
virtual HDU * clone(FITSBase *p) const =0
virtual copy constructor, to be implemented in subclasses.
exception to be thrown if user requests extension type that can not be understood as ImageExt,...
Definition: HDU.h:590
void writeComment(const String &comment="Generic Comment")
write a comment string.
Definition: HDU.cxx:407
const String & name() const
return the name of a keyword
Definition: Keyword.h:314
T & value(T &val) const
get the keyword value
Definition: KeywordT.h:29
bool operator==(const HDU &right) const
equality operator
Definition: HDU.cxx:147
ValueType
CCfits value types and their CFITSIO equivalents (in caps)
Definition: CCfits.h:81
virtual double zero() const
return the BZERO keyword value
Definition: HDU.h:910
const string & comment() const
return the comment string previously read by getComment()
Definition: HDU.h:852
Keyword & addKey(const String &name, T val, const String &comment)
create a new keyword in the HDU with specified value and comment fields
Definition: HDU.h:774
Base class for all HDU [Header-Data Unit] objects.
Definition: HDU.h:571
void writeHistory(const String &history="Generic History String")
write a history string.
Definition: HDU.cxx:430
exception to be thrown on seek errors for keywords.
Definition: HDU.h:614
virtual Keyword * clone() const =0
virtual copy constructor
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:783
void readAllKeys()
read all of the keys in the header
Definition: HDU.cxx:532
const String & getComments()
read the comments from the HDU and add it to the FITS object.
Definition: HDU.cxx:395
std::pair< int, int > verifyChecksum() const
verify the HDU by computing the checksums and comparing them with the CHECKSUM/DATASUM keywords
Definition: HDU.cxx:497
std::map< String, Keyword * > & keyWord()
return the associative array containing the HDU Keywords that have been read so far.
Definition: HDU.h:929
virtual double scale() const
return the BSCALE keyword value
Definition: HDU.h:900
void writeChecksum()
compute and write the DATASUM and CHECKSUM keyword values
Definition: HDU.cxx:479
void deleteKey(const String &doomed)
delete a keyword from the header
Definition: HDU.cxx:522
virtual void resetImageRead()
force next image reading operation to read from file instead of object cache.
Definition: HDU.h:920
exception to be thrown if user requests creation of an image of type not supported by cfitsio.
Definition: HDU.h:578
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:723
void copyAllKeys(const HDU *inHdu)
copy all keys from another header
Definition: HDU.cxx:573
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:792
void updateChecksum()
update the CHECKSUM keyword value, assuming DATASUM exists and is correct
Definition: HDU.cxx:488
InvalidImageDataType(const string &diag, bool silent=true)
Exception ctor, prefixes the string "Fits Error: Invalid Data Type for Image " before the specific me...
Definition: HDU.cxx:46
HDU(const HDU &right)
copy constructor
Definition: HDU.cxx:88
NoSuchKeyword(const string &diag, bool silent=true)
Exception ctor, prefixes the string "Fits Error: Keyword not found: " before the specific message.
Definition: HDU.cxx:68
virtual void suppressScaling(bool toggle=true)
turn off image scaling regardless of the BSCALE and BZERO keyword values
Definition: HDU.cxx:462
Abstract base class defining the interface for Keyword objects.
Definition: Keyword.h:198
int index() const
return the HDU number
Definition: HDU.h:885
exception to be thrown on seek errors for keywords.
Definition: HDU.h:602
long axes() const
return the number of axes in the HDU data section (always 2 for tables).
Definition: HDU.h:867
long bitpix() const
return the data type keyword.
Definition: HDU.h:890
virtual ~HDU()
destructor
Definition: HDU.cxx:140
std::ostream & operator<<(std::ostream &s, const Column &right)
output operator for Column objects.
Definition: Column.h:1334
Namespace enclosing all CCfits classes and globals definitions.
Definition: AsciiTable.cxx:26
FitsException is the base class for all exceptions thrown by this library.
Definition: FitsError.h:93
FITSBase * parent() const
return reference to the pointer representing the FITSBase object containing the HDU
Definition: HDU.cxx:316
InvalidExtensionType(const string &diag, bool silent=true)
Exception ctor, prefixes the string "Fits Error: Extension Type: " before the specific message.
Definition: HDU.cxx:56
long axis(size_t index) const
return the size of axis numbered index [zero based].
Definition: HDU.h:873
bool operator!=(const HDU &right) const
inequality operator
Definition: HDU.cxx:152
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:511