SourceXtractorPlusPlus  0.13
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 class FitsImageSource : public ImageSource, public std::enable_shared_from_this<ImageSource> {
43 public:
44 
45 
54  FitsImageSource(const std::string &filename, int hdu_number = 0, ImageTile::ImageType image_type = ImageTile::AutoType,
56 
57  FitsImageSource(const std::string &filename, int width, int height, ImageTile::ImageType image_type,
58  const std::shared_ptr<CoordinateSystem> coord_system = nullptr, bool append=false,
60 
61  virtual ~FitsImageSource() = default;
62 
63  std::string getRepr() const override {
64  return m_filename;
65  }
66 
68  int getWidth() const override {
69  return m_width;
70  }
71 
73  int getHeight() const override {
74  return m_height;
75  }
76 
77  std::shared_ptr<ImageTile> getImageTile(int x, int y, int width, int height) const override;
78 
79  void saveTile(ImageTile& 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  ImageTile::ImageType getType() const override {
97  return m_image_type;
98  }
99 
100  std::unique_ptr<std::vector<char>> getFitsHeaders(int& number_of_records) const;
101 
103  return m_fits_file->getHDUHeaders(m_hdu_number);
104  }
105 
106  void setMetadata(std::string key, MetadataEntry value) override;
107 
108 private:
109  void switchHdu(fitsfile* fptr, int hdu_number) const;
110 
111  int getDataType() const;
112  int getImageType() const;
113 
117 
119 
120  int m_width;
121  int m_height;
123 };
124 
125 }
126 
127 
128 #endif /* _SEFRAMEWORK_IMAGE_FITSIMAGESOURCE_H_ */
std::unique_ptr< std::vector< char > > getFitsHeaders(int &number_of_records) const
int getWidth() const override
Returns the width of the image in pixels.
const std::map< std::string, MetadataEntry > getMetadata() const override
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > x
static std::shared_ptr< FitsFileManager > getInstance()
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
std::shared_ptr< FitsFile > m_fits_file
STL class.
std::shared_ptr< FitsFileManager > m_manager
ImageTile::ImageType getType() const override
string filename
Definition: conf.py:63
void setMetadata(std::string key, MetadataEntry value) 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.
FitsImageSource(const std::string &filename, int hdu_number=0, ImageTile::ImageType image_type=ImageTile::AutoType, std::shared_ptr< FitsFileManager > manager=FitsFileManager::getInstance())
std::string getRepr() const override
Human readable representation of this source.