SourceXtractorPlusPlus  0.19
SourceXtractor++, the next generation SExtractor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FitsImageSource.h
Go to the documentation of this file.
1 
18 /*
19  * FitsImageSource.h
20  *
21  * Created on: Feb 21, 2018
22  * Author: mschefer
23  */
24 
25 #ifndef _SEFRAMEWORK_IMAGE_FITSIMAGESOURCE_H_
26 #define _SEFRAMEWORK_IMAGE_FITSIMAGESOURCE_H_
27 
28 #include <memory>
29 #include <vector>
30 #include <map>
31 
32 #include <boost/lexical_cast.hpp>
33 
34 #include "FilePool/FileManager.h"
38 #include "SEUtils/VariantCast.h"
39 
40 
41 namespace SourceXtractor {
42 
45 
46 class FitsImageSource : public ImageSource, public std::enable_shared_from_this<ImageSource> {
47 public:
48 
49 
58  explicit FitsImageSource(const std::string& filename, int hdu_number = 0,
61 
62  FitsImageSource(const std::string& filename, int width, int height,
63  ImageTile::ImageType image_type,
64  const std::shared_ptr<CoordinateSystem> coord_system = nullptr,
65  bool append = false,
66  bool empty_primary = false,
68 
69  virtual ~FitsImageSource() = default;
70 
71  std::string getRepr() const override {
72  return m_filename;
73  }
74 
76  int getWidth() const override {
77  return m_width;
78  }
79 
81  int getHeight() const override {
82  return m_height;
83  }
84 
86  int getDepth() const {
87  return m_depth;
88  }
89 
90  void setLayer(int layer);
91 
92  std::shared_ptr<ImageTile> getImageTile(int x, int y, int width, int height) const override;
93 
94  void saveTile(ImageTile& tile) override;
95 
96  template<typename TT>
97  bool readFitsKeyword(const std::string& header_keyword, TT& out_value) const {
98  auto& headers = getMetadata();
99  auto i = headers.find(header_keyword);
100  if (i != headers.end()) {
101  out_value = VariantCast<TT>(i->second.m_value);
102  return true;
103  }
104  return false;
105  }
106 
107  int getHDU() const {
108  return m_hdu_number;
109  }
110 
111  ImageTile::ImageType getType() const override {
112  return m_image_type;
113  }
114 
115  std::unique_ptr<std::vector<char>> getFitsHeaders(int& number_of_records) const;
116 
117  const std::map<std::string, MetadataEntry>& getMetadata() const override;
118 
119  void setMetadata(const std::string& key, const MetadataEntry& value) override;
120 
121 private:
122  void switchHdu(fitsfile *fptr, int hdu_number) const;
123 
124  int getDataType() const;
125 
126  int getImageType() const;
127 
131 
133 
134  int m_width;
135  int m_height;
136  int m_depth;
138 
140 };
141 
142 }
143 
144 
145 #endif /* _SEFRAMEWORK_IMAGE_FITSIMAGESOURCE_H_ */
std::unique_ptr< std::vector< char > > getFitsHeaders(int &number_of_records) const
std::shared_ptr< FileManager > m_file_manager
int getWidth() const override
Returns the width of the image in pixels.
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > x
static std::shared_ptr< FileManager > getDefault()
bool readFitsKeyword(const std::string &header_keyword, TT &out_value) const
virtual ~FitsImageSource()=default
ImageTile::ImageType m_image_type
std::shared_ptr< ImageTile > getImageTile(int x, int y, int width, int height) const override
STL class.
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > y
STL class.
void setMetadata(const std::string &key, const MetadataEntry &value) override
FitsImageSource(const std::string &filename, int hdu_number=0, ImageTile::ImageType image_type=ImageTile::AutoType, std::shared_ptr< FileManager > manager=FileManager::getDefault())
ImageTile::ImageType getType() const override
string filename
Definition: conf.py:65
int getDepth() const
Returns the depth of the image in pixels.
const std::map< std::string, MetadataEntry > & getMetadata() const override
void switchHdu(fitsfile *fptr, int hdu_number) const
STL class.
void saveTile(ImageTile &tile) override
int getHeight() const override
Returns the height of the image in pixels.
std::shared_ptr< FileHandler > m_handler
std::string getRepr() const override
Human readable representation of this source.