SourceXtractorPlusPlus  0.12
Please provide a description of the project.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FitsImageSource.h
Go to the documentation of this file.
1 
17 /*
18  * FitsImageSource.h
19  *
20  * Created on: Feb 21, 2018
21  * Author: mschefer
22  */
23 
24 #ifndef _SEFRAMEWORK_IMAGE_FITSIMAGESOURCE_H_
25 #define _SEFRAMEWORK_IMAGE_FITSIMAGESOURCE_H_
26 
27 #include <memory>
28 #include <vector>
29 #include <map>
30 
31 #include <boost/lexical_cast.hpp>
32 
37 #include "SEUtils/VariantCast.h"
38 
39 
40 namespace SourceXtractor {
41 
42 template <typename T>
43 class FitsImageSource : public ImageSourceWithMetadata<T>, public std::enable_shared_from_this<ImageSource<T>> {
44 public:
45 
54  FitsImageSource(const std::string &filename, int hdu_number = 0,
56 
57  FitsImageSource(const std::string &filename, int width, int height,
58  const std::shared_ptr<CoordinateSystem> coord_system = nullptr,
60 
61  virtual ~FitsImageSource() = default;
62 
63  std::string getRepr() const override {
64  return m_filename;
65  }
66 
67  std::shared_ptr<ImageTile<T>> getImageTile(int x, int y, int width, int height) const override;
68 
70  int getWidth() const override {
71  return m_width;
72  }
73 
75  int getHeight() const override {
76  return m_height;
77  }
78 
79  void saveTile(ImageTile<T>& tile) override;
80 
81  template <typename TT>
82  bool readFitsKeyword(const std::string& header_keyword, TT& out_value) const {
83  auto& headers = getMetadata();
84  auto i = headers.find(header_keyword);
85  if (i != headers.end()) {
86  out_value = VariantCast<TT>(i->second.m_value);
87  return true;
88  }
89  return false;
90  }
91 
92  int getHDU() const {
93  return m_hdu_number;
94  }
95 
96  std::unique_ptr<std::vector<char>> getFitsHeaders(int& number_of_records) const;
97 
99  return m_fits_file->getHDUHeaders(m_hdu_number);
100  }
101 
102 private:
103 
104 
105  void switchHdu(fitsfile* fptr, int hdu_number) const;
106 
107  int getDataType() const;
108  int getImageType() const;
109 
113 
114  int m_width;
115  int m_height;
116 
118 };
119 
120 }
121 
122 
123 
124 
125 #endif /* _SEFRAMEWORK_IMAGE_FITSIMAGESOURCE_H_ */
std::unique_ptr< std::vector< char > > getFitsHeaders(int &number_of_records) const
int getHeight() const override
Returns the height of the image in pixels.
virtual ~FitsImageSource()=default
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > x
static std::shared_ptr< FitsFileManager > getInstance()
std::shared_ptr< FitsFile > m_fits_file
std::string getRepr() const override
Human readable representation of this source.
STL class.
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > y
STL class.
std::shared_ptr< FitsFileManager > m_manager
string filename
Definition: conf.py:63
std::shared_ptr< ImageTile< T > > getImageTile(int x, int y, int width, int height) const override
const std::map< std::string, MetadataEntry > & getMetadata() const override
bool readFitsKeyword(const std::string &header_keyword, TT &out_value) const
STL class.
void switchHdu(fitsfile *fptr, int hdu_number) const
void saveTile(ImageTile< T > &tile) override
FitsImageSource(const std::string &filename, int hdu_number=0, std::shared_ptr< FitsFileManager > manager=FitsFileManager::getInstance())
int getWidth() const override
Returns the width of the image in pixels.