Luiza  v03-01
GloriaFitsHeader.h
1 // -*- mode: c++; mode: auto-fill; mode: flyspell-prog; -*-
2 
3 
4 #ifndef GloriaFitsHeader_h
5 #define GloriaFitsHeader_h 1
6 
7 
8 /*
9  * This source code is part of the LUIZA software package for GLORIA.
10  * You are free to use this source files for your own development as
11  * long as it stays in a public research context. You are not
12  * allowed to use it for commercial purpose. You must put this
13  * header with author names in all development based on this file.
14  *
15  */
16 
17 #include <string>
18 #include <vector>
19 #include <map>
20 #include <cfitsio/fitsio.h>
21 using namespace std;
22 
23 namespace gloria{
24 
26 
34 
35  friend class GloriaFitsImage ;
36  friend class GloriaSkyCatalog ;
37  friend class GloriaObjectList ;
38  friend class GloriaFitsTable ;
39 
40  public:
41 
43  struct HeaderRecord {
44  std::string Keyword;
45  std::string Value;
46  std::string Comment;
47  };
48 
49 
52 
53 
55  virtual ~GloriaFitsHeader();
56 
57 
59 
63  void ReadFitsHeader(fitsfile *fp);
64 
66 
68  void WriteFitsHeader(fitsfile *fp);
69 
70 
71  // Header access methods
72  // =====================
73 
74 
76  inline int GetKeywordNumber() {return _fitsHeaderRecords.size(); };
77 
78 
80  inline HeaderRecord& GetRecordAt(const int ikey) {return _fitsHeaderRecords.at(ikey); };
81 
83  inline std::string& GetKeywordAt(const int ikey) {return _fitsHeaderRecords.at(ikey).Keyword; };
84 
86  inline std::string& GetValueAt(const int ikey) {return _fitsHeaderRecords.at(ikey).Value; };
87 
89  inline std::string& GetCommentAt(const int ikey) {return _fitsHeaderRecords.at(ikey).Comment; };
90 
92  bool IsKeywordSet(const char *keyword);
93 
95  HeaderRecord& GetKeywordRecord(const char *keyword);
96 
98  std::string& GetKeywordValue(const char *keyword);
99 
101  long GetKeywordValueInt(const char *keyword);
102 
104  double GetKeywordValueDouble(const char *keyword);
105 
107  void AddKeyword(const char *keyword, std::string value, std::string comment);
108 
110  void AddKeywordDouble(const char *keyword, double value, std::string comment);
111 
113  void AddKeywordInt(const char *keyword, int value, std::string comment);
114 
116  void AddKeyword(HeaderRecord record);
117 
119  void SetKeyword(const char *keyword, std::string value, std::string comment);
120 
122  void SetKeywordDouble(const char *keyword, double value, std::string comment);
123 
125  void SetKeywordInt(const char *keyword, int value, std::string comment);
126 
128  void AddComment(std::string comment);
129 
131  void AddHistory(std::string history);
132 
134 
137  void RemoveKeyword(const char *keyword);
138 
140 
141  void RemoveKeywords(const char *keyword);
142 
143 
144 
146  void CopyHeader(GloriaFitsHeader* source);
147 
148 
150  void PrintHeader( std::ostream& os, int maxRec=100);
151 
152  // General status
153  // ==============
154 
156  inline bool OK() { return _statusOK; };
157 
159  inline bool Error() { return !_statusOK; };
160 
162  std::string ErrorMessage() { return _errorMessage; };
163 
164 
166  inline void ClearError() { _statusOK=true; _errorMessage.clear();};
167 
170  inline std::string InputFileName() { return _inputFileName; };
171 
174  inline void SetInputFileName(string name) {_inputFileName = name; };
175 
178  inline std::string OutputFileName() { return _outputFileName; };
179 
180 private:
181 
182 
184  std::vector<HeaderRecord> _fitsHeaderRecords;
185 
187  std::multimap<std::string,int> _headerKeywordMap;
188 
189 
190 
192 
193  std::string _inputFileName;
194 
196 
197  std::string _outputFileName;
198 
199 
201  bool _statusOK;
202 
204  std::string _errorMessage;
205 
206  } ;
207 
208 
209 }
210 
211 #endif
212 
213 
214 
std::string ErrorMessage()
Returns error message string.
Definition: GloriaFitsHeader.h:162
namespace for data storing and exchange formats
Definition: GloriaAstrometry.h:15
std::string & GetCommentAt(const int ikey)
Access header comment by record index.
Definition: GloriaFitsHeader.h:89
bool Error()
Method returning true if there was an error in data processing.
Definition: GloriaFitsHeader.h:159
bool OK()
Method returning true if processing was successful.
Definition: GloriaFitsHeader.h:156
Class for storing catalogs of sky objects (eg. stars)
Definition: GloriaSkyCatalog.h:36
void ClearError()
Method returning true if there was an error in data processing.
Definition: GloriaFitsHeader.h:166
std::string & GetValueAt(const int ikey)
Access header value (string) by record index.
Definition: GloriaFitsHeader.h:86
Class for reading and processing fits tables in Luiza.
Definition: GloriaFitsTable.h:109
void SetInputFileName(string name)
Definition: GloriaFitsHeader.h:174
Class for reading and processing fits images in Luiza.
Definition: GloriaFitsImage.h:43
Class for handling fits file headers.
Definition: GloriaFitsHeader.h:33
Class for storing object (star images on CCD) lists.
Definition: GloriaObjectList.h:35
std::string & GetKeywordAt(const int ikey)
Access header keyword by record index.
Definition: GloriaFitsHeader.h:83
HeaderRecord & GetRecordAt(const int ikey)
Access header record by record index.
Definition: GloriaFitsHeader.h:80
std::string OutputFileName()
Definition: GloriaFitsHeader.h:178
std::string InputFileName()
Definition: GloriaFitsHeader.h:170
int GetKeywordNumber()
Number of records defined in the header.
Definition: GloriaFitsHeader.h:76
Structure to store header records.
Definition: GloriaFitsHeader.h:43