SourceXtractorPlusPlus  0.11
Please provide a description of the project.
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_ */
SourceXtractor::FitsImageSource::m_filename
std::string m_filename
Definition: FitsImageSource.h:110
SourceXtractor::FitsImageSource
Definition: FitsImageSource.h:43
SourceXtractor::FitsImageSource::m_height
int m_height
Definition: FitsImageSource.h:115
std::string
STL class.
std::shared_ptr
STL class.
SourceXtractor::FitsImageSource::readFitsKeyword
bool readFitsKeyword(const std::string &header_keyword, TT &out_value) const
Definition: FitsImageSource.h:82
conf.filename
string filename
Definition: conf.py:63
SourceXtractor::FitsImageSource::getMetadata
const std::map< std::string, MetadataEntry > & getMetadata() const override
Definition: FitsImageSource.h:98
SourceXtractor::FitsImageSource::getRepr
std::string getRepr() const override
Human readable representation of this source.
Definition: FitsImageSource.h:63
SourceXtractor::FitsImageSource::getImageType
int getImageType() const
SourceXtractor::ImageSourceWithMetadata
Definition: ImageSourceWithMetadata.h:40
CoordinateSystem.h
SourceXtractor::ImageTile
Definition: ImageTile.h:57
SourceXtractor::FitsImageSource::saveTile
void saveTile(ImageTile< T > &tile) override
Definition: FitsImageSource.cpp:157
SourceXtractor::FitsImageSource::m_hdu_number
int m_hdu_number
Definition: FitsImageSource.h:117
SourceXtractor
Definition: Aperture.h:30
SourceXtractor::FitsFileManager::getInstance
static std::shared_ptr< FitsFileManager > getInstance()
Definition: FitsFileManager.h:47
ImageSourceWithMetadata.h
SourceXtractor::FitsImageSource::~FitsImageSource
virtual ~FitsImageSource()=default
std::enable_shared_from_this
SourceXtractor::FitsImageSource::m_width
int m_width
Definition: FitsImageSource.h:114
SourceXtractor::FitsImageSource::getWidth
int getWidth() const override
Returns the width of the image in pixels.
Definition: FitsImageSource.h:70
std::map
STL class.
SourceXtractor::FitsImageSource::getHDU
int getHDU() const
Definition: FitsImageSource.h:92
SourceXtractor::FitsImageSource::getFitsHeaders
std::unique_ptr< std::vector< char > > getFitsHeaders(int &number_of_records) const
Definition: FitsImageSource.cpp:197
SourceXtractor::FitsImageSource::getHeight
int getHeight() const override
Returns the height of the image in pixels.
Definition: FitsImageSource.h:75
VariantCast.h
x
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > x
Definition: MoffatModelFittingTask.cpp:93
SourceXtractor::FitsImageSource::FitsImageSource
FitsImageSource(const std::string &filename, int hdu_number=0, std::shared_ptr< FitsFileManager > manager=FitsFileManager::getInstance())
Definition: FitsImageSource.cpp:45
y
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > y
Definition: MoffatModelFittingTask.cpp:93
SourceXtractor::FitsImageSource::getImageTile
std::shared_ptr< ImageTile< T > > getImageTile(int x, int y, int width, int height) const override
Definition: FitsImageSource.cpp:133
SourceXtractor::FitsImageSource::m_fits_file
std::shared_ptr< FitsFile > m_fits_file
Definition: FitsImageSource.h:111
std::unique_ptr
STL class.
SourceXtractor::FitsImageSource::m_manager
std::shared_ptr< FitsFileManager > m_manager
Definition: FitsImageSource.h:112
SourceXtractor::FitsImageSource::getDataType
int getDataType() const
FitsFile.h
FitsFileManager.h
SourceXtractor::FitsImageSource::switchHdu
void switchHdu(fitsfile *fptr, int hdu_number) const
Definition: FitsImageSource.cpp:180