21 #include "NewKeyword.h"
23 #include "FitsError.h"
589 NoNullValue (
const string& diag,
bool silent =
true);
600 virtual HDU *
clone (FITSBase* p)
const = 0;
602 FITSBase*
parent ()
const;
610 const string&
comment ()
const;
616 const string&
history ()
const;
623 friend std::ostream& operator << (std::ostream& s,
const CCfits::HDU& right);
626 void index (
int value);
629 virtual double scale ()
const;
630 virtual void scale (
double value);
631 virtual double zero ()
const;
632 virtual void zero (
double value);
637 std::pair<unsigned long,unsigned long>
getChecksum ()
const;
641 std::map<String, Keyword*>&
keyWord ();
644 const std::map<string,Keyword*>&
keyWord ()
const;
649 template <
typename T>
650 void readKey(
const String& keyName, T& val);
652 template <
typename T>
653 void readKeys(std::vector<String>& keyNames, std::vector<T>& vals);
655 template <
typename T>
656 Keyword& addKey(
const String& name, T val,
const String&
comment);
663 Keyword& addKey(
const String& name,
const char* charString,
const String&
comment);
665 #ifdef TEMPLATE_AMBIG_DEFECT
666 inline void readKeyMS(
const String& keyName,
int & val);
667 inline void readKeys(std::vector<String>& keyNames, std::vector<String>& vals);
673 HDU (FITSBase* p = 0);
674 HDU (FITSBase* p,
int bitpix,
int naxis,
const std::vector<long>&
axes);
677 Keyword& readKeyword (
const String &keyname);
678 void readKeywords (std::list<String>& keynames);
679 virtual std::ostream & put (std::ostream &s)
const = 0;
681 bool checkImgDataTypeChange (
double zero,
double scale)
const;
683 void naxis (
const long& value);
687 void anynul (
const bool& value);
689 std::vector< long >&
naxes ();
699 virtual void initRead () = 0;
702 virtual bool compare (
const HDU &right)
const;
705 void copyKeys (
const HDU& right);
706 String getNamedLines (
const String& name);
709 void saveReadKeyword (
Keyword* newKey);
710 void zeroInit (
double value);
711 void scaleInit (
double value);
729 std::map<string,Keyword*> m_keyWord;
731 std::vector< long > m_naxes;
734 static const size_t s_nCategories;
735 static const int s_iKeywordCategories[];
737 friend class HDUCreator;
738 friend Keyword* KeywordCreator::getKeyword(
const String& keyname,
HDU* p);
739 friend Keyword* KeywordCreator::getKeyword(
const String& keyname,
ValueType keyType,
HDU* p);
741 template <
typename T>
742 Keyword& HDU::addKey(
const String& name, T value,
const String& comment)
745 NewKeyword<T> keyCreator(
this,value);
746 Keyword& newKey = *(addKeyword(keyCreator.createKeyword(name,comment)));
750 template <
typename T>
754 Keyword& key = readKeyword(keyName);
759 template <
typename T>
762 size_t nRead = keyNames.size();
764 std::list<String> valKeys;
765 std::list<T> valList;
766 for (
size_t i = 0; i < nRead; i++) valKeys.push_back(keyNames[i]);
769 readKeywords(valKeys);
775 std::list<String>::iterator it = valKeys.begin();
776 while (it != valKeys.end())
780 m_keyWord[*it]->value(current);
781 valList.push_back(current);
784 catch ( Keyword::WrongKeywordValueType )
786 it = valKeys.erase(it);
790 keyNames.erase(keyNames.begin(),keyNames.end());
792 if (!valList.empty())
794 if (valList.size() != vals.size()) vals.resize(valList.size());
797 for (
typename std::list<T>::const_iterator it1
798 = valList.begin(); it1 != valList.end(); ++it1,++i)
802 for (std::list<String>::const_iterator it1= valKeys.begin(); it1 != valKeys.end(); ++it1)
804 keyNames.push_back(*it1);
844 return m_naxes[
index];
888 inline void HDU::saveReadKeyword (
Keyword* newKey)
890 m_keyWord.insert(std::map<String,Keyword*>::value_type(newKey->
name(),newKey->
clone()));
901 std::map<String,Keyword*>::iterator key = m_keyWord.find(keyName);
903 return *((*key).second);
906 inline long& HDU::naxis ()
911 inline void HDU::naxis (
const long& value)
916 inline bool& HDU::anynul ()
921 inline void HDU::anynul (
const bool& value)
933 std::map<String,Keyword*>::const_iterator key = m_keyWord.find(keyname);
935 return *((*key).second);
950 return m_naxes[
index];
953 inline void HDU::naxes (
size_t index,
const long& value)
955 m_naxes[
index] = value;
959 #ifdef SPEC_TEMPLATE_IMP_DEFECT
962 inline void HDU::readKeyMS(
const String& keyName,
int & val)
965 Keyword& key = readKeyword(keyName);
969 inline void HDU::readKeys(std::vector<String>& keyNames, std::vector<String>& vals)
971 size_t nRead = keyNames.size();
973 std::list<String> valKeys;
974 std::list<String> valList;
975 for (
size_t i = 0; i < nRead; i++) valKeys.push_back(keyNames[i]);
978 readKeywords(valKeys);
984 std::list<String>::iterator it = valKeys.begin();
985 while (it != valKeys.end())
989 m_keyWord[*it]->value(current);
990 valList.push_back(current);
993 catch ( Keyword::WrongKeywordValueType )
995 it = valKeys.erase(it);
999 keyNames.erase(keyNames.begin(),keyNames.end());
1001 if (!valList.empty())
1003 if (valList.size() != vals.size()) vals.resize(valList.size());
1006 std::list<String>::const_iterator it1 = valList.begin();
1007 for ( ; it1 != valList.end(); ++it1,++i)
1011 for ( it1= valKeys.begin(); it1 != valKeys.end(); ++it1)
1013 keyNames.push_back(*it1);
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:508
void writeChecksum()
compute and write the DATASUM and CHECKSUM keyword values
Definition: HDU.cxx:476
static std::vector< int > keywordCategories()
return the enumerated keyword categories used by readAllKeys() and copyAllKeys()
Definition: HDU.cxx:597
void writeDate()
write a date string to *this.
Definition: HDU.cxx:436
exception to be thrown on seek errors for keywords.
Definition: HDU.h:574
void writeComment(const String &comment="Generic Comment")
write a comment string.
Definition: HDU.cxx:404
virtual Keyword * clone() const =0
virtual copy constructor
long axis(size_t index) const
return the size of axis numbered index [zero based].
Definition: HDU.h:841
bool operator!=(const HDU &right) const
inequality operator
Definition: HDU.cxx:151
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:77
long bitpix() const
return the data type keyword.
Definition: HDU.h:858
void deleteKey(const String &doomed)
delete a keyword from the header
Definition: HDU.cxx:519
void copyAllKeys(const HDU *inHdu)
copy all keys from another header
Definition: HDU.cxx:570
fitsfile * fitsPointer() const
return the fitsfile pointer for the FITS object containing the HDU
Definition: HDU.cxx:309
const String & name() const
return the name of a keyword
Definition: Keyword.h:312
std::pair< int, int > verifyChecksum() const
verify the HDU by computing the checksums and comparing them with the CHECKSUM/DATASUM keywords ...
Definition: HDU.cxx:494
exception to be thrown on seek errors for keywords.
Definition: HDU.h:586
Abstract base class defining the interface for Keyword objects.
Definition: Keyword.h:197
Base class for all HDU [Header-Data Unit] objects.
Definition: HDU.h:543
std::map< String, Keyword * > & keyWord()
return the associative array containing the HDU keywords so far read.
Definition: HDU.h:893
virtual HDU * clone(FITSBase *p) const =0
virtual copy constructor, to be implemented in subclasses.
const String & getHistory()
read the history information from the HDU and add it to the FITS object.
Definition: HDU.cxx:414
InvalidExtensionType(const string &diag, bool silent=true)
Exception ctor, prefixes the string "Fits Error: Extension Type: " before the specific message...
Definition: HDU.cxx:55
FitsException is the base class for all exceptions thrown by this library.
Definition: FitsError.h:93
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:751
ValueType
CCfits value types and their CFITSIO equivalents (in caps)
Definition: CCfits.h:79
int index() const
return the HDU number
Definition: HDU.h:853
virtual void makeThisCurrent() const
move the fitsfile pointer to this current HDU.
Definition: HDU.cxx:321
HDU(const HDU &right)
copy constructor
Definition: HDU.cxx:87
std::ostream & operator<<(std::ostream &s, const Column &right)
output operator for Column objects.
Definition: Column.h:1310
void readAllKeys()
read all of the keys in the header
Definition: HDU.cxx:529
void writeHistory(const String &history="Generic History String")
write a history string.
Definition: HDU.cxx:427
long axes() const
return the number of axes in the HDU data section (always 2 for tables).
Definition: HDU.h:835
FITSBase * parent() const
return reference to the pointer representing the FITSBase object containing the HDU ...
Definition: HDU.cxx:315
virtual ~HDU()
destructor
Definition: HDU.cxx:139
NoSuchKeyword(const string &diag, bool silent=true)
Exception ctor, prefixes the string "Fits Error: Keyword not found: " before the specific message...
Definition: HDU.cxx:67
const String & getComments()
read the comments from the HDU and add it to the FITS object.
Definition: HDU.cxx:392
exception to be thrown if user requests extension type that can not be understood as ImageExt...
Definition: HDU.h:562
bool operator==(const HDU &right) const
equality operator
Definition: HDU.cxx:146
std::vector< long > & naxes()
return the HDU data axis array.
Definition: HDU.h:943
const string & history() const
return the history string previously read by getHistory()
Definition: HDU.h:825
virtual double scale() const
return the BSCALE keyword value
Definition: HDU.h:868
virtual double zero() const
return the BZERO keyword value
Definition: HDU.h:878
void updateChecksum()
update the CHECKSUM keyword value, assuming DATASUM exists and is correct
Definition: HDU.cxx:485
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:45
const string & comment() const
return the comment string previously read by getComment()
Definition: HDU.h:820
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:760
void suppressScaling(bool toggle=true)
turn off image scaling regardless of the BSCALE and BZERO keyword values
Definition: HDU.cxx:459
exception to be thrown if user requests creation of an image of type not supported by cfitsio...
Definition: HDU.h:550